:root {
  color-scheme: dark;
  --bg: #081527;
  --ink: #f8fbff;
  --muted: #a9bad3;
  --panel: rgba(8, 21, 39, 0.8);
  --line: rgba(255, 255, 255, 0.14);
  --sky: #6fd7ff;
  --deep: #112b5c;
  --gold: #ffd865;
  --danger: #6a7286;
  --fuel: #84ff9d;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(111, 215, 255, 0.22), transparent 24rem),
    radial-gradient(circle at 90% 85%, rgba(255, 216, 101, 0.13), transparent 22rem),
    var(--bg);
  overscroll-behavior: none;
}

button,
a {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.game-shell {
  display: grid;
  width: min(100%, 470px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  gap: 10px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
}

.back-link,
.status-pill {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
}

.back-link {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  padding: 0 13px;
  color: #e7f2ff;
  font-size: 0.85rem;
  font-weight: 850;
  text-decoration: none;
}

.status-pill {
  min-width: 78px;
  padding: 8px 10px;
  text-align: center;
}

.status-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.status-pill b {
  display: block;
  margin-top: 2px;
  color: var(--fuel);
  font-size: 1rem;
}

.stage-card {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 30px;
  background: #10284c;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: min(70dvh, 760px);
  min-height: 520px;
  background: linear-gradient(#6fd7ff, #1e54a3 58%, #163970);
}

.overlay {
  position: absolute;
  inset: 18px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(8, 21, 39, 0.84), rgba(8, 21, 39, 0.66)),
    radial-gradient(circle at 50% 25%, rgba(111, 215, 255, 0.23), transparent 15rem);
  text-align: center;
  backdrop-filter: blur(10px);
}

.overlay.hidden {
  display: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.06em;
}

h1 {
  font-size: clamp(3.1rem, 14vw, 5.2rem);
  line-height: 0.9;
}

h2 {
  font-size: clamp(2.2rem, 11vw, 3.7rem);
}

.overlay p:not(.eyebrow) {
  max-width: 325px;
  margin: 18px 0 24px;
  color: #d2e4f6;
  line-height: 1.55;
}

.overlay button,
.controls button {
  border-radius: 18px;
  color: #071324;
  background: linear-gradient(135deg, var(--gold), #ff9f4f);
  font-weight: 950;
  box-shadow: 0 14px 28px rgba(255, 185, 70, 0.24);
}

.overlay button {
  min-width: 154px;
  padding: 15px 20px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.controls button {
  min-height: 54px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 1.45rem;
}

.secondary-controls {
  grid-template-columns: 1fr 1fr;
}

.secondary-controls button,
#pauseButton {
  color: #e8f3ff;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
  font-size: 0.86rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.hint {
  margin: 0;
  color: #8da2c1;
  font-size: 0.74rem;
  line-height: 1.35;
  text-align: center;
}

@media (max-height: 710px) {
  canvas {
    height: 62dvh;
    min-height: 410px;
  }

  .controls button {
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
