:root {
  /* Cribbage: a card table by a wooden pegboard (R5.3); the dark look is green felt, chosen with the switch beside Home */
  --bg: #efe6d4;
  --bg2: #e2d6bd;
  --ink: #2a241c;
  --inkDim: #5f5546;
  --line: #c6b694;
  /* the house amber (game-ui-colour §2): filled on Play, Continue, and the one action under your hand */
  --accent: #a26a00;
  --accentBorder: #a26a00;
  --accentInk: #ffffff;
  --sel: #d7c7a3;
  --shade: rgba(239, 230, 212, 0.97);
  --toastBg: #2a241c;
  --toastInk: #ffffff;
  --bad: #b91c1c;
  /* the cards: a white face, red and black ink, in both looks */
  --face: #fffdf8;
  --faceLine: #b9ac90;
  --red: #c41e2a;
  --black: #1d1d22;
  /* the two players, as the pegboard draws them (app.js SEAT) */
  --s0: #2563c9;
  --s1: #c2410c;
  /* the coach's ✨ mark round a card: 3:1 or more on the page and on a card's face */
  --coach: #8a5a00;
}
:root[data-theme="dark"] {
  --bg: #16261f;
  --bg2: #1f362c;
  --ink: #ece6d6;
  --inkDim: #a9bcae;
  --line: #355246;
  --accent: #ffb338;
  --accentBorder: #ffd27a;
  --accentInk: #3a2204;
  --sel: #2c4a3d;
  --shade: rgba(16, 29, 23, 0.97);
  --toastBg: #efe6d4;
  --toastInk: #16261f;
  --bad: #ff6b5b;
  --face: #fbf8f0;
  --faceLine: #6d7f73;
  --red: #c41e2a;
  --black: #1d1d22;
  --s0: #7fb0ff;
  --s1: #ff9a5c;
  --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; }
/* a little of the board: three pegs in a strip of wood, drawn in CSS */
#menuArt { width: 120px; height: 34px; border-radius: 10px; background: #b98a55; display: flex; align-items: center; justify-content: space-around; padding: 0 12px; }
#menuArt span { width: 12px; height: 12px; border-radius: 50%; background: var(--s0); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25); }
#menuArt span:nth-child(2) { background: var(--s1); }
#menuArt span:nth-child(3) { background: #3b2a17; opacity: 0.5; }
.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); }
#board { width: 100%; height: 58px; flex: none; border-radius: 10px; }
/* the computer's cards, then the cut and the crib (small), so the cards of the count have the whole width */
#cpuRow { display: flex; align-items: flex-start; gap: 8px; }
#cpuSide { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
#cpuHand { width: 110px; height: 48px; flex: none; }
#cpuLabel { font-weight: 800; color: var(--inkDim); font-size: 13.5px; }
.spot { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; width: 62px; }
.spotLabel { font-size: 12.5px; font-weight: 800; color: var(--inkDim); white-space: nowrap; }
#crib, #deck { width: 40px; height: 56px; }
#deck[hidden], #starter[hidden] { display: none; }
#starter .pc { width: 40px; height: 56px; }
#starter .pc .r, #starter .pc .s { font-size: 16px; }
#table { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#countLabel { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
/* the cards of the count, overlapped as they need (app.js sets the step), each with its rank and suit at the left */
#pile { display: flex; justify-content: center; min-height: 78px; width: 100%; }
#pile .pc { align-items: flex-start; justify-content: flex-start; padding: 4px 5px; }
#pile .pc .r { font-size: 19px; }
#pile .pc .s { font-size: 17px; }
#pile .pc.old { opacity: 0.75; filter: grayscale(0.6); }
#sayLine { text-align: center; font-weight: 800; font-size: 15px; min-height: 42px; line-height: 1.35; }
/* 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); }
#hand { display: flex; justify-content: center; gap: 4px; min-height: 84px; padding-bottom: 4px; }
#hand .pc { width: calc((100% - 20px) / 6); max-width: 64px; min-width: 44px; height: 80px; cursor: pointer; }
#hand .pc.sel { transform: translateY(-8px); border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent); }
#hand .pc:disabled { cursor: default; }
/* a card that cannot be played now: greyed, its ink still readable (the computer's turn dims nothing) */
#hand .pc.off { opacity: 0.7; filter: grayscale(1); border-style: dashed; }
#hand .pc.coach { outline: 3px dashed var(--coach); outline-offset: 2px; }
#btnAct { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
@media (max-height: 680px) {
  #hdr { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  #scr-play { gap: 5px; padding-bottom: 8px; }
  #board { height: 48px; }
  #cpuHand { height: 40px; }
  .pc { height: 66px; }
  #pile { min-height: 66px; }
  #hand { min-height: 74px; }
  #hand .pc { height: 70px; }
  #pile { min-height: 66px; }
}

/* the show: one count at a time, every score named */
#showTitle { font-size: 22px; font-weight: 900; }
#showCards { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
#showCards .pc { width: 48px; height: 68px; }
#showCards .pc.cut { border-style: dashed; }
#showItems { display: flex; flex-direction: column; gap: 4px; text-align: left; font-weight: 700; font-size: 15px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 4px 8px; border-radius: 8px; background: var(--bg2); }
.item .sum { font-variant-numeric: tabular-nums; color: var(--inkDim); }
.item.none { grid-template-columns: 1fr; color: var(--inkDim); }

/* 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: 340px; 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; }
