:root {
  /* the lamp-lit look (this product's own); the light look is chosen with the switch beside Home */
  --bg: #17110c;
  --bg2: #261c14;
  --ink: #f3ece0;
  --inkDim: #c2b29b;
  --line: #4a3a2b;
  --accent: #7dd3fc;
  --accentInk: #06121f;
  --sel: #3a2c20;
  --tableBg: #14100c;
  --countBg: rgba(10, 7, 4, 0.78);
  --countInk: #fdf6ea;
  --countLegal: #7dd3fc;
  --shade: rgba(23, 17, 12, 0.88);
  --toastBg: #fdf6ea;
  --toastInk: #17110c;
  --danger: #f87171;
}
:root[data-theme="light"] {
  --bg: #f3ece0;
  --bg2: #e6dac6;
  --ink: #2a1d10;
  --inkDim: #5f4a33;
  --line: #bfa98a;
  --accent: #0369a1;
  --accentInk: #ffffff;
  --sel: #d8c6a8;
  --tableBg: #d9cbb4;
  --countBg: rgba(255, 250, 240, 0.9);
  --countInk: #2a1d10;
  --countLegal: #0369a1;
  --shade: rgba(243, 236, 224, 0.92);
  --toastBg: #2a1d10;
  --toastInk: #ffffff;
  --danger: #b91c1c;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
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%, 900px); 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; }
#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); }

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

#scr-menu { align-items: center; text-align: center; justify-content: center; }
#scr-menu h1 { font-size: clamp(32px, 9vw, 46px); color: var(--ink); }
#scr-menu .sub { color: var(--inkDim); font-weight: 600; }
.menuGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.menuGrid > :first-child { grid-column: 1 / -1; }
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; }
#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: 800 15px inherit; cursor: pointer; }
.seg button.sel { border-color: var(--accent); background: var(--sel); }

/* play */
#playTop { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; min-height: 24px; }
#scoreA { text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#scoreB { text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#turnOut { color: var(--accent); white-space: nowrap; }
#stageWrap { flex: 1; position: relative; min-height: 0; border-radius: 12px; overflow: hidden; background: var(--tableBg); touch-action: none; }
canvas#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* R4.6 the counts: page text over the board, crisp at any detail */
#labels .n { position: absolute; transform: translate(-50%, -50%); min-width: 26px; padding: 1px 6px; border-radius: 999px; background: var(--countBg); color: var(--countInk);
  font: 800 15px/1.4 ui-monospace, "SF Mono", Menlo, monospace; text-align: center; pointer-events: none; }
#labels .n.store { font-size: 20px; min-width: 34px; }
#labels .n.legal { box-shadow: 0 0 0 2px var(--countLegal); }
#glFail { position: absolute; inset: 16px; display: flex; align-items: center; justify-content: center; text-align: center; font-weight: 800; font-size: 16px; line-height: 1.5; color: var(--ink); }
#glFail[hidden] { display: none; }
#fpsNow { position: absolute; left: 6px; bottom: 6px; font: 11px/1.3 ui-monospace, monospace; color: #c9d3df; background: rgba(5, 9, 20, 0.8); padding: 2px 6px; border-radius: 6px; pointer-events: none; }
#fpsNow[hidden] { display: none; }
#nextLine { text-align: center; font-weight: 800; color: var(--inkDim); min-height: 20px; font-size: 15px; }

/* 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: 12px; font-size: 15px; line-height: 1.55; font-weight: 600; }
#scr-set h2, #scr-how h2 { color: var(--ink); }
.setRow { display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.setNote { font: 12.5px/1.4 ui-monospace, monospace; color: var(--inkDim); }
/* R3.2 the computer's list, from MC.GOALS */
.goal { border-top: 2px solid var(--line); padding-top: 8px; display: grid; gap: 2px; }
.goal b { color: var(--ink); }
.goal span { color: var(--inkDim); font-size: 14px; }

.ovl { position: absolute; inset: 0; display: none; align-items: flex-start; justify-content: center; background: var(--shade); border-radius: 12px; 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; color: var(--ink); }
#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; }

/* the game is not being saved (a write the storage did not take): shown until a write goes in */
#saveNote { padding: 6px 12px; font-size: 14px; font-weight: 700; line-height: 1.4; text-align: center; color: var(--ink); background: var(--bg2); border-bottom: 2px solid var(--danger); }
#saveNote[hidden] { display: none; }
