:root {
  /* Deepwing's night look; the light look is chosen with the switch beside Home */
  --bg: #0b1422;
  --bg2: #13233a;
  --ink: #eef4fb;
  --inkDim: #9fb3c8;
  --line: #2a4466;
  --accent: #ffb338;
  --accentInk: #3a2204;
  --sel: #1e3858;
  --shade: rgba(8, 16, 30, 0.88);
  --toastBg: #f8fafc;
  --toastInk: #0b1422;
  --danger: #ff6b5b;
}
:root[data-theme="light"] {
  --bg: #eef3f9;
  --bg2: #dbe5f1;
  --ink: #0b1422;
  --inkDim: #3c516a;
  --line: #9fb3c8;
  --accent: #8a5200;
  --accentInk: #ffffff;
  --sel: #c7d6e9;
  --shade: rgba(238, 243, 249, 0.94);
  --toastBg: #0b1422;
  --toastInk: #ffffff;
  --danger: #b91c1c;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%); color: var(--ink); user-select: none; -webkit-user-select: none; overflow: hidden; }
#app { height: 100%; display: flex; flex-direction: column; max-width: min(100%, 720px); margin: 0 auto; }

#hdr { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
#hdr .pill { background: var(--bg2); border: 2px solid var(--line); border-radius: 999px; padding: 6px 11px; font-weight: 800; font-size: 15px; min-width: 44px; min-height: 44px; display: flex; align-items: center; cursor: pointer; justify-content: center; color: inherit; font-family: inherit; }
#saveNote { margin: 0 12px 6px; padding: 8px 12px; border-radius: 12px; background: var(--bg2); border: 2px solid var(--line); color: var(--ink); font-weight: 800; font-size: 14px; line-height: 1.4; text-align: center; }
#saveNote[hidden] { display: none; }
#hdrHome { border: none; background: var(--accent); color: var(--accentInk); font-size: 18px; }
#hdrStatus { flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--inkDim); font-variant-numeric: tabular-nums; }
#hdrPause[hidden] { display: none; }

.scr { flex: 1; display: none; flex-direction: column; overflow-y: auto; padding: 6px 14px 14px; gap: 10px; position: relative; }
.scr.on { display: flex; }

#scr-menu { align-items: center; text-align: center; justify-content: safe center; }
#scr-menu .art { font-size: 40px; letter-spacing: 6px; }
#scr-menu h1 { font-size: clamp(30px, 8.5vw, 44px); color: var(--ink); }
#scr-menu .sub { color: var(--inkDim); font-weight: 600; }
#modeNote { color: var(--inkDim); font-weight: 700; font-size: 14px; }
.menuGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
button.big { width: 100%; border-radius: 16px; min-height: 52px; font-size: 18px; font-weight: 800; background: var(--bg2); color: var(--ink); border: 3px solid var(--line); cursor: pointer; font-family: inherit; padding: 6px 10px; }
button.big:active { transform: translateY(2px); }
button.big.primary { background: var(--accent); border-color: var(--accent); color: var(--accentInk); }
button.big.danger { border-color: var(--danger); color: var(--danger); }
button.big[hidden] { display: none; }
button.big:disabled { opacity: 0.45; cursor: default; }
button.big.pick { font-size: 16px; text-align: left; line-height: 1.3; }
button.big.pick small { display: block; font-weight: 600; font-size: 13.5px; color: var(--inkDim); }
#statsLine { color: var(--inkDim); font-weight: 700; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.seg button { flex: 1; min-height: 44px; min-width: 64px; border-radius: 12px; border: 3px solid var(--line); background: var(--bg); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer; }
.seg button.sel { border-color: var(--accent); background: var(--sel); }

/* play */
#scr-play { padding: 0 6px 6px; gap: 6px; }
#playTop { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; gap: 6px; font-weight: 800; font-size: 15px; padding: 0 4px; min-height: 24px; font-variant-numeric: tabular-nums; }
#scoreOut { text-align: left; } #clockOut { text-align: center; color: var(--inkDim); } #spareOut { text-align: right; color: var(--inkDim); white-space: nowrap; }
#stageWrap { flex: 1; position: relative; min-height: 0; border-radius: 12px; overflow: hidden; background: var(--bg); }
canvas#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#foot { flex: none; display: flex; flex-direction: column; gap: 4px; padding: 2px 0 max(2px, env(safe-area-inset-bottom)); }
#chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 44px; }
.chip { min-width: 52px; min-height: 44px; border-radius: 999px; border: 3px solid var(--line); background: var(--bg2); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; }
.chip i { width: 18px; height: 18px; border-radius: 50%; display: block; }
.chip.armed { border-color: var(--danger); color: var(--danger); }
#hint { text-align: center; font-weight: 700; font-size: 14px; color: var(--inkDim); min-height: 20px; }

/* settings, help */
#scr-set .card, #scr-how .card { background: var(--bg2); border: 3px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; font-size: 15px; line-height: 1.55; font-weight: 600; }
.setNote { font-size: 13.5px; color: var(--inkDim); }
.legend { display: flex; flex-direction: column; gap: 6px; }
.lgRow { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.lgRow b { font-size: 20px; width: 28px; text-align: center; }

.ovl { position: absolute; inset: 0; display: none; align-items: flex-start; justify-content: center; background: var(--shade); padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.ovl.on { display: flex; }
.ovlCard { text-align: center; width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 10px; margin: auto; }
.ovlTitle { font-size: 26px; font-weight: 800; }
.ovlSub { color: var(--inkDim); font-weight: 700; }

#toast { position: fixed; left: 50%; bottom: 78px; transform: translateX(-50%); background: var(--toastBg); color: var(--toastInk); font-weight: 800; padding: 9px 16px; border-radius: 999px; opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 40; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; }

/* docs/offline-pwa.md R-C15 — the page never scrolls; each screen does */
html, body { overflow: hidden; overscroll-behavior: none; }
.scr { overscroll-behavior: contain; }
