/* Hangman: a chalkboard. Both themes are dark boards; "light" is the classic green board, "dark" is slate. */
:root {
  --board: #2f5044; --board-2: #37594c; --board-edge: #24403a;
  --chalk: #f4f1e8; --chalk-dim: #c9c6bd; --chalk-faint: rgb(244 241 232 / .28);
  --chalk-yellow: #f6d365; --chalk-pink: #f28ea0; --chalk-blue: #9bd0f0;
  --wood: #8a5a2b; --wood-2: #6b4320; --wood-3: #a97a48;
  --bg: var(--board); --surface: var(--board-2); --surface-2: rgb(255 255 255 / .06); --ink: var(--chalk); --ink-2: var(--chalk-dim); --line: var(--chalk-faint);
  --ok: var(--chalk-yellow); --warn: var(--chalk-blue); --bad: var(--chalk-pink); --info: var(--chalk-blue);
  --accent: var(--chalk-yellow); --accent-ink: #2a2418;
  --font-display: "Fredericka the Great", "Patrick Hand", cursive; --font-ui: "Patrick Hand", "Segoe Print", "Comic Sans MS", cursive;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --board: #1e2622; --board-2: #262f2a; --board-edge: #151c18; } }
:root[data-theme="dark"] { --board: #1e2622; --board-2: #262f2a; --board-edge: #151c18; }
:root[data-colorblind="1"] { --ok: #f6d365; --warn: #9bd0f0; --bad: #ffffff; }
:root[data-contrast="1"] { --chalk-dim: #f4f1e8; --chalk-faint: rgb(244 241 232 / .55); }

body { font-size: 1.15rem; letter-spacing: .01em; }
.board {
  position: relative; background-color: var(--board);
  background-image:
    radial-gradient(ellipse at 20% 10%, rgb(255 255 255 / .06), transparent 50%),
    radial-gradient(ellipse at 80% 90%, rgb(255 255 255 / .05), transparent 45%),
    repeating-linear-gradient(115deg, transparent 0 14px, rgb(255 255 255 / .012) 14px 16px);
  box-shadow: inset 0 0 0 10px var(--wood), inset 0 0 0 12px var(--wood-2), inset 0 0 80px rgb(0 0 0 / .35);
  padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-left)) max(22px, env(safe-area-inset-bottom));
}
@media (min-width: 640px) { .board { box-shadow: inset 0 0 0 14px var(--wood), inset 0 0 0 17px var(--wood-2), inset 0 0 100px rgb(0 0 0 / .35); padding: 32px; } }

/* Chalk primitives */
.chalk-btn { background: transparent; color: var(--chalk); border: 2px solid var(--chalk-faint); box-shadow: none; font-size: 1.05rem; }
.chalk-btn:hover { border-color: var(--chalk-dim); } .chalk-btn:active { background: rgb(255 255 255 / .06); }
.chalk-cta { background: var(--chalk-yellow); color: var(--accent-ink); font-size: 1.25rem; font-weight: 700; min-height: 52px; padding: 0 32px; box-shadow: 0 2px 0 rgb(0 0 0 / .25); }
.chalk-note { color: var(--chalk-dim); font-size: 1.05rem; }
.chalk-label { color: var(--chalk-dim); font-size: 1rem; margin: 0 0 6px 4px; }
.topbar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.screen-title { font-size: 2rem; font-weight: 400; margin-left: 8px; }

/* Home */
.hero { text-align: center; padding: 8px 0 12px; }
.hero-doodle { width: 120px; height: 120px; display: block; margin: 0 auto -6px; }
.title { font-size: clamp(3.2rem, 15vw, 5.5rem); font-weight: 400; color: var(--chalk); text-shadow: 0 0 12px rgb(255 255 255 / .18); letter-spacing: .02em; }
.tagline { color: var(--chalk-dim); font-size: 1.15rem; max-width: 28ch; margin: 4px auto 0; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.mode { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; min-height: 72px; border: 2px solid var(--chalk-faint); border-radius: 14px; color: var(--chalk); text-align: left; transition: border-color var(--t-base), background var(--t-base); }
.mode b { font-size: 1.3rem; font-weight: 400; } .mode span { color: var(--chalk-dim); font-size: .95rem; line-height: 1.2; }
.mode[aria-pressed="true"] { border-color: var(--chalk-yellow); background: rgb(246 211 101 / .10); } .mode[aria-pressed="true"] b { color: var(--chalk-yellow); }
.picker { margin-top: 16px; }
.cats { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 2px 8px; margin: 0 -4px; scrollbar-width: none; }
.cat { flex: 0 0 auto; scroll-snap-align: start; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px 0 10px; border-radius: var(--r-pill); border: 2px solid var(--chalk-faint); color: var(--chalk); font-size: 1.1rem; }
.cat[aria-checked="true"] { border-color: var(--chalk-yellow); color: var(--chalk-yellow); background: rgb(246 211 101 / .10); }
.cat .em { font-size: 1.3rem; }
.seg-chalk { display: flex; border: 2px solid var(--chalk-faint); border-radius: var(--r-pill); padding: 3px; }
.seg-chalk button { flex: 1; height: 40px; border-radius: var(--r-pill); color: var(--chalk-dim); font-size: 1.1rem; }
.seg-chalk button[aria-checked="true"] { background: var(--chalk); color: #2a2418; }
.home-actions { display: flex; gap: 10px; margin-top: 22px; } .home-actions .chalk-cta { flex: 1; }
.best-line { text-align: center; color: var(--chalk-dim); margin-top: 12px; min-height: 1.4em; }
@media (min-width: 640px) { .modes { grid-template-columns: repeat(4, 1fr); } .screen.board[data-screen="home"] { max-width: 760px; margin-inline: auto; min-height: 100dvh; } }

/* Play */
.screen[data-screen="play"] { display: flex; flex-direction: column; gap: 6px; height: 100dvh; min-height: 0; overflow: hidden; }
.hud { gap: 6px; } .hud hg-timer { font-size: 1.15rem; min-width: 3.2em; text-align: right; }
.lives { display: flex; gap: 3px; align-items: center; }
.lives .life { width: 16px; height: 16px; color: var(--chalk-pink); transition: transform var(--t-base) var(--ease-spring), opacity var(--t-base); }
.lives .life[data-lost="true"] { opacity: .22; transform: scale(.7); }
.lives .life.anim-crack { animation: crack .5s var(--ease-out); }
@keyframes crack { 30% { transform: scale(1.4) rotate(-12deg); } 60% { transform: scale(.9) rotate(10deg); } }
.stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
.gallows { width: 100%; height: 100%; max-height: min(38dvh, 340px); display: block; }
.chalk-msg { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; color: var(--chalk-yellow); font-size: 1.2rem; min-height: 1.5em; pointer-events: none; }
.word { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 0; padding: 4px 0 6px; --slot: clamp(22px, 7.4vw, 40px); }
.word .w { display: inline-flex; gap: 5px; margin: 0 8px; }
.slot { width: var(--slot); height: calc(var(--slot) * 1.35); position: relative; display: inline-flex; align-items: flex-end; justify-content: center; font-family: var(--font-ui); font-size: calc(var(--slot) * 1.05); line-height: 1; color: var(--chalk); text-transform: uppercase; }
.slot::after { content: ""; position: absolute; left: 2px; right: 2px; bottom: -3px; height: 3px; border-radius: 2px; background: var(--chalk-dim); opacity: .8; }
.slot[data-state="hint"] { color: var(--chalk-blue); } .slot[data-state="lost"] { color: var(--chalk-pink); }
.slot.anim-pop { animation: pop var(--t-slow) var(--ease-spring); }
.word[data-status="lost"] .slot::after, .word[data-status="won"] .slot::after { opacity: .35; }
.tools { display: flex; gap: 8px; justify-content: center; } .tools .btn { min-height: 42px; padding: 0 16px; font-size: 1rem; }
.word-form { display: flex; gap: 8px; }
.word-form input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border-radius: 10px; border: 2px solid var(--chalk-dim); background: rgb(255 255 255 / .06); color: var(--chalk); text-transform: uppercase; letter-spacing: .06em; }
.word-form .chalk-cta { min-height: 48px; padding: 0 18px; font-size: 1.1rem; }
hg-keyboard { gap: 5px; }
.key { background: transparent; color: var(--chalk); border: 2px solid var(--chalk-faint); height: 46px; max-width: 44px; font-size: 1.15rem; font-family: var(--font-ui); border-radius: 8px; }
.key[data-state="correct"] { background: var(--chalk-yellow); border-color: var(--chalk-yellow); color: #2a2418; }
.key[data-state="absent"] { background: transparent; border-color: transparent; color: var(--chalk-dim); opacity: .35; text-decoration: line-through; }
.key[data-state="present"] { background: var(--chalk-blue); border-color: var(--chalk-blue); color: #14283a; }
.key:disabled { cursor: default; }
.ledge { height: 14px; margin: 4px -10px -12px; background: linear-gradient(var(--wood-3), var(--wood)); border-radius: 3px; box-shadow: 0 3px 0 var(--wood-2), 0 6px 10px rgb(0 0 0 / .35); position: relative; }
.chalk-stick { position: absolute; top: -6px; left: 22px; width: 34px; height: 8px; border-radius: 3px; background: var(--chalk); box-shadow: inset 0 -2px 0 rgb(0 0 0 / .18); transform: rotate(-3deg); }
.chalk-stick.pink { left: 64px; width: 22px; background: var(--chalk-pink); transform: rotate(4deg); }
.eraser { position: absolute; top: -10px; right: 24px; width: 42px; height: 12px; border-radius: 3px; background: #3b2a1a; box-shadow: inset 0 3px 0 #d8c8a8; }
@media (max-height: 640px) { .gallows { max-height: 28dvh; } .key { height: 44px; } .tools .btn { min-height: 40px; } .word { --slot: clamp(20px, 6.6vw, 36px); } }
@media (min-width: 640px) { .screen[data-screen="play"] { max-width: 640px; margin-inline: auto; gap: 10px; } .word { --slot: 40px; } }

/* Result */
.screen[data-screen="result"] { justify-content: center; align-items: center; }
.result { width: min(100%, 460px); text-align: center; display: flex; flex-direction: column; gap: 10px; }
.result-verdict { font-family: var(--font-display); font-size: clamp(2.6rem, 12vw, 4rem); line-height: 1; }
.result-verdict[data-won="true"] { color: var(--chalk-yellow); } .result-verdict[data-won="false"] { color: var(--chalk-pink); }
.result-word { font-size: clamp(1.8rem, 8vw, 2.6rem); text-transform: uppercase; letter-spacing: .12em; }
.result-hint { color: var(--chalk-dim); font-style: italic; }
.stars { display: flex; justify-content: center; gap: 6px; } .stars .icon { width: 34px; height: 34px; color: var(--chalk-faint); }
.stars .icon[data-on="true"] { color: var(--chalk-yellow); fill: var(--chalk-yellow); animation: pop var(--t-slow) var(--ease-spring) both; animation-delay: calc(var(--i) * 140ms); }
.score-total { color: var(--chalk); } .score-rows li { background: rgb(255 255 255 / .06); }
.result-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; } .result-actions .chalk-cta { grid-column: 1 / -1; }

/* Leaderboard theming */
.screen[data-screen="board"] { gap: 16px; } .lb-stats div, .lb-row { background: rgb(255 255 255 / .06); box-shadow: none; }
.lb-tab { border: 2px solid var(--chalk-faint); background: transparent; color: var(--chalk); } .lb-tab[aria-selected="true"] { background: var(--chalk); color: #2a2418; border-color: var(--chalk); }
@media (min-width: 640px) { .screen[data-screen="board"] { max-width: 640px; margin-inline: auto; } }

/* Sheets */
.sheet-panel { background: var(--board-2); color: var(--chalk); border: 2px solid var(--chalk-faint); }
.sheet-body p { color: var(--chalk-dim); line-height: 1.45; } .sheet-body b { color: var(--chalk); }
.set-input { background: rgb(255 255 255 / .06); border-color: var(--chalk-faint); }
.seg { background: rgb(255 255 255 / .06); } .seg [aria-checked="true"] { background: var(--chalk); color: #2a2418; }
.toast { background: var(--chalk); color: #2a2418; } .toast[data-type="bad"] { background: var(--chalk-pink); color: #3a1a22; }
