:root {
  --gold: #ffd56a;
  --gold-deep: #f0a322;
  --ink: #e7f0ff;
  --muted: #a9bad2;
  --navy: rgba(7, 12, 28, 0.78);
  --line: rgba(255, 214, 120, 0.38);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05070f;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  font-family: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
}

button, a { font-family: inherit; }

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

#topbar {
  position: fixed;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(8px + env(safe-area-inset-top)) 12px 0;
  pointer-events: none;
}

.top-inner {
  width: min(520px, calc(100% - 4px));
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

#hudstats {
  flex: 1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

#hudstats.off { visibility: hidden; }

.stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  background: rgba(6, 10, 22, 0.42);
  border-radius: 16px;
  padding: 6px 10px 7px;
}

.stat.mid { align-items: center; padding-top: 6px; background: transparent; }
.stat.end { align-items: flex-end; }

.k {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 700;
}

.v {
  font-family: Orbitron, "Trebuchet MS", sans-serif;
  font-weight: 800;
  font-size: clamp(18px, 4.6vw, 26px);
  line-height: 1.1;
  color: white;
  font-variant-numeric: tabular-nums;
}

.v small {
  font-size: 0.55em;
  margin-left: 2px;
  color: var(--gold);
}

.sub {
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.coin-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(8, 12, 24, 0.45);
  border: 1px solid rgba(255, 213, 106, 0.35);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  font-family: Orbitron, "Trebuchet MS", sans-serif;
  font-weight: 800;
}

.me-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 8px;
  letter-spacing: -0.04em;
  color: #5c3d08;
  background: radial-gradient(circle at 35% 35%, #fff4c4, #ffd056 45%, #e39b12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

#mute {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(7, 12, 28, 0.72);
  color: var(--gold);
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  flex: none;
}

#mute svg { width: 22px; height: 22px; display: block; }
#mute .slash { display: none; }
#mute.muted .slash { display: block; }
#mute.muted { color: #8ea0b8; }

#hint, #boost, #chevrons { pointer-events: none; }

#hint {
  position: fixed;
  z-index: 4;
  top: calc(78px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(6, 10, 22, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: white;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  display: none;
}

#hint.on { display: block; }

#chevrons { display: none; }
#chevrons.on { display: block; }

.chev {
  position: fixed;
  z-index: 3;
  top: 46%;
  font-size: 34px;
  line-height: 1;
  color: white;
  opacity: 0.2;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  transition: opacity 0.12s linear;
}

.chev.left { left: max(8px, calc(50% - 250px)); }
.chev.right { right: max(8px, calc(50% - 250px)); }
.chev.hot { opacity: 0.8; }

#boost {
  position: fixed;
  z-index: 4;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(260px, calc(100% - 48px));
  display: none;
  text-align: center;
}

#boost.on { display: block; }

#boost p {
  margin: 6px 0 0;
  font-family: Orbitron, "Trebuchet MS", sans-serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: #ffe7a8;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 214, 120, 0.4);
  overflow: hidden;
}

#boostFill {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff7a2a, #ffe08a);
  border-radius: inherit;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: safe center;
  padding: calc(64px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(3, 6, 16, 0.18), rgba(3, 6, 16, 0.38));
  overflow: auto;
}

.overlay.open { display: flex; }

#menu.overlay.open {
  align-items: flex-start;
  justify-content: flex-start;
}

#menu .card { margin: 0 auto; }

.card {
  width: min(420px, 100%);
  margin: auto;
  padding: 22px 22px 18px;
  border-radius: 28px;
  background: var(--navy);
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px);
  text-align: center;
}

.card-moon {
  width: 74px;
  height: 74px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 62% 58%, rgba(190, 184, 160, 0.0) 0 7px, transparent 8px),
    radial-gradient(circle at 34% 42%, rgba(170, 164, 142, 0.55) 0 8px, transparent 9px),
    radial-gradient(circle at 48% 70%, rgba(160, 154, 132, 0.45) 0 5px, transparent 6px),
    radial-gradient(circle at 32% 32%, #fff, #f3ead2 42%, #d9d0b4 78%);
  box-shadow: 0 0 32px rgba(255, 244, 214, 0.55), inset -10px -8px 18px rgba(120, 110, 80, 0.25);
  animation: bob 3.6s ease-in-out infinite;
}

.logo {
  margin: 0;
  font-family: Orbitron, "Trebuchet MS", sans-serif;
  font-weight: 800;
  font-size: clamp(36px, 10vw, 58px);
  letter-spacing: 0.04em;
  line-height: 1;
  background: linear-gradient(180deg, #ffffff 10%, #ffe7a3 55%, #f5a524 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 8px 0 16px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  font-size: 13px;
  font-weight: 700;
  color: #d5e8ff;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-gold {
  color: #2a1b04;
  background: linear-gradient(180deg, #ffe7a8, #f5b42a);
  box-shadow: 0 8px 20px rgba(245, 164, 36, 0.28);
}

.btn-gold:hover { filter: brightness(1.05); }
.btn-gold:active { transform: translateY(1px); }

.btn-x {
  margin-top: 10px;
  color: white;
  background: #0b0d12;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.btn-x svg { width: 16px; height: 16px; display: block; }

.best-line, .meta-line {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.best-line strong, .meta-line strong { color: white; }

.help {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  text-align: left;
  color: #d5e2f4;
  font-size: 14px;
  line-height: 1.45;
}

.help li { padding: 3px 0 3px 2px; }
.help b { color: var(--gold); font-weight: 700; }

.reason {
  margin: 0;
  font-family: Orbitron, "Trebuchet MS", sans-serif;
  font-size: clamp(26px, 7vw, 34px);
  letter-spacing: 0.04em;
}

.reason-line {
  margin: 6px 0 8px;
  color: var(--muted);
}

.final-score {
  margin: 0;
  font-family: Orbitron, "Trebuchet MS", sans-serif;
  font-size: clamp(42px, 12vw, 64px);
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}

.final-score span { font-size: 0.42em; margin-left: 4px; letter-spacing: 0.08em; }

.record {
  display: none;
  margin: 8px auto 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 213, 106, 0.16);
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.record.show { display: inline-block; }

.stack { margin-top: 16px; }

button:focus-visible, a:focus-visible {
  outline: 2px solid #ffe08a;
  outline-offset: 3px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

noscript p {
  position: fixed;
  inset: auto 16px 16px 16px;
  z-index: 8;
  background: white;
  color: #111;
  padding: 12px 14px;
  border-radius: 12px;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@media (max-height: 700px) {
  .card { padding: 14px 16px 12px; }
  .card-moon { width: 52px; height: 52px; }
  .logo { font-size: 36px; }
  .tagline { margin: 6px 0 10px; }
  .help { font-size: 12px; margin-top: 8px; }
  .btn { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .card-moon { animation: none; }
}

@media (max-width: 380px) {
  #hint { font-size: 12px; white-space: normal; width: min(280px, calc(100% - 32px)); text-align: center; }
  .k { letter-spacing: 0.08em; }
}
