/* Menus follow the NCv3 site: same tokens, lowercase Outfit display,
   DM Mono meta, pill buttons, flavour grounds. The game itself is pixels. */

:root {
  --ink: #0d1215;
  --ink-lift: #131b1f;
  --panel: #182126;
  --sugar: #f2eff2;
  --sugar-mid: rgba(242, 239, 242, 0.66);
  --sugar-dim: rgba(242, 239, 242, 0.5);
  --line: rgba(242, 239, 242, 0.1);
  --line-hi: rgba(242, 239, 242, 0.2);
  --raspberry: #ff4a7d;
  --tangerine: #ffa03f;
  --mint: #63e0bf;
  --flavour: var(--raspberry);

  --display: 'Outfit', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --pixel: 'Press Start 2P', var(--mono);

  --pad: clamp(16px, 4vw, 48px);
  --r-sm: 16px;
  --r-md: 26px;
  --r-pill: 999px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-hover: 0.42s;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--ink);
  color: var(--sugar);
  font-family: var(--display);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}
#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  /* width/height set by game.js to the largest fit */
}

/* ------------------------------------------------------------ type */
.meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--sugar-dim);
}
.display {
  font-weight: 700;
  font-size: clamp(2.6rem, 7.4vw, 6.8rem);
  line-height: 0.88;
  letter-spacing: -0.055em;
  margin: 0.25em 0 0.3em;
}
.display .line { display: block; }
.chapter {
  font-weight: 700;
  font-size: clamp(2rem, 5.4vw, 4rem);
  line-height: 0.92;
  letter-spacing: -0.05em;
  margin: 0.2em 0 0.35em;
}
.lead {
  font-size: clamp(1rem, 1.6vw, 1.3rem);
  line-height: 1.45;
  color: var(--sugar-mid);
  max-width: 34ch;
}

/* ------------------------------------------------------------ pills */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background-color var(--t-hover) var(--ease-out), color var(--t-hover) var(--ease-out),
    border-color var(--t-hover) var(--ease-out), transform 0.2s var(--ease-out);
}
.pill:active { transform: scale(0.97); }
.pill .icon { width: 18px; height: 18px; }
.pill-solid { background: var(--sugar); color: var(--ink); }
.pill-solid:hover, .pill-solid:focus-visible { background: var(--raspberry); }
.pill-ghost { border-color: var(--line-hi); }
.pill-ghost:hover, .pill-ghost:focus-visible { border-color: var(--sugar); }
/* fall club: monochrome, like the artwork */
.pill-fall { background: #050506; color: #f2eff2; border-color: #f2eff2; letter-spacing: 0.02em; }
.pill-fall:hover, .pill-fall:focus-visible { background: #f2eff2; color: #050506; }
a.pill { text-decoration: none; color: inherit; }
.pill-sm { min-height: 38px; padding: 0 16px; font-size: 0.85rem; }
:focus-visible { outline: 2px solid var(--mint); outline-offset: 3px; }

.round-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line-hi);
  display: grid; place-items: center;
  background: rgba(13, 18, 21, 0.55);
  backdrop-filter: blur(6px);
  transition: border-color var(--t-hover) var(--ease-out);
}
.round-btn:hover { border-color: var(--sugar); }
.round-btn img { width: 20px; height: 20px; filter: invert(1); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 1.6rem; }
.actions-col { flex-direction: column; align-items: stretch; }

.facts {
  display: flex;
  gap: clamp(20px, 4vw, 48px);
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.facts dt { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.06em; color: var(--sugar-dim); }
.facts dd { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.03em; margin-top: 2px; }

/* ------------------------------------------------------------ screens */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  animation: screen-in 0.6s var(--ease-out) both;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px var(--pad);
}
.lockup { height: 46px; width: auto; }

.screen-title {
  background: linear-gradient(90deg, rgba(13, 18, 21, 0.94) 0%, rgba(13, 18, 21, 0.78) 45%, rgba(13, 18, 21, 0.1) 100%);
}
.title-body { padding: clamp(12px, 6vh, 72px) var(--pad) 48px; max-width: 900px; }

.screen-select { background: rgba(13, 18, 21, 0.9); }
.select-body { padding: 8px var(--pad) 48px; max-width: 980px; }
.cards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 1rem; }
.card {
  --flavour: var(--raspberry);
  background: var(--flavour);
  color: var(--ink);
  border-radius: var(--r-md);
  padding: 20px 22px 24px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  outline: 3px solid transparent;
  outline-offset: 4px;
  transition: outline-color 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}
.card:hover { transform: translateY(-3px); }
.card[aria-checked='true'] { outline-color: var(--sugar); }
.f-raspberry { --flavour: var(--raspberry); }
.f-mint { --flavour: var(--mint); }
.f-tangerine { --flavour: var(--tangerine); }
.f-sugar { --flavour: var(--sugar); }
.f-blush { --flavour: #ffb8cb; }
.card-sprite {
  width: min(140px, 14vw);
  height: auto;
  aspect-ratio: 1;
  image-rendering: pixelated;
  align-self: center;
  margin: 4px 0 10px;
  animation: bob 1.1s steps(4) infinite alternate;
}
@keyframes bob { to { transform: translateY(-8px); } }
.card-name { font-size: clamp(1.6rem, 3.4vw, 2.4rem); font-weight: 700; letter-spacing: -0.04em; line-height: 1; }
.card-meta { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.04em; color: rgba(13, 18, 21, 0.72); }

.screen-how, .screen-pause, .screen-over, .screen-level {
  display: grid;
  place-items: center;
  padding: 24px var(--pad);
  background: rgba(13, 18, 21, 0.72);
  backdrop-filter: blur(3px);
}
.sheet {
  width: min(560px, 100%);
  background: var(--ink-lift);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: clamp(22px, 4vw, 36px);
}
.sheet-sm { width: min(400px, 100%); }
.how-list, .power-list { list-style: none; display: grid; gap: 10px; margin: 0.4rem 0 1.4rem; color: var(--sugar-mid); line-height: 1.45; }
.how-list b, .power-list b { color: var(--sugar); font-weight: 600; }
.power-list li { display: flex; gap: 12px; align-items: center; }
.power-list canvas { width: 28px; height: 28px; image-rendering: pixelated; flex: none; }
.keys { margin-top: -0.4rem; }

.figure {
  font-size: clamp(4.5rem, 14vw, 8.5rem);
  font-weight: 700;
  letter-spacing: -0.06em;
  line-height: 0.9;
  color: var(--tangerine);
  margin-top: 0.2em;
}
.figure-unit { font-size: 0.4em; letter-spacing: -0.02em; margin-left: 0.08em; }
#over-kicker.is-best { color: var(--mint); }

/* ------------------------------------------------------------ hud */
.hud {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  padding: 14px var(--pad);
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: start;
  gap: 18px;
}
.hud-dist {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.05em;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.hud-unit { font-size: 0.5em; margin-left: 2px; color: var(--sugar-mid); }
.hud-best { margin-top: 4px; }
.hud-level { margin-top: 2px; color: var(--sugar-mid); }
.hud-progress { margin-top: 5px; width: clamp(90px, 16vw, 150px); height: 4px; border-radius: 4px; background: rgba(242, 239, 242, 0.18); overflow: hidden; }
.hud-progress i { display: block; height: 100%; width: 0; background: var(--tangerine); transition: width 0.2s linear; }
.hud-progress i.is-final { background: var(--raspberry); animation: blink 0.5s steps(2) infinite; }
.pill:disabled { opacity: 0.45; cursor: not-allowed; }
.hud-coins {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 8px;
  border-radius: var(--r-pill);
  background: rgba(13, 18, 21, 0.55);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  margin-top: 4px;
}
.coin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0 0 18%, #ffc83d 20% 60%, #e07a1e 62%);
  box-shadow: 0 0 0 2px #5a2d06;
}
.hud-powers { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 6px; }
.power-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--r-pill);
  background: var(--flavour);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.power-pill .veh-hp { letter-spacing: 0.1em; }
.power-pill canvas { width: 24px; height: 24px; image-rendering: pixelated; background: rgba(13,18,21,0.15); border-radius: 50%; }
.power-pill .bar-fill { width: 40px; height: 4px; border-radius: 4px; background: rgba(13, 18, 21, 0.25); overflow: hidden; }
.power-pill .bar-fill i { display: block; height: 100%; background: var(--ink); }
.hud-pause { pointer-events: auto; }

/* ------------------------------------------------------------ dock */
.dock {
  position: absolute;
  left: var(--pad);
  bottom: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 6px 6px;
  border-radius: var(--r-pill);
  background: rgba(19, 27, 31, 0.82);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  max-width: min(360px, calc(100vw - 2 * var(--pad)));
  animation: screen-in 0.6s var(--ease-out) both;
}
.dock-cover { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dock-cover.is-mark { object-fit: contain; padding: 7px; }
.dock.is-muted .dock-cover { animation-play-state: paused; opacity: 0.5; }
.dock-text { min-width: 0; padding-right: 4px; }
.dock-text .meta { font-size: 0.66rem; }
.dock-title { font-weight: 600; font-size: 0.95rem; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock .round-btn { width: 40px; height: 40px; flex: none; }
.dock.is-playing-run { opacity: 0.8; }

.tap-hint {
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-family: var(--pixel);
  font-size: clamp(10px, 1.6vw, 14px);
  color: var(--sugar);
  text-shadow: 0 2px 0 var(--ink);
  pointer-events: none;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.press-hint {
  margin-top: 1.6rem;
  font-family: var(--pixel);
  font-size: 11px;
  line-height: 1.6;
  color: var(--tangerine);
  animation: blink 1.2s steps(2) infinite;
}

@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card-sprite { width: min(120px, 30vw); }
  .card { padding: 14px 14px 18px; }
  .hud { grid-template-columns: auto 1fr auto; }
  .hud-coins { grid-column: 1; grid-row: 2; justify-self: start; margin-top: 0; }
  .hud-powers { grid-column: 2; grid-row: 1; }
  .lockup { height: 34px; }
  .dock { bottom: 10px; }
}
/* ------------------------------------------------------------ phones */
body { -webkit-touch-callout: none; overscroll-behavior: none; position: fixed; inset: 0; }
#game { touch-action: none; }

/* keep HUD and dock clear of the notch / dynamic island in landscape */
.hud {
  padding-left: max(var(--pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--pad), env(safe-area-inset-right, 0px));
  padding-top: max(14px, env(safe-area-inset-top, 0px));
}
.dock { left: max(var(--pad), env(safe-area-inset-left, 0px)); bottom: max(14px, env(safe-area-inset-bottom, 0px)); }
.bar, .title-body, .select-body {
  padding-left: max(var(--pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--pad), env(safe-area-inset-right, 0px));
}

/* sheets centre when they fit and scroll from the top when they don't */
.screen-how, .screen-pause, .screen-over, .screen-level { display: flex; flex-direction: column; }
.screen-how .sheet, .screen-pause .sheet, .screen-over .sheet, .screen-level .sheet { margin: auto; }
.screen-level .sheet { border-color: var(--tangerine); }
#lvl-kicker { color: var(--tangerine); }

/* keyboard tips mean nothing on a touch screen */
@media (pointer: coarse) { .keys { display: none; } }

/* the turn-sideways card */
.rotate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px max(24px, env(safe-area-inset-left, 0px));
  background: var(--ink);
}
.rotate .lead { margin-top: 0.2rem; }
.rotate-phone {
  width: 64px; height: 108px;
  border: 3px solid var(--sugar);
  border-radius: 14px;
  display: grid; place-items: center;
  margin: 0 0 28px 22px;
  animation: turn 2.4s var(--ease-out) infinite;
}
.rotate-phone img { width: 34px; }
@keyframes turn {
  0%, 25% { transform: rotate(0deg); }
  55%, 100% { transform: rotate(-90deg); }
}

/* Phones in landscape: during a run the dock moves out of the flight lane
   to a small pill at the top. */
@media (max-height: 520px) {
  .dock.is-playing-run {
    top: 10px; bottom: auto; left: 50%;
    transform: translateX(-50%);
    padding: 3px 10px 3px 3px; gap: 8px;
    animation: none;
  }
  .dock.is-playing-run .dock-cover { width: 26px; height: 26px; }
  .dock.is-playing-run .dock-text .meta, .dock.is-playing-run .round-btn { display: none; }
  .dock.is-playing-run .dock-title { font-size: 0.8rem; max-width: 30vw; }
}
/* very short screens: drop the blurb and the press hint to keep the buttons in view */
@media (max-height: 430px) {
  .screen-title .lead, .press-hint { display: none; }
  /* five character cards: names and sprites only, and no song bar over them */
  .card-meta { display: none; }
  body[data-screen="select"] .dock { display: none; }
}
/* Phones held sideways (short screens): every menu fits without scrolling. */
@media (max-height: 520px) {
  .bar { padding-top: max(10px, env(safe-area-inset-top, 0px)); padding-bottom: 6px; }
  .lockup { height: 32px; }
  .pill { min-height: 42px; padding: 0 18px; font-size: 0.9rem; }
  .pill-sm { min-height: 34px; padding: 0 14px; }
  .actions { margin-top: 0.9rem; gap: 8px; }
  .facts { margin-top: 0.9rem; padding-top: 0.6rem; }
  .facts dd { font-size: 1.15rem; }

  .title-body { padding-top: 4px; padding-bottom: 20px; }
  .display { font-size: clamp(1.9rem, 5.6vw, 3.4rem); margin: 0.15em 0 0.25em; }
  .lead { font-size: 0.95rem; max-width: 46ch; }
  .press-hint { margin-top: 0.8rem; font-size: 9px; }

  .chapter { font-size: clamp(1.5rem, 4.2vw, 2.4rem); margin: 0.1em 0 0.3em; }
  .select-body { padding-bottom: 20px; }
  .cards { margin-top: 0.4rem; max-width: 900px; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
  .card-meta { font-size: 0.66rem; line-height: 1.35; }
  .card { padding: 12px 16px 14px; }
  .card-sprite { width: min(120px, 24vh); margin: 0 0 4px; }
  .card-name { font-size: 1.25rem; }

  .screen-how, .screen-pause, .screen-over { padding-block: 12px; }
  .sheet { padding: 16px 22px 18px; }
  .screen-how .sheet { width: min(760px, 100%); }
  .how-list { margin: 0.2rem 0 0.6rem; gap: 3px; font-size: 0.88rem; line-height: 1.35; }
  .screen-how .chapter { font-size: 1.5rem; }
  .screen-how .actions { margin-top: 0.5rem; }
  .power-list { grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 0.2rem 0 0.8rem; font-size: 0.9rem; }
  .figure { font-size: clamp(2.6rem, 11vh, 3.8rem); }
  .screen-over .lead { font-size: 0.9rem; }
  .actions-col .pill { min-height: 40px; }

  /* no room for the song bar during a run or over a sheet on a short screen:
     it shows on the title and candy screens only */
  body[data-screen="run"] .dock, body[data-screen="over"] .dock,
  body[data-screen="pause"] .dock, body[data-screen="how"] .dock, body[data-screen="level"] .dock { display: none; }
  .facts { gap: 18px; }
  .facts dt { font-size: 0.68rem; }
  /* on menus the dock tucks into the bottom-right corner, away from the buttons */
  .dock:not(.is-playing-run) { left: auto; right: max(var(--pad), env(safe-area-inset-right, 0px)); bottom: 10px; }
  .dock:not(.is-playing-run) .dock-cover { width: 32px; height: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .screen, .dock { animation: none; }
  .card-sprite, .dock-cover { animation: none; }
}
