:root {
  /* the night look (this product's own); the light look is chosen with the switch beside Home */
  --bg: #16201a;
  --bg2: #223027;
  --ink: #eef4ef;
  --inkDim: #a8bcaf;
  --line: #3b5244;
  --accent: #ffb338;
  --accentInk: #3a2204;
  --sel: #2e4337;
  --shade: rgba(14, 16, 28, 0.88);
  --toastBg: #f8fafc;
  --toastInk: #161a2b;
  --danger: #f87171;
  --lkUnmet: #4a4f5a; --lkGetting: #e9973f; --lkRelaxed: #2f7d8c; --lkSteady: #2fae7e; --lkQuick: #7fd36a; --lkSnap: #f6e27a; --lkInk: #0b1226; --lkInkUnmet: #e6ecf7;
  --slow: #e9973f; --wrong: #f87171;
}
:root[data-theme="light"] {
  --bg: #f3f6ef;
  --bg2: #e0e8da;
  --ink: #172417;
  --inkDim: #455544;
  --line: #a9bba2;
  --accent: #8a5200;
  --accentInk: #ffffff;
  --sel: #cfdcc8;
  --shade: rgba(241, 242, 248, 0.94);
  --toastBg: #141833;
  --toastInk: #ffffff;
  --danger: #b91c1c;
  --lkUnmet: #a2adb7; --lkGetting: #cb7b19; --lkRelaxed: #158076; --lkSteady: #15ac6f; --lkQuick: #88c060; --lkSnap: #f7bf12; --lkInk: #0e1730; --lkInkUnmet: #0e1730;
  --slow: #9a5a00; --wrong: #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%, 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; }
#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 14px; gap: 10px; position: relative; }
.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; }
#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(--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[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(--accent); background: var(--sel); }

/* the menu's four kinds of card */
#kindGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
button.kind { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 84px; }
button.kind .ki { font-size: 26px; } button.kind .kn { font-size: 18px; } button.kind .kc { font-size: 13px; font-weight: 700; opacity: 0.85; }
.menuGrid { grid-template-columns: 1fr 1fr 1fr; }
.menuGrid button.big { font-size: 15px; }

/* play */
#playTop { display: flex; justify-content: space-between; font-weight: 800; color: var(--inkDim); }
#card { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 14px; background: var(--bg2); border-radius: 16px; padding: 14px 12px; }
/* the question as a price tag: the toy and its price large, what to do under it */
#ask { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
#ask .tag { display: flex; align-items: center; gap: 12px; }
#ask .toy { font-size: clamp(48px, 15vw, 76px); line-height: 1; }
#ask .price { font: 900 clamp(40px, 13vw, 64px)/1 ui-monospace, Menlo, monospace; color: var(--ink); }
#ask .how { font-weight: 800; font-size: clamp(17px, 5vw, 22px); max-width: 30ch; }
#ask .how.big { font-size: clamp(22px, 6.5vw, 30px); }
#card.keyed .toy { font-size: clamp(36px, 10vw, 52px); }
#card.keyed .price { font-size: clamp(32px, 9vw, 46px); }
#card.keyed .how { font-size: clamp(16px, 4.6vw, 19px); }
.coins { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.money { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 0; padding: 0; color: var(--ink); font-family: inherit; font-weight: 700; font-size: clamp(12px, 3.8vw, 16px); }
.money svg { display: block; }
.money.bill svg { max-width: 100%; height: auto; }
button.money { cursor: pointer; min-width: 44px; min-height: 44px; justify-content: center; }
#entry { font: 800 clamp(40px, 14vw, 64px)/1 ui-monospace, Menlo, monospace; min-height: 48px; display: flex; align-items: baseline; gap: 2px; }
#entry[hidden], #tray[hidden], #purse[hidden], #yesNo[hidden], #pad[hidden] { display: none; }
#typed { min-width: 1ch; border-bottom: 3px solid var(--accent); padding: 0 4px; }
#tray { flex: 1 1 auto; min-height: 120px; max-height: 60vh; max-height: 60dvh; border: 2px dashed var(--line); border-radius: 12px; padding: 10px; width: 100%; align-content: center; gap: 8px; }
.paidSum { width: 100%; text-align: center; font-weight: 900; font-size: clamp(20px, 6vw, 28px); color: var(--inkDim); }
#verdict { font-weight: 900; font-size: clamp(20px, 6vw, 26px); min-height: 26px; text-align: center; }
#verdict.slow { color: var(--slow); } #verdict.wrong { color: var(--wrong); }
#verdict[class^="look-"] { background: none; }
#verdict.look-relaxed { color: var(--lkRelaxed); } #verdict.look-steady { color: var(--lkSteady); }
#verdict.look-quick, #verdict.look-snap { color: var(--ink); }
#pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.key { min-height: clamp(52px, 7vh, 68px); min-height: clamp(52px, 7dvh, 68px); border-radius: 12px; border: 3px solid var(--line); background: var(--bg2); color: var(--ink); font-family: inherit; font-weight: 800; font-size: clamp(22px, 7vw, 30px); cursor: pointer; }
.key.go { border-color: var(--accent); }
#purse { display: flex; flex-direction: column; gap: 10px; }
.purseRow { display: flex; justify-content: space-around; align-items: flex-end; gap: 4px; }
#yesNo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#yesNo button.big { min-height: clamp(52px, 11vh, 96px); min-height: clamp(52px, 11dvh, 96px); font-size: clamp(18px, 5.5vw, 24px); }

/* done */
#scr-done { align-items: center; justify-content: center; text-align: center; }
#doneSub, #doneUp { color: var(--inkDim); font-weight: 700; }

/* the chart: a hundred chart of the stage's amounts */
#chart { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 6px; font: 800 12px ui-monospace, Menlo, monospace; }
#chartCount { font-weight: 700; color: var(--inkDim); }
.look-unmet { background: var(--lkUnmet); color: var(--lkInkUnmet); } .look-getting { background: var(--lkGetting); color: var(--lkInk); }
.look-relaxed { background: var(--lkRelaxed); color: #ffffff; } .look-steady { background: var(--lkSteady); color: var(--lkInk); }
.look-quick { background: var(--lkQuick); color: var(--lkInk); } .look-snap { background: var(--lkSnap); color: var(--lkInk); }
.lgRow .sw { width: 22px; height: 22px; border-radius: 6px; flex: none; }
.coinList { display: flex; flex-direction: column; gap: 8px; }
.coinRow { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.coinRow .money { width: 64px; align-items: 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); }
.legend { display: flex; flex-direction: column; gap: 6px; }
.lgRow { display: flex; align-items: center; gap: 10px; font-size: 14px; 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; }
/* R7.3 a lasting note while a write has not gone in (the toast says it once; this stays until a save goes in) */
#saveNote { position: fixed; left: 50%; top: 8px; transform: translateX(-50%); background: var(--toastBg); color: var(--toastInk); font-weight: 800; font-size: 14px; padding: 8px 14px; border-radius: 12px; pointer-events: none; z-index: 41; max-width: 90vw; text-align: center; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); }
#saveNote[hidden] { display: none; }

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

/* R1.3 a short screen: a smaller pad and answer, keys still 44 px */
@media (max-height: 640px) {
  .key { min-height: 44px; font-size: 20px; }
  #entry { font-size: 32px; min-height: 38px; }
  #ask .how { font-size: 16px; }
  #card { gap: 6px; padding: 8px; }
  #tray { min-height: 72px; }
  #ask .toy, #card.keyed .toy { font-size: 34px; }
  #ask .price, #card.keyed .price { font-size: 30px; }
  #verdict:empty { min-height: 0; }
}
