:root {
  /* Pebble Pond, the night pond; the light look is chosen with the switch beside Home */
  --bg: #0d2a2e;
  --bg2: #143a40;
  --ink: #eef7f5;
  --inkDim: #9fc2bd;
  --line: #2d5a60;
  /* the house amber (game-ui-colour §2): filled on Play and Continue only */
  --accent: #ffb338;
  --accentBorder: #ffd27a;
  --accentInk: #3a2204;
  --sel: #1d4a52;
  --shade: rgba(8, 26, 29, 0.9);
  --toastBg: #f3faf8;
  --toastInk: #0d2a2e;
  --bad: #ff6b5b;
  --good: #6fd38b;
  /* the pond: water, a lily pad, the glow of a pad where a pebble would merge */
  --water: #0f3338;
  --pad: #3f8a5a;
  --padRim: #2b6a42;
  --hint: #c9f6ff;
}
:root[data-theme="light"] {
  --bg: #e6f2ef;
  --bg2: #cfe6e2;
  --ink: #0d2a2e;
  --inkDim: #33585a;
  --line: #8fb6b1;
  --accent: #a26a00;
  --accentBorder: #a26a00;
  --accentInk: #ffffff;
  --sel: #b9dad5;
  --shade: rgba(230, 242, 239, 0.94);
  --toastBg: #0d2a2e;
  --toastInk: #ffffff;
  --bad: #b91c1c;
  --good: #157f3c;
  --water: #a9d3d6;
  --pad: #5fa872;
  --padRim: #3f8a55;
  --hint: #0b5f73;
}

* { 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 { 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; }

#scr-menu { align-items: center; text-align: center; justify-content: safe center; }
#scr-menu h1 { font-size: clamp(32px, 9vw, 46px); color: var(--ink); }
#scr-menu .sub { color: var(--inkDim); font-weight: 600; max-width: 34ch; }
#menuArt { display: flex; gap: 8px; justify-content: center; --peb: 56px; }
#menuArt .peb { position: static; width: var(--peb); height: var(--peb); font-size: 22px; }
#sizeNote { 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(--accentBorder); color: var(--accentInk); }
button.big.danger { border-color: var(--bad); color: var(--bad); }
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-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer; }
.seg button.sel { border-color: var(--ink); background: var(--sel); }

/* play */
#scoreRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat { background: var(--bg2); border-radius: 12px; padding: 4px 8px; text-align: center; display: flex; flex-direction: column; min-width: 0; }
.stat small { font-size: 12px; font-weight: 700; color: var(--inkDim); }
.stat b { font-size: 20px; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.low b { color: var(--bad); }
#pondWrap { flex: 1; min-height: 200px; overflow: auto; display: flex; align-items: safe center; justify-content: safe center; }
#pond { position: relative; flex: none; }
/* R9.1 a lily pad: a round leaf with a notch, the water showing through it */
.pad { position: absolute; border: none; border-radius: 50%; padding: 0; cursor: pointer; font-family: inherit; color: inherit;
  background: conic-gradient(from 150deg, var(--water) 0deg 26deg, var(--pad) 26deg 360deg);
  box-shadow: inset 0 0 0 2px var(--padRim); display: flex; align-items: center; justify-content: center; }
.pad:disabled { cursor: default; }
/* R6.3 a pad the picked pebble can reach is ringed; one where it would merge glows */
.pad.reach { box-shadow: inset 0 0 0 2px var(--padRim), 0 0 0 2px var(--hint); }
.pad.hint { box-shadow: inset 0 0 0 2px var(--padRim), 0 0 0 4px var(--hint), 0 0 12px var(--hint); }
/* R6.1 the picked pebble is lifted and ringed, never filled */
.pad.sel .peb { transform: translateY(-3px); box-shadow: 0 0 0 3px var(--ink), 0 5px 6px rgba(0, 0, 0, 0.4); }
.pad:focus-visible { outline: 3px solid var(--ink); outline-offset: 1px; }
/* R9.2 a pebble: a round stone with its number, its colour set by the number */
.peb { width: 84%; height: 84%; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 900; line-height: 1;
  font-variant-numeric: tabular-nums; box-shadow: inset -3px -4px 0 rgba(0, 0, 0, 0.18), 0 2px 3px rgba(0, 0, 0, 0.35); }
.pad.pop .peb, .pad.new .peb { animation: pop 0.36s ease-out; }
@keyframes pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .pad.pop .peb, .pad.new .peb { animation: none; } }
/* lint:runtime v1 v2 v4 v8 v16 v32 v64 v128 v256 v512 v1024 vbig */
.v1 { background: #e9dcc0; color: #3a2e17; }
.v2 { background: #b9c7d6; color: #1b2a3a; }
.v4 { background: #9fd18b; color: #173a10; }
.v8 { background: #f2a46b; color: #3d1d05; }
.v16 { background: #e58c8c; color: #3d0f0f; }
.v32 { background: #c9a0e0; color: #2c1340; }
.v64 { background: #f3d35b; color: #3a2e00; }
.v128 { background: #5fb7a8; color: #062a25; }
.v256 { background: #7f9cec; color: #0b1636; }
.v512 { background: #e07bb5; color: #3a0a26; }
.v1024 { background: #fff1c9; color: #3a2204; box-shadow: inset 0 0 0 3px #d79a1f, 0 2px 3px rgba(0, 0, 0, 0.35); }
.vbig { background: #262b38; color: #ffe08a; box-shadow: inset 0 0 0 3px #ffe08a, 0 2px 3px rgba(0, 0, 0, 0.35); }
#sayLine { text-align: center; font-weight: 800; font-size: 16px; min-height: 22px; }
/* R6.1 the next pebbles to arrive: shown, never picked */
#nextRow { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; --peb: 34px; padding-bottom: max(0px, env(safe-area-inset-bottom)); }
#nextRow .nextLbl { font-weight: 800; font-size: 14px; color: var(--inkDim); }
#next { display: flex; gap: 6px; }
#next .peb { width: var(--peb); height: var(--peb); font-size: calc(var(--peb) * 0.4); }
/* R9.1 a short phone (360 x 640): the header, the gaps and the next row give way
   before the pads do, so the long pond fits with no scrolling */
@media (max-height: 700px) {
  #hdr { padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: 4px; }
  #scr-play { gap: 6px; padding-bottom: 8px; }
  #nextRow { min-height: 40px; }
}

/* 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 .peb { width: 36px; height: 36px; flex: none; font-size: 14px; }

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