:root {
  --night: #06141d;
  --panel: #0d2632;
  --ink: #f4fff8;
  --muted: #9eb9b1;
  --lime: #d8ff4f;
  --cyan: #43ead7;
  --coral: #ff765e;
  --line: rgba(235, 255, 246, .17);
  --header: 64px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box }
html, body { margin: 0; min-height: 100%; background: var(--night); color: var(--ink) }
[hidden] { display: none !important }
body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 5%, rgba(67, 234, 215, .13), transparent 32rem),
    radial-gradient(circle at 88% 70%, rgba(255, 118, 94, .1), transparent 34rem),
    var(--night);
}
button { font: inherit }
button, a { -webkit-tap-highlight-color: transparent }
button:focus-visible, a:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px }
#app { min-height: 100vh; min-height: 100dvh }

.topbar {
  height: var(--header);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(6, 20, 29, .92);
  backdrop-filter: blur(14px);
  position: relative;
  z-index: 20;
}
.back { justify-self: start; color: var(--ink); font-size: 11px; font-weight: 900; letter-spacing: .14em; text-decoration: none }
.back:hover { color: var(--lime) }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 950; letter-spacing: .09em; font-size: 14px }
.brand em { font-style: normal; color: var(--lime) }
.mini-ball { display: grid; place-items: center; width: 30px; height: 30px; border: 2px solid var(--cyan); border-radius: 50%; color: var(--cyan); font-size: 9px; transform: rotate(18deg) }
.icon-button, .hud-button {
  border: 1px solid var(--line);
  background: rgba(10, 35, 45, .88);
  color: var(--muted);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .1em;
  padding: 8px 10px;
  cursor: pointer;
}
.icon-button { justify-self: end }
.icon-button:hover, .hud-button:hover { color: var(--ink); border-color: var(--cyan) }

.menu-screen {
  max-width: 1210px;
  margin: 0 auto;
  padding: clamp(40px, 6.5vw, 78px) clamp(18px, 5vw, 62px) 34px;
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(420px, 1.12fr);
  gap: clamp(36px, 7vw, 90px);
  align-items: center;
  min-height: calc(100vh - var(--header));
  min-height: calc(100dvh - var(--header));
}
.eyebrow { margin: 0 0 15px; color: var(--cyan); font-size: 11px; font-weight: 950; letter-spacing: .19em }
.hero h1 { margin: 0; font-size: clamp(72px, 9.5vw, 126px); line-height: .75; letter-spacing: -.07em }
.hero h1 em { font-style: normal; color: transparent; -webkit-text-stroke: 2px var(--coral) }
.lede { color: #cee1db; max-width: 570px; font-size: clamp(17px, 2vw, 22px); line-height: 1.48; margin: 30px 0 24px }
.how-to { display: flex; gap: 9px; flex-wrap: wrap }
.how-to span { padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-size: 10px; letter-spacing: .04em; background: rgba(4, 20, 28, .35) }
.how-to strong { color: var(--lime) }
.key-note { margin: 16px 0 0; color: #6f918a; font-size: 9px; letter-spacing: .08em; text-transform: uppercase }
.course-panel {
  background: linear-gradient(145deg, rgba(16, 48, 61, .97), rgba(8, 29, 40, .98));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(18px, 3vw, 28px);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .34);
}
.course-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; color: var(--muted); font-size: 10px; font-weight: 900; letter-spacing: .14em }
.course-heading small { color: var(--cyan) }
.course-list { display: grid; gap: 11px }
.course-card {
  --course-accent: var(--lime);
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 14px;
  align-items: center;
  text-align: left;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #081d27;
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.course-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--course-accent); box-shadow: 0 0 18px var(--course-accent) }
.course-card:hover { transform: translateY(-2px); border-color: var(--course-accent); background: #0b2632 }
.course-number { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: color-mix(in srgb, var(--course-accent) 14%, transparent); color: var(--course-accent); font-weight: 950; font-size: 18px }
.course-copy strong { display: block; font-size: 15px; letter-spacing: .06em }
.course-copy small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px }
.course-data { display: flex; gap: 8px; margin-top: 7px; color: #71918a; font-size: 8px; font-weight: 800; letter-spacing: .09em }
.course-meta { min-width: 88px; text-align: right }
.course-meta strong, .course-meta small, .course-boots { display: block }
.course-meta strong { color: var(--course-accent); font-size: 9px; letter-spacing: .12em }
.course-meta small { margin-top: 5px; color: var(--muted); font-size: 9px }
.course-boots { margin-top: 6px; color: #546f69; font-size: 13px; letter-spacing: .05em }
.course-boots .earned { color: #ffd84a; text-shadow: 0 0 10px rgba(255, 216, 74, .45) }
.boot-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px 16px; margin-top: 16px; color: #6d8c85; font-size: 8px; font-weight: 800; letter-spacing: .09em }
.boot-legend span::first-letter { color: #ffd84a }
.original-note { grid-column: 1 / -1; text-align: center; color: #718f88; font-size: 10px; letter-spacing: .05em; margin: 0 }

.game-screen {
  position: relative;
  height: calc(100vh - var(--header));
  height: calc(100dvh - var(--header));
  overflow: hidden;
  background: #050e14;
  touch-action: none;
  user-select: none;
}
.game-screen:not([hidden]) { display: block }
.game-screen canvas { display: block; width: 100%; height: 100%; touch-action: none }
.hud {
  position: absolute;
  z-index: 8;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: auto minmax(180px, 520px) auto;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  pointer-events: none;
}
.hud > * { pointer-events: auto }
.progress-wrap { width: min(43vw, 520px) }
.progress-copy { display: flex; justify-content: space-between; gap: 16px; font-size: 10px; font-weight: 950; letter-spacing: .11em; text-shadow: 0 2px 10px #000 }
.progress-copy strong { color: var(--lime) }
.progress-track { position: relative; margin-top: 7px; height: 8px; padding: 1px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 999px; background: rgba(0, 0, 0, .4) }
.progress-track > span { display: block; width: 0; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--cyan), var(--lime)); box-shadow: 0 0 12px rgba(216, 255, 79, .35) }
.progress-track i { position: absolute; top: -4px; width: 2px; height: 14px; background: var(--coral); box-shadow: 0 0 7px var(--coral); transform: translateX(-1px) }
.hud-stats { display: flex; align-items: center; gap: 13px; text-align: right; text-shadow: 0 2px 10px #000 }
.score small, .score strong { display: block }
.score small { color: var(--muted); font-size: 7px; letter-spacing: .13em }
.score strong { font-size: 12px; letter-spacing: .08em }
.badge-count { font-size: 10px; font-weight: 950; letter-spacing: .05em }
.badge-count b { color: #ffd84a; font-size: 15px; margin-right: 4px }
.flow-meter { position: absolute; z-index: 7; top: 64px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid color-mix(in srgb, var(--lime) 55%, transparent); border-radius: 999px; background: rgba(5, 24, 30, .76); box-shadow: 0 0 24px rgba(216, 255, 79, .15) }
.flow-meter small { color: var(--muted); font-size: 7px; font-weight: 900; letter-spacing: .16em }
.flow-meter strong { color: var(--lime); font-size: 13px }
.flow-meter.pop { animation: meter-pop .28s ease }
.attempt { position: absolute; z-index: 5; left: 50%; top: 22%; transform: translateX(-50%); font-size: clamp(15px, 2.5vw, 24px); font-weight: 950; letter-spacing: .16em; text-shadow: 0 3px 18px #000; transition: .35s }
.attempt.hidden { opacity: 0; transform: translate(-50%, -10px) }
.countdown { position: absolute; z-index: 10; inset: 0; display: grid; place-items: center; color: var(--ink); font-size: clamp(96px, 17vw, 190px); font-weight: 950; font-style: italic; letter-spacing: -.08em; text-shadow: 0 0 45px var(--cyan), 0 8px 0 rgba(0, 0, 0, .2); pointer-events: none; animation: count-pop .28s ease }
.event-callout { position: absolute; z-index: 9; left: 28%; top: 34%; transform: translateX(-50%); color: var(--lime); font-size: clamp(17px, 3vw, 29px); font-weight: 950; font-style: italic; letter-spacing: .05em; text-shadow: 0 4px 18px #000, 0 0 18px currentColor; pointer-events: none; animation: callout .72s ease both }
.event-callout.cyan { color: var(--cyan) }
.event-callout.gold { color: #ffd84a }
.event-callout.coral { color: var(--coral) }
.jump-hint { position: absolute; z-index: 5; left: 28%; bottom: 8%; transform: translateX(-50%); padding: 10px 15px; border-radius: 999px; background: rgba(4, 19, 27, .76); border: 1px solid var(--line); font-size: 10px; font-weight: 900; letter-spacing: .13em; color: var(--muted); transition: .3s; pointer-events: none }
.jump-hint.hidden { opacity: 0 }

.shot-prompt { position: absolute; z-index: 11; left: 50%; top: 45%; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 9px; pointer-events: none; text-align: center }
.shot-prompt strong { color: var(--lime); font-size: clamp(20px, 4vw, 40px); font-style: italic; letter-spacing: .05em; text-shadow: 0 4px 18px #000, 0 0 18px rgba(216, 255, 79, .5) }
.shot-prompt small { color: var(--ink); font-size: 9px; font-weight: 850; letter-spacing: .1em; text-shadow: 0 2px 8px #000 }
.shot-target { position: relative; width: 82px; height: 82px; display: grid; place-items: center }
.shot-target i, .shot-target b { position: absolute; inset: 0; border-radius: 50% }
.shot-target i { border: 4px solid var(--coral); transform: scale(var(--shot-scale, 2.5)); opacity: .85; transition: transform .04s linear, border-color .08s linear }
.shot-target b { inset: 12px; border: 4px solid var(--lime); box-shadow: 0 0 17px rgba(216, 255, 79, .6) }
.shot-target span { font-size: 34px; filter: drop-shadow(0 3px 6px #000) }
.shot-prompt.in-window .shot-target i { border-color: var(--lime) }
.failure-strip { position: absolute; z-index: 13; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(520px, calc(100% - 28px)); display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 18px; border: 1px solid rgba(255, 118, 94, .48); border-radius: 14px; background: rgba(27, 12, 17, .91); box-shadow: 0 14px 44px rgba(0, 0, 0, .42); pointer-events: none; animation: fail-in .22s ease }
.failure-strip strong { color: var(--coral); font-size: 16px; letter-spacing: .08em }
.failure-strip span { color: var(--ink); font-size: 9px; font-weight: 900; letter-spacing: .12em }

.result-panel { position: absolute; z-index: 14; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(470px, calc(100% - 28px)); padding: 28px; border: 1px solid rgba(216, 255, 79, .32); border-radius: 24px; background: linear-gradient(145deg, rgba(15, 46, 59, .985), rgba(5, 20, 29, .99)); box-shadow: 0 28px 90px rgba(0, 0, 0, .58), 0 0 70px rgba(216, 255, 79, .08); text-align: center; animation: result-in .32s cubic-bezier(.2, .8, .2, 1) }
.result-panel h2 { margin: 0; font-size: clamp(48px, 10vw, 76px); line-height: .86; letter-spacing: -.05em }
.result-panel > p:not(.eyebrow) { color: var(--muted); line-height: 1.5 }
.earned-boots { margin: 10px 0 4px; color: #536b66; font-size: 31px; letter-spacing: .1em }
.earned-boots .earned { color: #ffd84a; text-shadow: 0 0 16px rgba(255, 216, 74, .55) }
.result-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 20px 0 }
.result-stats span { padding: 11px 5px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5, 18, 26, .56) }
.result-stats small, .result-stats strong { display: block }
.result-stats small { font-size: 7px; color: var(--muted); letter-spacing: .12em }
.result-stats strong { font-size: 16px; margin-top: 5px }
.primary, .secondary { width: 100%; border-radius: 12px; font-weight: 950; letter-spacing: .07em; cursor: pointer }
.primary { border: 0; padding: 15px 18px; background: var(--lime); color: #111b0b }
.primary span { float: right }
.secondary { margin-top: 9px; padding: 12px 18px; border: 1px solid var(--line); background: transparent; color: var(--muted) }
.primary:hover { filter: brightness(1.06) }
.secondary:hover { color: var(--ink); border-color: var(--cyan) }

@keyframes count-pop { from { opacity: .3; transform: scale(1.25) } to { opacity: 1; transform: scale(1) } }
@keyframes callout { 0% { opacity: 0; transform: translate(-50%, 14px) scale(.75) } 22% { opacity: 1; transform: translate(-50%, 0) scale(1.05) } 100% { opacity: 0; transform: translate(-50%, -30px) scale(.96) } }
@keyframes meter-pop { 50% { transform: translateX(-50%) scale(1.13) } }
@keyframes fail-in { from { opacity: 0; transform: translate(-50%, 12px) } }
@keyframes result-in { from { opacity: 0; transform: translate(-50%, -46%) scale(.9) } }

@media (max-width: 820px) {
  .menu-screen { grid-template-columns: 1fr; align-items: start; padding-top: 34px }
  .hero h1 { font-size: 78px }
  .course-panel { padding: 16px }
  .original-note { grid-column: auto }
  .progress-wrap { width: auto }
  .hud { grid-template-columns: auto 1fr auto }
  .progress-copy span { max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
}

@media (max-width: 540px) {
  :root { --header: 58px }
  .topbar { padding-inline: max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-right)) }
  .brand { font-size: 12px }
  .mini-ball { display: none }
  .icon-button { font-size: 8px; padding: 7px }
  .back { font-size: 9px }
  .menu-screen { padding: 28px 14px }
  .hero h1 { font-size: 66px }
  .lede { margin: 24px 0; font-size: 16px }
  .key-note { line-height: 1.5 }
  .course-card { grid-template-columns: 42px 1fr; padding: 12px }
  .course-number { width: 36px; height: 36px }
  .course-meta { grid-column: 2; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; min-width: 0; text-align: left }
  .course-meta small, .course-boots { margin: 0 }
  .hud { top: 8px; left: 8px; right: 8px; gap: 7px }
  .hud-button { font-size: 8px; padding: 7px 8px }
  .hud-stats { gap: 6px }
  .score small { display: none }
  .score strong { font-size: 9px }
  .badge-count { font-size: 8px }
  .badge-count b { display: none }
  .progress-copy { font-size: 8px }
  .flow-meter { top: 51px }
  .jump-hint { left: 50%; bottom: 5%; font-size: 8px }
  .event-callout { left: 30%; top: 30% }
  .failure-strip { bottom: max(16px, env(safe-area-inset-bottom)); flex-direction: column; gap: 5px; padding: 12px }
  .result-panel { padding: 22px 18px }
  .result-stats { grid-template-columns: repeat(2, 1fr) }
}

@media (max-height: 500px) and (orientation: landscape) {
  :root { --header: 48px }
  .hud { top: 7px }
  .flow-meter { top: 42px }
  .jump-hint { bottom: 4%; padding: 7px 11px }
  .result-panel { padding: 14px 22px }
  .result-panel h2 { font-size: 43px }
  .result-panel > p:not(.eyebrow) { margin: 7px }
  .earned-boots { font-size: 22px; margin: 4px }
  .result-stats { margin: 9px 0 }
  .result-stats span { padding: 7px }
  .primary { padding: 10px }
  .secondary { padding: 7px }
}

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