:root {
  /* Gin Rummy: a slate card table (R5.3); the dark look is a night-blue table, chosen with the switch beside Home */
  --bg: #e9eef0;
  --bg2: #dbe3e7;
  --ink: #1c2a33;
  --inkDim: #50626d;
  --line: #b4c3ca;
  /* the house amber (game-ui-colour §2): filled on Play, Continue, and the one main action under your hand */
  --accent: #a26a00;
  --accentBorder: #a26a00;
  --accentInk: #ffffff;
  --sel: #c7d5db;
  --shade: rgba(233, 238, 240, 0.97);
  --toastBg: #1c2a33;
  --toastInk: #ffffff;
  --bad: #b91c1c;
  /* the cards: a white face, red and black ink, in both looks */
  --face: #fffdf8;
  --faceLine: #a9b6bc;
  --red: #c41e2a;
  --black: #1d1d22;
  /* the two players' chips */
  --s0: #2563c9;
  --s1: #c2410c;
  /* each meld in your hand is framed in its own colour (3:1 or more on the page and on a card's face) */
  --m0: #1f6f8b;
  --m1: #7c3aed;
  --m2: #2f7d32;
  /* the coach's ✨ mark round a card */
  --coach: #8a5a00;
}
:root[data-theme="dark"] {
  --bg: #15232b;
  --bg2: #1d3240;
  --ink: #e6eef2;
  --inkDim: #a3b6c1;
  --line: #33505f;
  --accent: #ffb338;
  --accentBorder: #ffd27a;
  --accentInk: #3a2204;
  --sel: #284555;
  --shade: rgba(16, 27, 34, 0.97);
  --toastBg: #e9eef0;
  --toastInk: #15232b;
  --bad: #ff6b5b;
  --face: #fbf8f0;
  --faceLine: #6d7f88;
  --red: #c41e2a;
  --black: #1d1d22;
  --s0: #7fb0ff;
  --s1: #ff9a5c;
  --m0: #2f95bf;
  --m1: #9b72ee;
  --m2: #3f9e48;
  --coach: #ffd27a;
}

* { 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: var(--bg); 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 { 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 14px; gap: 10px; position: relative; }
.scr.on { display: flex; }

/* the menu */
#scr-menu { align-items: center; text-align: center; justify-content: safe center; }
#scr-menu > * { flex-shrink: 0; }
#scr-menu h1 { font-size: clamp(30px, 8.5vw, 44px); color: var(--ink); }
#scr-menu .sub { color: var(--inkDim); font-weight: 600; max-width: 36ch; }
/* three sevens, a set: drawn in CSS */
#menuArt { display: flex; gap: 6px; }
#menuArt span { width: 34px; height: 48px; border-radius: 6px; background: var(--face); border: 3px solid var(--m0); color: var(--black); font-weight: 900; font-size: 22px; display: flex; align-items: center; justify-content: center; }
#menuArt span.red { color: var(--red); }
.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(--accentBorder); color: var(--accentInk); }
button.big.danger { border-color: var(--bad); color: var(--bad); }
button.big[hidden] { display: none; }
/* a button that is off still says what it would do: its words stay readable (4.5:1), its border dashed */
button.big:disabled, button.big.primary:disabled { cursor: default; background: var(--bg2); color: var(--inkDim); border-color: var(--line); border-style: dashed; }
#statsLine { color: var(--inkDim); font-weight: 700; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.seg[hidden] { display: none; }
.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(--ink); background: var(--sel); }

/* play */
#scr-play { gap: 8px; }
#scoreRow { display: flex; gap: 6px; justify-content: center; }
.chip { flex: 1; max-width: 200px; padding: 4px 10px; border-radius: 999px; border: 3px solid var(--line); background: var(--bg2); font-weight: 900; font-size: 18px; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* lint:runtime s0 s1 */
.chip.s0 { border-color: var(--s0); } .chip.s1 { border-color: var(--s1); }
/* whose turn: the chip's border doubled, never filled */
.chip.turn.s0 { box-shadow: 0 0 0 3px var(--s0); } .chip.turn.s1 { box-shadow: 0 0 0 3px var(--s1); }
#cpuRow { display: flex; align-items: center; gap: 10px; }
#cpuHand { width: 160px; height: 48px; flex: none; }
#cpuLabel { font-weight: 800; color: var(--inkDim); font-size: 13.5px; }
#table { display: flex; justify-content: center; gap: 24px; }
/* the stock and the pile are buttons: a tap draws from it */
.spot { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; min-height: 44px; background: none; border: 3px solid transparent; border-radius: 12px; padding: 3px; font-family: inherit; color: inherit; cursor: pointer; }
.spot:disabled { cursor: default; }
.spot.can { border-color: var(--accent); }
.spotLabel { font-size: 12.5px; font-weight: 800; color: var(--inkDim); white-space: nowrap; }
#stock { width: 54px; height: 76px; }
#pileTop { min-width: 54px; min-height: 76px; display: flex; }
#sayLine { text-align: center; font-weight: 800; font-size: 15px; min-height: 40px; line-height: 1.35; }
#meldLine { text-align: center; font-weight: 800; font-size: 14px; color: var(--inkDim); min-height: 20px; font-variant-numeric: tabular-nums; }
/* a card: a white face with its rank over its suit, red or black */
.pc { width: 54px; height: 76px; flex: none; border-radius: 8px; background: var(--face); border: 2px solid var(--faceLine); display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: inherit; font-weight: 900; line-height: 1; color: var(--black); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
.pc .r { font-size: 22px; }
.pc .s { font-size: 22px; margin-top: 2px; }
.pc.red { color: var(--red); }
.pc.down { background: var(--bg2); color: var(--inkDim); }
/* your hand: two rows of up to six; each meld framed in its colour */
#hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-height: 140px; align-content: flex-start; }
#hand .pc { width: calc((100% - 20px) / 6); max-width: 60px; min-width: 44px; height: 66px; cursor: pointer; }
#hand .pc .r, #hand .pc .s { font-size: 19px; }
/* lint:runtime m0 m1 m2 */
#hand .pc.m0 { border: 3px solid var(--m0); } #hand .pc.m1 { border: 3px solid var(--m1); } #hand .pc.m2 { border: 3px solid var(--m2); }
#hand .pc.sel { transform: translateY(-6px); box-shadow: 0 0 0 3px var(--accent); }
#hand .pc.drew { border-style: dashed; }
#hand .pc:disabled { cursor: default; }
#hand .pc.coach { outline: 3px dashed var(--coach); outline-offset: 2px; }
#actRow { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: max(4px, env(safe-area-inset-bottom)); }
#actRow button:only-child { grid-column: 1 / -1; }
@media (max-height: 680px) {
  #hdr { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  #scr-play { gap: 5px; padding-bottom: 8px; }
  #cpuHand { height: 40px; }
  #stock, #pileTop .pc { width: 46px; height: 64px; }
  #pileTop { min-width: 46px; min-height: 64px; }
  #hand .pc { height: 60px; }
  #hand { min-height: 128px; }
}

/* the end of a hand: both players' melds, the layoffs, the deadwood and the points */
#resTitle { font-size: 22px; font-weight: 900; }
#resBody { display: flex; flex-direction: column; gap: 8px; text-align: left; }
.resSide { display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 10px; background: var(--bg2); }
.resHead { font-weight: 800; font-size: 15px; }
.resCards { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.resCards .pc { width: 34px; height: 46px; border-radius: 6px; }
.resCards .pc .r, .resCards .pc .s { font-size: 14px; }
.resCards .pc.m0 { border: 3px solid var(--m0); } .resCards .pc.m1 { border: 3px solid var(--m1); } .resCards .pc.m2 { border: 3px solid var(--m2); }
.resCards .pc.off { border: 3px dashed var(--accent); }
.resCards .gap { width: 6px; }
.resPts { font-weight: 900; font-size: 17px; text-align: center; }

/* 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); }
.recLine { font-weight: 700; font-variant-numeric: tabular-nums; }
#goalTable { display: flex; flex-direction: column; gap: 6px; }
.goal { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--bg); border: 2px solid var(--line); font-size: 14px; line-height: 1.4; }
.goal .gw { font-weight: 800; }
.goal .gl { color: var(--inkDim); font-size: 13px; }

.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: 360px; display: flex; flex-direction: column; gap: 10px; margin: auto; }
#ovlTitle { font-size: 26px; font-weight: 800; }
#ovlSub { color: var(--inkDim); font-weight: 700; font-size: 18px; }

#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; }
