:root {
  --paper: #f6f0e4;
  --paper-2: #ece3d0;
  --card: #fffdf8;
  --ink: #1d1b1a;
  --ink-2: #5d574f;
  --ink-3: #9a9288;
  --tomato: #ff5a3c;
  --sun: #ffc93c;
  --mint: #2fc98b;
  --mint-bg: #d9f7e8;
  --sky: #3d7bff;
  --grape: #9b6bff;
  --pink: #ff7fbf;
  --warn-bg: #fff2c7;
  --line: 2.5px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2px 2px 0 var(--ink);
  --r: 14px;
  --font: 'Bricolage Grotesque', ui-rounded, 'Trebuchet MS', sans-serif;
  --hand: 'Caveat', 'Comic Sans MS', cursive;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(29, 27, 26, 0.13) 1px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

.card { background: var(--card); border: var(--line); border-radius: var(--r); box-shadow: var(--shadow); }

.btn {
  border: var(--line); border-radius: 12px; background: var(--card); padding: 0.55rem 1rem; font-weight: 600;
  box-shadow: var(--shadow-sm); transition: transform 0.08s, box-shadow 0.08s; white-space: nowrap;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: var(--shadow-sm); }
.btn.primary { background: var(--sun); }
.btn.go { background: var(--mint); }
.btn.danger { background: var(--tomato); color: #fff; }
.btn.big { font-size: 1.15rem; padding: 0.8rem 1.2rem; width: 100%; font-weight: 800; }
.icon-btn {
  border: var(--line); border-radius: 10px; background: var(--card); width: 40px; height: 40px; display: grid;
  place-items: center; font-size: 1.1rem; box-shadow: var(--shadow-sm); padding: 0;
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.chip {
  white-space: nowrap;
  border: var(--line); border-radius: 999px; background: var(--card); padding: 0.3rem 0.75rem; font-weight: 600;
  font-size: 0.9rem; box-shadow: var(--shadow-sm);
}
.chip b { letter-spacing: 0.12em; }

/* ---------- home ---------- */
.home { min-height: 100dvh; display: grid; place-items: center; padding: 2rem 1rem; position: relative; overflow: hidden; }
.home-wrap { width: min(440px, 100%); display: flex; flex-direction: column; gap: 1.5rem; position: relative; z-index: 1; }
.brand { text-align: center; position: relative; }
.logo { font-weight: 800; letter-spacing: -0.04em; margin: 0; line-height: 0.9; }
.home .logo { font-size: clamp(3.6rem, 16vw, 5.5rem); transform: rotate(-3deg); }
.logo .dot { color: var(--tomato); }
.underline { width: 70%; height: 22px; margin: -2px auto 0; display: block; }
.underline path { fill: none; stroke: var(--tomato); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 340; stroke-dashoffset: 340; animation: draw 1s 0.2s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.tag { font-family: var(--hand); font-size: 1.6rem; margin: 0.4rem 0 0; color: var(--ink-2); }
.home-card { padding: 1.4rem; display: flex; flex-direction: column; gap: 0.9rem; }
.avatar-pick { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.avatar {
  display: grid; place-items: center; border-radius: 50%; border: var(--line); width: 38px; height: 38px;
  font-size: 1.3rem; flex: none; line-height: 1; padding: 0;
}
.avatar.xl { width: 96px; height: 96px; font-size: 3.2rem; box-shadow: var(--shadow); transition: transform 0.2s; }
.avatar.xl:hover { transform: rotate(-8deg) scale(1.05); }
.dots { display: flex; justify-content: center; gap: 0.45rem; flex-wrap: wrap; }
.dots button { width: 26px; height: 26px; border-radius: 50%; border: var(--line); padding: 0; }
.dots button[aria-checked='true'] { box-shadow: 0 0 0 3px var(--card), 0 0 0 5.5px var(--ink); }
.field { display: flex; flex-direction: column; gap: 0.3rem; font-weight: 600; font-size: 0.9rem; }
input, select, textarea {
  border: var(--line); border-radius: 10px; background: #fff; padding: 0.6rem 0.75rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 0 0 0 3px var(--sun); }
.row { display: flex; gap: 0.6rem; }
#codeIn { text-transform: uppercase; letter-spacing: 0.25em; font-weight: 800; text-align: center; }
.or { display: flex; align-items: center; gap: 0.6rem; color: var(--ink-3); font-size: 0.85rem; }
.or::before, .or::after { content: ''; flex: 1; border-top: 2px dashed var(--ink-3); }
.err { color: var(--tomato); margin: 0; min-height: 1.2em; font-weight: 600; text-align: center; }
.join-banner { background: var(--warn-bg); border: 2px dashed var(--ink); border-radius: 10px; padding: 0.6rem; text-align: center; }
.join-banner b { letter-spacing: 0.15em; }
.perks { list-style: none; padding: 0; margin: 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.9rem; font-weight: 600; color: var(--ink-2); }
.doodle { position: absolute; fill: none; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }
.d1 { width: 220px; top: 8%; left: -30px; stroke: var(--sky); transform: rotate(-12deg); }
.d2 { width: 110px; bottom: 10%; right: 6%; stroke: var(--sun); fill: var(--sun); transform: rotate(14deg); }
.d3 { width: 130px; top: 12%; right: 4%; stroke: var(--pink); }
@media (max-width: 600px) { .doodle { opacity: 0.35; } }

/* ---------- game layout ---------- */
.game { height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: 0.6rem 1rem;
  border-bottom: var(--line); background: var(--card); min-height: 68px;
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 0.6rem; }
.tb-right { justify-content: flex-end; }
.logo.sm { font-size: 1.6rem; }
.tb-mid { text-align: center; }
.round-lbl { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.word-area { display: flex; align-items: baseline; justify-content: center; gap: 0.5rem; flex-wrap: wrap; min-height: 2rem; }
.word-area .lbl { font-size: 0.75rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.1em; }
.word-area .big { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.02em; overflow-wrap: anywhere; max-width: 100%; }
.word-area .big.good { color: #0f8a58; }
.slots { display: inline-flex; gap: 0.3rem; font-size: 1.5rem; font-weight: 800; }
.slot { width: 1.05ch; text-align: center; border-bottom: 3px solid var(--ink); line-height: 1.1; text-transform: lowercase; }
.slot.rev { color: var(--grape); animation: pop 0.4s; }
.slot.gap { border: none; width: 0.6ch; }
.slot.lit { border: none; }
.counts { font-size: 0.8rem; color: var(--ink-3); font-weight: 600; }
.diff { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; padding: 0.15rem 0.5rem; border-radius: 999px; border: 2px solid var(--ink); }
.diff.easy { background: var(--mint-bg); }
.diff.medium { background: var(--warn-bg); }
.diff.hard { background: #ffd6cc; }

.timer { position: relative; width: 48px; height: 48px; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: var(--card); stroke: var(--paper-2); stroke-width: 5; }
.timer .prog { fill: none; stroke: var(--mint); stroke-linecap: round; stroke-dasharray: 119.4; transition: stroke 0.3s; }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 1rem; font-variant-numeric: tabular-nums; }
.timer.urgent .prog { stroke: var(--tomato); }
.timer.urgent { animation: throb 1s infinite; }
@keyframes throb { 50% { transform: scale(1.1); } }

.layout {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 210px minmax(0, 1fr) 290px; gap: 1rem; padding: 1rem;
}
.players { padding: 0.5rem; overflow-y: auto; }
.players ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.pl {
  display: grid; grid-template-columns: 1.4rem auto minmax(0, 1fr); align-items: center; gap: 0 0.5rem; padding: 0.45rem 0.5rem;
  border-radius: 10px; border: 2px solid transparent; position: relative; transition: background 0.3s;
}
.pl.me { border-color: var(--ink); border-style: dashed; }
.pl.guessed { background: var(--mint-bg); }
.pl.drawing { background: var(--warn-bg); }
.pl.off { opacity: 0.45; }
.pl .rank { font-weight: 800; color: var(--ink-3); font-size: 0.85rem; text-align: center; }
.pl .who { min-width: 0; }
.pl .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.pl .sc { display: block; white-space: nowrap; font-size: 0.8rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
/* Badges get their own line under the score: the sidebar is too narrow to
   share one line with the name, and overlapping emoji hid the points. */
.pl .rank, .pl > .avatar { grid-row: 1 / span 2; }
.pl .badges { grid-column: 3; display: flex; flex-wrap: wrap; gap: 0.2rem; font-size: 0.95rem; align-items: center; margin-top: 0.15rem; }
.pl .badges:empty { display: none; }
.pl .badges .kick { margin-left: auto; }
.pl .kick { border: none; background: none; font-size: 0.9rem; padding: 0.15rem 0.25rem; opacity: 0.55; transition: opacity 0.15s; }
.pl:hover .kick, .pl .kick:focus-visible { opacity: 1; }
.bump { animation: pop 0.5s; }
@keyframes pop { 40% { transform: scale(1.25); } }

.stage { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; min-width: 0; min-height: 0; }
.board-wrap {
  position: relative; width: min(100%, calc((100dvh - 68px - 2rem - var(--below, 136px)) * 4 / 3)); aspect-ratio: 4 / 3;
  border: var(--line); border-radius: var(--r); box-shadow: var(--shadow); background: #fff; overflow: hidden; flex: none;
}
#board, #fx { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#fx { pointer-events: none; }
.board-wrap.can-draw #board { cursor: crosshair; }
.blind { position: absolute; inset: 0; background: repeating-linear-gradient(45deg, #2a2724 0 18px, #1d1b1a 18px 36px); display: grid; place-items: center; color: #fff; text-align: center; pointer-events: none; font-size: 3rem; }
.blind b { display: block; font-size: 1.5rem; margin-top: 0.3rem; }
.blind span { display: block; font-size: 0.95rem; color: #d8d0c4; }
#curtain { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.challenge { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: 100%; max-width: 1000px; padding: 0.5rem 0.8rem; background: #e8dcff; border: var(--line); border-radius: 12px; }
.challenge.guesser { background: #dfe7f5; }
.challenge > div:first-child { display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; align-items: baseline; }
.challenge span { font-size: 0.85rem; }
.budget { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.budget meter { width: 90px; height: 16px; accent-color: #6840aa; }
.choice-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.challenge-recap { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 1rem; font-size: 0.85rem; }
.reveal-recap { background: #fff5d9; }
.reveal-summary { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.4rem 1rem; width: 100%; }
.reveal-summary p { margin: 0; }
.reveal-scores { display: flex; flex-wrap: wrap; gap: 0.4rem 0.8rem; font-size: 0.85rem; }
.lobby .mode-field { grid-column: 1 / -1; }
.settings-pill { position: absolute; top: 10px; left: 10px; z-index: 3; }
.settings-pill, .overlay .btn { font-size: 0.95rem; }
.react-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.floaty { position: absolute; bottom: -10px; font-size: 2.2rem; animation: floatUp 2.4s ease-out forwards; display: flex; flex-direction: column; align-items: center; }
.floaty small { font-size: 0.7rem; font-weight: 800; background: var(--card); border: 2px solid var(--ink); border-radius: 999px; padding: 0 0.4rem; }
@keyframes floatUp { 0% { transform: translateY(0) scale(0.6); opacity: 0; } 15% { opacity: 1; transform: translateY(-40px) scale(1.1); } 100% { transform: translateY(-420px) translateX(var(--dx)) scale(1); opacity: 0; } }

.overlay {
  position: absolute; inset: 0; background: rgba(246, 240, 228, 0.9); backdrop-filter: blur(3px); display: grid; place-items: center;
  padding: 1rem; overflow-y: auto; z-index: 5; animation: fadeIn 0.25s;
}
@keyframes fadeIn { from { opacity: 0; } }
.ov-inner { width: min(560px, 100%); text-align: center; display: flex; flex-direction: column; gap: 0.9rem; align-items: center; }
.ov-inner h2 { margin: 0; font-size: clamp(1.4rem, 3.4vw, 2.1rem); letter-spacing: -0.02em; }
.ov-inner p { margin: 0; color: var(--ink-2); }
.choices { display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: center; }
.choice {
  border: var(--line); border-radius: var(--r); background: var(--card); box-shadow: var(--shadow); padding: 0.9rem 1.2rem; display: flex; flex-direction: column;
  gap: 0.4rem; align-items: center; min-width: 140px; transition: transform 0.1s;
}
.choice:hover { transform: translate(-2px, -2px) rotate(-1.5deg); box-shadow: 6px 6px 0 var(--ink); }
.choice .w { font-size: 1.35rem; font-weight: 800; overflow-wrap: anywhere; max-width: 16ch; }
.mod-card { background: #e8dcff; color: var(--ink); border: var(--line); border-radius: var(--r); padding: 0.7rem 1rem; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 0.2rem; }
.mod-card.guesser { background: #dfe7f5; }
.mod-card b { font-size: 1.1rem; }
.mod-card span { font-size: 0.9rem; }
.big-av { width: 84px; height: 84px; font-size: 2.8rem; animation: wiggle 1.2s infinite; }
@keyframes wiggle { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.reveal-word { font-size: clamp(2rem, 6vw, 3.4rem); font-weight: 800; letter-spacing: -0.02em; transform: rotate(-2deg); background: var(--sun); border: var(--line); padding: 0.1rem 1rem; border-radius: 12px; box-shadow: var(--shadow); animation: pop 0.5s; }
.deltas { list-style: none; padding: 0; margin: 0; width: min(340px, 100%); display: flex; flex-direction: column; gap: 0.3rem; }
.deltas li { display: flex; align-items: center; gap: 0.5rem; background: var(--card); border: 2px solid var(--ink); border-radius: 10px; padding: 0.3rem 0.6rem; font-weight: 600; }
.deltas li .avatar { width: 28px; height: 28px; font-size: 1rem; border-width: 2px; }
.deltas li .p { margin-left: auto; color: #0f8a58; font-weight: 800; }
.deltas li .t { font-size: 0.75rem; color: var(--ink-3); }

/* lobby */
.lobby-head { display: flex; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.lobby .row { display: flex; gap: 0.8rem; }
.lobby .row .field { flex: 1; }
.lobby details.custom { border: 2px solid var(--ink); border-radius: 12px; background: #fff; padding: 0.6rem 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.lobby details.custom[open] { display: flex; }
.lobby details.custom summary { cursor: pointer; font-weight: 700; }
.lobby details.custom .toggle { border: 0; padding: 0.2rem 0; }
.btn.ghost { background: transparent; box-shadow: none; }
.lobby { width: min(620px, 100%); text-align: left; padding: 1.2rem; display: flex; flex-direction: column; gap: 0.9rem; }
.toggle { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.75rem; border: 2px solid var(--ink); border-radius: 12px; background: #fff; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--grape); flex: none; }
.toggle b { display: block; }
.toggle small { color: var(--ink-2); }
.lobby textarea { min-height: 64px; resize: vertical; font-size: 0.9rem; }
.muted { color: var(--ink-2); font-size: 0.85rem; }

/* toolbar */
.toolbar, .reactbar {
  display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; align-items: center; width: 100%; max-width: 1000px;
}
.tgroup { display: flex; gap: 0.3rem; align-items: center; background: var(--card); border: var(--line); border-radius: 12px; padding: 0.3rem; box-shadow: var(--shadow-sm); }
.tgroup.disabled { opacity: 0.35; }
.tgroup.disabled .tbtn, .tbtn:disabled { pointer-events: none; cursor: not-allowed; opacity: 0.55; }
.tbtn { width: 34px; height: 34px; border-radius: 8px; border: 2px solid transparent; background: none; display: grid; place-items: center; padding: 0; }
.tbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tbtn:hover { background: var(--paper); }
.tbtn.on { background: var(--sun); border-color: var(--ink); }
.tbtn.sz { width: 30px; }
.tdiv { width: 2px; height: 24px; background: var(--paper-2); margin: 0 3px; border-radius: 2px; }
.size-dot { background: var(--ink); border-radius: 50%; display: block; }
.palette { display: grid; grid-template-columns: repeat(9, 22px); gap: 3px; }
.sw { width: 22px; height: 22px; border-radius: 5px; border: 2px solid var(--ink); padding: 0; }
.sw.on { transform: scale(1.18); box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); z-index: 1; }
.custom-color { width: 34px; height: 34px; padding: 2px; border-radius: 8px; border: 2px solid var(--ink); cursor: pointer; }
.cur-color { width: 30px; height: 30px; border-radius: 50%; border: var(--line); }
.rbtn { border: var(--line); border-radius: 12px; background: var(--card); padding: 0.35rem 0.7rem; font-size: 1.35rem; box-shadow: var(--shadow-sm); line-height: 1.2; transition: transform 0.08s; }
.rbtn:active { transform: scale(0.9); }
.rbtn.on { background: var(--sun); }
.rbtn small { font-size: 0.8rem; font-weight: 800; margin-left: 0.2rem; vertical-align: middle; }
.reactbar .sep { width: 2px; height: 30px; background: var(--ink-3); border-radius: 2px; }

/* chat */
.chat { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.msgs { flex: 1; overflow-y: auto; padding: 0.6rem; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.93rem; overscroll-behavior: contain; }
.msg { padding: 0.25rem 0.5rem; border-radius: 8px; overflow-wrap: anywhere; line-height: 1.35; }
.msg b { font-weight: 800; }
.msg.system { color: var(--ink-2); font-size: 0.8rem; text-align: center; }
.msg.system.turn { border-top: 1px dashed var(--ink-3); border-radius: 0; margin-top: 0.4rem; padding-top: 0.4rem; font-weight: 700; color: var(--ink); }
.msg.system.good { color: #0f8a58; }
.msg.system.warn { color: #b35c00; }
.msg.correct { background: var(--mint); color: #06331f; font-weight: 700; border: 2px solid var(--ink); animation: pop 0.4s; }
.msg.close { background: var(--warn-bg); border: 2px dashed #b38600; font-weight: 600; }
.msg.solved { background: var(--mint-bg); }
.msg.solved::before { content: '🤫 '; }
.chat-form { display: flex; gap: 0.4rem; padding: 0.5rem; border-top: var(--line); }
.chat-form .btn { padding: 0.4rem 0.8rem; }

.confirm-modal { width: min(420px, calc(100% - 2rem)); padding: 1.2rem; }
.confirm-modal::backdrop { background: rgba(29, 27, 26, 0.55); }
.confirm-modal h2 { margin: 0 0 1.2rem; font-size: 1.3rem; overflow-wrap: anywhere; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

/* end */
.end-modal { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0; background: rgba(29, 27, 26, 0.55); overflow-y: auto; padding: 2rem 1rem; color: inherit; }
.end-modal[open] { display: grid; place-items: start center; animation: fadeIn 0.3s; }
.end-modal::backdrop, .lightbox::backdrop { background: transparent; }
.end-card { width: min(980px, 100%); padding: 1.5rem; display: flex; flex-direction: column; gap: 1.4rem; }
.end-card h2 { margin: 0; text-align: center; font-size: clamp(1.8rem, 5vw, 2.8rem); letter-spacing: -0.03em; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 0.8rem; }
.pod { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; width: min(150px, 30%); }
.pod .avatar { width: 64px; height: 64px; font-size: 2.1rem; box-shadow: var(--shadow-sm); }
.pod .nm { font-weight: 800; text-align: center; overflow-wrap: anywhere; }
.pod .blk { width: 100%; border: var(--line); border-radius: 10px 10px 0 0; display: grid; place-items: center; font-size: 2rem; font-weight: 800; box-shadow: var(--shadow-sm); animation: rise 0.7s cubic-bezier(.2, 1.4, .4, 1) both; transform-origin: bottom; }
.pod .pts { font-size: 0.85rem; color: var(--ink-2); font-weight: 600; }
.pod.p1 .blk { height: 130px; background: var(--sun); animation-delay: 0.5s; }
.pod.p2 .blk { height: 95px; background: #dfe7f5; animation-delay: 0.25s; }
.pod.p3 .blk { height: 70px; background: #f3c9a8; }
@keyframes rise { from { transform: scaleY(0); } }
.rest { list-style: none; padding: 0; margin: 0 auto; width: min(420px, 100%); display: flex; flex-direction: column; gap: 0.3rem; }
.rest li { display: flex; gap: 0.6rem; align-items: center; padding: 0.3rem 0.6rem; border: 2px solid var(--ink); border-radius: 10px; background: #fff; }
.rest li .p { margin-left: auto; font-weight: 800; }
.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.7rem; }
.award { border: var(--line); border-radius: 12px; padding: 0.7rem; background: var(--warn-bg); display: flex; gap: 0.6rem; align-items: center; }
.award:nth-child(2n) { background: var(--mint-bg); }
.award:nth-child(3n) { background: #e8dcff; }
.award .i { font-size: 2rem; }
.award b { display: block; }
.award small { color: var(--ink-2); }
.section-h { font-size: 1.1rem; font-weight: 800; margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; }
.gal { border: var(--line); border-radius: 12px; background: #fff; overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; }
.gal:nth-child(odd) { transform: rotate(-0.8deg); }
.gal:nth-child(even) { transform: rotate(0.8deg); }
.gal canvas { width: 100%; aspect-ratio: 4 / 3; display: block; border-bottom: 2px solid var(--ink); }
.gal .cap { padding: 0.5rem 0.6rem; display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; }
.gal .cap .w { font-weight: 800; font-size: 1rem; }
.gal .cap .by { color: var(--ink-2); }
.gal .cap .dl { margin-left: auto; border: 2px solid var(--ink); border-radius: 8px; background: var(--paper); padding: 0.15rem 0.45rem; font-size: 0.85rem; }
.end-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.end-actions .btn { min-width: 180px; width: auto; flex: 0 1 auto; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 150%); background: var(--ink); color: var(--paper); padding: 0.6rem 1rem;
  border-radius: 12px; font-weight: 600; transition: transform 0.25s, opacity 0.25s; z-index: 100; pointer-events: none; max-width: calc(100% - 2rem); text-align: center;
  opacity: 0;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 14px; border: 1.5px solid var(--ink); animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

/* ---------- responsive ---------- */
/* The toolbar wraps to two rows below ~1400px; reserve room for it. */
@media (max-width: 1400px) { .board-wrap { --below: 182px; } }
@media (max-width: 1100px) {
  .layout { grid-template-columns: 190px minmax(0, 1fr) 260px; gap: 0.7rem; padding: 0.7rem; }
  .palette { grid-template-columns: repeat(9, 20px); }
  .sw { width: 20px; height: 20px; }
}
@media (max-width: 860px) {
  .game { height: auto; min-height: 100dvh; }
  .topbar { grid-template-columns: auto 1fr auto; gap: 0.5rem; padding: 0.5rem 0.75rem; position: sticky; top: 0; z-index: 20; min-height: 58px; }
  .logo.sm { display: none; }
  .chip { padding: 0.25rem 0.55rem; font-size: 0.8rem; }
  .icon-btn { width: 36px; height: 36px; }
  .timer { width: 40px; height: 40px; }
  .word-area .big { font-size: 1.25rem; }
  .slots { font-size: 1.15rem; gap: 0.2rem; }
  .word-area .lbl { display: none; }
  .layout { display: flex; flex-direction: column; padding: 0.6rem 0.75rem 0.75rem; gap: 0.6rem; }
  .stage { order: 1; }
  .board-wrap { width: 100%; }
  .players { order: 2; padding: 0.35rem; box-shadow: var(--shadow-sm); }
  .players ol { flex-direction: row; overflow-x: auto; }
  .pl { grid-template-columns: auto auto; flex: none; padding: 0.3rem 0.5rem; gap: 0.35rem; }
  .pl .rank { display: none; }
  .pl .kick { opacity: 1; }
  .pl > .avatar { grid-row: auto; }
  .pl .badges { grid-column: 1 / -1; justify-content: center; }
  .pl .nm { max-width: 80px; font-size: 0.85rem; }
  .chat { order: 3; height: 44dvh; min-height: 260px; box-shadow: var(--shadow-sm); }
  .game .layout { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .chat-form { position: fixed; bottom: 0; left: 0; width: 100%; z-index: 21; background: var(--card); padding-bottom: calc(0.5rem + env(safe-area-inset-bottom)); }
  .toolbar { gap: 0.4rem; }
  .challenge { flex-wrap: wrap; gap: 0.4rem; padding: 0.5rem 0.65rem; }
  .tbtn { width: 34px; height: 34px; }
  .palette { grid-template-columns: repeat(9, minmax(0, 1fr)); width: 100%; }
  .sw { width: 100%; height: 24px; }
  .tgroup.pal { flex: 1 1 100%; }
  .overlay { padding: 0.6rem; }
  .lobby { padding: 0.8rem; gap: 0.6rem; }
  .choice { min-width: 0; flex: 1; padding: 0.6rem; }
  .choice .w { font-size: 1.05rem; }
  .ov-inner { gap: 0.6rem; }
  .big-av { width: 60px; height: 60px; font-size: 2rem; }
  /* Overlays outgrow a phone-sized 4:3 board; let the board stretch to fit them. */
  .board-wrap.expand { aspect-ratio: auto; min-height: 75vw; }
  .board-wrap.expand .overlay { position: relative; min-height: 75vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

.pause-banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6;
  background: var(--warn-bg); border: var(--line); border-radius: 12px; padding: 0.8rem 1.1rem;
  box-shadow: var(--shadow); font-weight: 700; text-align: center; max-width: 90%;
}
.gal .thumb-btn { display: block; padding: 0; border: 0; background: #fff; cursor: zoom-in; border-bottom: 2px solid var(--ink); }
.gal .thumb-btn:focus-visible { outline: 3px solid var(--grape); outline-offset: -3px; }
.gal canvas.thumb { width: 100%; aspect-ratio: 4 / 3; display: block; border: 0; }
.lightbox { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0; padding: 1rem; background: rgba(29,27,26,0.72); overflow: auto; }
.lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.6rem; }
.lightbox canvas { max-width: min(1000px, 96vw); width: 100%; background: #fff; border: var(--line); border-radius: 12px; }
.lightbox .muted { color: #f3ede2; }
.pod-who { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
.pod-p { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; max-width: 110px; }
.timer.paused { opacity: 0.55; }
.end-card h2:focus { outline: none; }
.word-area .slots { max-width: 100%; flex-wrap: wrap; justify-content: center; }

/* ---------- lobby settings grid ---------- */
.lobby .grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.7rem 0.8rem; }
@media (max-width: 560px) { .lobby .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.chaos-list ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.35rem 0.8rem; max-height: 220px; overflow-y: auto; }
.chaos-list li { display: flex; flex-direction: column; font-size: 0.85rem; }
.chaos-list li small { color: var(--ink-2); }
.tgroup.pal.locked { opacity: 0.35; pointer-events: none; }

/* ---------- music player ---------- */
.music { position: relative; }
.music-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 240px; padding: 0.8rem; display: flex; flex-direction: column; gap: 0.6rem;
  background: var(--card); border: var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
.music-panel[hidden] { display: none; }
.music-panel .now { font-weight: 800; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-panel .now small { display: block; font-weight: 600; color: var(--ink-2); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; }
.music-panel .ctrls { display: flex; gap: 0.4rem; justify-content: center; }
.music-panel .ctrls .icon-btn { width: 40px; height: 40px; }
.music-panel label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; font-weight: 600; }
.music-panel input[type=range] { flex: 1; accent-color: var(--grape); }
#musicBtn.on { background: var(--sun); }
.music-panel .sfx-toggle { border-top: 2px dashed var(--line-soft, #d8d0c4); padding-top: 0.55rem; }
.music-panel .sfx-toggle input { width: 18px; height: 18px; accent-color: var(--grape); }
