/* Coffee Break — shared styles */
:root {
  --bg: #f4ece1;
  --bg-2: #ebe0d1;
  --surface: #fffaf3;
  --surface-2: #f7efe4;
  --line: #e2d4c2;
  --text: #2a1c13;
  --muted: #7b6656;
  --accent: #b4542a;
  --accent-ink: #ffffff;
  --espresso: #4a2c1d;
  --good: #3f8a4f;
  --bad: #c0392b;
  --warn: #c98a1b;
  --shadow: 0 1px 2px rgba(60, 35, 20, .08), 0 6px 20px rgba(60, 35, 20, .08);
  --radius: 18px;
  --radius-sm: 12px;
  --tone1: #d23f31; --tone2: #e08a00; --tone3: #2e8b57; --tone4: #2f6fd6; --tone5: #8a7a6e;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-han: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17110d; --bg-2: #201812; --surface: #261c16; --surface-2: #2f241c; --line: #3d3027;
    --text: #f3e8dc; --muted: #b29e8d; --accent: #e3864f; --accent-ink: #1b120c; --espresso: #f0d9c4;
    --good: #5fb873; --bad: #ec6a5b; --warn: #e5b04a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --tone1: #ff6b5c; --tone2: #ffb03b; --tone3: #5ccf8a; --tone4: #6fa2ff; --tone5: #a8988b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17110d; --bg-2: #201812; --surface: #261c16; --surface-2: #2f241c; --line: #3d3027;
  --text: #f3e8dc; --muted: #b29e8d; --accent: #e3864f; --accent-ink: #1b120c; --espresso: #f0d9c4;
  --good: #5fb873; --bad: #ec6a5b; --warn: #e5b04a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --tone1: #ff6b5c; --tone2: #ffb03b; --tone3: #5ccf8a; --tone4: #6fa2ff; --tone5: #a8988b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
.han { font-family: var(--font-han); }

/* layout */
.app { max-width: 720px; margin: 0 auto; padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; margin: 0 -16px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
}
.topbar h1 { flex: 1; margin: 0; font-family: var(--font-display); font-size: 1.3rem; font-weight: 650; letter-spacing: -.01em; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(.95); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn { white-space: nowrap; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1; }

/* cards & sections */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 4px 8px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* home */
.hero { padding: 26px 4px 10px; }
.hero h1 { font-family: var(--font-display); font-size: clamp(2.2rem, 9vw, 3.2rem); line-height: 1; margin: 0 0 6px; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.game-tile {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; min-height: 150px;
  padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); text-decoration: none; color: var(--text); overflow: hidden;
}
.game-tile .glyph { font-size: 2.4rem; line-height: 1; }
.game-tile h2 { margin: 12px 0 2px; font-size: 1.05rem; }
.game-tile p { margin: 0; font-size: .85rem; color: var(--muted); }
.game-tile.soon { opacity: .62; }
.badge {
  position: absolute; top: 12px; right: 12px; font-size: .68rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--bg-2); color: var(--muted);
}
.game-tile.featured { grid-column: 1 / -1; min-height: 130px; background: var(--espresso); color: var(--bg); border-color: transparent; }
:root[data-theme="dark"] .game-tile.featured, :root:not([data-theme="light"]) .game-tile.featured { color: var(--bg); }
.game-tile.featured p { color: color-mix(in srgb, var(--bg) 75%, transparent); }
.game-tile.featured .glyph { font-family: var(--font-han); font-size: 3rem; }

/* list rows / settings */
.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--line); }
.setting { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 56px; }
.setting .label { flex: 1; }
.setting .label small { display: block; color: var(--muted); font-size: .8rem; }
.seg { display: inline-flex; background: var(--bg-2); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
select.select { background: var(--bg-2); border: 0; border-radius: 10px; padding: 8px 10px; }

/* players setup */
.player-count { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.player-count button { min-height: 52px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 1.1rem; }
.player-count button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.player-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.player-row input[type=text] { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }
.swatch:disabled { opacity: .25; cursor: not-allowed; }
.player-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }

/* turn banner & scoreboard (shared by multiplayer games) */
.scoreboard { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.score { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 2px solid var(--line); text-align: center; transition: transform .15s, border-color .15s; }
.score .name { font-size: .78rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score .pts { font-size: 1.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.score.active { border-color: var(--pc, var(--accent)); transform: translateY(-2px); box-shadow: 0 6px 16px color-mix(in srgb, var(--pc, var(--accent)) 30%, transparent); }

/* timer */
.timer { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.timer > i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transition: background .3s; }
.timer.low > i { background: var(--bad); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* modal sheet */
.sheet-back { position: fixed; inset: 0; background: rgba(20, 10, 5, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 720px; max-height: 88dvh; overflow: auto; background: var(--bg); border-radius: 22px 22px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
.sheet h2 { font-family: var(--font-display); margin: 4px 4px 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@media (min-width: 760px) { .sheet-back { align-items: center; } .sheet { border-radius: 22px; } }

/* shared quiz bits */
.choices { display: grid; gap: 10px; }
.choice { min-height: 58px; text-align: left; padding: 12px 16px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: var(--surface); font-size: 1rem; display: flex; align-items: center; gap: 12px; }
.choice .k { width: 26px; height: 26px; flex: none; border-radius: 8px; background: var(--bg-2); display: grid; place-items: center; font-size: .8rem; font-weight: 700; color: var(--muted); }
.choice.han { font-family: var(--font-han); font-size: 1.6rem; justify-content: flex-start; }
.choice.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.choice:disabled { cursor: default; }
.feedback { min-height: 26px; text-align: center; font-weight: 700; margin: 12px 0; }
.feedback.ok { color: var(--good); } .feedback.no { color: var(--bad); }

.done-card { text-align: center; padding: 32px 20px; }
.done-card .big { font-size: 3rem; }
.done-card h2 { font-family: var(--font-display); margin: 8px 0 6px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
