:root {
  --plum: #120E24;
  --deep: #2E2152;
  --purple: #6C50E7;
  --purple-2: #8A72F0;
  --lime: #CFFD38;
  --cream: #F7F4EE;
  --lav: #DCD3F2;
  --coral: #FF6A5E;
  --amber: #FFB020;
  --ink: #1A1432;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Sora', 'Avenir Next', 'Helvetica Neue', sans-serif;
  --pixel: 'Press Start 2P', monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--plum);
  color: var(--cream);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(60% 50% at 50% 100%, rgba(108,80,231,.22), transparent 70%),
    radial-gradient(40% 40% at 50% 0%, rgba(207,253,56,.05), transparent 70%),
    var(--plum);
}
#app::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  opacity: .06; mix-blend-mode: overlay;
}

#stage {
  position: relative;
  width: 100vw; height: 100vh; height: 100dvh;
  overflow: hidden;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  background: var(--plum);
}
@media (min-aspect-ratio: 3/4) {
  #stage {
    width: min(100vw, calc(100dvh * 0.66));
    border-radius: 22px;
    box-shadow: 0 0 0 1px rgba(220,211,242,.08), 0 40px 120px rgba(0,0,0,.55), 0 0 80px rgba(108,80,231,.12);
  }
}
@media (min-aspect-ratio: 3/4) and (min-height: 760px) {
  #stage { height: calc(100dvh - 40px); }
}

canvas#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
.lbl {
  font: 600 10px/1 var(--sans);
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--lav); opacity: .85;
}
.hud {
  position: absolute; left: 0; right: 0; top: 0;
  padding: calc(44px + env(safe-area-inset-top)) 18px 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  pointer-events: none;
  text-shadow: 0 1px 12px rgba(18,14,36,.7);
}
.hud-left { display: grid; gap: 4px; }
.score {
  font: 700 34px/1 var(--sans); letter-spacing: -.02em; color: var(--lime);
  font-variant-numeric: tabular-nums;
  transition: transform .12s ease;
}
.score.bump { transform: scale(1.12); }
.best { font: 500 10px/1 var(--sans); letter-spacing: .1em; color: var(--lav); opacity: .7; }
.hud-center { display: grid; justify-items: center; gap: 7px; }
.ctx { display: flex; gap: 5px; }
.ctx i {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--lime); box-shadow: 0 0 10px rgba(207,253,56,.35), inset 0 -2px 0 rgba(0,0,0,.15);
  transition: background .25s, box-shadow .25s, transform .25s;
}
.ctx i.off { background: rgba(220,211,242,.16); box-shadow: inset 0 0 0 1px rgba(220,211,242,.25); transform: scale(.9); }
.ctx.low i:not(.off) { animation: pulse .7s ease-in-out infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 18px rgba(255,106,94,.6); background: #F3F76A; } }
.hud-right { display: grid; justify-items: end; gap: 5px; }
.timer { font: 700 22px/1 var(--sans); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stage-lbl { color: var(--lime); }

.bossbar {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(100px + env(safe-area-inset-top));
  width: min(70%, 320px);
  display: grid; justify-items: center; gap: 6px;
  pointer-events: none;
}
.bossbar .lbl { color: var(--coral); text-shadow: 0 0 12px rgba(255,106,94,.6); }
.bossbar .bar {
  width: 100%; height: 9px; border-radius: 99px;
  background: rgba(247,244,238,.12); box-shadow: inset 0 0 0 1px rgba(247,244,238,.18);
  overflow: hidden;
}
.bossbar .bar i {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, #FF6A5E, #FFB020);
  box-shadow: 0 0 14px rgba(255,106,94,.6);
  transition: width .12s linear;
  border-radius: 99px;
}

.powerbadge {
  position: absolute; left: 14px; bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px 11px 10px; border-radius: 14px;
  background: rgba(18,14,36,.72); backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(220,211,242,.18);
  overflow: hidden; pointer-events: none;
  animation: rise .3s cubic-bezier(.2,.9,.3,1.2);
}
.pb-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font: 700 15px var(--sans); }
.powerbadge[data-type="MCP"] .pb-icon { background: var(--lime); color: var(--plum); }
.powerbadge[data-type="AGENT"] .pb-icon { background: var(--purple); color: var(--cream); }
.powerbadge[data-type="MEMORY"] .pb-icon { background: var(--amber); color: var(--plum); }
.pb-text { display: grid; line-height: 1.15; }
.pb-text b { font: 700 13px var(--sans); letter-spacing: .04em; }
.pb-text small { font: 500 10px var(--sans); color: var(--lav); opacity: .85; }
.powerbadge i { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--lime); transform-origin: left; }
.powerbadge[data-type="AGENT"] i { background: var(--purple-2); }
.powerbadge[data-type="MEMORY"] i { background: var(--amber); }

.toasts {
  position: absolute; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: grid; justify-items: center; gap: 6px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 9px; border-radius: 99px;
  background: rgba(18,14,36,.78); backdrop-filter: blur(8px);
  box-shadow: inset 0 0 0 1px rgba(220,211,242,.16);
  font: 600 12px var(--sans); color: var(--cream); white-space: nowrap;
  animation: toast 1.7s cubic-bezier(.2,.8,.3,1) forwards;
}
.toast::before {
  content: '✓'; width: 18px; height: 18px; border-radius: 50%;
  background: var(--lime); color: var(--plum); display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
}
.toast.combo { color: var(--lime); }
.toast.combo::before { content: '×'; background: var(--purple); color: var(--cream); }
.toast.power::before { content: '★'; background: var(--purple); color: var(--lime); }
@keyframes toast {
  0% { opacity: 0; transform: translateY(10px) scale(.92); }
  12% { opacity: 1; transform: none; }
  80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-14px); }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Countdown ---------- */
.countdown {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 22px;
  pointer-events: none; padding-bottom: 22%;
}
#cd-text {
  font: 400 54px/1 var(--pixel); color: var(--lime);
  text-shadow: 0 0 24px rgba(207,253,56,.55), 0 0 60px rgba(207,253,56,.25);
  animation: cdpop .7s cubic-bezier(.2,.9,.3,1.1);
}
#cd-text.big { font-size: 40px; letter-spacing: .04em; }
.cd-sub { font: 500 12px var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--lav); opacity: .8; }
@keyframes cdpop { 0% { transform: scale(1.6); opacity: 0; } 35% { transform: scale(1); opacity: 1; } 100% { opacity: 1; } }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: calc(56px + env(safe-area-inset-top)) 28px calc(28px + env(safe-area-inset-bottom));
}
.topbar {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(12px + env(safe-area-inset-top));
  z-index: 5; color: var(--cream); display: block; opacity: .95;
  filter: drop-shadow(0 2px 10px rgba(18,14,36,.7));
  transition: opacity .2s, transform .2s;
}
.topbar:hover { opacity: 1; transform: translateX(-50%) scale(1.04); }
.topbar .logo { height: 20px; width: auto; display: block; }
.logo .lm { fill: var(--lime); }
.logo .lt { fill: currentColor; }

.start {
  justify-content: flex-start;
  background: linear-gradient(180deg, rgba(18,14,36,.55) 0%, rgba(18,14,36,.15) 40%, rgba(18,14,36,0) 60%, rgba(18,14,36,.55) 100%);
}
.start > * { animation: reveal .7s cubic-bezier(.2,.8,.2,1) both; }
.start > *:nth-child(2) { animation-delay: .08s; }
.start > *:nth-child(3) { animation-delay: .18s; }
.start > *:nth-child(4) { animation-delay: .28s; }
.start > *:nth-child(5) { animation-delay: .38s; }
@keyframes reveal { from { opacity: 0; transform: translateY(16px); } }

.title {
  margin: 34px 0 10px; display: grid; line-height: .92;
  font-family: var(--serif); font-weight: 600; font-size: clamp(56px, 17vw, 84px);
  letter-spacing: -.03em; text-shadow: 0 6px 40px rgba(18,14,36,.6);
}
.title .t1 { color: var(--cream); font-variation-settings: 'opsz' 144; }
.title .t2 { color: var(--lime); font-style: italic; font-weight: 500; font-variation-settings: 'opsz' 144; padding-left: .18em; }
.tag { margin: 0 0 26px; font: 500 15px var(--sans); color: var(--lav); }
.hint { margin: 14px 0 0; font: 500 11px var(--sans); letter-spacing: .06em; color: var(--lav); opacity: .75; }
.hint kbd {
  font: 600 10px var(--sans); padding: 2px 5px; border-radius: 4px; margin-right: 2px;
  background: rgba(247,244,238,.1); box-shadow: inset 0 0 0 1px rgba(247,244,238,.22);
}
.hint .mob { display: none; }
@media (pointer: coarse) { .hint .desk { display: none; } .hint .mob { display: inline; } }

.btn {
  appearance: none; border: 0; cursor: pointer;
  font: 700 15px var(--sans); letter-spacing: .01em;
  padding: 15px 34px; border-radius: 99px;
  transition: transform .15s cubic-bezier(.2,.9,.3,1.3), box-shadow .15s, background .15s;
  text-decoration: none; display: inline-flex; align-items: center; gap: 10px; justify-content: center;
}
.btn:active { transform: scale(.96); }
.btn-lime {
  background: var(--lime); color: var(--plum);
  box-shadow: 0 10px 30px rgba(207,253,56,.25), 0 0 0 4px rgba(207,253,56,.12);
}
.btn-lime:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(207,253,56,.35), 0 0 0 6px rgba(207,253,56,.14); }
.btn-ghost {
  background: transparent; color: var(--lav);
  box-shadow: inset 0 0 0 1.5px rgba(220,211,242,.3); padding: 12px 26px; font-size: 13px;
}
.btn-ghost:hover { background: rgba(220,211,242,.08); color: var(--cream); }
.btn-cta { width: 100%; max-width: 330px; padding: 16px 22px; font-size: 15px; }
.ph-badge {
  width: 24px; height: 24px; border-radius: 50%; background: var(--plum); color: var(--lime);
  display: grid; place-items: center; font: 800 13px var(--sans);
}
.arrow { transition: transform .2s; }
.btn-cta:hover .arrow { transform: translateX(4px); }

.end {
  justify-content: center; overflow-y: auto;
  background: radial-gradient(70% 60% at 50% 40%, rgba(18,14,36,.4), rgba(18,14,36,.85));
}
.end { justify-content: safe center; }
.panel {
  width: 100%; max-width: 380px; flex: none;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 30px 26px 26px; border-radius: 26px;
  background: rgba(18,14,36,.62); backdrop-filter: blur(14px);
  box-shadow: inset 0 0 0 1px rgba(220,211,242,.16), 0 30px 80px rgba(0,0,0,.45);
  animation: reveal .6s cubic-bezier(.2,.8,.2,1) both;
}
.eyebrow { font: 600 10px var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--coral); }
.eyebrow.lime { color: var(--lime); }
.h2 {
  margin: 0; font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1.12; letter-spacing: -.02em;
  color: var(--cream); font-variation-settings: 'opsz' 72;
}
.h2 em { font-style: italic; font-weight: 500; color: var(--lime); }
.final { display: grid; justify-items: center; gap: 2px; margin: 4px 0; }
.final span:first-child { font: 700 64px/1 var(--sans); letter-spacing: -.04em; color: var(--lime); font-variant-numeric: tabular-nums; text-shadow: 0 0 40px rgba(207,253,56,.3); }
.final-lbl { font: 600 10px var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--lav); }
.recap { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 7px; justify-items: start; }
.recap li { display: flex; align-items: center; gap: 9px; font: 500 13px var(--sans); color: var(--cream); animation: reveal .5s both; }
.recap li:nth-child(2) { animation-delay: .1s; } .recap li:nth-child(3) { animation-delay: .2s; } .recap li:nth-child(4) { animation-delay: .3s; }
.recap li::before {
  content: '✓'; width: 18px; height: 18px; border-radius: 50%; background: var(--lime); color: var(--plum);
  display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: none;
}
.pitch { margin: 2px 0 4px; font: 400 13px/1.5 var(--sans); color: var(--lav); text-align: center; max-width: 300px; }
.pitch b { font-weight: 600; color: var(--cream); }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.recap li.todo { color: var(--lav); opacity: .8; }
.recap li.todo::before { content: '…'; background: rgba(255,106,94,.9); color: var(--cream); font-size: 12px; }
.foot { margin: 4px 0 0; font-family: var(--serif); font-style: italic; font-size: 14px; color: var(--lav); opacity: .8; }

.mute {
  position: absolute; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom));
  width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(18,14,36,.6); color: var(--lav);
  box-shadow: inset 0 0 0 1px rgba(220,211,242,.18);
  display: grid; place-items: center; opacity: .7; transition: opacity .2s;
}
.mute:hover { opacity: 1; }
.mute .wave { display: none; }
.mute.on .wave { display: block; }
.mute.on .x { display: none; }

@media (max-height: 640px) {
  .title { font-size: 56px; }
  .screen { padding-top: 32px; }
  .panel { gap: 10px; padding: 22px 20px; }
  .h2 { font-size: 23px; }
  .final span:first-child { font-size: 50px; }
}

@media (max-height: 880px) {
  .end .panel { gap: 10px; padding: 22px 22px 20px; }
  .end .h2 { font-size: 24px; }
  .end .final span:first-child { font-size: 50px; }
  .end .recap { gap: 5px; }
}
