:root {
 --paper:#f8f7f3; --ink:#242a25; --muted:#70776c; --line:#dddfd7;
 --accent:#e67555; --selected:#e8ecdf;
 font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
 color:var(--ink); background:var(--paper); line-height:1.5;
}
* { box-sizing:border-box; }
html { height:100%; }
body {
 margin:0; height:100svh; height:100dvh; overflow:hidden;
 display:flex; flex-direction:column; overscroll-behavior:none;
 padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button,input,textarea { font:inherit; }
button,a,summary { touch-action:manipulation; -webkit-tap-highlight-color:transparent; }
button { cursor:pointer; color:inherit; }
button:disabled { opacity:.3; cursor:default; }
a { color:inherit; text-decoration:none; }
button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible {
 outline:2px solid var(--accent); outline-offset:3px;
}
header {
 width:100%; max-width:640px; flex-shrink:0; margin:0 auto;
 padding:12px 24px 4px; display:flex; align-items:center; justify-content:space-between;
}
.brand { font-size:19px; font-weight:650; letter-spacing:-.7px; min-height:44px; display:flex; align-items:center; }
.text-btn { min-height:44px; background:none; border:0; color:var(--muted); font-size:13px; padding:10px 4px; }
.text-btn:hover { color:var(--ink); }
main { width:100%; max-width:640px; margin:0 auto; flex:1; min-height:0; padding:12px 24px 16px; }
h1 { font-size:clamp(28px,7vw,38px); line-height:1.2; letter-spacing:-1.2px; font-weight:550; margin:0 0 12px; overflow-wrap:anywhere; }
h2 { font-size:15px; font-weight:600; margin:0; }
.intro { color:var(--muted); margin:0; font-size:14px; }
.setup { display:flex; flex-direction:column; height:100%; min-height:0; gap:20px; }
.settings-row { display:flex; align-items:center; justify-content:space-between; flex-shrink:0; padding-bottom:18px; border-bottom:1px solid var(--line); }
.counter { display:flex; align-items:center; gap:14px; }
.counter button { border:1px solid var(--line); border-radius:50%; width:44px; height:44px; background:none; font-size:23px; }
.counter output { font-size:20px; min-width:30px; text-align:center; font-weight:500; font-variant-numeric:tabular-nums; }
.topic-section { flex:1; min-height:0; display:flex; flex-direction:column; gap:12px; }
.pack-grid {
 display:flex; flex-wrap:wrap; align-items:flex-start; flex:1;
 gap:8px; align-content:start; overflow-y:auto; min-height:0; padding:4px 4px 12px;
 margin:0 -4px; overscroll-behavior-y:contain; touch-action:pan-y; scrollbar-width:thin;
 -webkit-overflow-scrolling:touch;
}
.pack {
 position:relative; display:flex; align-items:center; justify-content:center; flex:0 0 auto; min-height:44px;
 border:1px solid var(--line); background:transparent; border-radius:8px;
 padding:10px 13px; font-size:13px; font-weight:500; cursor:pointer;
 transition:background .12s,border-color .12s;
}
.pack.selected { background:var(--selected); border-color:#8e9f7f; }
.pack input { position:absolute; opacity:0; width:1px; height:1px; pointer-events:none; }
.pack:has(input:focus-visible) { outline:2px solid var(--accent); outline-offset:2px; }
.setup-actions { flex-shrink:0; display:flex; flex-direction:column; gap:8px; }
.setup-actions>.text-btn { align-self:center; }
.primary { display:block; border:0; background:var(--ink); color:var(--paper); font-size:16px; font-weight:550; border-radius:14px; width:100%; min-height:54px; padding:15px 20px; text-align:center; }
.primary:hover { background:#3e493e; }
.primary:active,.counter button:active { transform:scale(.98); }
.secondary { background:none; border:1px solid var(--line); border-radius:10px; min-height:48px; padding:12px 16px; font-size:15px; }
.secondary:hover { background:var(--selected); }
.validation { color:var(--muted); font-size:12px; text-align:center; margin:0; }
.validation:empty { display:none; }
.in-game header { display:none; }
.in-game main { padding:24px; }
.exit-btn { position:absolute; top:calc(12px + env(safe-area-inset-top)); left:calc(20px + env(safe-area-inset-left)); min-height:44px; background:none; border:0; color:var(--muted); font-size:13px; padding:10px 4px; }
.game-wrap { height:100%; min-height:0; max-width:440px; margin:auto; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:44px 0 12px; overflow-y:auto; }
.game-wrap>.primary { max-width:280px; margin-top:32px; flex-shrink:0; }
.reveal-screen { width:100%; display:flex; flex-direction:column; align-items:center; }
.player-name { color:var(--muted); font-size:15px; margin:0 0 24px; }
.reveal-screen h1 { font-size:clamp(28px,7vw,42px); min-height:100px; display:flex; align-items:center; justify-content:center; margin:0 0 32px; width:100%; }
.reveal-screen .secret-word { font-size:clamp(30px,8vw,48px); letter-spacing:-1.3px; }
.reveal-screen .primary { max-width:280px; }
dialog { position:fixed; background:var(--paper); color:var(--ink); border:1px solid var(--line); border-radius:20px; width:440px; max-width:calc(100% - 28px); max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding:38px 24px 24px; overflow-y:auto; box-shadow:0 25px 80px #222a2220; }
dialog::backdrop { background:#242a2570; backdrop-filter:blur(4px); }
dialog h2 { font-size:24px; letter-spacing:-.7px; font-weight:550; margin:0 24px 20px 0; }
.close { position:absolute; top:4px; right:8px; width:44px; height:44px; border:0; background:none; color:var(--muted); font-size:26px; }
.modal-copy { font-size:14px; line-height:1.8; color:#626a5d; }
.modal-copy li { margin-bottom:16px; padding-left:4px; }
ol.modal-copy { padding-left:18px; }
.option-list { display:flex; flex-direction:column; gap:12px; }
.form-input,textarea { background:#fffefb; border:1px solid var(--line); border-radius:8px; padding:12px; width:100%; color:var(--ink); font-size:16px; min-height:48px; }
textarea { min-height:130px; resize:vertical; }
.names-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; max-height:45dvh; overflow:auto; }
.names-grid input { min-width:0; }
.input-label { display:block; font-size:13px; margin:18px 0 10px; color:var(--muted); }
.error { font-size:13px; color:#ad4936; }
#modal-content>.primary { margin-top:22px; }
#modal-content>.secondary { width:100%; margin-top:10px; }
@media(max-height:600px) {
 header { padding-top:4px; }
 main { padding-top:4px; padding-bottom:10px; }
 .setup { gap:12px; }
 .settings-row { padding-bottom:10px; }
 .topic-section { gap:6px; }
 .setup-actions { gap:0; }
 .reveal-screen h1 { min-height:60px; margin-bottom:20px; }
 .player-name { margin-bottom:12px; }
}
@media(max-width:359px) { header,main { padding-left:18px; padding-right:18px; } .pack { padding:10px; font-size:12px; } }
@media(min-width:700px) { header { padding-top:24px; } main { padding-top:20px; padding-bottom:28px; } .setup { gap:24px; } }
@media(prefers-reduced-motion:reduce) { * { transition:none!important; } .primary:active,.counter button:active { transform:none; } }

.setup[aria-busy="true"] .pack { opacity:.55; cursor:wait; }
.primary .loading-dot { display:inline-block; width:14px; height:14px; margin-right:9px; border:2px solid #ffffff50; border-top-color:currentColor; border-radius:50%; vertical-align:-1px; animation:word-spin .8s linear infinite; }
@keyframes word-spin { to { transform:rotate(360deg); } }
@media(prefers-reduced-motion:reduce) { .primary .loading-dot { animation:none; } }

[hidden] { display:none!important; }
.custom-topic-field { flex-shrink:0; }
.custom-topic-field .form-input { min-height:44px; }
.topic-hint { color:var(--muted); font-size:12px; line-height:1.4; margin:6px 0 0; }

.game-topic { margin:0 0 20px; font-size:15px; font-weight:600; overflow-wrap:anywhere; max-width:100%; }
.game-topic>span { display:block; color:var(--muted); font-size:11px; font-weight:400; margin-bottom:3px; }
.option-list { margin-top:18px; }
select.form-input { appearance:auto; background:var(--paper); }
@media(max-height:600px) { .game-topic { margin-bottom:10px; } }
@media(max-height:500px) and (min-width:550px) {
 .setup-actions { display:grid; grid-template-columns:1fr 2fr; gap:8px 16px; align-items:center; }
 .setup-actions>.text-btn { justify-self:start; }
 .setup-actions>.validation { grid-column:1 / -1; }
}

.game-topic { font-size:clamp(28px,7vw,40px); line-height:1.15; font-weight:650; letter-spacing:-.8px; margin-bottom:20px; }
.game-topic>span { font-size:12px; line-height:1.5; letter-spacing:1px; text-transform:uppercase; margin-bottom:8px; }
.reveal-screen { margin-block:auto; flex-shrink:0; padding:8px 0; }
.reveal-screen:has(.word-image) h1 { min-height:0; margin-bottom:16px; }
.word-image { width:100%; max-width:300px; margin:0 0 22px; }
.word-image img { display:block; width:100%; height:clamp(120px,26dvh,220px); object-fit:contain; border-radius:14px; background:#eeeee7; }
.word-image figcaption { margin-top:6px; color:var(--muted); font-size:11px; }
.word-image a { text-decoration:underline; text-underline-offset:2px; }
.image-status { color:var(--muted); font-size:13px; margin:12px 0; }
.word-explanation { width:100%; max-width:360px; margin:0 0 16px; }
.word-explanation>div { max-height:min(18dvh,140px); overflow-y:auto; text-align:left; font-size:14px; line-height:1.6; padding:0 8px; }
.word-explanation p { margin:0 0 8px; white-space:pre-line; }
.word-explanation a { color:var(--muted); font-size:11px; text-decoration:underline; }
@media(max-height:600px) {
 .game-topic { font-size:28px; margin-bottom:12px; }
 .word-image { margin-bottom:14px; }
 .word-image img { height:120px; }
}
