/* Press Start 2P, self-hosted (SIL OFL 1.1, see /fonts/PressStart2P-OFL.txt): no third-party requests */
@font-face {
  font-family: 'Press Start 2P'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/press-start-2p-latin-400-normal.woff2') format('woff2');
}
:root {
  --bg: #140a24;
  --bg-2: #21103a;
  --panel: #2b1650;
  --line: #5b2fa0;
  --text: #e9dcff;
  --muted: #a58fd0;
  --accent: #b46bff;
  --accent-2: #6ef2c8;
  --danger: #ff6b8b;
  --px: 4px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { touch-action: manipulation; } /* no double-tap zoom; pinch zoom stays available */
body.playing { overscroll-behavior: none; }
body {
  background:
    repeating-linear-gradient(0deg, transparent 0 calc(var(--px) * 8), rgba(0,0,0,.18) calc(var(--px) * 8) calc(var(--px) * 9)),
    radial-gradient(ellipse at 50% 0%, var(--bg-2), var(--bg) 70%);
  background-color: var(--bg);
  color: var(--text);
  font: 12px/1.8 'Press Start 2P', ui-monospace, monospace;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
}
.shell { max-width: 560px; margin: 0 auto; padding: 32px 16px 48px; text-align: center; }
.title h1 { font-size: 24px; line-height: 1.5; margin: 0; color: var(--text); text-shadow: 4px 4px 0 var(--line); letter-spacing: 2px; }
.title h1 span { color: var(--accent); }
.tag { color: var(--accent-2); font-size: 10px; margin: 8px 0 32px; text-transform: uppercase; letter-spacing: 3px; }
.screen { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.blurb { max-width: 420px; margin: 0; }
.blurb b { color: var(--accent); font-weight: normal; }
.fine { color: var(--muted); font-size: 9px; margin: 0; }

.btn {
  font: inherit; color: var(--bg); background: var(--accent);
  border: 0; padding: 14px 20px; cursor: pointer; text-decoration: none; display: inline-block;
  box-shadow: inset -4px -4px 0 rgba(0,0,0,.35), 4px 4px 0 var(--line);
  min-height: 44px; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: translate(2px, 2px); box-shadow: inset -4px -4px 0 rgba(0,0,0,.35), 2px 2px 0 var(--line); }
.btn:disabled { opacity: .5; cursor: wait; }
.btn:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.btn-ghost { background: var(--panel); color: var(--text); }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.link { color: var(--accent-2); font-size: 10px; }
.no-wallet { display: flex; flex-direction: column; align-items: center; gap: 12px; }

.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }

.kid-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, 132px); justify-content: center; width: 100%; }
.kid-card {
  font: inherit; color: var(--text); width: 100%; background: var(--panel); border: 0; cursor: pointer;
  padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: inset -4px -4px 0 rgba(0,0,0,.35), 4px 4px 0 var(--line);
}
.kid-card:hover, .kid-card:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.kid-card img { width: 96px; height: 96px; image-rendering: pixelated; background: var(--bg); }
.kid-card span { font-size: 10px; }

body.playing .shell { max-width: 1000px; }
.game { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0b0614; box-shadow: 0 0 0 4px var(--line), 8px 8px 0 4px rgba(0,0,0,.4); user-select: none; -webkit-user-select: none; }
.game-canvas { display: block; width: 100%; height: 100%; touch-action: none; image-rendering: pixelated; }
.hud { position: absolute; inset: 8px 12px auto; display: flex; justify-content: space-between; font-size: 12px; pointer-events: none; text-shadow: 2px 2px 0 #000; }
#hud-lives { color: var(--danger); letter-spacing: 2px; }
#hud-best { color: var(--muted); }
.overlay { pointer-events: none; position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 16px; background: rgba(11,6,20,.35); }
.overlay .btn { pointer-events: auto; }
.overlay-title { margin: 0; font-size: 18px; color: var(--accent); text-shadow: 3px 3px 0 #000; }
.overlay-text { margin: 0; font-size: 11px; text-shadow: 2px 2px 0 #000; }
.overlay-help { margin: 0; max-width: 560px; padding-inline: 8px; text-align: center; font-size: 8px; color: var(--muted); line-height: 2; text-shadow: 1px 1px 0 #000; }

.rotate-hint { display: none; margin: 0; font-size: 8px; color: var(--muted); }
@media (orientation: portrait) and (pointer: coarse) { .rotate-hint { display: block; } }
@media (orientation: landscape) and (pointer: coarse) and (max-height: 500px) { body.playing .shell { padding-top: 8px; } body.playing .title { display: none; } body.playing .game { width: auto; max-width: 100%; height: calc(100vh - 24px); margin: 0 auto; } body.playing.dev .game { height: calc(100vh - 60px); } }
@media (max-width: 520px) { .overlay-title { font-size: 13px; } .hud { font-size: 9px; } }
.kid-label { font-size: 16px; color: var(--accent); margin: 8px 0 0; }

.status { min-height: 1.8em; margin: 24px 0 0; color: var(--muted); font-size: 10px; }
.status.error { color: var(--danger); }
.foot { color: var(--muted); font-size: 8px; margin-top: 24px; }
#wallet-label { word-break: break-all; }

.dev-banner { background: var(--accent-2); color: var(--bg); text-align: center; padding: 8px; font-size: 9px; }

@media (max-width: 380px) { .title h1 { font-size: 18px; } }
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }

.overlay.counting .overlay-title { font-size: 48px; color: var(--accent-2); }
.board { width: 100%; max-width: 560px; text-align: left; }
.board-title { font-size: 14px; color: var(--accent); margin: 8px 0; text-align: center; font-weight: normal; }
.board-sub { font-size: 10px; color: var(--muted); margin: 12px 0 4px; font-weight: normal; }
.board-list, .board-mine { list-style: none; margin: 0; padding: 0; }
.board-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 4px 8px; font-size: 10px; }
.board-row:nth-child(odd) { background: rgba(43,22,80,.5); }
.board-row.you { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.board-kid { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 8px; }
a.board-kid { color: inherit; text-decoration: none; }
a.board-kid:hover .name { text-decoration: underline; }
a.board-kid:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.board-external { font: 12px system-ui, sans-serif; }
.board-row.current .name { color: var(--accent-2); }
.board-row .rank { color: var(--muted); }
.board-row .score { color: var(--accent); }
.board-empty { font-size: 10px; color: var(--muted); padding: 8px; text-align: center; }
.thumb { display: block; width: 48px; height: 48px; image-rendering: pixelated; background: var(--bg); }

/* ---- Phase 2: polish ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 10; background: var(--accent-2); color: var(--bg); padding: 8px 12px; font: inherit; font-size: 10px; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; }
.btn-big { min-height: 56px; padding: 18px 28px; font-size: 14px; }
.safe { margin: 0; font-size: 10px; line-height: 2; color: var(--accent-2); max-width: 420px; }
.unofficial { margin: 0 0 6px; font-size: 8px; color: var(--muted); }
.empty-ghost canvas { width: 96px; height: 96px; image-rendering: pixelated; }
.empty-title { font-size: 13px; line-height: 1.8; color: var(--accent); margin: 0; font-weight: normal; max-width: 420px; }
.overlay-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.hud { z-index: 3; align-items: center; }
.hud-right { display: inline-flex; gap: 8px; align-items: center; }
.icon-btn {
  pointer-events: auto; width: 44px; height: 44px; flex: none;
  font: inherit; font-size: 16px; color: var(--text); background: rgba(43,22,80,.85); border: 0; cursor: pointer;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.35);
}
.icon-btn.muted { color: var(--muted); text-decoration: line-through; }
.game { touch-action: none; }
@media (pointer: coarse) {
  .btn { min-height: 52px; }
  .icon-btn { width: 52px; height: 52px; }
  .kid-card { padding: 16px; }
}
@media (orientation: portrait) and (pointer: coarse) {
  body.playing .title { margin-bottom: 0; }
  body.playing .title h1 { font-size: 16px; }
  body.playing .tag { margin: 4px 0 12px; }
}

/* wisps */
.hud-left, .hud-mid { display: inline-flex; gap: 10px; align-items: baseline; }
.hud-wisps { color: var(--accent-2); }
.hud-mult { color: #ffcf5a; }
#hud-score.flash { color: #ffcf5a; text-shadow: 0 0 6px #ffcf5a, 2px 2px 0 #000; }
@media (prefers-reduced-motion: no-preference) { #hud-score.flash { animation: pop .3s steps(3); } }
@keyframes pop { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* overlay buttons never collide with anything: they wrap and stay inside the game box */
.overlay-actions .btn { max-width: 100%; white-space: nowrap; }
@media (max-width: 520px) {
  .overlay { gap: 6px; padding: 48px 8px 8px; }
  .overlay-actions { gap: 8px; }
  .overlay-actions .btn { padding: 10px 14px; font-size: 11px; min-height: 44px; }
  .overlay-text { font-size: 9px; line-height: 1.6; text-align: center; }
  .icon-btn { width: 40px; height: 40px; font-size: 14px; }
}

.shell:has(#screen-hub:not([hidden])) { max-width: 830px; }
.game-cards { display: grid; width: 100%; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.game-card { display: grid; gap: 8px; font: inherit; text-align: left; color: inherit; background: #241539; border: 1px solid #674385; padding: 12px; cursor: pointer; }
.game-card:focus-visible, .game-card:hover { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.game-card canvas { width: 100%; aspect-ratio: 16 / 9; image-rendering: pixelated; }
.game-card span, .practice-controls { font-size: 11px; line-height: 1.6; }
.practice-controls input { color-scheme: dark; }
#hud-practice { color: var(--accent); }
#game[data-game="drop"] .overlay { background: rgba(12, 5, 23, 0.88); }
#game[data-game="drop"] .hud { z-index: 1; }

.hub-profile { width: 100%; max-width: 630px; border-collapse: collapse; font-size: 10px; line-height: 1.7; text-align: left; }
.hub-profile th, .hub-profile td { padding: 6px; border-bottom: 1px solid var(--line); }
.hub-profile th { font-weight: normal; }
.hub-profile thead { color: var(--muted); }
.hub-badges { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 0; padding: 0; }
.hub-badges li { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; background: var(--panel); font-size: 9px; }
.hub-badges canvas { width: 14px; height: 14px; image-rendering: pixelated; }

/* Kids whose original image is lost: art rebuilt from traits, never shown as official. */
.restored-note { display: block; font: 11px/1.3 system-ui, sans-serif; color: var(--muted, #b9a6d6); font-style: italic; }
.kid-card .restored-note { text-align: center; }
