/* Doodle Hunch: a sketchbook. Light: cream graph paper, pencil orange, ink blue. Dark: a slate desk at night.
   house/theme.js sets data-theme="dark" on <html>. The drawing sheet (house/sketch.css) stays white in both. */
@font-face { font-family: "Jost"; font-style: normal; font-weight: 300 800; font-display: swap; src: url(/fonts/jost-latin-wght-normal.woff2) format("woff2"); }

:root {
  --bg: #F6F1E6; --bg2: #EDE5D5; --card: #FFFDF7; --ink: #22252E; --muted: #63666F; --line: #E2D9C8;
  --grid: rgba(48, 98, 196, .09); --accent: #BD4A12; --accent-2: #2754C5; --on-accent: #FFFFFF;
  --good: #23784A; --close: #9A6212; --bad: #B8323F; --t0: #2754C5; --t1: #BD4A12;
  --backdrop: rgba(30, 28, 24, .45); --cover: rgba(255, 253, 247, .9);
  --font: "Jost", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --lb-panel: var(--card); --lb-panel2: var(--bg2); --lb-text: var(--ink); --lb-muted: var(--muted); --lb-line: var(--line);
  --lb-accent: var(--accent); --lb-ink: var(--on-accent); --lb-bad: var(--bad); --lb-font: var(--font);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #15171C; --bg2: #1F232B; --card: #1C1F26; --ink: #EEEFF3; --muted: #A3A8B5; --line: #30343F;
  --grid: rgba(140, 170, 255, .06); --accent: #FF8A4C; --accent-2: #8FB0FF; --on-accent: #1C0D04;
  --good: #6FD39A; --close: #FFC857; --bad: #FF8A98; --t0: #8FB0FF; --t1: #FF9D63;
  --backdrop: rgba(0, 0, 0, .6); --cover: rgba(28, 31, 38, .9);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { touch-action: manipulation; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.45; min-height: 100vh; min-height: 100dvh;
  -webkit-text-size-adjust: 100%; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 22px 22px; }
.wrap { max-width: 668px; margin: 0 auto; padding: 0 14px; }
body.dh-in .wrap { max-width: 1120px; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 0; max-width: 1120px; }
.back { text-decoration: none; color: var(--muted); font-size: .95rem; white-space: nowrap; }
.top-actions { display: flex; gap: 4px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; color: var(--ink); font-family: var(--font); }
@media (hover: hover) { .icon-btn:hover { background: var(--bg2); } }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; padding: 4px 0 10px; gap: 4px 10px; max-width: 640px; margin: 0 auto; }
h1 { font-weight: 700; font-size: 2rem; margin: 0; line-height: 1; display: flex; align-items: center; gap: 8px; }
.h-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); position: relative; transform: rotate(-8deg); flex: none; }
.h-mark::before { content: ""; position: absolute; left: 6px; right: 6px; top: 13px; height: 4px; border-radius: 2px; background: var(--card); }
.h-mark::after { content: ""; position: absolute; right: 4px; top: 11px; border-left: 6px solid var(--card); border-top: 4px solid transparent; border-bottom: 4px solid transparent; }
.sub { margin: 0; color: var(--muted); font-size: .95rem; }
.fine { color: var(--muted); font-size: .9rem; margin: 6px 0; }
.linkish { background: none; border: 0; padding: 0; color: var(--accent-2); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 32px; }
.linkish.arm { color: var(--bad); }

/* ------------------------------------------------------------ home */
.home { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.intro p { margin: 0 0 6px; }
.sets-h { font-size: 1.1rem; margin: 0 0 8px; }
.pack-line { margin: 8px 0; } .pack-line span { color: var(--muted); }
.go { -webkit-appearance: none; appearance: none; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font: 700 1rem var(--font); padding: 11px 22px; min-height: 44px; cursor: pointer; }
.go.small { padding: 8px 16px; min-height: 40px; font-size: .95rem; }
.go.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.go:disabled { opacity: .5; cursor: default; }
.go:focus-visible, .linkish:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* ------------------------------------------------------------ the game */
.game { padding: 2px 0 10px; }
.g-top { display: flex; align-items: center; gap: 10px; min-height: 52px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 6px 12px; }
.g-word { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.g-word small { color: var(--muted); font-size: .85rem; }
.g-word .w-word { font-size: 1.45rem; letter-spacing: .01em; color: var(--accent); overflow-wrap: anywhere; }
.g-word .w-word.ok { color: var(--good); }
.g-word .w-mask { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: clamp(.95rem, 4.2vw, 1.3rem); letter-spacing: 0; white-space: pre; max-width: 100%; overflow: hidden; text-overflow: clip; }
.g-word .w-n { width: 100%; margin-top: -4px; }
.g-word .w-sys { font-weight: 600; font-size: 1.1rem; }
.g-clock { flex: none; width: 74px; height: 34px; border-radius: 999px; background: var(--bg2); position: relative; overflow: hidden; display: grid; place-items: center; }
.g-clock i { position: absolute; inset: 0; background: var(--accent-2); opacity: .22; transform-origin: left center; }
.g-clock span { position: relative; font-weight: 700; font-variant-numeric: tabular-nums; }
.g-clock.low i { background: var(--bad); opacity: .3; }
.g-clock.low span { color: var(--bad); }
.g-line { margin: 6px 2px; color: var(--muted); font-size: .9rem; min-height: 1.3em; }
.g-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.g-sheet { min-width: 0; width: 100%; margin: 0 auto; }
.g-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
@media (min-width: 900px) {
  .g-main { grid-template-columns: minmax(0, 1fr) 330px; }
  .g-sheet { max-width: min(100%, calc(100vh - 250px), 680px); max-width: min(100%, calc(100dvh - 250px), 680px); min-width: 420px; }
  body.dh-drawing .g-sheet { max-width: min(100%, calc(100vh - 330px), 680px); max-width: min(100%, calc(100dvh - 330px), 680px); }
}
.g-guess { display: flex; gap: 8px; }
.g-guess input { flex: 1; min-width: 0; font: 500 1rem var(--font); padding: 10px 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); min-height: 44px; }
.g-guess input:focus { outline: none; border-color: var(--accent-2); }
.g-guess input:disabled { opacity: .6; }
.g-feed { list-style: none; margin: 0; padding: 8px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; height: 150px; overflow-y: auto; font-size: .92rem; overscroll-behavior: contain; }
@media (min-width: 900px) { .g-feed { height: 240px; } }
.g-feed li { padding: 2px 0; overflow-wrap: anywhere; }
.g-feed .f-sys { color: var(--muted); font-style: normal; }
.g-feed .f-ok { color: var(--good); font-weight: 700; }
.g-feed .f-close { color: var(--close); font-weight: 600; }
.g-feed .f-secret { color: var(--good); }
.g-feed .f-secret b { opacity: .8; }
.g-ps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ps, .ps-team { display: flex; align-items: center; gap: 8px; padding: 7px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.ps-team { background: transparent; border: 0; padding: 6px 4px 0; font-size: .95rem; }
.ps-team.t0 b { color: var(--t0); } .ps-team.t1 b { color: var(--t1); }
.ps.t0 { border-left: 4px solid var(--t0); } .ps.t1 { border-left: 4px solid var(--t1); }
.ps-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-sc { font-weight: 700; font-variant-numeric: tabular-nums; margin-left: auto; }
.ps-team .ps-sc { margin-left: 8px; }
.ps-d { color: var(--good); font-weight: 700; font-size: .9rem; }
.ps.me { box-shadow: inset 0 0 0 1.5px var(--accent-2); }
.ps.off { opacity: .5; }
.ps.got { background: color-mix(in srgb, var(--good) 14%, var(--card)); }
.ps-pen, .ps-ok { width: 18px; height: 18px; flex: none; border-radius: 50%; display: inline-block; position: relative; }
.ps-pen { background: var(--accent); }
.ps-pen::after { content: ""; position: absolute; left: 4px; top: 8px; width: 10px; height: 2px; background: var(--card); transform: rotate(-35deg); }
.ps-ok { background: var(--good); }
.ps-ok::after { content: ""; position: absolute; left: 6px; top: 3px; width: 4px; height: 8px; border: solid var(--card); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.g-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.g-code { color: var(--muted); font-size: .85rem; }
body.dh-in .ad-inline { display: none; }

/* the cover over the sheet: get ready, choosing, the word, the final scores */
.g-cover { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 14px; background: var(--cover); overflow: auto; color: var(--ink); }
.cv-box { text-align: center; max-width: 420px; width: 100%; }
.cv-big { font-size: 1.6rem; font-weight: 700; margin: 4px 0 8px; overflow-wrap: anywhere; }
.ph-reveal .cv-big { color: var(--accent); font-size: 2rem; }
/* the word over the drawing: a card at the bottom, so the picture stays in view */
.g-cover.ph-reveal { background: linear-gradient(to bottom, transparent 30%, var(--cover) 75%); align-items: end; }
.ph-reveal .cv-box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.ph-reveal .cv-box > .fine { margin: 0; }
.ph-reveal .cv-big { margin: 0 0 4px; }
.cv-list, .cv-rank { list-style: none; margin: 8px auto 0; padding: 0; max-width: 300px; text-align: left; }
.cv-list li, .cv-rank li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.cv-list b { color: var(--good); }
.cv-rank { counter-reset: rk; }
.cv-rank li::before { counter-increment: rk; content: counter(rk) "."; color: var(--muted); width: 1.6em; flex: none; }
.cv-rank li span { flex: 1; text-align: left; }
.cv-rank li.me { font-weight: 700; }
.cv-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.cv-sets { text-align: left; margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
@media (prefers-reduced-motion: no-preference) { .ph-reveal .cv-big { animation: pop .45s cubic-bezier(.34, 1.5, .64, 1); } @keyframes pop { from { transform: scale(.6); opacity: 0; } } }

/* the word choice */
dialog.pick .pick-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.pick-w { -webkit-appearance: none; appearance: none; border: 1.5px solid var(--line); background: var(--bg2); color: var(--ink); border-radius: 14px; padding: 14px; font: 700 1.2rem var(--font); cursor: pointer; min-height: 52px; }
@media (hover: hover) { .pick-w:hover { border-color: var(--accent); } }
.pick-w:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }

/* ------------------------------------------------------------ dialogs, toast, footer */
dialog.dlg { border: 1px solid var(--line); border-radius: 20px; background: var(--card); color: var(--ink); max-width: min(480px, calc(100vw - 24px)); width: 100%; padding: 24px 22px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; }
dialog.dlg::backdrop { background: var(--backdrop); }
dialog.dlg h2 { margin: 0 0 10px; font-size: 1.35rem; }
dialog.dlg h3 { margin: 14px 0 4px; font-size: 1.02rem; }
dialog.dlg p { margin: 6px 0; }
dialog.dlg form:first-child { position: sticky; top: 0; height: 0; z-index: 3; }
.x { position: absolute; top: -14px; right: -12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--bg2); color: var(--ink); font-size: 1.5rem; cursor: pointer; line-height: 1; }
dialog.dlg .go { display: block; margin: 14px auto 0; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.ad-inline { margin: 18px 0; }
.tg-about { max-width: 640px; margin-left: auto; margin-right: auto; }
.foot { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; padding: 18px 0 30px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); margin-top: 10px; }
.foot a { color: var(--muted); }
