:root {
  color-scheme: dark;
  --table: oklch(.21 .05 265); --table-2: oklch(.29 .05 265); --ink: oklch(.15 .03 265);
  --cream: oklch(.96 .02 95); --muted: oklch(.80 .025 265); --pop: oklch(.90 .18 100);
  --paper: oklch(.90 .05 85); --reject: oklch(.65 .23 25); --safe: oklch(.80 .13 190); --shadow: 0 4px 0 var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--cream); font: 400 16px/1.5 Kanit,sans-serif; background-color: var(--table); background-image: radial-gradient(ellipse at 50% 0%, oklch(.36 .06 265), transparent 65%),radial-gradient(circle, #ffffff0c 1px, transparent 1px); background-size: 100% 100%,22px 22px; background-attachment: fixed; }
main { min-width: 0; min-height: 100dvh; }
h1,h2,p { margin: 0; overflow-wrap: anywhere; }
h1 { font-size: clamp(28px,7vw,40px); line-height: 1.2; text-wrap: balance; }
h2 { font-size: 22px; }
button,input { font: inherit; }
button,input,.ticket,.how { border: 3px solid var(--ink); box-shadow: var(--shadow); }
button { min-width: 44px; min-height: 48px; border-radius: 999px; padding: 10px 18px; background: var(--cream); color: var(--ink); font-weight: 600; cursor: pointer; transition: transform 150ms,box-shadow 150ms; overflow-wrap: anywhere; }
button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button:disabled { background: var(--table-2); color: var(--muted); cursor: default; box-shadow: none; }
button.primary,button[aria-pressed=true] { background: var(--pop); }
button[aria-pressed=true]::before { content: '✓ '; }
button.large { width: 100%; min-height: 60px; font-size: 22px; }
button.quiet { background: transparent; color: var(--muted); box-shadow: none; }
:focus-visible { outline: 3px solid var(--pop); outline-offset: 4px; }
input { width: 100%; min-height: 52px; min-width: 0; border-radius: 14px; background: var(--cream); color: var(--ink); padding: 10px 14px; font-size: 18px; }
input::placeholder { color: #525461; }
.setup { width: 100%; max-width: 560px; margin: auto; padding: max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left)); display: grid; gap: 20px; }
.hero { aspect-ratio: 3/2; border: 3px solid var(--ink); border-radius: 24px; overflow: hidden; background: var(--table-2); box-shadow: 0 6px 0 var(--ink); transform: rotate(-1.5deg); }
.hero img { display: block; width: 100%; height: 100%; object-fit: cover; }
.title { display: grid; justify-items: center; gap: 8px; margin-top: -52px; text-align: center; position: relative; }
.title h1 { font: 700 clamp(44px,13vw,64px)/1 'Chakra Petch',sans-serif; letter-spacing: .08em; color: var(--ink); background: var(--pop); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 5px 0 var(--ink); padding: 8px 18px 6px; transform: rotate(-2deg); }
.title p { font-size: 22px; font-weight: 600; }
.title .eyebrow { font-size: 14px; padding: 2px 12px; border: 2px solid var(--muted); border-radius: 999px; color: var(--muted); }
.eyebrow { font-family: 'Chakra Petch',sans-serif; letter-spacing: .08em; }
.home form { display: grid; gap: 12px; }
.join { display: flex; gap: 8px; } .join button { flex-shrink: 0; }
.how { padding: 16px; border-radius: 16px; background: var(--table-2); }
.how summary { cursor: pointer; min-height: 44px; display: list-item; align-content: center; font-size: 20px; }
.how p { margin-top: 8px; }
.room-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.room-pill { font-family: 'Chakra Petch',sans-serif; letter-spacing: .08em; }
.instruction { text-align: center; min-height: 48px; font-size: 19px; color: var(--pop); }
.dossier { width: 100%; }
.peek { position: relative; width: 100%; height: 180px; padding: 30px 12px 12px; border-radius: 6px 20px 20px 20px; background: var(--paper); color: var(--ink); overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
/* No press-down transform here: it would re-anchor the fixed role card to the button. */
.peek:active:not(:disabled) { transform: none; box-shadow: var(--shadow); }
.peek::before { content: ''; position: absolute; inset: 0 0 auto; height: 18px; background: repeating-linear-gradient(-45deg, var(--ink) 0 12px, var(--pop) 12px 24px); border-bottom: 3px solid var(--ink); }
.cover { display: grid; justify-items: center; gap: 2px; }
.cover .finger { font-style: normal; font-size: 30px; width: 56px; height: 56px; display: grid; place-items: center; border: 3px dashed var(--ink); border-radius: 50%; animation: ring 1.6s ease-in-out infinite; }
.cover strong { font: 700 22px 'Chakra Petch',sans-serif; letter-spacing: .06em; }
.cover span { font-weight: 600; }
.cover small { font-size: 13px; color: oklch(.38 .04 265); }
.seal { position: absolute; right: 14px; top: 34px; padding: 0 10px; border: 3px solid var(--reject); border-radius: 8px; color: var(--reject); font: 700 24px 'Chakra Petch',sans-serif; transform: rotate(12deg); opacity: .85; }
.secret { position: fixed; inset: 0; z-index: 80; display: grid; grid-template-columns: min(74vw,300px); justify-content: center; align-content: center; background: oklch(.10 .03 265 / .88); color: var(--ink); text-align: center; pointer-events: none; animation: pop-card 180ms cubic-bezier(.16,1,.3,1); }
.portrait { max-height: 52dvh; aspect-ratio: 3/4; border: 4px solid var(--ink); border-bottom: 0; border-radius: 22px 22px 0 0; overflow: hidden; background: var(--ink); justify-self: center; width: 100%; }
.portrait img { display: block; width: 100%; height: 100%; object-fit: cover; }
.secret strong { font: 700 30px/1.5 'Chakra Petch',sans-serif; border: 4px solid var(--ink); background: var(--safe); }
.secret[data-role=master] strong { background: var(--pop); }
.secret[data-role=insider] strong { background: var(--reject); color: var(--cream); }
.secret > span { border: 4px solid var(--ink); border-top: 0; border-radius: 0 0 22px 22px; background: var(--paper); padding: 10px 12px 12px; font-size: 22px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; box-shadow: 0 6px 0 var(--ink); }
.master-chip { justify-self: center; padding: 2px 14px; border: 3px solid var(--ink); border-radius: 999px; background: var(--pop); color: var(--ink); font-weight: 600; }
.clock { text-align: center; font: 700 60px/1 'Chakra Petch',sans-serif; font-variant-numeric: tabular-nums; }
.clock.huge { font-size: clamp(90px,24vw,140px); color: var(--pop); }
.clock.huge::before { content: ''; display: block; height: 10px; margin: 0 0 10px; border: 2px solid var(--ink); border-radius: 999px; background: linear-gradient(to right, currentColor calc(var(--left,1) * 100%), var(--table-2) 0); }
.clock.urgent { color: var(--reject); animation: pulse 1s ease-in-out infinite; }
.clock.urgent::after { content: 'เหลือไม่ถึงครึ่งนาที!'; display: block; font: 500 18px Kanit,sans-serif; }
.phase { display: grid; gap: 16px; text-align: center; }
.ticket { padding: 20px; display: grid; justify-items: center; gap: 8px; border-radius: 16px; color: var(--ink); background: var(--pop); transform: rotate(-1deg); }
.ticket strong { font: 700 56px/1.2 'Chakra Petch',sans-serif; letter-spacing: .15em; }
.times { border: 0; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 0; padding: 0; }
.times legend { padding: 0 0 8px; }
.times label { border-radius: 12px; padding: 10px 4px; background: var(--table-2); cursor: pointer; }
.times input { width: 20px; height: 20px; min-height: 20px; vertical-align: middle; accent-color: var(--pop); box-shadow: none; }
.times span { margin-left: 6px; }
.word-tools { display: grid; gap: 14px; }
.word-choices { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.word-card { min-height: 76px; border-radius: 10px; font-size: 22px; background: var(--paper); transform: rotate(-1.2deg); }
.word-card:nth-child(even) { transform: rotate(1.4deg); }
.word-tools label { text-align: left; color: var(--muted); margin-bottom: -8px; }
.word-card:last-child { grid-column: 1/-1; }
.word-tools form { display: flex; gap: 8px; } .word-tools form button { flex-shrink: 0; }
.waiting { padding: 24px; border: 2px dashed var(--muted); border-radius: 16px; }
.example { color: var(--muted); font-size: 22px; min-height: 34px; }
.vote-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.vote { min-height: 124px; font-size: 26px; border-radius: 22px; display: grid; align-content: center; gap: 2px; }
.vote.accuse { background: var(--reject); color: var(--cream); } .vote.clear { background: var(--safe); }
.vote[aria-pressed=true] { outline: 5px solid var(--cream); outline-offset: -9px; transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.vote[aria-pressed=true]::before { content: none; } .vote[aria-pressed=true]::after { content: 'เลือกแล้ว ✓'; font-size: 16px; }
.vote-pair:has([aria-pressed=true]) .vote[aria-pressed=false] { filter: saturate(.35) brightness(.75); }
.vote-count { text-align: center; color: var(--muted); }
.players,.suspects { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.player-chip { max-width: 100%; display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 5px; border: 2px solid var(--ink); border-radius: 999px; background: var(--table-2); overflow-wrap: anywhere; }
.player-chip::before, .suspect::before, .board li::before { content: attr(data-initial); flex: none; width: 32px; height: 32px; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--cream); color: var(--ink); font-weight: 700; line-height: 1; }
.player-chip.master { background: var(--pop); color: var(--ink); }
.player-chip.voted { background: var(--safe); color: var(--ink); }
.player-chip.offline { border-style: dashed; color: var(--muted); }
.suspects { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.suspect { min-height: 76px; border-radius: 18px; font-size: 20px; display: flex; align-items: center; gap: 10px; text-align: left; }
.suspect::before { width: 40px; height: 40px; } .suspect[aria-pressed=true]::before { content: attr(data-initial); }
.suspect[aria-pressed=true]::after { content: 'คุณชี้คนนี้'; font-size: 13px; margin-left: auto; }
.room { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
.bar { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; align-items: center; gap: 10px; padding: 10px max(12px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left)); background: oklch(.17 .04 265 / .94); border-top: 3px solid var(--ink); }
.reactions { display: flex; gap: 6px; justify-content: center; }
.reactions button { padding: 4px; width: 46px; min-height: 46px; font-size: 22px; }
.host-menu { position: relative; } .host-menu summary { list-style: none; min-height: 46px; display: grid; place-items: center; padding: 0 12px; border: 2px solid var(--muted); border-radius: 999px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.host-menu summary::-webkit-details-marker { display: none; }
.host-menu[open] { position: static; } .host-menu[open] > button { position: absolute; right: 12px; bottom: calc(100% + 10px); white-space: nowrap; z-index: 26; }
.host-menu[open] > button + button { bottom: calc(100% + 68px); } .host-menu[open] > button[hidden] + button { bottom: calc(100% + 10px); }
.host-menu button.quiet { background: var(--table-2); color: var(--cream); box-shadow: var(--shadow); }
/* Lobby: who is here comes right under the ticket. */
.room[data-phase=lobby] .phase.lobby { display: contents; } .room[data-phase=lobby] > *, .room[data-phase=lobby] .phase.lobby > * { order: 6; text-align: center; }
.room[data-phase=lobby] > .room-controls { order: 0; } .room[data-phase=lobby] > .instruction { order: 1; } .room[data-phase=lobby] .phase.lobby > .ticket { order: 2; } .room[data-phase=lobby] > .players { order: 3; }
.scores { display: grid; gap: 12px; padding: 16px; border: 3px solid var(--ink); border-radius: 20px; background: var(--table-2); text-align: left; }
.scores h2 { font: 700 16px 'Chakra Petch',sans-serif; letter-spacing: .08em; color: var(--muted); margin-top: 6px; }
.stamp, .verdict { justify-self: center; padding: 10px 22px; border: 5px solid currentColor; border-radius: 14px; color: var(--pop); font: 800 clamp(28px,8vw,40px)/1.2 Kanit,sans-serif; transform: rotate(-4deg); margin: 10px 0; background: oklch(.17 .04 265 / .6); }
[data-outcome=caught] { color: var(--safe); } [data-outcome=escaped] { color: var(--reject); } [data-outcome=timeout] { color: var(--muted); }
.culprit { display: flex; align-items: center; gap: 14px; } .culprit small { display: block; color: var(--muted); } .culprit strong { font-size: 26px; overflow-wrap: anywhere; }
.culprit-art { flex: none; width: 84px; aspect-ratio: 3/4; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; transform: rotate(-4deg); background: var(--reject); } .culprit-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.paper { padding: 8px 14px; border: 3px solid var(--ink); border-radius: 6px; background: var(--paper); color: var(--ink); font-size: 20px; font-weight: 600; transform: rotate(-.8deg); }
.accused { color: var(--muted); }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board li { display: flex; align-items: center; gap: 10px; } .board li span { flex: 1; min-width: 0; overflow-wrap: anywhere; } .board li b { font-family: 'Chakra Petch',sans-serif; }
.board li em { font-style: normal; font-weight: 700; padding: 0 8px; border: 2px solid var(--ink); border-radius: 999px; background: var(--pop); color: var(--ink); }
.votes { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); gap: 6px 12px; align-items: center; } .votes b { font-size: 13px; font-weight: 400; color: var(--muted); } .votes span { overflow-wrap: anywhere; }
.settings-wrap { position: relative; flex: 0 0 44px; }
.sound { width: 48px; padding: 6px; }
.settings { position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; width: min(290px,calc(100vw - 32px)); padding: 14px; display: grid; gap: 12px; background: var(--cream); color: var(--ink); border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); }
.home > .settings-wrap { justify-self: end; }
.settings-row { display: flex; gap: 8px; align-items: center; }
.settings-row input[type=range] { padding: 0; border: 0; box-shadow: none; min-width: 0; accent-color: var(--ink); }
.settings-row input { min-width: 0; } .settings-row button { flex-shrink: 0; padding: 8px; }
.settings-value { flex-shrink: 0; }
.connection:not(:empty) { position: sticky; top: 0; z-index: 30; padding: 12px; color: var(--ink); background: var(--pop); text-align: center; }
.toast:empty { display: none; }
.toast { position: fixed; z-index: 60; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); border: 3px solid var(--ink); background: var(--cream); color: var(--ink); padding: 12px 18px; border-radius: 16px; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sheet { width: min(520px,calc(100vw - 24px)); max-height: 85dvh; border: 3px solid var(--ink); border-radius: 24px; color: var(--cream); background: var(--table); padding: 20px; }
.sheet[open] { display: grid; gap: 12px; } .sheet::backdrop { background: #000b; }
.reveal { position: fixed; inset: 0; z-index: 50; width: 100%; height: 100dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 22px; border: 0; border-radius: 0; box-shadow: none; background: radial-gradient(ellipse 70% 55% at 50% 0%, oklch(.90 .18 100 / .35), transparent 70%), var(--ink); color: var(--cream); padding: 24px; perspective: 900px; }
.reveal:active:not(:disabled) { transform: none; box-shadow: none; }
.reveal strong { font-size: clamp(32px,8.5vw,52px); line-height: 1.25; max-width: 600px; text-wrap: balance; }
.reveal p { color: var(--muted); }
.reveal .verdict { font-size: clamp(34px,10vw,60px); padding: 14px 26px; border-width: 6px; }
.reveal-card { width: min(62vw,280px); aspect-ratio: 3/4; background: var(--table-2); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 8px 0 #000; overflow: hidden; }
.reveal-card img { width: 100%; height: 100%; object-fit: cover; }
.floating-emoji { position: fixed; bottom: 100px; z-index: 70; pointer-events: none; font-size: 48px; }
@keyframes pulse { 50% { transform: scale(1.035); } }
@keyframes ring { 50% { box-shadow: 0 0 0 10px oklch(.15 .03 265 / .14); } }
@keyframes pop-card { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
