:root {
  color-scheme: dark;
  --table: oklch(0.27 0.07 330); --table-2: oklch(0.33 0.09 330);
  --ink: oklch(0.24 0.05 300); --cream: oklch(0.97 0.02 90); --muted: oklch(0.82 0.04 330);
  --brand: oklch(0.70 0.22 355); --pop: oklch(0.92 0.19 115); --accept: oklch(0.80 0.19 155);
  --reject: oklch(0.66 0.22 25); --warn: oklch(0.82 0.16 70);
  --z-board: 1; --z-dock: 10; --z-toast: 30; --z-verdict: 40; --z-takeover: 50; --z-reaction: 60;
  --ease: cubic-bezier(.22,1,.36,1); --shadow: 0 4px 0 var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--cream); font: 400 16px/1.45 Kanit, sans-serif; background-color: var(--table); background-image: radial-gradient(60% 50% at 50% 40%, oklch(0.36 0.1 330), transparent), radial-gradient(circle, oklch(1 0 0 / .04) 1.5px, transparent 1.5px); background-size: 100% 100%, 22px 22px; background-attachment: fixed; }
body.in-game { overflow: hidden; }
main { min-width: 0; }
svg { display: block; width: 100%; height: 100%; }
h1, h2, p { margin: 0; overflow-wrap: anywhere; }
h1 { font-size: 32px; font-weight: 900; line-height: 1.15; text-wrap: balance; }
h2 { font-size: 20px; font-weight: 600; }
button, input { font: inherit; }
button, input, .ticket, .level, .how { border: 3px solid var(--ink); box-shadow: var(--shadow); }
button { min-height: 44px; min-width: 44px; border-radius: 999px; padding: 8px 16px; background: var(--cream); color: var(--ink); font-weight: 600; cursor: pointer; transition: transform 180ms var(--ease), box-shadow 180ms var(--ease), filter 180ms var(--ease); }
button:hover:not(:disabled) { filter: brightness(1.06); }
button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
/* Disabled = flat plum sticker, not a faded lime (faded lime on plum reads as muddy olive). */
button:disabled:not(.card) { background: var(--table-2); color: var(--muted); box-shadow: 0 2px 0 var(--ink); cursor: default; }
button.card:disabled { cursor: default; }
button.primary { background: var(--pop); font-weight: 800; }
button.warning { background: var(--reject); }
:focus-visible { outline: 3px solid var(--pop); outline-offset: 3px; }
input { color-scheme: light; width: 100%; min-height: 56px; border-radius: 16px; background: var(--cream); color: var(--ink); padding: 12px 16px; font-size: 20px; }
input::placeholder { color: var(--ink); opacity: .8; }
.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 max(24px, env(safe-area-inset-bottom)); }
.home { padding: 0 0 24px; text-align: center; }
.hero { position: relative; isolation: isolate; padding: 28px 16px 34px; min-height: 350px; }
.hero::before { content: ''; position: absolute; inset: 0; background: var(--brand); z-index: -1; clip-path: polygon(0 0,100% 0,100% 94%,90% 98%,80% 95%,70% 99%,60% 96%,50% 100%,40% 97%,30% 99%,20% 95%,10% 98%,0 94%); }
.hero h1 { font-size: 64px; font-weight: 900; text-shadow: 3px 4px 0 var(--ink); }
.hero p { color: var(--ink); font-size: 20px; font-weight: 600; margin: 8px 0 12px; }
.hero-fan { display: flex; justify-content: center; padding: 22px 0 24px; }
.hero-fan .card { margin: 0 -14px; transform: rotate(var(--angle)); transform-origin: 50% 120%; }
.hero-fan .card-motion { animation: wobble 3.8s ease-in-out infinite; animation-delay: var(--delay); }
.home form { display: grid; gap: 14px; padding: 22px 24px; }
.home form > .primary { min-height: 58px; font-size: 22px; }
.join { display: flex; gap: 8px; }
.join input { min-width: 0; }
.join button { flex-shrink: 0; }
.lobby-heading, .room-controls { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sound { padding: 4px; width: 44px; flex: 0 0 44px; }
.ticket { display: flex; flex-direction: column; align-items: center; width: 100%; border-radius: 16px; background: var(--brand); margin: 24px 0; transform: rotate(-2deg); padding: 18px 8px; }
.ticket strong { font-size: clamp(32px, 10vw, 52px); letter-spacing: .12em; font-weight: 900; }
.ticket small { font-size: 16px; }
.cluster { flex-wrap: wrap; justify-content: center; }
.levels { border: 0; padding: 0; margin: 18px 0; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
.levels legend { font-weight: 600; margin-bottom: 8px; }
.level { position: relative; background: var(--cream); color: var(--ink); border-radius: 16px; padding: 10px 6px; text-align: center; cursor: pointer; }
.level input { width: 22px; min-height: 22px; height: 22px; accent-color: var(--ink); box-shadow: none; margin: 0 0 4px; }
.level strong, .level span { display: block; }
.level strong { font-size: 15px; }
.level span { font-size: 12px; }
.level:has(:checked) { background: var(--pop); }
.start { width: 100%; font-size: 26px; min-height: 60px; }
.how { margin: 24px 0 16px; padding: 0 12px; border-radius: 16px; background: var(--table-2); }
summary { min-height: 44px; cursor: pointer; padding: 10px 0; font-weight: 600; }
.how ol { margin: 8px 0 16px; padding-left: 24px; }
.how li { padding: 8px 0; }
.how .mini { vertical-align: middle; margin-right: 8px; }
.game { max-width: 960px; margin: auto; height: 100dvh; display: grid; grid-template-rows: auto minmax(0,1fr) auto; min-width: 0; }
.topbar { min-width: 0; max-width: 560px; width: 100%; margin: auto; padding: max(6px, env(safe-area-inset-top)) 12px 0; }
.room-controls { height: 44px; }
.room-pill { background: var(--brand); letter-spacing: .08em; }
.clock { margin-left: auto; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.players { position: relative; display: flex; align-items: flex-start; overflow-x: auto; gap: 14px; padding: 16px 10px 8px; scrollbar-width: none; }
.player-chip { position: relative; flex: 0 0 70px; min-width: 0; text-align: center; animation: pop-in 220ms var(--ease); }
.avatar { margin: 0 auto 4px; display: grid; place-items: center; width: 44px; height: 44px; border: 3px solid var(--ink); border-radius: 50%; color: var(--ink); box-shadow: var(--shadow); font-size: 21px; font-weight: 800; transition: transform 200ms var(--ease); }
.player-chip.active .avatar { transform: scale(1.2); box-shadow: 0 0 0 3px var(--pop), var(--shadow); }
.player-chip.offline { opacity: .4; }
.player-name { display: block; font-size: 12px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-top: 4px; }
.count { position: absolute; top: 32px; right: -5px; color: var(--ink); background: var(--cream); border: 3px solid var(--ink); border-radius: 999px; padding: 0 4px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tension { background: var(--warn); animation: tension 1.3s ease-in-out infinite; }
.timer-ring { position: absolute; width: 64px; height: 64px; left: 3px; top: -10px; pointer-events: none; }
.timer-ring circle { fill: none; stroke: var(--pop); stroke-width: 3; stroke-dasharray: 100; transform: rotate(-90deg); transform-origin: center; }
.timer-ring.urgent circle { stroke: var(--reject); }
.public { position: relative; min-width: 0; min-height: 0; z-index: var(--z-board); display: flex; margin: 2px 8px 10px; border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); background: var(--table-2); }
.board-row { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 16px 12px 12px; overflow: auto; min-width: 0; flex: 1; overscroll-behavior: contain; }
.board-column { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 5px; min-width: 76px; }
.table-caption { color: var(--muted); font-size: 12px; }
.card { --c: #ef5b5b; --c2: #b8323a; --c3: #ffb3ad; position: relative; display: inline-block; flex: 0 0 auto; width: 76px; height: 106px; padding: 0; border: 0; border-radius: 12px; background: none; box-shadow: none; line-height: 1; color: var(--ink); vertical-align: middle; }
.card-motion, .card-face { display: block; width: 100%; height: 100%; border-radius: inherit; }
.card-face { position: relative; border: 3px solid var(--ink); box-shadow: var(--shadow); background: var(--cream); transition: transform 200ms var(--ease); }
.red { --c: #ef5b5b; --c2: #b8323a; --c3: #ffb3ad; }
.blue { --c: #4f8df7; --c2: #2457c5; --c3: #b9d3ff; }
.green { --c: #3fbf7f; --c2: #1f8455; --c3: #aee8c9; }
.yellow { --c: #f7c33c; --c2: #b07c08; --c3: #ffe79c; }
.card .n, .card .n2 { position: absolute; font-weight: 800; }
.card .n { top: 4px; left: 5px; font-size: 22px; }
.card .n2 { bottom: 4px; right: 5px; font-size: 16px; transform: rotate(180deg); }
.card .suit { position: absolute; top: 28px; left: 5px; width: 11px; height: 11px; }
.card .art { position: absolute; width: 57px; height: 57px; left: 10px; top: 25px; }
.color-name { position: absolute; bottom: 5px; left: 5px; font-size: 10px; font-weight: 600; }
.sheen { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: radial-gradient(circle at var(--mx,50%) var(--my,50%), oklch(1 0 0 / .22), transparent 65%); opacity: 0; }
.card:hover .sheen { opacity: 1; }
.card.mini { width: 36px; height: 49px; border-radius: 8px; }
.mini .n { font-size: 12px; top: 2px; left: 3px; }
.mini .art { width: 29px; height: 29px; top: 14px; left: 1px; }
.mini .suit, .mini .n2, .mini .color-name { display: none; }
.rule-back { flex: 0 0 76px; width: 76px; height: 106px; perspective: 700px; }
.rule-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 600ms var(--ease); }
.rule-cover, .rule-face { position: absolute; inset: 0; border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 5px; text-align: center; }
.rule-cover { background: var(--brand); color: var(--ink); font-size: 14px; }
.rule-cover svg { width: 50px; height: 50px; }
.rule-face { background: var(--cream); color: var(--ink); transform: rotateY(180deg); font-size: 11px; overflow-wrap: anywhere; }
.rule-face small { font-size: 10px; }
.flipped .rule-inner { transform: rotateY(180deg); }
.pile { position: relative; flex: 0 0 38px; height: 54px; margin: 8px 8px 0; border: 3px solid var(--ink); border-radius: 8px; background: var(--brand); color: var(--ink); box-shadow: 3px -3px 0 var(--cream), 6px -6px 0 var(--ink), var(--shadow); }
.pile-count { position: absolute; bottom: -8px; right: -9px; border: 3px solid var(--ink); border-radius: 999px; background: var(--cream); min-width: 26px; padding: 0 3px; text-align: center; font-size: 12px; font-weight: 600; }
.rejects { display: grid; grid-template-rows: repeat(2,auto); grid-auto-flow: column; gap: 6px 10px; padding: 3px 4px; }
.rejected-group { position: relative; justify-self: start; width: max-content; display: flex; gap: 3px; padding-top: 3px; transform: rotate(-4deg); }
.reject-label { position: absolute; z-index: 1; top: -6px; right: -8px; /* top-right: mini cards print their number top-left */ background: var(--reject); color: var(--ink); border: 3px solid var(--ink); border-radius: 999px; font-size: 10px; font-weight: 800; padding: 0 4px; }
.drop-hint { display: none; position: absolute; top: 8px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--pop); color: var(--ink); border: 3px solid var(--ink); border-radius: 999px; padding: 5px 12px; font-weight: 800; }
.drop-ready { outline: 3px dashed var(--pop); outline-offset: -6px; }
.drop-ready .drop-hint { display: block; }
.feed { display: none; }
.tray { position: relative; z-index: var(--z-dock); width: 100%; max-width: 560px; margin: auto; padding: 8px 10px max(6px,env(safe-area-inset-bottom)); border: 3px solid var(--ink); border-bottom: 0; border-radius: 16px 16px 0 0; background: var(--table-2); box-shadow: var(--shadow); }
.tray.your-turn { box-shadow: 0 0 0 3px var(--pop); animation: dock-pulse 3s ease-in-out infinite; }
.turn-banner { text-align: center; font-size: 16px; font-weight: 600; line-height: 1.5; min-height: 24px; }
.your-turn .turn-banner { color: var(--pop); }
.waiting::after { content: ' ● ● ●'; display: inline-block; font-size: 9px; animation: dots 1.3s ease-in-out infinite; }
.hand { position: relative; height: 156px; overflow: visible; margin: 0 0 4px; }
.hand .card { position: absolute; top: 28px; touch-action: none; transform: translateY(var(--arc)) rotate(var(--angle)); transition: transform 260ms var(--ease); z-index: var(--order); }
.hand .card-motion { animation: wobble 3.6s ease-in-out infinite; animation-delay: var(--delay); }
.hand .card.selected { transform: translateY(-22px) rotate(0); z-index: 16; }
.hand .selected .card-face { box-shadow: 0 0 0 3px var(--pop), var(--shadow); }
.hand .card:disabled { opacity: .9; }
.hand .card.dragging { z-index: 20; transition: none; }
.hand .card.following { z-index: 19; transition: transform 180ms var(--ease); }
.hand .following .card-motion { animation: none; }
.hand .dragging .card-motion, .hand .selected .card-motion { animation: none; }
.badge { position: absolute; top: -10px; right: -7px; width: 27px; height: 27px; display: grid; place-items: center; background: var(--pop); color: var(--ink); border: 3px solid var(--ink); border-radius: 50%; box-shadow: 0 3px 0 var(--ink); font-size: 15px; font-weight: 800; }
.actions { display: flex; gap: 6px; }
.actions button { padding: 6px 9px; font-size: 14px; white-space: nowrap; }
.actions .primary { flex: 1; font-size: 18px; }
.reactions { display: flex; justify-content: center; gap: 12px; padding: 10px 0 3px; }
.reactions button { width: 44px; height: 44px; padding: 0; font-size: 24px; }
.options { display: flex; gap: 8px; margin: 10px 0 14px; perspective: 800px; }
.guess-card { position: relative; flex: 1; min-width: 0; height: 154px; padding: 10px; font-size: 14px; border-radius: 12px; transform-style: preserve-3d; animation: deal 450ms var(--ease) both; animation-delay: var(--delay); }
.guess-face { display: grid; place-items: center; height: 100%; backface-visibility: hidden; overflow-wrap: anywhere; }
.guess-back { position: absolute; inset: 0; padding: 12px; border-radius: 8px; background: var(--brand); transform: rotateY(180deg); backface-visibility: hidden; }
.guess-card.chosen { transform: translateY(-10px); box-shadow: 0 0 0 3px var(--pop), var(--shadow); animation: none; }
.guess-hidden { flex: 1; height: 116px; padding: 20px; background: var(--brand); color: var(--ink); border: 3px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); }
.tray > .primary { width: 100%; margin-top: 12px; }
.connection { position: fixed; z-index: var(--z-toast); top: 8px; left: 8px; right: 8px; margin: auto; max-width: 520px; text-align: center; background: var(--warn); color: var(--ink); padding: 8px 12px; border: 3px solid var(--ink); border-radius: 999px; box-shadow: var(--shadow); }
.connection:empty, .toast:empty { display: none; }
.toast { position: fixed; z-index: var(--z-toast); top: max(10px,env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); padding: 10px 16px; border: 3px solid var(--ink); border-radius: 999px; box-shadow: var(--shadow); background: var(--cream); color: var(--ink); text-align: center; pointer-events: none; animation: toast-in 200ms var(--ease); }
.moment { position: fixed; inset: 0; z-index: var(--z-verdict); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; pointer-events: none; background: oklch(0.15 0.05 330 / .6); overflow: hidden; }
.moment-name { font-size: 24px; font-weight: 800; text-shadow: 0 2px 0 var(--ink); }
.moment-cards { display: flex; justify-content: center; max-width: calc(100vw - 40px); }
.moment-cards .card { width: 112px; height: 156px; margin: 0 -8px; transform: rotate(-5deg); }
.moment-cards .card:nth-child(even) { transform: rotate(5deg); }
.moment-cards:has(.card:nth-child(4)) .card { width: min(80px, 15vw); height: 112px; margin: 0 -5px; }
.moment-cards .art { width: 80%; height: 65%; top: 23%; left: 12%; }
.moment-cards .n { font-size: 28px; }
.verdict:not(.accepted):not(.rejected) .moment-cards { animation: anticipation 150ms ease-in-out infinite alternate; }
.drumroll { font-size: 24px; color: var(--pop); animation: dots 500ms ease-in-out infinite; }
.stamp { display: block; max-width: calc(100vw - 24px); text-align: center; line-height: 1.15; padding: 10px 22px; border: 3px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); color: var(--ink); font-size: clamp(36px, 12vw, 56px); font-weight: 900; font-style: italic; transform: rotate(-8deg); overflow-wrap: anywhere; }
.accept { background: var(--accept); }
.reject { background: var(--reject); }
.accepted { background-image: radial-gradient(circle, oklch(.8 .19 155 / .24), transparent 65%); }
.takeover { position: fixed; inset: 0; width: 100%; height: 100dvh; z-index: var(--z-takeover); background: var(--pop); border: 0; border-radius: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; animation: takeover 350ms var(--ease); }
.takeover strong { font-size: 64px; font-style: italic; font-weight: 900; }
.takeover-avatar { border: 3px solid var(--ink); background: var(--brand); box-shadow: var(--shadow); border-radius: 999px; padding: 12px 24px; max-width: 90%; overflow-wrap: anywhere; font-size: 24px; }
.floating-emoji { position: fixed; z-index: var(--z-reaction); pointer-events: none; font-size: 40px; line-height: 1; }
.confetti { position: fixed; inset: 0; z-index: var(--z-reaction); pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; bottom: 0; width: 8px; height: 14px; }
@keyframes wobble { 0%,100% { transform: translateY(0) rotate(-1.2deg); } 50% { transform: translateY(-2px) rotate(1.2deg); } }
@keyframes pop-in { from { transform: scale(0); } 70% { transform: scale(1.1); } to { transform: scale(1); } }
@keyframes dots { 50% { opacity: .35; transform: translateY(-3px); } }
@keyframes tension { 50% { transform: scale(1.08); } }
@keyframes dock-pulse { 50% { box-shadow: 0 0 0 5px oklch(.92 .19 115 / .45); } }
@keyframes deal { from { transform: translateY(20px) rotateY(180deg); } 30% { transform: rotateY(180deg); } to { transform: rotateY(0); } }
@keyframes anticipation { to { transform: rotate(1.5deg) translateY(-3px); } }
@keyframes takeover { from { clip-path: circle(0 at 50% 100%); } to { clip-path: circle(150% at 50% 100%); } }
@keyframes toast-in { from { transform: translate(-50%,-30px); opacity: 0; } to { transform: translate(-50%,0); opacity: 1; } }
@media (min-width: 900px) {
  .feed { display: block; width: 220px; flex: 0 0 220px; padding: 16px; overflow-y: auto; }
  .log { list-style: none; margin: 0; padding: 0; }
  .log li { margin-top: 16px; font-size: 14px; color: var(--muted); }
  .rejects { grid-template-rows: repeat(3,auto); }
  .board-row { padding: 24px 18px; gap: 20px; }
  .board-column > .card, .rule-back { width: 96px; height: 134px; }
  .rule-back { flex-basis: 96px; }
  .board-column > .card .art { width: 72px; height: 72px; top: 32px; left: 15px; }
}
@media (max-height: 680px) {
  .hand { height: 145px; }
  .players { padding-top: 13px; padding-bottom: 4px; }
  .reactions { padding-top: 7px; }
  .board-row { padding-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .hand .card, .hero-fan .card { transform: none; }
  .hand .selected { transform: translateY(-22px); }
  .card-face { transform: none !important; }
  .sheen, .confetti { display: none; }
  .takeover { height: auto; bottom: auto; padding: 16px; }
  .takeover strong { font-size: 44px; }
  .rejected-group, .moment-cards .card { transform: none; }
}
.rule-back.flipped { flex-basis: 168px; width: 168px; height: 174px; }
.flipped .rule-face { font-size: 16px; padding: 12px; }
.flipped .rule-face small { font-size: 12px; margin-bottom: 8px; }
.takeover .takeover-avatar { width: 88px; height: 88px; padding: 0; font-size: 44px; }
.options:has(.guess-card) { flex-direction: column; gap: 8px; }
.guess-card { flex: auto; width: 100%; height: auto; min-height: 64px; padding: 10px 14px; text-align: left; }
.guess-face { min-height: 38px; }
