:root {
  --bg: #f6f5fb; --surface: #ffffff; --text: #1d1b2b; --muted: #5d5a70; --line: #dcd9ea;
  --brand: #5b3df5; --brand-text: #ffffff; --accent: #ffb800; --danger: #c62828; --ok: #1b7f4b;
  --radius: 14px; --tap: 48px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans TC", "PingFang HK", "Microsoft JhengHei", sans-serif;
}
:root[data-theme="dark"] { --bg: #14121f; --surface: #1f1c30; --text: #f0eefc; --muted: #aaa6c4; --line: #38334f; --brand: #8f7bff; --brand-text: #14121f; --danger: #ff8a80; --ok: #6fdba0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #14121f; --surface: #1f1c30; --text: #f0eefc; --muted: #aaa6c4; --line: #38334f; --brand: #8f7bff; --brand-text: #14121f; --danger: #ff8a80; --ok: #6fdba0; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; font-size: 17px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
#app { max-width: 560px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom)); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; } .muted { color: var(--muted); } .center { text-align: center; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--tap); margin-bottom: 8px; }
.topbar .title { font-weight: 700; font-size: 1.1rem; flex: 1; text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
button, .btn { font: inherit; min-height: var(--tap); min-width: var(--tap); padding: 0 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
button.primary { background: var(--brand); color: var(--brand-text); border-color: var(--brand); font-weight: 700; }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; }
button.big { min-height: 64px; font-size: 1.2rem; width: 100%; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input[type=text], input[type=number], select { font: inherit; min-height: var(--tap); padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); width: 100%; }
label.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
label.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 600; }
label.check input { width: 24px; height: 24px; }
.gamecard { display: flex; flex-direction: column; gap: 4px; text-align: left; width: 100%; height: auto; padding: 14px; }
.gamecard strong { font-size: 1.1rem; }
.chip { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.chip.on { background: var(--brand); color: var(--brand-text); border-color: var(--brand); }
.chip.out { opacity: .5; text-decoration: line-through; }
.curtain { min-height: 70dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.curtain .who { font-size: 2.2rem; font-weight: 800; word-break: break-word; }
.dice { display: flex; flex-wrap: wrap; gap: 8px; }
.die { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 10px; background: var(--surface); border: 2px solid var(--text); font-weight: 800; font-size: 1.25rem; }
.die.wild { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.die.hit { background: var(--accent); color: #1d1b2b; }
.bigword { font-size: 2.2rem; font-weight: 800; text-align: center; padding: 18px 8px; word-break: break-word; }
.err { color: var(--danger); font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: no-preference) { button { transition: transform .08s; } button:active:not(:disabled) { transform: scale(.97); } }
#app:focus { outline: none; }
