:root {
  color-scheme: dark;
  --ink: #191322;
  --ink-soft: #2b2138;
  --line: #0b0810;
  --cream: #fff5e4;
  --muted: #c6b8c9;
  --pink: #ff5f8f;
  --mint: #4fe0b0;
  --gold: #ffcf5c;
  --violet: #a68bff;
  --sky: #7cc9ff;
  font: 500 14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #0d1622; color: var(--cream); }
body { isolation: isolate; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
#isle, #flash {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
}
#isle { touch-action: none; }
#flash { pointer-events: none; opacity: 0; background: #ff8f6a; transition: opacity .22s ease-out; z-index: 1; }
#flash.hit { opacity: .3; transition: none; }
#flash.heat { background: #ffb04f; opacity: .35; transition: none; }

main { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

button { font: inherit; pointer-events: auto; touch-action: manipulation; cursor: pointer; color: inherit; }
button { min-width: 44px; min-height: 44px; }
button:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
button:disabled { cursor: progress; opacity: .55; }
svg { display: block; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; inset: 8px 8px auto 8px; z-index: 3;
  display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 6px;
}
.panel {
  background: #191322f2; border: 2px solid #05030a; border-radius: 13px;
  box-shadow: 0 3px 0 #05030a80; padding: 5px 9px 6px; min-width: 0;
}
.eyebrow { margin: 0; font-size: .6rem; font-weight: 850; letter-spacing: .13em; color: var(--mint); }
.figure { margin: 0; display: flex; align-items: baseline; gap: 3px; line-height: 1; }
.figure strong { font-size: clamp(1.15rem, 5.6vw, 1.6rem); font-weight: 850; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.figure span { font-size: .66rem; font-weight: 800; color: var(--muted); }
.grow { margin: 4px 0 3px; height: 4px; border-radius: 3px; background: #3a2f47; overflow: hidden; }
.grow i { display: block; height: 100%; width: 0%; border-radius: 3px; background: linear-gradient(90deg, var(--mint), var(--gold)); transition: width .25s ease; }
.tier { margin: 0; font-size: .64rem; font-weight: 850; letter-spacing: .12em; color: var(--gold); }
.clock { justify-self: center; text-align: center; border-color: var(--line); }
.clock .eyebrow { color: var(--pink); }
.clock strong { display: block; font-size: clamp(1.05rem, 4.8vw, 1.4rem); font-weight: 850; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hearts { margin: 1px 0 0; font-size: .66rem; font-weight: 800; color: var(--muted); }
.hearts b { color: var(--pink); }
.hearts.live { color: var(--gold); }
.board { justify-self: end; display: grid; gap: 4px; justify-items: end; padding: 5px 8px; margin-top: 50px; }
.audio {
  position: absolute; top: 8px; right: 8px; z-index: 12;
  display: grid; place-items: center; width: 44px; height: 44px; min-width: 44px; min-height: 44px;
  border-radius: 12px; border: 2px solid #05030a; background: #191322f2; color: var(--cream);
  box-shadow: 0 3px 0 #05030a80;
}
.audio:active { transform: translateY(2px); box-shadow: 0 1px 0 #05030a80; }
.audio svg { width: 22px; height: 22px; }
.audio[aria-pressed="false"] { border-color: var(--pink); color: var(--pink); }
.audio[aria-pressed="false"] .waves, .audio[aria-pressed="true"] .cross { display: none; }
.standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: .64rem; font-weight: 800; max-width: 34vw; }
.standings li { display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; }
.standings li i { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--mint); }
.standings li b { font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.standings li span { color: var(--muted); font-variant-numeric: tabular-nums; }
.standings li.me { color: var(--gold); }
.standings li.down { opacity: .45; }

#callout {
  position: absolute; left: 50%; top: 110px; transform: translateX(-50%);
  margin: 0; padding: 6px 14px; width: max-content; max-width: min(74%, 21rem);
  border-radius: 999px; border: 2px solid #05030a; background: #fff5e4f2; color: var(--ink);
  font-size: .8rem; font-weight: 820; text-align: center; box-shadow: 0 3px 0 #05030a66;
}
#callout:empty { display: none; }
#callout.hot { background: var(--gold); }

/* ---------- touch ---------- */
.touch {
  position: absolute; inset: auto 12px max(12px, env(safe-area-inset-bottom)) 12px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 10px;
}
.stick {
  position: relative; width: 108px; height: 108px; border-radius: 50%;
  border: 2px solid #05030a; background: #191322cc; box-shadow: 0 4px 0 #05030a66;
  pointer-events: auto; touch-action: none; display: grid; place-items: center; flex: none;
}
.stick .ring { position: absolute; inset: 15px; border-radius: 50%; border: 2px dashed #fff5e433; }
.thumb {
  width: 46px; height: 46px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 36% 30%, #ffffff, var(--mint) 62%, #1e9b7a);
  border: 3px solid #05030a; box-shadow: 0 3px 0 #05030a66;
}
.actions { display: flex; align-items: flex-end; gap: 9px; }
.action {
  position: relative; width: 72px; height: 72px; min-width: 72px; min-height: 72px;
  border-radius: 50%; border: 2px solid #05030a; box-shadow: 0 4px 0 #05030a99;
  display: grid; place-items: center; gap: 1px; padding: 10px 0 0;
  background: var(--ink-soft); color: var(--cream);
  font-size: .58rem; font-weight: 850; letter-spacing: .1em;
}
.action svg { width: 26px; height: 26px; }
.action:active { transform: translateY(3px); box-shadow: 0 1px 0 #05030a99; }
.hop { color: var(--sky); }
.roar { color: var(--gold); }
.roar.ready { background: radial-gradient(circle at 50% 30%, #4a3a20, #2b2138); color: var(--gold); box-shadow: 0 0 0 3px #ffcf5c55, 0 4px 0 #05030a99; }
.charge { display: none; }
.roar::before {
  content: ''; position: absolute; inset: -6px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from -90deg, var(--gold) calc(var(--charge, 0) * 1%), #ffffff1a 0);
  -webkit-mask: radial-gradient(circle, transparent 0 84%, #000 85% 100%);
  mask: radial-gradient(circle, transparent 0 84%, #000 85% 100%);
}

/* ---------- overlays ---------- */
.overlay {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center;
  padding: 14px; overflow: auto; background: radial-gradient(circle at 50% 18%, #191322cc, #05030ae8);
  pointer-events: auto;
}
.card {
  width: min(100%, 24rem); max-height: calc(100% - 4px); overflow: auto;
  padding: 15px 16px 13px; border-radius: 20px; border: 3px solid #05030a;
  background: linear-gradient(180deg, #2b2138f7, #191322fa);
  box-shadow: 0 7px 0 #05030a99, inset 0 1px 0 #fff5e41f;
  pointer-events: auto; scrollbar-width: thin;
}
.label { margin: 0 0 4px; font-size: .66rem; font-weight: 850; letter-spacing: .14em; color: var(--mint); }
h1, h2 { margin: 0; letter-spacing: -.03em; line-height: .92; }
h1 {
  font-size: clamp(2.5rem, 15.5vw, 4.2rem); font-weight: 900; text-transform: uppercase;
  background: linear-gradient(100deg, var(--cream) 12%, var(--pink) 58%, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #05030a) drop-shadow(0 5px 0 #05030a55);
}
h1 em { font-style: normal; display: block; }
h2 { font-size: clamp(1.4rem, 7vw, 2rem); font-weight: 850; }
.pitch { margin: 9px 0 10px; font-size: .84rem; line-height: 1.42; color: var(--cream); }
.how { list-style: none; margin: 0 0 9px; padding: 0; display: grid; gap: 6px; }
.how li { display: flex; gap: 8px; align-items: flex-start; font-size: .79rem; line-height: 1.36; color: var(--muted); }
.how b {
  flex: none; display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%;
  background: var(--pink); color: #2a0d17; font-size: .68rem; font-weight: 900; margin-top: 1px;
}
.how li:nth-child(2) b { background: var(--mint); color: #06231b; }
.how li:nth-child(3) b { background: var(--gold); color: #2a1e05; }
.keys { margin: 0 0 10px; font-size: .7rem; font-weight: 700; color: #a396b4; }
.keys-desktop { display: none; }
.primary {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 16px; border-radius: 13px; border: 3px solid #05030a;
  background: linear-gradient(180deg, var(--mint), #26c191); color: #04231a;
  font-size: .95rem; font-weight: 900; letter-spacing: .04em; text-transform: uppercase;
  box-shadow: 0 5px 0 #05030a99;
}
.primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #05030a99; }
.primary span:last-child { font-size: 1.1rem; }
form { display: grid; gap: 7px; }
form label { font-size: .68rem; font-weight: 850; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
input {
  width: 100%; padding: 10px 12px; border-radius: 11px; border: 2px solid #05030a;
  background: #0f0b15; color: var(--cream); font: inherit; pointer-events: auto; touch-action: manipulation;
}
.credit { margin: 9px 0 0; font-size: .63rem; font-weight: 800; letter-spacing: .1em; color: #8f83a0; text-transform: uppercase; }
.credit span { color: var(--pink); }

.result-card { width: min(100%, 22rem); }
.medal {
  margin: 8px 0 10px; padding: 6px 12px; width: max-content; border-radius: 999px;
  border: 2px solid #05030a; background: var(--gold); color: #2a1e05;
  font-size: .72rem; font-weight: 900; letter-spacing: .12em;
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0 0 9px; }
.stats div { padding: 6px 8px; border-radius: 11px; background: #0f0b15a8; border: 1px solid #fff5e41a; }
.stats dt { font-size: .6rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stats dd { margin: 1px 0 0; font-size: .92rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.final-board { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 3px; font-size: .76rem; font-weight: 800; }
.final-board li { display: flex; align-items: center; gap: 6px; padding: 4px 7px; border-radius: 8px; background: #0f0b1594; }
.final-board li.me { background: #ffcf5c22; color: var(--gold); }
.final-board li i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.final-board li span { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
#score-status { margin: 0 0 8px; min-height: 1em; font-size: .7rem; font-weight: 700; color: var(--muted); }
body.fatal .hud, body.fatal .touch { display: none; }

@media (min-width: 620px) {
  .card { width: min(100%, 27rem); }
  .hud { inset: 12px 12px auto; }
  .audio { top: 12px; right: 12px; }
  .board { margin-top: 0; margin-right: 54px; }
  .standings { font-size: .7rem; max-width: 26vw; }
}
@media (pointer: fine) {
  .keys-touch { display: none; }
  .keys-desktop { display: block; }
}
body[data-device="desktop"] .touch,
body[data-device="desktop"] .keys-touch { display: none !important; }
body[data-device="desktop"] .keys-desktop { display: block !important; }
body[data-device="touch"] .keys-desktop { display: none !important; }
body[data-device="touch"] .keys-touch { display: block !important; }
@media (orientation: landscape) and (max-height: 470px) {
  .hud { inset: 6px 8px auto; gap: 5px; }
  .audio { top: 6px; right: 8px; }
  .board { margin-top: 0; margin-right: 52px; }
  .panel { padding: 4px 8px; border-radius: 11px; }
  .figure strong { font-size: 1.05rem; }
  .standings { grid-auto-flow: column; grid-template-rows: repeat(2, auto); gap: 2px 10px; max-width: 42vw; }
  .standings li:nth-child(n+5) { display: none; }
  #callout { top: 82px; font-size: .74rem; padding: 4px 11px; max-width: min(64%, 22rem); }
  .stick { width: 92px; height: 92px; }
  .thumb { width: 40px; height: 40px; }
  .action { width: 62px; height: 62px; min-width: 62px; min-height: 62px; }
  .action svg { width: 22px; height: 22px; }
  .touch { inset: auto 10px max(8px, env(safe-area-inset-bottom)) 10px; }
  .card { width: min(100%, 34rem); max-height: calc(100% - 2px); padding: 11px 14px; }
  h1 { font-size: clamp(2rem, 8vw, 3rem); }
  h1 em { display: inline; }
  .how { grid-template-columns: repeat(3, 1fr); display: grid; }
  .pitch { margin: 5px 0 6px; }
  .keys { margin-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  #flash { transition: none; }
  .grow i { transition: none; }
}
