:root {
  color-scheme: light;
  --cream: oklch(.96 .03 85); --paper: oklch(.99 .012 85); --ink: oklch(.27 .05 300);
  --coral: oklch(.72 .17 30); --sun: oklch(.90 .15 95); --mint: oklch(.85 .11 165);
  --sky: oklch(.80 .10 235); --berry: oklch(.62 .20 5); --muted: oklch(.43 .04 300);
  --shadow: 0 4px 0 var(--ink); --ease: cubic-bezier(.22,1,.36,1);
  --z-board: 1; --z-drag: 5; --z-top: 10; --z-settings: 20; --z-toast: 30; --z-reaction: 40;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; font: 400 16px/1.5 Kanit, sans-serif; color: var(--ink); background-color: var(--cream); background-image: radial-gradient(ellipse at 0 10%, oklch(.85 .11 165 / .3), transparent 50%), radial-gradient(circle, oklch(.27 .05 300 / .09) 1px, transparent 1px); background-size: 100% 100%, 20px 20px; background-attachment: fixed; }
h1, h2, p { margin: 0; overflow-wrap: anywhere; }
h1, h2 { text-wrap: balance; line-height: 1.3; }
h1 { font-size: 32px; font-weight: 900; } h2 { font-size: 24px; }
button, input { font: inherit; color: var(--ink); }
button { min-width: 44px; min-height: 44px; padding: 9px 16px; background: var(--paper); border: 3px solid var(--ink); box-shadow: var(--shadow); border-radius: 999px; cursor: pointer; font-weight: 600; transition: transform 160ms var(--ease), box-shadow 160ms var(--ease); overflow-wrap: anywhere; }
button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button:hover:not(:disabled) { background: var(--sun); }
button:disabled { cursor: default; background: var(--cream); color: var(--muted); box-shadow: none; border-style: dashed; }
button.primary { background: var(--coral); font-weight: 700; }
button.primary:disabled { background: var(--cream); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
input { min-width: 0; width: 100%; min-height: 52px; padding: 10px 14px; font-size: 18px; background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow); }
input::placeholder { color: var(--muted); opacity: 1; }
img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.setup { width: 100%; max-width: 560px; margin: auto; padding: 24px 18px; }
.home { padding-top: max(20px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.home-heading, .room-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sticker { background: var(--sun); border: 2px solid var(--ink); border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; }
.hero { position: relative; text-align: center; padding-top: 20px; }
.hero h1 { font-size: 96px; line-height: 1; letter-spacing: -.03em; color: var(--ink); text-shadow: 4px 4px 0 var(--coral); }
.hero h2 { margin-top: 12px; font-size: 28px; }
.hero p { margin-top: 6px; }
.hero-art { display: block; width: 100%; aspect-ratio: 3/2; border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); transform: rotate(-2deg); background: var(--mint); overflow: hidden; margin-top: 20px; }
.hero-art img { object-fit: contain; }
.hero-fan { display: flex; justify-content: center; margin-top: -22px; position: relative; padding-bottom: 18px; }
.back-tile { display: block; aspect-ratio: 3/4; width: 48px; flex: 0 0 48px; border: 2px solid var(--ink); border-radius: 9px; background: var(--sky); background-image: repeating-linear-gradient(45deg, transparent 0 6px, oklch(.99 .012 85 / .4) 6px 9px); overflow: hidden; }
.hero-fan .back-tile { width: 76px; flex-basis: 76px; margin: 0 -8px; transform: rotate(var(--angle)); box-shadow: var(--shadow); }
.home form { display: grid; gap: 14px; margin-top: 12px; text-align: center; }
.join, .custom { display: flex; gap: 10px; align-items: center; } .join button, .custom button { flex-shrink: 0; }
.join input { text-transform: uppercase; letter-spacing: .15em; }
.start { width: 100%; min-height: 58px; font-size: 22px; }
.how { margin-top: 26px; border-top: 2px dashed var(--ink); border-bottom: 2px dashed var(--ink); }
summary { min-height: 48px; padding: 12px 0; cursor: pointer; font-weight: 600; }
.how ol { margin: 0 0 16px; padding-left: 26px; } .how li { margin: 8px 0; }
.game { max-width: 720px; min-height: 100dvh; margin: auto; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: var(--z-top); padding: max(8px, env(safe-area-inset-top)) 18px 14px; background: var(--cream); border-bottom: 2px solid var(--ink); box-shadow: 0 4px 0 oklch(.27 .05 300 / .08); }
.wordmark { font-size: 26px; font-weight: 900; line-height: 1; background: var(--sun); padding: 6px 14px; }
.room-pill { margin-left: auto; background: var(--sky); letter-spacing: .08em; }
.players { display: flex; gap: 10px; overflow-x: auto; padding: 12px 1px 8px; scrollbar-width: thin; }
.player-chip { flex: 0 0 74px; text-align: center; min-width: 0; }
.avatar { display: grid; place-items: center; width: 44px; height: 44px; margin: 0 auto 5px; font-size: 26px; background: var(--paper); border: 2px solid var(--ink); border-radius: 50%; }
.player-name { display: block; font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.player-chip.active .avatar { background: var(--sun); box-shadow: 0 0 0 3px var(--coral); }
.offline .avatar { border-style: dashed; background: var(--cream); }
.stats { font-weight: 700; padding: 4px 0; }
.theme-title { font-size: 24px; } .instruction { font-size: 15px; margin-top: 6px; color: var(--muted); }
.ticket { display: flex; flex-direction: column; align-items: center; width: 100%; margin: 8px 0 24px; padding: 18px; border-radius: 22px; background: var(--sun); transform: rotate(-1.5deg); }
.ticket strong { font-size: 52px; font-weight: 900; letter-spacing: .12em; }
.ticket small { font-size: 16px; } .ticket span { font-size: 15px; }
.waiting, .best { text-align: center; margin: 14px 0; }
.theme-options { display: grid; gap: 18px; }
.theme-option { position: relative; text-align: left; border-radius: 20px; padding: 24px; min-height: 100px; font-size: 23px; background: var(--sun); }
.theme-option:nth-child(2) { background: var(--mint); } .theme-option:nth-child(3) { background: var(--sky); }
.theme-option:disabled { color: var(--ink); border-style: solid; }
.theme-options > .custom { margin-top: 10px; }
.board-panel { padding: 8px 8px calc(var(--action-height, 120px) + 64px) 20px; position: relative; }
.board-panel::before { content: ''; position: absolute; left: 8px; top: 25px; bottom: calc(var(--action-height, 120px) + 64px); width: 5px; border: 1px solid var(--ink); border-radius: 8px; background: linear-gradient(var(--sky), var(--coral)); }
.endpoint { width: fit-content; padding: 0 8px; border: 2px solid var(--ink); border-radius: 999px; background: var(--sky); font-weight: 700; font-size: 14px; margin: 0 0 6px; } .endpoint.high { margin: 10px 0 0 auto; background: var(--coral); }
.card-row { display: flex; flex-direction: column; gap: 8px; }
.number-card { position: relative; display: flex; align-items: center; gap: 6px; min-height: 76px; padding: 4px 4px 4px 0; background: var(--paper); border: 3px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow); }
.grip { display: grid; place-items: center; align-self: stretch; flex: 0 0 44px; font-size: 24px; user-select: none; color: var(--muted); }
.number-card.arranging .grip { touch-action: none; cursor: grab; }
.number-card:not(.arranging) .grip { display: none; }
.number-card .back-tile { width: 40px; height: 54px; flex: 0 0 40px; }
.number-card.mine { background: oklch(.95 .10 95); }
.number-card.dragging { position: fixed; z-index: var(--z-settings); transform: scale(1.03) rotate(-1.5deg); box-shadow: 0 9px 0 var(--ink); cursor: grabbing; }
.drag-gap { border: 2px dashed var(--ink); border-radius: 14px; background: oklch(.80 .10 235 / .25); flex-shrink: 0; }
.card-content { flex: 1; min-width: 0; position: relative; }
.owner { font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clue { font-family: Kanit, sans-serif; font-size: 18px; line-height: 23px; font-weight: 700; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mine.arranging .clue { cursor: pointer; padding-right: 22px; min-height: 44px; }
.clue.empty { font-style: italic; font-weight: 400; color: var(--muted); }
.secret { position: absolute; top: -8px; left: 36px; z-index: 1; min-width: 27px; border: 2px solid var(--ink); background: var(--sun); border-radius: 8px; text-align: center; font-size: 18px; line-height: 1.2; }
.edit { min-width: 44px; width: 44px; min-height: 44px; padding: 0; position: absolute; top: 16px; right: -8px; background: transparent; border: 0; box-shadow: none; text-align: right; padding-right: 8px; }
.arrows { display: flex; flex: 0 0 88px; gap: 0; }
.arrows button { width: 44px; height: 44px; padding: 0; border-width: 2px; box-shadow: 0 2px 0 var(--ink); font-size: 14px; }
.clue-form { display: flex; gap: 6px; position: relative; margin: 8px 0; } .clue-form input { font-size: 16px; min-height: 44px; padding: 6px; } .clue-form button { background: var(--mint); padding: 4px 8px; }
.number-card:has(.clue-form:not([hidden])) :is(.arrows, .edit) { display: none; }
.clue-form input { flex: 1; min-width: 0; } .clue-form button { flex: none; white-space: nowrap; }
.flipped { background: var(--mint); padding: 8px; }
.flipped.mine { background: var(--mint); } .flipped.wrong { background: oklch(.92 .06 5); }
.number-card:not(.arranging) .arrows { display: none; }
.revealed-number { order: -1; font-size: 48px; line-height: 1; font-weight: 900; min-width: 72px; text-align: center; }
.verdict { font-size: 14px; line-height: 20px; font-weight: 600; }
.actions { padding: 8px 12px max(8px, env(safe-area-inset-bottom)); text-align: center; background: var(--cream); }
.game[data-phase=arrange] .actions, .game[data-phase=reveal] .actions { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 720px; z-index: var(--z-top); border-top: 2px solid var(--ink); }
.actions > button { margin: 2px; } .actions > .start { margin: 0; min-height: 44px; font-size: 20px; }
.action-status { min-height: 32px; padding: 4px; }
.action-social { display: flex; align-items: center; justify-content: center; gap: 6px; }
.result-sheet { position: fixed; bottom: var(--action-height, 120px); left: max(12px, calc((100vw - 696px) / 2)); width: min(696px, calc(100% - 24px)); padding: 12px; background: var(--paper); border: 3px solid var(--ink); border-radius: 16px 16px 0 0; z-index: var(--z-top); text-align: center; max-height: 50dvh; overflow-y: auto; }
.result { font-size: 24px; margin-bottom: 6px; } .bonus, .result-hearts { font-size: 18px; margin-bottom: 6px; }
.result-sheet > button { min-height: 44px; padding: 4px 18px; }
.speed { background: var(--sky); } button.quiet { background: var(--paper); font-size: 14px; }
.reactions { display: flex; justify-content: center; gap: 4px; padding: 6px 0 0; min-width: 0; } .reactions button { padding: 4px; font-size: 22px; box-shadow: none; border-width: 2px; }
.host-menu { position: relative; flex-shrink: 0; font-size: 13px; }
.host-menu summary { min-height: 44px; padding: 12px 4px; list-style: none; }
.host-menu button { position: absolute; right: 0; bottom: 100%; width: 160px; }
.settings-wrap { position: relative; flex: 0 0 44px; } .sound { padding: 4px; width: 44px; }
.settings { position: absolute; z-index: var(--z-settings); top: calc(100% + 8px); right: 0; width: min(300px, calc(100vw - 36px)); display: grid; gap: 14px; padding: 14px; border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); background: var(--paper); }
.settings-row { display: flex; align-items: center; gap: 10px; } .settings-row input { min-width: 0; font-size: 16px; }
.settings-row input[type=range] { min-height: 44px; padding: 0; border: 0; box-shadow: none; accent-color: var(--ink); }
.settings-value { min-width: 4ch; } .settings-row button { padding: 8px; flex-shrink: 0; }
.connection { position: sticky; top: 0; z-index: var(--z-toast); background: var(--sun); text-align: center; padding: 8px; } .connection:empty { display: none; }
.toast { position: fixed; bottom: calc(var(--action-height, 0px) + 12px); left: 50%; transform: translateX(-50%); z-index: var(--z-toast); width: max-content; max-width: calc(100vw - 32px); border: 3px solid var(--ink); border-radius: 16px; padding: 12px 18px; background: var(--sun); box-shadow: var(--shadow); text-align: center; } .toast:empty { display: none; }
.floating-emoji { position: fixed; z-index: var(--z-reaction); pointer-events: none; font-size: 42px; }
.confetti { position: fixed; inset: 0; z-index: var(--z-reaction); pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; width: 10px; height: 16px; top: 15%; border: 1px solid var(--ink); }
@media (max-width: 400px) { .custom { flex-wrap: wrap; } .custom button { width: 100%; } .theme-title { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* Keep the play header short enough to leave the table in view. */
.game[data-phase=arrange] .topbar, .game[data-phase=reveal] .topbar { display: grid; grid-template-columns: 1fr auto; gap: 3px 6px; padding: max(4px, env(safe-area-inset-top)) 10px 4px; }
.game[data-phase=arrange] .room-controls, .game[data-phase=reveal] .room-controls { grid-column: 2; grid-row: 1; gap: 4px; }
.game[data-phase=arrange] .wordmark, .game[data-phase=reveal] .wordmark { display: none; }
.game[data-phase=arrange] .room-pill, .game[data-phase=reveal] .room-pill { padding: 4px 8px; font-size: 13px; }
.game[data-phase=arrange] .stats, .game[data-phase=reveal] .stats { grid-column: 1; grid-row: 1; align-self: center; font-size: 13px; padding: 0; }
.game[data-phase=arrange] .theme-title, .game[data-phase=reveal] .theme-title { grid-column: 1 / -1; font-size: 22px; font-weight: 700; line-height: 26px; padding: 2px 8px; border: 2px solid var(--ink); border-radius: 8px; background: var(--sun); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.game[data-phase=arrange] .players, .game[data-phase=reveal] .players { grid-column: 1 / -1; gap: 10px; padding: 0 16px 0 0; scrollbar-width: none; mask-image: linear-gradient(to right, black calc(100% - 18px), transparent); }
.game[data-phase=arrange] .player-chip, .game[data-phase=reveal] .player-chip { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; max-width: 150px; }
.game[data-phase=arrange] .avatar, .game[data-phase=reveal] .avatar { width: 28px; height: 28px; flex: 0 0 28px; font-size: 18px; margin: 0; }
.game[data-phase=arrange] .player-name, .game[data-phase=reveal] .player-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.game[data-phase=arrange] .instruction, .game[data-phase=reveal] .instruction { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (prefers-reduced-motion: reduce) { .number-card.dragging { transform: none; } }
