body { background: #eef1f7; color: var(--ink); min-height: 100vh; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.6rem 1rem; background: var(--navy); flex-wrap: wrap; }
.logo.small { font-size: 1.3rem; margin: 0; }
.logo.small em { font-style: normal; font-weight: 400; color: #9fb3d9; margin-left: 0.4rem; font-size: 1rem; }
.topbar-tools { display: flex; gap: 0.5rem; }
#app { padding: 1rem; max-width: 1300px; margin: 0 auto; }

.btn { font: inherit; border: 2px solid #c6cfe0; background: #fff; color: var(--ink); border-radius: 10px; padding: 0.55rem 1rem; cursor: pointer; text-decoration: none; display: inline-block; min-height: 44px; }
.btn:hover:not(:disabled) { border-color: var(--navy); }
.actions:focus { outline: none; }
.btn:focus-visible, .key:focus-visible, .mini-board:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn.primary:focus-visible { box-shadow: 0 0 0 2px #fff inset; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.danger { color: #b3261e; border-color: #e8b4b0; }
.btn.subtle { border-color: transparent; background: transparent; text-decoration: underline; }
.btn.big { font-size: 1.2rem; padding: 0.8rem 1.4rem; font-weight: 700; }
.btn.small { min-height: 0; padding: 0.2rem 0.5rem; font-size: 0.85rem; }
.btn.icon { padding: 0.4rem 0.7rem; }
.topbar .btn { background: transparent; color: #fff; border-color: #4a5f8f; }

input[type=text], input[type=number] { font: inherit; padding: 0.55rem 0.7rem; border: 2px solid #c6cfe0; border-radius: 8px; min-height: 44px; }
input:focus { outline: 3px solid var(--gold); border-color: var(--navy); }
input.short { width: 7rem; }

.panel { background: #fff; border-radius: 14px; padding: 1rem 1.2rem; box-shadow: 0 2px 8px rgba(20, 30, 60, 0.08); }
.panel h2 { margin: 0.4rem 0 0.3rem; font-size: 1.15rem; }
.hint { color: #5a6478; font-size: 0.9rem; margin: 0.4rem 0; }
.error { color: #b3261e; font-size: 0.9rem; flex-basis: 100%; padding-left: 2rem; }

/* setup */
.setup { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem; }
.setup .panel.wide { grid-row: span 2; }
.rows { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.7rem; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row input { flex: 1; min-width: 8rem; }
.row input.grow { flex: 2; }
.num { width: 1.5rem; color: #5a6478; }
.radio { display: block; margin: 0.4rem 0; }
.start-wrap { margin-top: 1.4rem; display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

/* game */
.game { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; align-items: start; }
.answer-head { display: flex; gap: 1rem; align-items: center; color: #5a6478; flex-wrap: wrap; }
.answer-head .cat { font-weight: 700; color: var(--ink); }
.mini-board { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 3px; margin: 0.6rem 0 1rem; padding: 8px; background: #0e1726; border-radius: 10px; container-type: inline-size; }
.mb-cell { aspect-ratio: 0.68; border-radius: 3px; background: #1f6f63; display: grid; place-items: center; font-weight: 800; font-size: calc((100cqi - 16px) / var(--cols) * 0.72); line-height: 1; color: #1b1b2f; }
.mb-cell.tile { background: #fdfdfd; box-shadow: inset 0 -2px 0 #d8dce6; }
.mb-cell.peek { color: #b4bccb; }
.answer-text { font-size: 2rem; font-weight: 800; letter-spacing: 0.08em; margin: 0.5rem 0 1rem; line-height: 1.4; word-break: break-word; }
.ch.hidden { color: #9aa6bd; }
.ch.shown { color: var(--navy); background: #fff1b8; border-radius: 4px; }
.status { font-size: 1.25rem; font-weight: 700; padding: 0.8rem 1rem; background: #f4f6fb; border-left: 6px solid var(--gold); border-radius: 8px; margin-bottom: 1rem; }
.actions { display: flex; flex-direction: column; gap: 0.7rem; }
.action-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 0.45rem; }
.key { font: inherit; font-size: 1.5rem; font-weight: 800; min-height: 56px; border-radius: 10px; border: 2px solid #c6cfe0; background: #fff; cursor: pointer; }
.key:hover { border-color: var(--navy); background: #fffbe6; }
.key.used { background: #e3e7ef; color: #8b94a7; }
.solve-input { font-size: 1.6rem !important; text-transform: uppercase; width: 100%; }
.side { display: flex; flex-direction: column; gap: 0.8rem; }
.mini-wheel { width: 200px; margin: 0 auto; border-radius: 50%; }
.mini-wheel.can-spin { cursor: grab; transition: transform .15s; touch-action: none; user-select: none; -webkit-user-select: none; }
.mini-wheel:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }
.mini-wheel.can-spin:hover, .mini-wheel.can-spin:focus-visible { transform: scale(1.04); filter: drop-shadow(0 0 10px rgba(255, 210, 63, .6)); }
.mini-wheel.can-spin:active, .mini-wheel.pressed { transform: scale(.97); cursor: grabbing; }
.timer { font-weight: 700; text-align: center; font-size: 1.1rem; }
.players { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.players li { display: flex; justify-content: space-between; padding: 0.5rem 0.7rem; border-radius: 8px; background: #f4f6fb; font-size: 1.05rem; }
.players li.current { background: var(--gold); font-weight: 800; }
.players .total { font-variant-numeric: tabular-nums; margin-left: auto; }
.players li { align-items: center; gap: 0.5rem; }
.players li.paused { opacity: 0.6; }
.players .away { font-weight: 400; font-size: 0.85rem; }
.roster { display: flex; gap: 0.25rem; }
.btn.tiny { min-height: 30px; padding: 0.1rem 0.5rem; font-size: 0.8rem; border-radius: 7px; }
.add-player { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.add-player input { flex: 1; min-width: 0; font: inherit; padding: 0.4rem 0.6rem; border: 2px solid #c6cfe0; border-radius: 8px; }
.tools { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.game-over { max-width: 560px; margin: 2rem auto; text-align: center; }
.game-over h2 { font-size: 2rem; }
.players.final { margin: 1rem 0; text-align: left; }
.players.final li:first-child { background: var(--gold); font-weight: 800; }

.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 0.7rem 1.2rem; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.25); z-index: 10; }

.wheel-svg { width: 100%; height: auto; display: block; }
.wheel-rotor { transform-origin: 0 0; transform-box: view-box; }
.wheel-label { font-weight: 800; font-family: var(--font); }

/* landing */
body.landing { display: grid; place-items: center; background: var(--navy); padding: 1rem; }
.landing .card { background: #fff; border-radius: 16px; padding: 2rem; max-width: 560px; line-height: 1.5; }
.landing .logo { color: var(--navy); font-size: 2.2rem; margin-top: 0; }
.landing .logo span { color: #e0a800; }

@media (max-width: 800px) {
  .setup, .game { grid-template-columns: 1fr; }
  .answer-text { font-size: 1.5rem; }
}

/* puzzle source + imported library */
.radio.source { margin: 0.3rem 0 0.5rem; }
.bank { border-top: 1px solid #e3e7ef; margin-top: 0.6rem; padding-top: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; }
.bank h3 { margin: 0.4rem 0 0; font-size: 1rem; }
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.4rem; }
.cat-check { display: flex; align-items: center; gap: 0.3rem; padding: 0.35rem 0.5rem; background: #f4f6fb; border-radius: 8px; }
.cat-check input { width: 20px; height: 20px; }
.error-list ul { margin: 0; padding-left: 1.2rem; }
.error-list .error { padding-left: 0; }
.block { display: block; }
code { background: #f1f3f8; padding: 0.05rem 0.3rem; border-radius: 4px; }
.lib-source { display: flex; flex-direction: column; gap: 0.1rem; }
.start-msg { margin: 0.5rem 0 0; font-weight: 700; }

.timer-setup { margin-top: 0.4rem; }
.turn-timer { background: #f4f6fb; border-radius: 10px; padding: 0.6rem 0.7rem; display: flex; flex-direction: column; gap: 0.4rem; }
.turn-timer-text { font-weight: 800; font-size: 1.1rem; text-align: center; font-variant-numeric: tabular-nums; }

.wheel-select { font: inherit; padding: 0.5rem; border: 2px solid #c6cfe0; border-radius: 8px; min-height: 44px; max-width: 100%; }
.wheel-switch { margin-top: 0.4rem; }

.surprise-btn { background: #7b2cbf; border-color: #7b2cbf; font-size: 1.5rem; }

.update-bar { position: sticky; top: 0; z-index: 50; background: var(--gold); color: var(--ink); font-weight: 700; padding: 0.7rem 1rem; display: flex; gap: 0.8rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.puzzle-fix { margin-top: 1rem; padding: 0.8rem 1rem; border: 2px dashed #c6cfe0; border-radius: 10px; }
.puzzle-fix h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.puzzle-fix label.block { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.puzzle-fix input { font: inherit; padding: 0.4rem 0.6rem; border: 2px solid #c6cfe0; border-radius: 8px; flex: 1; min-width: 0; }
.radio.first-pick { margin-top: 1rem; }
.timer-lengths { display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; font-size: 0.95rem; }
.turn-timer .timer-lengths input.short { width: 3.6rem; padding: 0.15rem 0.35rem; font-size: 0.95rem; }
.timer-toggle { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.timer-toggle-label { font-weight: 700; }
.switch { position: relative; width: 4.6rem; height: 2rem; border-radius: 999px; border: 0; padding: 0; cursor: pointer; background: #b8bfcc; color: #fff; font: inherit; font-weight: 800; font-size: 0.85rem; transition: background 0.15s; flex: none; }
.switch.on { background: #2f9e57; }
.switch-knob { position: absolute; top: 0.2rem; left: 0.2rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.15s; }
.switch.on .switch-knob { transform: translateX(2.6rem); }
.switch-text { position: absolute; top: 50%; transform: translateY(-50%); right: 0.6rem; }
.switch.on .switch-text { right: auto; left: 0.7rem; }
.board-address { display: flex; align-items: center; gap: 0.5rem; color: #dfe6f5; font-size: 0.95rem; flex-wrap: wrap; }
.board-address .ba-label { color: #aab6d3; }
.board-address code { background: rgba(255,255,255,0.1); color: #fff; padding: 0.15rem 0.45rem; border-radius: 6px; font-size: 1rem; user-select: all; }
.board-address .ba-off code { font-size: 0.9rem; }
/* Turned like the Board's side wheel, so the pointer is on the left. The
   wheel's centre is 115/225 of the way down its drawing. */
.mini-wheel .wheel-svg { transform: rotate(-90deg); transform-origin: 50% 51.11%; }
