:root {
  --bg: #070b16;
  --card: rgba(12, 18, 36, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef2ff;
  --muted: #94a0c2;
  --cyan: #3de7ff;
  --magenta: #ff4fd8;
  --green: #7dffa0;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Ubuntu, sans-serif;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

#versionTag {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 0px));
  right: 10px;
  z-index: 8;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  opacity: 0.55;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  letter-spacing: 0.4px;
  line-height: normal;
}

#stage {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  /* canvas sets pixel size; stage wraps it */
  line-height: 0;
}

#cv {
  display: block;
  border-radius: 18px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 20px 60px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(61, 231, 255, 0.08);
  cursor: grab;
  touch-action: none;
}

#cv:active { cursor: grabbing; }

/* Menu / game-over screens sit on top of canvas.
   Play chrome is ONLY the menu button + hint — never a full-screen hit target. */
.screen {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  overflow: hidden;
  line-height: normal;
}

.screen[data-screen="menu"],
.screen[data-screen="over"] {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(7, 11, 22, 0.55), rgba(7, 11, 22, 0.82));
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 5;
}

.play-chrome {
  z-index: 6;
}

.menu-card {
  width: min(340px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 20px 18px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

.logo-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  margin-bottom: 8px;
  box-shadow: 0 0 0 1px rgba(61, 231, 255, 0.35), 0 8px 24px rgba(61, 231, 255, 0.2);
}

.menu-card h1 {
  margin: 4px 0 2px;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.menu-card h1 .c1 {
  background: linear-gradient(100deg, #fff, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.menu-card h1 .c2 {
  background: linear-gradient(100deg, var(--magenta), #ffb4f0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.menu-card h2 {
  margin: 0 0 4px;
  font-size: 1.7rem;
  font-weight: 900;
}

.tagline {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 16px;
}

.stats.tall {
  grid-template-columns: repeat(2, 1fr);
}

.stats > div {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 6px;
}

.stats .lbl {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.stats strong {
  font-size: 1.05rem;
  font-weight: 800;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.primary, .secondary, .ghost {
  display: block;
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 8px;
  transition: filter 0.12s, transform 0.08s;
}

.primary {
  color: #061018;
  background: linear-gradient(180deg, #9af7ff, var(--cyan));
  box-shadow:
    0 4px 0 #1a8ea0,
    0 10px 24px rgba(61, 231, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.primary:hover { filter: brightness(1.05); }
.primary:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 #1a8ea0,
    0 6px 16px rgba(61, 231, 255, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.secondary:hover { background: rgba(255, 255, 255, 0.12); }

.ghost {
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  font-size: 0.9rem;
  padding: 8px;
}

.ghost:hover { color: var(--text); }

.how {
  text-align: left;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 6px 0 10px;
  border: 1px solid var(--line);
}

.how ol {
  margin: 0;
  padding-left: 18px;
  color: #c7d0ea;
  font-size: 0.82rem;
  line-height: 1.45;
}

.how b { color: var(--cyan); }

.orb-ladder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 2px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.orb-ladder .step {
  display: flex;
  align-items: center;
  gap: 2px;
}

.orb-ladder .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25), 0 0 8px currentColor;
  flex-shrink: 0;
}

.orb-ladder .arrow {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  margin: 0 1px;
  opacity: 0.7;
}

.orb-ladder .name {
  display: none;
}

.ver {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.8;
}

.new-best {
  color: #ffd56a;
  font-weight: 800;
  margin: -4px 0 10px;
}

.icon-btn {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 10px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 12, 24, 0.65);
  color: #fff;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  pointer-events: auto;
  z-index: 6;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.12); }

.hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(12px + var(--safe-bot));
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(200, 210, 240, 0.55);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
