/* Hangman Words — mobile-first, follows the system theme. */
:root {
  color-scheme: light dark;
  --banner-h: 0px;
  --bg: #fdf6ec;
  --surface: #ffffff;
  --text: #241a08;
  --muted: #7a6a4d;
  --accent: #b45309;
  --accent-soft: #fdeecd;
  --correct: #2e7d32;
  --correct-soft: #d9efe4;
  --wrong: #b3261e;
  --wrong-soft: #fbe4e2;
  --border: #e8dcc3;
  --shadow: 0 8px 32px rgba(0, 0, 0, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c150a;
    --surface: #2a2113;
    --text: #fdf3dd;
    --muted: #c9b48a;
    --accent: #f59e0b;
    --accent-soft: #3a2c12;
    --correct: #66bb6a;
    --correct-soft: #1e3a2d;
    --wrong: #ff8a80;
    --wrong-soft: #4a1f1c;
    --border: #453a24;
    --shadow: 0 8px 32px rgba(0, 0, 0, .45);
  }
}
* { box-sizing: border-box; }
/* Sheets and the toast set display values — without this the
   [hidden] attribute is overridden and overlays cover the screen
   from boot, swallowing every tap. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: var(--banner-h);
}
body.hw_banner { padding-bottom: var(--banner-h); }
button { font: inherit; color: inherit; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; max-width: 560px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 700;
}
.title { font-size: 20px; font-weight: 700; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 19px; cursor: pointer;
}
.icon-btn:active { transform: scale(.95); }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; }
.tagline { text-align: center; color: var(--muted); font-size: 15px; line-height: 1.5; margin: 6px 8px 14px; }
.section-title { font-size: 15px; margin: 16px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-size: 14px;
}
.chip-on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.pool-note { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.primary-btn {
  width: 100%; padding: 15px; border: none; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 18px; font-weight: 700; cursor: pointer;
  margin-top: 20px;
}
.primary-btn:active { transform: scale(.98); }
.primary-btn:disabled { opacity: .45; cursor: default; }
.ghost-btn {
  flex: 1 1 40%; padding: 11px 6px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); font-size: 14px;
}
.ghost-btn.wide { flex: none; width: 100%; margin-top: 8px; }
.ghost-btn:disabled { opacity: .45; cursor: default; }

.stats { display: flex; gap: 8px; margin-top: 18px; }
.stat {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 4px; text-align: center;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-size: 20px; font-weight: 700; }
.stat-label { font-size: 11px; color: var(--muted); }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin: 16px 8px 0; line-height: 1.45; }

/* Game view */
.game-category { text-align: center; color: var(--muted); font-size: 14px; margin: 4px 0 0; }
.gallows-wrap { text-align: center; margin: 2px auto 0; }
.gallows { width: 180px; height: 198px; }
.gallows .wood { stroke: var(--muted); stroke-width: 5; stroke-linecap: round; fill: none; }
.gallows .figure { stroke: var(--text); stroke-width: 4; stroke-linecap: round; fill: none; }
.wrong-count { color: var(--wrong); font-weight: 700; font-size: 15px; margin: 0 0 8px; }

.word-slots {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  margin: 10px 0 12px; min-height: 44px;
}
.slot {
  width: 32px; height: 42px;
  border-bottom: 3px solid var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; text-transform: uppercase;
}
.wrong-tray { text-align: center; color: var(--muted); font-size: 14px; min-height: 20px; margin: 0 0 12px; }

.keyboard { display: flex; flex-direction: column; gap: 6px; }
.kb-row { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1; max-width: 34px; height: 46px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 16px; font-weight: 700; cursor: pointer; padding: 0;
}
.key:active { transform: scale(.94); }
.key:disabled { cursor: default; }
.key-correct { background: var(--correct); border-color: var(--correct); color: #fff; }
.key-wrong { background: var(--wrong-soft); border-color: var(--wrong); color: var(--wrong); opacity: .55; }

.game-actions { display: flex; margin-top: 14px; }

/* Result popup + sheets: fixed overlays with their own banner offset. */
.sheet {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 560px; max-height: calc(92vh - var(--banner-h));
  background: var(--surface); color: var(--text);
  border-radius: 20px 20px 0 0; padding: 16px 18px calc(18px + var(--banner-h));
  overflow-y: auto; box-shadow: var(--shadow);
  margin-bottom: var(--banner-h);
}
body.hw_banner .sheet-card { margin-bottom: var(--banner-h); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 4px 0 10px; font-size: 20px; }
.sheet-note { color: var(--muted); font-size: 13px; line-height: 1.5; }

.result-card { text-align: center; }
.result-title { font-size: 28px; margin: 6px 0 4px; }
.result-word { font-size: 18px; font-weight: 700; margin: 6px 0; }
.result-detail { color: var(--muted); font-size: 15px; margin: 4px 0 10px; }
.result-stats { font-size: 14px; margin: 0 0 6px; }
.result-card .primary-btn { margin-top: 8px; }

/* Duplicate-guess toast: sits above the banner zone. */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + var(--banner-h)); z-index: 60;
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow); white-space: nowrap;
}
