:root {
  --paper: #f3eddc;
  --paper-2: #ebe3cc;
  --line: #d9cfae;
  --ink: #2b2a28;
  --ink-2: #6b665a;
  --red: #b3261e;
  --red-bg: #f6d9d5;
  --green: #2e6b3a;
  --green-bg: #d9e8d6;
  --sel: #1d4ed8;
  --hint: #a15c07;
  --cell: 56px;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #1f1d19; --paper-2: #2a2721; --line: #3b372e; --ink: #ece6d6; --ink-2: #a9a292; --red: #ff7b6e; --red-bg: #4a221f; --green: #8fd39a; --green-bg: #1f3a26; --sel: #8ab4ff; --hint: #f2b45a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", "Hiragino Mincho ProN", serif;
  line-height: 1.45;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
main { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px 24px; flex: 1; }
a { color: inherit; }
button { font: inherit; color: inherit; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; cursor: pointer; }
button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
button.icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; font-weight: bold; }
button:disabled { opacity: .5; cursor: default; }
kbd { font-family: ui-monospace, Menlo, monospace; font-size: .8em; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; margin-left: 4px; color: var(--ink-2); }
.hidden { display: none !important; }
.small { font-size: .85em; color: var(--ink-2); }
.red { color: var(--red); } .green { color: var(--green); }

/* header */
.top { max-width: 640px; margin: 0 auto; padding: 14px 16px 6px; display: flex; align-items: flex-end; justify-content: space-between; border-bottom: 2px solid var(--ink); width: 100%; }
.top h1 { margin: 0; font-size: 1.7rem; letter-spacing: .5px; font-weight: 700; }
.top .sub { color: var(--ink-2); font-size: .9rem; }
.brand { min-width: 0; }
.day-nav { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.nav-arrow { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 50%; text-decoration: none; font-size: 1.1rem; line-height: 1; color: var(--ink); background: var(--paper-2); }
.nav-arrow[hidden] { display: none; }
.archive-tag { font-size: .6rem; letter-spacing: .5px; text-transform: uppercase; border: 1px solid var(--ink-2); border-radius: 3px; padding: 0 4px; margin-left: 2px; }
.actions { display: flex; gap: 8px; flex-shrink: 0; }

.status { display: flex; justify-content: space-between; padding: 10px 2px; font-size: .95rem; color: var(--ink-2); border-bottom: 1px dashed var(--line); }
.status b { color: var(--ink); font-size: 1.05em; }

/* board */
.ledger { padding: 16px 0 8px; }
/* --c: the cell size, shrunk to fit narrow phones (320 px) and 7x7 pack boards: viewport − main padding 32 − row labels 22 − gaps */
.board-wrap { --c: min(var(--cell), calc((min(100vw, 640px) - 54px - (var(--n) - 1) * 4px) / var(--n))); display: grid; grid-template-columns: 22px 1fr; grid-template-rows: 18px 1fr; justify-content: center; width: max-content; margin: 0 auto; max-width: 100%; }
.col-labels { grid-column: 2; grid-row: 1; display: grid; grid-template-columns: repeat(var(--n), var(--c)); gap: 4px; font-size: .75rem; color: var(--ink-2); text-align: center; font-family: ui-monospace, Menlo, monospace; }
.row-labels { grid-column: 1; grid-row: 2; display: grid; grid-template-rows: repeat(var(--n), var(--c)); gap: 4px; font-size: .75rem; color: var(--ink-2); font-family: ui-monospace, Menlo, monospace; align-items: center; }
.board { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(var(--n), var(--c)); grid-auto-rows: var(--c); gap: 4px; background: var(--paper); }
.cell {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; user-select: none;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; transition: transform .08s;
  padding: 0; color: var(--ink); overflow: hidden;
}
.cell:active { transform: scale(.97); }
.cell .amt { font-weight: 600; letter-spacing: -.3px; }
.cell .amt::before { content: "$"; opacity: .55; font-weight: 400; }
.cell .tag { position: absolute; top: 2px; left: 4px; font-size: .55rem; line-height: 1; color: var(--ink-2); opacity: .8; }
.cell .note-dot { position: absolute; right: 4px; top: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-2); opacity: .6; }
.cell.genuine { background: var(--green-bg); border-color: var(--green); }
.cell.forged { background: var(--red-bg); border-color: var(--red); }
/* judged: stamp in the upper part, amount stays readable along the bottom (clues still refer to it) */
.cell .stamp { position: absolute; inset: 12px 2px 13px; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.cell .stamp span { font-family: Georgia, serif; font-weight: 700; font-size: .5rem; letter-spacing: 0; line-height: 1.1; padding: 0 2px; border: 1.5px solid currentColor; border-radius: 3px; transform: rotate(-6deg); opacity: .9; mix-blend-mode: multiply; }
.cell.genuine .stamp span, .cell.forged .stamp span { white-space: nowrap; }
@media (prefers-color-scheme: dark) { .cell .stamp span { mix-blend-mode: normal; } }
.cell.genuine .stamp span { color: var(--green); }
.cell.forged .stamp span { color: var(--red); }
.cell.genuine .amt, .cell.forged .amt { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: .66rem; line-height: 1; opacity: .8; }
/* small cells (7x7 boards, 320 px phones): text scales with the cell width (cqw); at 46 px and up the sizes above apply unchanged */
.cell { container-type: size; }
.cell .amt { font-size: min(1em, 25cqw); }
.cell .tag { font-size: min(.55rem, 19cqw); }
.cell .stamp span { font-size: min(.5rem, 17cqw); }
.cell.genuine .amt, .cell.forged .amt { font-size: min(.66rem, 23cqw); }
.cell.selected { outline: 3px solid var(--sel); outline-offset: 1px; z-index: 1; }
.cell.ref { box-shadow: inset 0 0 0 3px var(--sel); }
.cell.ref-self { box-shadow: inset 0 0 0 3px var(--ink); }
.cell.mistake { animation: shake .35s; }
/* after the audit: frame the misjudged entries (dashed ink reads on green and red, and without colour) */
.board.finished .cell.wrong-once::before, .missed-key { content: ""; border: 1.5px dashed var(--ink); border-radius: 4px; pointer-events: none; }
.board.finished .cell.wrong-once::before { position: absolute; inset: 0; border-radius: calc(var(--radius) - 1px); }
.board.finished .cell.wrong-once .tag { top: 3px; left: 5px; }
.board.finished .cell.wrong-once::after { font-size: .7rem; font-weight: 700; top: 2px; line-height: 1; }
.missed-key { display: inline-block; width: 14px; height: 14px; border-width: 2px; vertical-align: -2px; margin-right: 2px; }
.cell.wrong-once::after { content: "✕"; position: absolute; right: 12px; top: 0; font-size: .6rem; color: var(--red); }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

/* panel */
.panel { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); min-height: 92px; padding: 10px 12px; }
.panel-empty { color: var(--ink-2); font-size: .9rem; }
.pc-head { display: flex; gap: 10px; align-items: baseline; font-family: ui-monospace, Menlo, monospace; }
.pc-name { font-weight: 700; }
.pc-amount::before { content: "$"; opacity: .6; }
.pc-status { font-size: .8rem; font-weight: 700; letter-spacing: 1px; }
.pc-status.genuine { color: var(--green); } .pc-status.forged { color: var(--red); }
.pc-note { margin: 8px 0 4px; font-size: 1.05rem; }
.pc-note .lie { color: var(--red); font-size: .85rem; }
.pc-note .truth { color: var(--green); font-size: .85rem; }
.pc-note.sealed { color: var(--ink-2); font-style: italic; }
.pc-hint { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 6px 0 2px; padding: 6px 8px; border-left: 3px solid var(--sel); background: var(--paper); font-size: .85rem; color: var(--ink-2); }
.pc-hint .sel { color: var(--sel); }
button.link { background: none; border: 0; padding: 2px 4px; text-decoration: underline; font-size: .85rem; color: var(--ink); flex-shrink: 0; }
.pc-judge { display: flex; gap: 10px; margin-top: 8px; }
.judge { flex: 1; padding: 12px; font-weight: 700; font-size: 1rem; }
.judge.genuine { background: var(--green-bg); border-color: var(--green); color: var(--green); }
.judge.forged { background: var(--red-bg); border-color: var(--red); color: var(--red); }

/* notes */
.notes { margin-top: 18px; }
.notes h2 { font-size: 1rem; margin: 0 0 6px; color: var(--ink-2); font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.notes ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.notes li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; padding: 6px 8px; border-left: 3px solid var(--line); background: var(--paper-2); border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; font-size: .95rem; }
.notes li:hover, .notes li.active { border-left-color: var(--sel); }
.notes li .who { font-family: ui-monospace, Menlo, monospace; font-weight: 700; font-size: .85rem; }
.notes li.forged .who { color: var(--red); } .notes li.genuine .who { color: var(--green); }
.notes li.forged .what { text-decoration: line-through; text-decoration-color: var(--red); text-decoration-thickness: 1px; }

/* done */
.done { margin-top: 18px; padding: 14px; border: 2px solid var(--ink); border-radius: var(--radius); text-align: center; }
.done h2 { margin: 0 0 8px; }
.share-grid { font-size: 1.1rem; line-height: 1.25; margin: 6px 0 8px; font-family: ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.done-row { margin: 8px 0; display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }

footer { max-width: 640px; margin: 0 auto; padding: 16px 16px 32px; font-size: .85rem; color: var(--ink-2); border-top: 1px solid var(--line); width: 100%; }

dialog { background: var(--paper); color: var(--ink); border: 2px solid var(--ink); border-radius: var(--radius); max-width: 460px; width: calc(100% - 32px); padding: 18px 20px; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin-top: 0; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin-bottom: 12px; }
.stats-grid b { display: block; font-size: 1.6rem; }
.stats-grid span { font-size: .75rem; color: var(--ink-2); }

@media (max-width: 420px) {
  :root { --cell: 50px; }
  .top h1 { font-size: 1.45rem; }
}
@media (max-width: 380px) { :root { --cell: 46px; } .cell { font-size: .72rem; } }
@media (max-width: 360px) { .archive-tag { display: none; } }

/* packs dialog (2026-10-19) */
.packs-list { list-style: none; padding: 0; margin: 8px 0; }
.packs-list li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px dashed var(--ink-2); }
.packs-list li a { margin-left: auto; }
.packs-msg:empty { display: none; }
.file-btn { display: inline-block; margin: 4px 0 12px; padding: 8px 14px; border: 2px solid var(--ink); border-radius: var(--radius); cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 2px solid var(--sel, #2563eb); outline-offset: 2px; }

/* pack hints (2026-10-21): the notes that prove the hinted entry get an amber dotted frame, in the ledger and the notes list */
.cell.why::before { content: ""; position: absolute; inset: 1px; border: 2px dotted var(--hint); border-radius: calc(var(--radius) - 1px); pointer-events: none; }
.notes li.why { border-left-color: var(--hint); }
.hint-row { display: flex; gap: 10px; align-items: baseline; margin-top: 8px; font-size: .88rem; color: var(--ink-2); }
.hint-row button { flex-shrink: 0; padding: 4px 10px; border-color: var(--hint); }
.hint-row b { color: var(--ink); font-family: ui-monospace, Menlo, monospace; }
.noscript { padding: 12px; border: 1px solid var(--line); border-radius: 6px; }

/* Pennywick stationery edition */
:root{--paper:#f5f0e5;--paper-2:#ece3ce;--line:#d7cbb0;--ink:#2e3936;--ink-2:#788075;--green:#446e54;--green-bg:#e5eddf;--red:#a04b3e;--red-bg:#f2e0d8;--sel:#477d95;--hint:#987349;--cell:66px}
body{background:radial-gradient(ellipse at 10% 0,#e4eade,transparent 60%),#f5f0e5;line-height:1.5}main{max-width:760px;padding:0 24px 30px}.top{max-width:760px;padding:27px 26px 18px;align-items:center;border-bottom:1px solid #c5cbbd}.kicker{font:600 9px system-ui;letter-spacing:.23em;color:#7a8876;margin:0 0 5px}.top h1{font:400 32px Georgia,serif;letter-spacing:-.03em}.top .sub{font:11px system-ui;letter-spacing:.03em;margin-top:7px}.actions{gap:8px}button.icon{width:40px;height:40px;background:transparent;border-color:#bac4b4}.intro{text-align:center;font:400 18px Georgia,serif;line-height:1.6;margin:25px 0 18px;color:#566d5c}.intro em{font-size:14px;color:#85907e}.status{font:12px system-ui;border-top:1px solid #d8dece;border-bottom:1px solid #d8dece;padding:14px 5px}.ledger{padding:24px 0 20px}.board{background:#e2e4d5;padding:6px;border-radius:10px;gap:5px;box-shadow:0 5px 0 #ccd4c1,0 12px 25px #3f4f3012}.board-wrap{--c:min(var(--cell),calc((min(100vw,760px) - 82px - (var(--n) - 1)*5px)/var(--n)));grid-template-columns:22px 1fr}.col-labels{gap:5px;padding-left:6px;padding-right:6px}.row-labels{gap:5px;padding-top:6px;padding-bottom:6px}.cell{background:#f5eedc url('paper.webp') center/300px;border-color:#d5c9b0;border-radius:5px;box-shadow:inset 0 1px 1px #fff8;transition:transform .1s,outline .1s}.cell.genuine{background-image:linear-gradient(#dce9d5b0,#dce9d5b0),url('paper.webp')}.cell.forged{background-image:linear-gradient(#f1d9d0ba,#f1d9d0ba),url('paper.webp')}.cell .amt{font-size:12px}.cell .tag{font-size:8px;top:4px;left:5px}.cell .stamp span{border:0;font-size:0;padding:0;width:25px;height:25px;background:center/contain no-repeat;transform:rotate(-6deg);opacity:.94;mix-blend-mode:normal}.cell.genuine .stamp span{background-image:url('seal-genuine.webp')}.cell.forged .stamp span{background-image:url('seal-forged.webp')}.cell.genuine .amt,.cell.forged .amt{font-size:10px}.panel{border:1px solid #d4d9c7;border-radius:12px;background:#fffcf4;margin-top:8px;box-shadow:0 6px 20px #53633c05}.pc-note{font-size:16px;line-height:1.6}.judge{background-position:12px center;background-repeat:no-repeat;background-size:29px 29px;padding:12px 18px 12px 48px;min-height:48px;border-radius:8px}.judge.genuine{background-image:url('seal-genuine.webp')}.judge.forged{background-image:url('seal-forged.webp')}.notes{border-top:1px solid #d8dece;padding-top:20px}.notes h2{font-size:18px;font-weight:400}.notes li{padding:10px 12px;font-size:13px;background:#fffcf366;border-radius:7px;margin-bottom:5px}footer{max-width:760px;border-top:1px solid #d2dac6;font-size:11px;color:#8a927e;padding:20px 26px 30px}footer p{margin:5px 0}dialog{border-color:#cad2bd;border-radius:14px;background:#fcf8ed;box-shadow:0 20px 90px #253c2844}button{border-radius:7px}.nav-arrow{min-width:28px;height:28px}button:focus-visible,a:focus-visible{outline:3px solid #a27b42;outline-offset:3px}.hint-row{font:12px system-ui;line-height:1.6}#btn-hint{min-height:40px}.done h2{font-weight:400}#pc-hint{font-size:11px}
@media(max-width:480px){main{padding:0 14px 24px}.top{padding:20px 16px 15px}.top h1{font-size:25px}.kicker{font-size:8px}.intro{font-size:16px;margin:20px 0 16px}.intro em{font-size:12px}.status{font-size:11px}.cell .amt{font-size:10px}.cell.genuine .amt,.cell.forged .amt{font-size:9px}.cell .stamp span{width:21px;height:21px}.cell .tag{font-size:7px}.pc-note{font-size:14px}.judge{font-size:13px;padding:12px 10px 12px 40px;background-position:8px center;background-size:26px}.board-wrap{--c:min(var(--cell),calc((100vw - 70px - (var(--n) - 1)*5px)/var(--n)))}footer{padding:18px 18px 26px}}
