/* Spin Defense. The arena is the page; everything else sits in the bands around the circle and
   speaks the same thin-line language as the play field. Colours come from the theme in JS. */

@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --font: "Space Grotesk", system-ui, sans-serif;
  --bg: #0b0d12;
  --ink: #e9e4d8;
  --dim: #7d8190;
  --line: rgba(233, 228, 216, 0.22);
  --panel: rgba(11, 13, 18, 0.86);
  --act: #e9e4d8;
  --gutter: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  /* set from JS: arena centre and radius, and the four bands around it */
  --ax: 50vw; --ay: 50vh; --ar: 40vmin;
}

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

#app { position: fixed; inset: 0; height: 100dvh; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#app[data-screen="paused"] #gl { visibility: hidden; }

/* ---- bands: the space outside the circle ---------------------------------------------------- */

.band { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 8px var(--gutter); }
/* portrait: bands above and below the arena */
.portrait .top { left: 0; right: 0; top: var(--safe-t); height: calc(var(--ay) - var(--ar) - var(--safe-t)); }
.portrait .bottom { left: 0; right: 0; top: calc(var(--ay) + var(--ar)); bottom: var(--safe-b); }
/* landscape: bands left and right of it */
.landscape .top { top: 0; bottom: 0; left: var(--safe-l); width: calc(var(--ax) - var(--ar) - var(--safe-l)); }
.landscape .bottom { top: 0; bottom: 0; right: var(--safe-r); left: calc(var(--ax) + var(--ar)); }

#hud { pointer-events: none; transition: opacity 0.8s ease; }
#hudPause { pointer-events: auto; display: flex; flex-direction: column; align-items: center; min-width: 88px; min-height: 44px; padding: 4px 14px; cursor: pointer; border-radius: 6px; outline-offset: 2px; }
#hudTime { font-size: 30px; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; line-height: 1.05; }
#hudWave { font-size: 13px; color: var(--dim); letter-spacing: 0.04em; }
#app:not([data-screen="play"]) #hud { opacity: 0; }
#app:not([data-screen="play"]) #hudPause { pointer-events: none; }

#hint { pointer-events: none; font-size: 14px; color: var(--dim); text-align: center; }

/* ---- breather ------------------------------------------------------------------------------- */

#breather { gap: 10px; }
#bLine { margin: 0; font-size: 14px; color: var(--dim); text-align: center; min-height: 1.3em; }
#cards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.landscape #cards { flex-direction: column; }
.card { position: relative; display: flex; align-items: center; gap: 10px; min-width: 104px; min-height: 56px; padding: 8px 14px 8px 10px; background: transparent; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; text-align: left; }
.card canvas { width: 34px; height: 34px; flex: none; }
.card .name { font-size: 15px; line-height: 1.15; }
.card .lv { display: flex; gap: 4px; margin-top: 4px; }
.card .lv i { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--ink); }
.card .lv i.on { background: var(--ink); }
.card:hover, .card:focus-visible { border-color: var(--ink); outline: none; }
.card.picked { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.card.faded { opacity: 0.3; }
.card kbd { position: absolute; top: -9px; right: -7px; }

kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; font: 600 11px var(--font); color: var(--bg); background: var(--ink); border-radius: 4px; }
#app:not(.kb):not(.pad) kbd { display: none; }

/* ---- buttons -------------------------------------------------------------------------------- */

.menu { display: flex; flex-direction: column; gap: 10px; width: min(340px, 100%); }
.menu .row { display: flex; gap: 10px; }
.menu .row > * { flex: 1; }
.menu button, .bar button, .grid2 button, #bNext, .chips button, .opt {
  min-height: 48px; padding: 0 16px; border: 1px solid var(--line); background: transparent; border-radius: 6px; cursor: pointer; font-size: 16px;
}
.menu button:hover, .grid2 button:hover, .chips button:hover, .opt:hover { border-color: var(--ink); }
button:focus-visible, .opt:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button.primary, #bNext { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 700; }
button.primary:disabled { opacity: 0.35; cursor: default; }
button.quiet { color: var(--dim); }
#bNext { min-width: 180px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
#bNext kbd { background: var(--bg); color: var(--ink); }

/* ---- screens -------------------------------------------------------------------------------- */

.screen { position: absolute; inset: 0; }
#title, #death { pointer-events: none; }
#title > *, #death > * { pointer-events: auto; }

#logo { margin: 0; font-size: clamp(34px, 9vw, 60px); font-weight: 700; letter-spacing: -0.01em; line-height: 1; }
#title .menu, #death .menu, #paused .menu { margin: 0 auto; }
#tDailyLine { margin: 0; font-size: 14px; text-align: center; }

#paused { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px var(--gutter); background: var(--bg); }
#paused h2 { margin: 0; font-size: 28px; }
#paused p { max-width: 520px; text-align: center; font-size: 14px; line-height: 1.45; margin: 0; }

#deathFacts { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#dTime { font-size: 44px; font-variant-numeric: tabular-nums; line-height: 1; }
#dMeta { font-size: 14px; text-align: center; }
#dStatus { margin: 0; font-size: 13px; min-height: 1.2em; text-align: center; }
#death .band { transition: opacity 1.2s ease; }
#death.composing .band { opacity: 0; pointer-events: none; }

/* full panels: meta, gallery, piece, settings, credits */
#meta, #gallery, #piece, #settings, #credits { display: flex; flex-direction: column; background: var(--bg); padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.bar { display: flex; align-items: center; gap: 12px; padding: 10px var(--gutter); border-bottom: 1px solid var(--line); flex: none; }
footer.bar { border-bottom: 0; border-top: 1px solid var(--line); justify-content: center; }
footer.bar .primary { min-width: 200px; }
.bar h2 { margin: 0; font-size: 20px; flex: 1; }
.bar [data-back] { min-width: 48px; padding: 0; font-size: 20px; }
.cur { font-variant-numeric: tabular-nums; font-size: 18px; }
.scroll { flex: 1; overflow-y: auto; padding: 8px var(--gutter) 24px; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.scroll h3 { font-size: 13px; color: var(--dim); font-weight: 500; letter-spacing: 0.06em; margin: 18px 0 6px; }

.list { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.item .what { font-size: 16px; }
.item .why { grid-column: 1; font-size: 13px; color: var(--dim); line-height: 1.35; }
.item .lvl { display: flex; gap: 4px; }
.item .lvl i { width: 7px; height: 7px; border-radius: 50%; border: 1px solid var(--ink); }
.item .lvl i.on { background: var(--ink); }
.item .buy { grid-row: 1 / span 2; grid-column: 2; min-width: 96px; min-height: 44px; border: 1px solid var(--ink); background: transparent; border-radius: 6px; font-variant-numeric: tabular-nums; cursor: pointer; }
.item .buy:disabled { border-color: var(--line); color: var(--dim); cursor: default; }
.item .buy.owned { border: 0; color: var(--dim); }

.chips { display: flex; gap: 8px; padding: 10px var(--gutter) 0; flex-wrap: wrap; flex: none; }
.chips button { min-height: 40px; font-size: 14px; }
.chips button.on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
#gGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding-top: 8px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.tile img { width: 100%; aspect-ratio: 1; display: block; border-radius: 4px; background: var(--panel); }
.tile span { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }
.tile:focus-visible img { outline: 2px solid var(--ink); outline-offset: 2px; }

#pcImg { display: block; width: min(100%, 560px); aspect-ratio: 1; margin: 8px auto; border-radius: 4px; }
#pcFacts { text-align: center; font-size: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 560px; margin: 12px auto; }
#pcStatus { text-align: center; font-size: 13px; min-height: 1.2em; }

.opt { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0; text-align: left; }
.opt .v { color: var(--dim); }
.opt[aria-pressed="true"] .v { color: var(--ink); }

#cList p { margin: 0 0 14px; font-size: 14px; line-height: 1.45; }
#cList b { font-weight: 700; }
#cList .k { display: block; font-size: 12px; color: var(--dim); letter-spacing: 0.05em; }

/* key prompts for keyboard and controller, never on touch */
#prompts { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 8px); display: flex; justify-content: center; gap: 16px; font-size: 13px; color: var(--dim); pointer-events: none; }
#prompts span { display: inline-flex; align-items: center; gap: 6px; }
#app:not(.kb):not(.pad) #prompts { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- fixes from the UX pass ------------------------------------------------------------------ */
/* narrow side bands: rows wrap instead of running off the screen */
.menu .row { flex-wrap: wrap; }
.menu .row > * { flex: 1 1 auto; min-width: 0; padding: 0 10px; }
.landscape .menu { width: 100%; max-width: 340px; }
/* key prompts live in a band, never over the arena */
.landscape #prompts { left: var(--safe-l); right: auto; width: calc(var(--ax) - var(--ar) - var(--safe-l)); flex-wrap: wrap; justify-content: center; padding: 0 12px; }
.portrait #prompts { top: calc(var(--ay) + var(--ar) + 4px); bottom: auto; }
#app[data-screen="play"] #breather:not([hidden]) ~ #prompts { display: none; }
/* scale type up on big screens */
#hudTime { font-size: clamp(30px, 4.2vmin, 48px); }
#hudWave { font-size: clamp(13px, 1.6vmin, 17px); }
#dTime { font-size: clamp(40px, 6vmin, 64px); }
#gl { aspect-ratio: auto; }
button.link { border: 0; background: none; color: var(--dim); font-size: 13px; min-height: 44px; padding: 0 12px; cursor: pointer; }
button.link:hover { color: var(--ink); }
#bReport { margin: 0; font-size: 13px; color: var(--dim); text-align: center; line-height: 1.5; }
#bReport b { font-weight: 500; }

/* the carts tray is a spine on the left edge: keep the left band clear of it */
.landscape .top { padding-left: 48px; }
.landscape #logo { font-size: clamp(26px, 3.4vw, 56px); text-align: center; }
