/* Muddl: "title card", violet dusk. Lilac paper page, indigo title band, thick outlines, chunky buttons.
   Every colour is a variable below; the dark scheme is indigo-charcoal, not pure black. */
/* Pixelify Sans (SIL Open Font License 1.1, see fonts/OFL.txt), subset to Latin with the ligature feature removed
   (its "fi" glyph reads as "A"; CSS cannot switch it off reliably because the font shorthand resets it). */
@font-face { font-family: "Pixelify Sans"; src: url("../fonts/PixelifySans.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap; }
:root {
  --room: #dcd7e8; --panel: #f6f3fc; --field: #fdfcff; --ink: #1d1535; --edge: #1d1535; --muted: #5f5a78; --hair: #c9c3dd;
  --band: #2a2150; --band-ink: #f1ecff; --band-muted: #b7aedb; --glitch-a: #3fd0f0; --glitch-b: #ff5c9a;
  --accent: #d6336c; --accent-ink: #fff6fa; --a: #2b6cb0; --b: #e8a21a; --b-ink: #8a5a00; --daily: #c9c3dd;
  --good: #2f7a45; --bad: #b3204d; --radius: 4px;
  --pixel: "Pixelify Sans", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --room: #17142a; --panel: #221d3d; --field: #1a1633; --ink: #ebe6ff; --edge: #bdb4e6; --muted: #a59fc6; --hair: #3a3360;
    --band: #0d0a1f; --band-ink: #ebe6ff; --band-muted: #a59fc6;
    --accent: #d6336c; --accent-ink: #fff6fa; --a: #6aa7e8; --b: #f2b13b; --b-ink: #f2b13b; --daily: #342d58;
    --good: #5cc07a; --bad: #ff7a9a;
  }
}
:root[data-theme="dark"] {
  --room: #17142a; --panel: #221d3d; --field: #1a1633; --ink: #ebe6ff; --edge: #bdb4e6; --muted: #a59fc6; --hair: #3a3360;
  --band: #0d0a1f; --band-ink: #ebe6ff; --band-muted: #a59fc6;
  --accent: #d6336c; --accent-ink: #fff6fa; --a: #6aa7e8; --b: #f2b13b; --b-ink: #f2b13b; --daily: #342d58;
  --good: #5cc07a; --bad: #ff7a9a;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--room); color: var(--ink); line-height: 1.45; position: relative; min-height: 100vh; }
/* the title band runs the full width of the page, with faint scanlines */
body::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 62px; background-color: var(--band);
  background-image: repeating-linear-gradient(0deg, rgb(255 255 255 / .05) 0 1px, transparent 1px 3px);
  border-bottom: 3px solid var(--edge); z-index: 0; }
/* film grain */
body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.app { position: relative; z-index: 2; max-width: 560px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; height: 62px; margin-bottom: 12px; }
h1 { margin: 0; font: 500 1.55rem/1 var(--pixel); letter-spacing: 2px; color: var(--band-ink);
  text-shadow: 1px 0 var(--glitch-a), -1px 0 var(--glitch-b); }
h2 { margin: 0 0 4px; font: 600 1.12rem/1.25 var(--pixel); }
h3 { margin: 0 0 8px; font: 600 .84rem var(--pixel); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.meta { display: flex; align-items: center; gap: 12px; font-family: var(--pixel); }
.meta .muted { color: var(--band-muted); }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .875rem; }
.pips { display: inline-flex; gap: 5px; }
.pip { width: 10px; height: 10px; border: 2px solid var(--band-muted); }
.pip.used { background: var(--band-muted); }
.pip.now { border-color: var(--band-ink); }
.icon-btn { width: 30px; height: 30px; border-radius: 3px; border: 2px solid var(--band-ink); border-bottom-width: 4px;
  background: var(--panel); color: var(--ink); font: 600 .95rem var(--pixel); cursor: pointer; }
.icon-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.banner { background: #f4e4a6; color: #4d3b00; border: 2px solid var(--edge); border-radius: 3px; padding: 8px 12px; font-size: .85rem; margin: 4px 0 8px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .banner { background: #4a3d12; color: #f6e3a1; } }

.card { background: var(--panel); border: 2px solid var(--edge); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.daily-card { text-align: center; }
.daily-card .label { font: 600 1.2rem/1.25 var(--pixel); }
.step { font: 500 .8rem var(--pixel); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 3px; }
.step::before { content: "// "; opacity: .7; }

.chip { display: inline-flex; align-items: baseline; gap: 6px; max-width: 100%; padding: 5px 10px; border-radius: 3px;
  border: 2px solid var(--a); background: color-mix(in srgb, var(--a) 18%, var(--panel)); font-weight: 600; }
.chip .fam { font: 500 .76rem var(--pixel); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chip.a { border-color: var(--a); background: color-mix(in srgb, var(--a) 18%, var(--panel)); }
.chip.b { border-color: var(--b); background: color-mix(in srgb, var(--b) 22%, var(--panel)); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.search { position: relative; }
.search input { width: 100%; font: inherit; font-size: 1rem; padding: 12px 14px; border-radius: 3px; border: 2px solid var(--edge);
  background: var(--field); color: var(--ink); min-height: 48px; }
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: 3px solid color-mix(in srgb, var(--a) 55%, transparent); outline-offset: 2px; }
.search ul { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  background: var(--panel); border: 2px solid var(--edge); border-radius: 3px; max-height: 320px; overflow: auto; }
.search li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 2px;
  cursor: pointer; min-height: 44px; }
.search li[aria-selected="true"], .search li:hover { background: color-mix(in srgb, var(--a) 22%, transparent); }
.search li .fam { font: 500 .76rem var(--pixel); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.search .none { padding: 12px; color: var(--muted); cursor: default; }

.btn { font: 600 .95rem var(--pixel); border-radius: 3px; padding: 10px 18px 8px; min-height: 48px; cursor: pointer;
  border: 2px solid var(--edge); border-bottom-width: 5px; background: var(--panel); color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn:active { transform: translateY(3px); border-bottom-width: 2px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1 1 140px; }
.link { background: none; border: none; color: var(--a); font: inherit; cursor: pointer; padding: 6px 0; text-decoration: underline; }

.bars { display: grid; gap: 8px; margin-top: 10px; }
.bar { display: grid; grid-template-columns: 3.2em 1fr; gap: 10px; align-items: center; }
.bar .pct { font: 600 1rem var(--pixel); text-align: right; }
.bar .track { position: relative; height: 30px; border: 2px solid var(--edge); border-radius: 2px; background: var(--field); overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--a) 40%, transparent); }
.bar .txt { position: relative; padding: 0 10px; line-height: 26px; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .txt small { color: var(--muted); margin-left: 6px; }
.big { font: 600 2.2rem/1.1 var(--pixel); letter-spacing: -.01em; }
/* a bust is a rubber stamp */
.big.bust { display: inline-block; color: var(--bad); border: 3px solid var(--bad); border-radius: 3px; padding: 2px 16px;
  text-transform: uppercase; letter-spacing: 3px; transform: rotate(-4deg); margin: 6px 0; }
.bust { color: var(--bad); }

.venn { width: 100%; height: auto; max-width: 340px; display: block; margin: 0 auto; }
.venn .v-daily { fill: var(--daily); stroke: var(--edge); stroke-width: 3; }
.venn .v-a { fill: var(--a); fill-opacity: .6; stroke: var(--a); stroke-width: 3; }
.venn .v-b { fill: var(--b); fill-opacity: .6; stroke: var(--b); stroke-width: 3; }
.venn .venn-i { font: 600 15px var(--pixel); fill: var(--ink); }
.venn .venn-cap { font: 12px var(--pixel); fill: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; margin-top: 8px; }
.stats b { display: block; font: 600 1.25rem var(--pixel); }
.stats span { font: .75rem var(--pixel); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stats .a b { color: var(--a); } .stats .b b { color: var(--b-ink); }
.score { text-align: center; margin: 6px 0 2px; }
.films { columns: 2 150px; column-gap: 18px; padding: 0; margin: 6px 0 0; list-style: none; font-size: .92rem; }
.films li { break-inside: avoid; padding: 2px 0; }
.films .yr { color: var(--muted); }
table.res { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.res td, table.res th { padding: 8px 4px; border-bottom: 2px solid var(--hair); text-align: left; vertical-align: top; }
table.res th { font: .75rem var(--pixel); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
table.res td.n { text-align: right; font-family: var(--pixel); white-space: nowrap; }
pre.share { background: var(--field); border: 2px dashed var(--edge); border-radius: 3px; padding: 12px; margin: 10px 0 0;
  font: 1.02rem/1.5 var(--pixel); white-space: pre-wrap; text-align: center; }
.streaks { display: flex; justify-content: space-around; text-align: center; }
.streaks b { display: block; font: 600 1.5rem var(--pixel); }
dialog { border: 2px solid var(--edge); border-radius: var(--radius); background: var(--panel); color: var(--ink); max-width: 420px; padding: 20px; }
dialog::backdrop { background: rgb(26 24 20 / .6); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--room);
  border: 2px solid var(--edge); padding: 10px 16px; border-radius: 3px; font: .9rem var(--pixel); z-index: 10; }
@media (max-width: 380px) { .stats { grid-template-columns: repeat(2, 1fr); } .big { font-size: 1.85rem; } }

/* ---- how to play ---- */
dialog#help { width: min(560px, calc(100vw - 24px)); max-height: min(88vh, 760px); overflow: auto; padding: 22px 20px 18px;
  overscroll-behavior: contain; }
#help h2 { font-size: 1.25rem; margin: 0 0 6px; }
#help h3 { margin: 18px 0 8px; }
#help .lead { margin: 0 0 12px; font-size: 1.02rem; }
#help .steps { margin: 0; padding-left: 1.25rem; display: grid; gap: 8px; }
#help .steps li::marker { font: 600 1rem var(--pixel); color: var(--accent); }
#help .examples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
#help .example { margin: 0; padding: 10px 8px 12px; border: 2px solid var(--edge); border-radius: 3px; background: var(--field);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
#help .example.best { border-color: var(--good); box-shadow: 0 0 0 2px var(--good) inset; }
#help .example figcaption { display: grid; gap: 3px; font-size: .78rem; line-height: 1.3; }
#help .example figcaption b { font: 600 .84rem var(--pixel); }
#help .example figcaption span { color: var(--muted); }
.venn-mini { width: 100%; max-width: 104px; height: auto; display: block; }
.venn-mini .v-daily { fill: var(--daily); stroke: var(--edge); stroke-width: 2.4; }
.venn-mini .v-a { fill: var(--a); fill-opacity: .6; stroke: var(--a); stroke-width: 2.4; }
.venn-mini .v-b { fill: var(--b); fill-opacity: .6; stroke: var(--b); stroke-width: 2.4; }
#help .key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 10px 0 8px; font-size: .8rem; }
#help .key .note { flex-basis: 100%; }
#help .sw { width: 12px; height: 12px; display: inline-block; border: 2px solid var(--edge); }
#help .sw.daily { background: var(--daily); }
#help .sw.a { background: color-mix(in srgb, var(--a) 60%, transparent); border-color: var(--a); margin-left: 6px; }
#help .sw.b { background: color-mix(in srgb, var(--b) 60%, transparent); border-color: var(--b); margin-left: 6px; }
#help .notes { margin: 8px 0 0; padding-left: 1.2rem; display: grid; gap: 4px; font-size: .92rem; }
#help form { margin-top: 16px; }
#help form .btn { width: 100%; }
@media (max-width: 440px) {
  #help .examples { grid-template-columns: 1fr; }
  #help .example { flex-direction: row; text-align: left; gap: 12px; padding: 8px 10px; }
  #help .example .venn-mini { max-width: 76px; flex: none; }
}
