:root {
  color-scheme: dark;
  --bg: #090b10;
  --panel: #111722;
  --border: #2a374c;
  --text: #eef2fa;
  --muted: #a2aec1;
  --accent: #a9c9ff;
  --accent-surface: #1b2c46;
  --action: #b73550;
  --action-hover: #c2415c;
  --red: #f2887d;
  --green: #9dc993;
  --blue: #91b8f1;
  --rainbow: #d4a9f0;
  font: 16px/1.55 Inter, 'Malgun Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: radial-gradient(ellipse 750px 360px at 20% 0, #15223a, transparent), radial-gradient(ellipse 540px 320px at 90% 5%, #281420, transparent), var(--bg); color: var(--text); }
body > main { flex: 1; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .46; }
button, input, select, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
button, input, select { border-radius: 8px; }
input, select { min-width: 0; border: 1px solid var(--border); background: #0b1018; color: var(--text); padding: .68rem .85rem; }
input::placeholder { color: #8797ad; }
.frame { width: min(1160px, calc(100% - 64px)); margin-inline: auto; }
.topbar { border-bottom: 1px solid #202a3a; }
.header-inner { height: 73px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.header-actions { display: flex; align-items: center; justify-content: end; gap: 6px; min-width: 0; }
.brand { display: inline-flex; align-items: center; gap: 13px; font-weight: 850; font-size: 1.19rem; letter-spacing: -.05em; }
.brand-mark { width: 34px; height: 34px; background: url('/favicon.svg') center/cover; border: 1px solid #334766; border-radius: 8px; }
.brand-three { color: var(--accent); }
.quiet { display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); border: 1px solid var(--border); background: #141c29; padding: .48rem .78rem; font-size: .85rem; font-weight: 700; }
.quiet:hover:not(:disabled) { color: var(--text); border-color: #506c96; }
.profile { min-width: 0; max-width: 180px; }
.sound-button { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; }
.sound-button[aria-pressed="true"] { color: var(--accent); }
.sound-button[aria-pressed="true"] .sound-muted, .sound-button[aria-pressed="false"] .sound-waves { display: none; }
.profile span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-icon { color: var(--accent); font-size: .63rem; }
.footer { display: grid; gap: 8px; border-top: 1px solid var(--border); margin-top: 45px; padding-block: 19px 25px; font-size: .78rem; color: var(--muted); }
.footer-credit { display: flex; justify-content: space-between; gap: 12px; }
.footer-link { justify-self: center; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--accent); text-decoration: underline; text-underline-offset: .22em; }
.footer-link:hover { color: var(--text); }
.hero { display: grid; justify-items: center; padding: clamp(12px, 4vw, 32px); margin-top: clamp(12px, 3vw, 34px); }
.hero img { display: block; width: min(100%, 620px); height: auto; }
.home-grid { display: grid; grid-template-columns: 1.28fr 1fr; gap: 21px; margin-top: 29px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 13px; padding: 23px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.panel h2 { font-size: 1.15rem; line-height: 1.3; letter-spacing: -.045em; }
.panel-note { color: var(--muted); font-size: .86rem; }
.game-option { display: flex; align-items: center; text-align: left; gap: 13px; width: 100%; border: 1px solid #3d5880; background: #172237; color: var(--text); padding: 10px 13px; margin-bottom: 13px; }
.game-option:hover { border-color: var(--accent); }
.game-icon { display: grid; place-items: center; flex: 0 0 41px; height: 41px; border-radius: 7px; color: var(--accent); background: var(--accent-surface); }
.game-icon svg { width: 24px; height: 24px; }
.game-icon-risk { color: #ffacbd; background: #382033; }
.poker-icon { font-size: 1.55rem; }
.game-option strong, .game-option small { display: block; }
.game-option small { color: var(--muted); font-size: .75rem; }
.game-option input { margin-left: auto; width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.primary, .secondary { border: 1px solid transparent; padding: .68rem .98rem; font-size: .87rem; font-weight: 800; }
.primary { color: #fff; background: var(--action); }
.primary:hover:not(:disabled) { background: var(--action-hover); }
.secondary { color: var(--text); background: #1b2536; border-color: #35465f; }
.secondary:hover:not(:disabled) { border-color: var(--accent); }
.wide { width: 100%; }
.practice-actions:not([hidden]) { display: grid; margin-top: 8px; text-align: center; }
.join-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 14px; }
.join-form input { width: 100%; font-size: .84rem; }
.code-cells { display: flex; flex-wrap: nowrap; gap: clamp(4px, 1vw, 8px); min-width: 0; }
.code-cells input { flex: 1 1 0; min-height: 48px; padding: 0; text-align: center; font: 750 clamp(1rem, 3vw, 1.4rem)/1 Consolas, monospace; }
.code-cells input:valid { border-color: #3d5880; }
.join-panel { display: flex; flex-direction: column; }
.join-error { margin-top: 10px; padding: 8px 10px; border: 1px solid #783747; border-radius: 7px; background: #2a1520; color: #ffb5c3; font-size: .83rem; }
.join-panel .resume { margin-top: auto; padding-top: 14px; color: var(--accent); font-size: .83rem; }
.link-button { background: none; color: var(--accent); border: 0; padding: 0; font-size: .83rem; text-align: left; }
.link-button:hover { text-decoration: underline; }
.page-head { margin-block: 27px 22px; }
.page-head h1 { font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -.07em; }
.back { display: inline-block; color: var(--muted); font-size: .83rem; margin-bottom: 8px; }
.title-row, .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.title-row { justify-content: space-between; }
.game-change-options { display: grid; gap: 8px; margin-top: 14px; }
.game-change-options button { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; }
.game-change-options button span { color: var(--muted); white-space: nowrap; }
.game-change-warning { background: #311e26; color: #ffd8cf; border: 1px solid #73434d; border-radius: 8px; padding: 10px 12px; margin: 12px 0 8px; }
.game-change-names { margin: 0 0 14px; padding-inline-start: 1.5rem; overflow-wrap: anywhere; }
.lobby-spectators { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; }
.lobby-spectators h3 { margin: 0; font-size: .95rem; }
.spectator-list { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 10px 0 0; }
.spectator-list li { border: 1px solid var(--border); border-radius: 7px; padding: 4px 8px; overflow-wrap: anywhere; }
.spectator-badge { color: var(--accent); }
.room-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; gap: 18px; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.room-code { font: 750 clamp(1.7rem, 4vw, 2.5rem)/1.35 Consolas, monospace; letter-spacing: .12em; color: var(--accent); margin-block: 6px 12px; }
.seats { padding: 0; margin: 0; display: grid; list-style: none; }
.seat { display: flex; align-items: center; gap: 11px; padding-block: 9px; min-height: 49px; border-bottom: 1px solid #283344; }
.seat:last-child { border-bottom: 0; }
.seat-num { flex: 0 0 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; background: #202c40; font: 700 .82rem Consolas, monospace; color: var(--muted); }
.seat.active .seat-num { background: var(--accent); color: #0b162a; }
.seat-name { min-width: 0; overflow-wrap: anywhere; }
.inspect-hand { min-height: 32px; font: inherit; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.remaining-hand { display: grid; gap: 8px; margin-top: 12px; }
.remaining-hand h3 { font-size: .9rem; }
.remaining-list { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.remaining-chips li { background: var(--accent-surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 7px; }
.seat-end { margin-left: auto; flex-shrink: 0; color: var(--muted); font-size: .8rem; }
.seat-end strong { color: var(--text); }
.tag { display: inline-block; border: 1px solid #3c5277; border-radius: 4px; color: var(--accent); font-size: .66rem; padding: 0 4px; vertical-align: middle; margin-left: 3px; }
.settings { display: grid; gap: 11px; }
.settings label { display: grid; gap: 5px; font-size: .84rem; }
.lobby-ready { background: linear-gradient(140deg, #19263b, #111722 65%); border-color: #3b5274; }
.lobby-ready .panel-head { margin: 0; }
.lobby-ready .primary { display: flex; justify-content: center; gap: 16px; }
.ready-status { display: inline-flex; align-items: center; min-height: 28px; border-radius: 20px; padding: 3px 9px; background: #1b2330; color: var(--muted); font-size: .73rem; }
.ready-status.is-ready { color: #b7d5ff; background: #223c60; }
.connection-status:not([hidden]) { position: sticky; top: 0; z-index: 8; margin: 0; padding: 10px 16px; text-align: center; background: #352438; color: #ffd9df; font-size: .82rem; border-bottom: 1px solid #6f4256; pointer-events: none; }
.practice-exit { min-height: 44px; margin-bottom: 10px; border-radius: 8px; color: var(--text); }
.start-stage {
  display: grid; place-items: center; align-content: center; gap: 12px;
  min-height: clamp(300px, 54svh, 480px); padding: 32px 16px;
  border-block: 1px solid #313b4e;
  background: radial-gradient(ellipse at 50% 35%, #242339 0%, transparent 60%),
    repeating-linear-gradient(116deg, transparent 0 59px, #8ba2cd08 59px 60px), #0a0d15;
  text-align: center;
}
.start-round { color: var(--muted); font-size: .8rem; }
.start-countdown { display: grid; place-items: center; height: clamp(116px, 26vw, 188px); }
.start-countdown strong {
  color: #f6f2ec; font: 850 clamp(7rem, 20vw, 12rem)/.9 system-ui, sans-serif;
  font-variant-numeric: tabular-nums; text-shadow: 0 0 44px #afbddb44;
}
.start-countdown .start-go { font-size: clamp(2.8rem, 10vw, 5rem); }
.start-progress { width: min(40%, 180px); height: 3px; margin-block: 4px 16px; background: #323749; }
.start-progress span { display: block; height: 100%; background: #e29eaa; transform-origin: left; }
.start-stage h2 { font-size: clamp(1.3rem, 4vw, 2rem); line-height: 1.2; letter-spacing: -.04em; }
.start-hint { color: #b5c4db; font-size: .9rem; line-height: 1.6; }
.start-stage .link-button { color: var(--muted); min-height: 44px; padding-inline: 12px; }
@media (prefers-reduced-motion: reduce) { .start-progress { visibility: hidden; } }
@media (max-height: 520px) {
  .start-stage { min-height: 0; gap: 8px; padding-block: 18px; }
  .start-countdown { height: 96px; }
  .start-countdown strong { font-size: 6.5rem; }
  .start-progress { margin-block: 2px 6px; }
}
.game-head { margin-block: 16px 20px; }
.game-nav, .game-status, .move-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.game-nav { margin-bottom: 12px; }
.game-nav .back { margin: 0; }
.game-status { border-bottom: 1px solid #303f58; padding-bottom: 15px; }
.game-status h1 { font-size: clamp(1.85rem, 5vw, 3.2rem); line-height: 1.12; letter-spacing: -.065em; }
.leader-draw { display: grid; justify-items: center; gap: 16px; max-width: 650px; margin-inline: auto; }
.leader-wheel-frame { position: relative; width: min(100%, 265px); padding-top: 10px; }
.leader-wheel-frame::after { content: ''; position: absolute; z-index: 1; top: 0; left: 50%; transform: translateX(-50%); border: 10px solid transparent; border-top: 18px solid #ff9cb0; border-bottom: 0; }
.leader-wheel { position: relative; aspect-ratio: 1; border: 3px solid #7896c3; border-radius: 50%; background: conic-gradient(from -25.714deg, #28446a 0 14.285%, #632e4c 0 28.571%, #315477 0 42.857%, #74344b 0 57.143%, #25416b 0 71.429%, #593251 0 85.714%, #365170 0); box-shadow: 0 8px 25px #0007; }
.leader-wheel::after { content: ''; position: absolute; inset: 43%; border: 2px solid #9db6da; border-radius: 50%; background: #142136; }
.leader-wheel-number { position: absolute; inset: 0; display: grid; justify-items: center; align-content: start; padding-top: 9%; color: #fff; font: 750 1.35rem/1 Consolas, monospace; }
.leader-wheel-number:nth-child(2) { rotate: calc(1 * 360deg / 7); }
.leader-wheel-number:nth-child(3) { rotate: calc(2 * 360deg / 7); }
.leader-wheel-number:nth-child(4) { rotate: calc(3 * 360deg / 7); }
.leader-wheel-number:nth-child(5) { rotate: calc(4 * 360deg / 7); }
.leader-wheel-number:nth-child(6) { rotate: calc(5 * 360deg / 7); }
.leader-wheel-number:nth-child(7) { rotate: calc(6 * 360deg / 7); }
.leader-draw-status { font-weight: 800; color: var(--accent); text-align: center; overflow-wrap: anywhere; }
.leader-draw-seats { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }
.leader-draw-seats li { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 4px 7px; border: 1px solid var(--border); border-radius: 7px; overflow-wrap: anywhere; }
.leader-draw-seats li.chosen { border-color: var(--accent); background: var(--accent-surface); }
.game-round { color: var(--accent); font-size: .83rem; font-weight: 700; margin-bottom: 4px; }
.game-round strong { font: 800 1.15em Consolas, monospace; }
.game-time { display: grid; place-items: center; text-align: center; gap: 3px; min-width: 96px; padding: 7px 11px; border: 1px solid #3d567c; border-radius: 8px; background: #132239; color: var(--accent); }
.game-time span { font-size: .69rem; color: #a5b7d4; }
.game-time strong { font: 750 clamp(1.25rem, 3vw, 1.8rem)/1 Consolas, monospace; font-variant-numeric: tabular-nums; }
.game-time.is-urgent { background: #351c26; border-color: #a75164; color: #ff9cac; }
.game-grid { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); }
.board-panel { background: radial-gradient(ellipse at 50% 0%, #1a2940, #101620 72%); }
.tray.tray-target { border-color: var(--color); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color) 22%, transparent); }
.move-panel { background: #111824; }
.move-panel.is-your-move { border-color: #5275a4; background: linear-gradient(160deg, #1a2c46, #111824 75%); }
.move-heading { flex-wrap: wrap; }
.move-heading h2 { overflow-wrap: anywhere; }
.move-preview { display: inline-flex; align-items: center; gap: 7px; }
.move-rock { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid #eee2c7; border-right: 3px solid #968b73; border-bottom: 3px solid #817560; border-radius: 4px; background: linear-gradient(145deg, #efe5d0, #b7ab92); color: #27241d; font: 800 1.1rem Consolas, monospace; }
.move-chip { color: var(--color); font-weight: 700; font-size: .8rem; }
.move-tray { color: var(--color); }
.move-actions { display: flex; gap: 8px; margin-top: 13px; }
.move-actions .primary { flex: 1; }
.move-actions .secondary { flex: 0 1 28%; }
.move-panel button { touch-action: manipulation; }
.submit-count { color: var(--muted); font: 700 .88rem Consolas, monospace; white-space: nowrap; }
.submit-count strong { color: var(--accent); }
.hand-group { min-width: 0; padding: 0; border: 0; margin: 0; }
.move-heading + .hand-group { margin-top: 12px; }
.hand-group .choices { display: grid; margin: 5px 0 9px; }
.card-choices { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.chip-choices { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.target-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-choices .choice { min-width: 0; min-height: 49px; padding-inline: 0; font: 750 1.2rem Consolas, monospace; background: linear-gradient(#263750, #192438); box-shadow: inset 0 -2px #0b1018; }
.card-choices .choice[aria-pressed="true"] { color: #0b162a; background: var(--accent); box-shadow: inset 0 -2px #678bc0; }
.chip-choices .choice, .target-choices .choice { min-width: 0; padding-inline: 5px; font-weight: 700; }
.chip-choices .choice { white-space: nowrap; }
.chip-choices small { margin-left: 1px; font: 700 .76rem Consolas, monospace; }
.game-sidebar .seat { padding-inline: 7px; }
.game-sidebar .seat.active { background: #1a2c46; border-radius: 6px; border-bottom-color: transparent; }
.risk-board { background: radial-gradient(ellipse at center, #1a2940, #111722 70%); }
.risk-ring { position: relative; isolation: isolate; width: min(100%, 450px); aspect-ratio: 1; margin: 0 auto; }
.risk-ring::before { content: ''; position: absolute; inset: 12%; border: 1px solid #49658e; border-radius: 50%; background: radial-gradient(circle, #1b2b43, #141c29 70%); box-shadow: 0 0 0 5px #87afff18, inset 0 0 0 8px #87afff12; }
.risk-hub { position: absolute; inset: 33%; display: grid; place-items: center; }
.risk-dial { width: 78%; aspect-ratio: 1; border: 2px solid #52709d; border-radius: 50%; background: radial-gradient(circle, #7b9ecb 0 8%, #233149 9% 45%, transparent 46%), repeating-conic-gradient(#93b9ff60 0 2deg, #1a273a 2deg 30deg); box-shadow: 0 0 0 6px #0c111a, 0 0 0 7px #3b5275, 0 8px 18px #0008; }
.risk-indicator { position: absolute; inset: 0; transform: rotate(var(--angle)); filter: drop-shadow(0 2px 2px #000c); }
.risk-silhouette { position: absolute; left: 50%; top: 50%; width: 95%; height: 48%; transform: translate(-50%, -50%) rotate(-90deg); background: linear-gradient(180deg, #e3edff 0%, #7893b9 32%, #c0d2ec 39%, #435575 68%, #8da5c9); clip-path: polygon(23% 10%, 36% 10%, 36% 16%, 92% 16%, 92% 11%, 100% 11%, 100% 43%, 44% 43%, 40% 59%, 23% 59%, 17% 90%, 12% 100%, 0 92%, 12% 44%, 8% 34%, 9% 20%, 23% 20%); }
.risk-indicator-turn { animation: risk-rotate .28s ease-out both; }
.risk-seats { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; }
.risk-seat { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: 29%; min-height: clamp(60px, 14vw, 79px); display: grid; place-content: center; gap: 1px; padding: 5px 3px; text-align: center; border: 1px solid #384960; border-radius: 9px; background: #111824; box-shadow: 0 3px 12px #0006; overflow-wrap: anywhere; }
.risk-seat > span { font-size: clamp(.72rem, 2.6vw, .94rem); }
.direction-0 { --x: 50%; --y: 12%; --angle: 0deg; }
.direction-1 { --x: 83%; --y: 31%; --angle: 60deg; }
.direction-2 { --x: 83%; --y: 69%; --angle: 120deg; }
.direction-3 { --x: 50%; --y: 88%; --angle: 180deg; }
.direction-4 { --x: 17%; --y: 69%; --angle: 240deg; }
.direction-5 { --x: 17%; --y: 31%; --angle: 300deg; }
.risk-seat-number { position: absolute; z-index: 1; bottom: calc(100% - 3px); left: 4px; display: grid; place-items: center; width: clamp(23px, 6vw, 28px); aspect-ratio: 1; border: 1px solid #5374a3; border-radius: 6px; background: #1a2a43; color: #bdd5fb; box-shadow: 0 2px 5px #0008; font: 800 clamp(.96rem, 4vw, 1.15rem)/1 Consolas, monospace; }
.risk-pointer .risk-seat-number { border-color: var(--accent); background: var(--accent); color: #0b162a; }
.risk-out .risk-seat-number { border-color: #ba586e; background: #3b1d2a; color: #ffb5c3; }
.risk-seats small { color: var(--muted); font-size: .71rem; }
.risk-slot-status, .risk-legend, .risk-event, .risk-observations { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 7px; }
.risk-slot-status, .risk-legend { justify-content: center; }
.risk-slot { display: inline-grid; place-items: center; min-width: 1.18rem; height: 1.18rem; border: 1px solid #425c84; border-radius: 4px; background: #1a2942; color: #bcd4fb; font: 750 .76rem/1 Consolas, monospace; }
.risk-mark { color: var(--muted); font-weight: 800; line-height: 1; }
.risk-mark-present { color: var(--red); }
.risk-mark-clear { color: var(--green); }
.risk-legend { gap: 4px 13px; color: var(--muted); font-size: .73rem; margin-top: 7px; }
.risk-round + .risk-round { margin-top: 13px; }
.risk-round h3 { border-bottom: 1px solid var(--border); color: var(--accent); font-size: .76rem; padding-bottom: 4px; }
.risk-visibility { padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); color: var(--muted); font-size: .69rem; }
.risk-observations { margin-top: 4px; gap: 4px 12px; }
.risk-observations > span { display: inline-flex; align-items: center; gap: 4px; }
.risk-seats .risk-pointer { border-color: var(--accent); }
.risk-seats .risk-acting { background: #1b2d49; }
.risk-seats .risk-out { border-color: #ba586e; background: #3b1d2a; }
.risk-out .risk-outcome { color: #ff9bae; font-weight: 800; }
.risk-safe .risk-outcome { color: #b3d19e; font-weight: 750; }
.risk-just-revealed .risk-outcome { animation: risk-reveal .45s ease-out both; }
@keyframes risk-rotate { from { transform: rotate(calc(var(--angle) - 60deg)); } }
@keyframes risk-reveal { 0% { opacity: 0; } 60% { opacity: 1; transform: scale(1.16); } }
@media (prefers-reduced-motion: reduce) { .risk-indicator-turn, .risk-just-revealed .risk-outcome { animation: none; } }
.risk-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 13px; }
.risk-actions small { display: block; color: var(--muted); font-size: .73rem; }
.trays { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.red { --color: var(--red); }
.green { --color: var(--green); }
.blue { --color: var(--blue); }
.rainbow { --color: var(--rainbow); }
.tray { container-type: inline-size; display: flex; flex-direction: column; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #0c111b; }
.tray.red { --plinth: #a63f34; }
.tray.green { --plinth: #427b4c; }
.tray.blue { --plinth: #3d60a8; }
.tray-stage { --plinth-width: min(100%, 168px); flex: 1; min-height: 137px; display: flex; flex-direction: column; justify-content: end; align-items: center; }
.cubes { position: relative; z-index: 1; display: flex; flex-wrap: wrap-reverse; justify-content: center; gap: 2px 3px; width: var(--plinth-width); list-style: none; margin: 0; padding: 0 0 0 3px; }
.cube { display: grid; place-items: center; inline-size: clamp(21px, 29cqi, 42px); aspect-ratio: 1; border: 1px solid #e5ddc8; border-right: 3px solid #777368; border-bottom: 3px solid #605c50; border-radius: 3px; background: repeating-linear-gradient(132deg, #ffffff20 0 1px, #3d38260e 1px 3px), linear-gradient(145deg, #ede7d4, #b8b09e); color: #27241d; box-shadow: inset 1px 1px 0 #ffffff85, 0 2px 3px #0007; font: 800 clamp(14px, 17cqi, 25px)/1 Consolas, monospace; }
.pedestal { position: relative; width: var(--plinth-width); height: 51px; margin-bottom: 9px; border-radius: 3px 3px 4px 4px; border: 1px solid var(--plinth); border-top: 7px solid var(--color); background: linear-gradient(90deg, #0004, transparent 40%, #0003), var(--plinth); box-shadow: inset 0 2px 0 #ffffff2a, inset -5px 0 0 #0003, 0 4px 7px #0005; }
.pedestal::before { content: ''; position: absolute; inset: 6px 10% 6px; border: 1px solid #ffffff38; border-radius: 2px; background: repeating-linear-gradient(90deg, #0002 0 8%, #ffffff16 8% 10%, transparent 10% 20%); }
.pedestal::after { content: ''; position: absolute; inset: auto -2px -1px; height: 5px; border-radius: 2px; background: var(--plinth); box-shadow: inset 0 1px 0 #ffffff4d, inset 0 -2px 0 #0003; }
.tray h3 { color: var(--color); font-size: .82rem; text-align: center; }
.choices { display: flex; flex-wrap: wrap; gap: 7px; margin-block: 7px 14px; }
.choice { background: #1a2433; border: 1px solid #35435a; color: var(--color, var(--text)); min-width: 41px; padding: 7px 10px; }
.choice[aria-pressed="true"] { border-color: var(--color, var(--accent)); background: #1d2e49; }
.choice:hover:not(:disabled) { border-color: var(--color, var(--accent)); }
.step-label { font-weight: 700; font-size: .84rem; }
.dot { display: inline-block; width: .63em; height: .63em; border-radius: 50%; background: var(--color); margin-right: 3px; }
.dot.rainbow { background: conic-gradient(var(--red), var(--green), var(--blue), var(--red)); }
.placement-queue { margin-top: 14px; }
.placement-queue h3 { margin-bottom: 7px; color: var(--muted); font-size: .82rem; }
.placement-queue ol { display: grid; gap: 4px; padding: 0; margin: 0; list-style: none; }
.placement-entry { display: grid; grid-template-columns: 15px minmax(0, 1fr) 118px minmax(55px, 22%); align-items: center; gap: 6px; min-height: 34px; padding: 4px 7px; border: 1px solid var(--border); border-radius: 6px; background: #151f2f; font-size: .82rem; }
.placement-entry.is-current { background: #213550; border-color: #6b92c5; }
.placement-index { color: var(--muted); font: 700 .78rem Consolas, monospace; text-align: center; }
.placement-name { overflow-wrap: anywhere; }
.placement-entry .move-preview { gap: 5px; }
.placement-entry .move-rock { flex: 0 0 23px; height: 23px; border-right-width: 2px; border-bottom-width: 2px; font-size: .9rem; }
.placement-entry .move-chip { font-size: .72rem; white-space: nowrap; }
.placement-status { display: flex; align-items: center; justify-content: end; flex-wrap: wrap; gap: 2px 5px; color: var(--muted); font-size: .7rem; white-space: nowrap; }
.placement-status strong { color: var(--accent); }
.placement-pass { color: #ffd6a1; background: #4b3223; border-radius: 4px; padding-inline: 4px; }
.logs { list-style: none; margin: 0; padding: 0; font-size: .82rem; }
.logs li { padding: 7px 0; border-bottom: 1px solid #293548; overflow-wrap: anywhere; }
.logs li:last-child { border-bottom: 0; }
.danger { color: var(--red); }
.history { margin-top: 12px; }
details { border-top: 1px solid var(--border); padding-block: 7px; }
summary { cursor: pointer; color: var(--muted); font-size: .83rem; }
.results { width: 100%; border-collapse: collapse; text-align: left; font-size: .86rem; }
.results td, .results th { padding: 9px 5px; border-bottom: 1px solid var(--border); }
.results td:nth-child(2) { overflow-wrap: anywhere; }
.results th { color: var(--muted); }
.results tr:last-child td { border-bottom: 0; }
.results .winner { color: var(--accent); }
.poker-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-block: 12px; }
.poker-board[hidden] { display: none; }
.poker-tile { display: grid; justify-items: center; align-content: center; gap: 4px; min-width: 0; padding: 3px 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: #121c2c; color: var(--accent); }
.poker-tile small { font: 700 .69rem/1.2 Consolas, monospace; }
button.poker-tile:hover, .poker-tile[aria-pressed="true"], .poker-tile.marked { border-color: var(--accent); background: #263e5c; }
.poker-card { position: relative; display: inline-grid; place-items: center; flex: none; width: 40px; aspect-ratio: 5 / 7; overflow: hidden; border: 1px solid #c8c9d3; border-radius: 6px; background: linear-gradient(145deg, #fffefa 26%, #eeedf0); color: #192235; box-shadow: 0 2px 3px #0006, inset 0 0 0 1px #fff9; font-size: 10px; vertical-align: middle; }
.poker-tile .poker-card { width: clamp(42px, 13vw, 58px); font-size: clamp(11px, 3vw, 14px); }
.poker-card-red { color: #ad213d; }
.poker-card-index { position: absolute; inset: 7% auto auto 8%; display: grid; justify-items: center; font: 700 1em/.95 Georgia, serif; }
.poker-card-index span + span { font-size: .78em; line-height: 1.02; }
.poker-card-index-bottom { inset: auto 8% 7% auto; transform: rotate(180deg); }
.poker-card-center { display: grid; justify-items: center; font: 400 2.05em/1 Georgia, serif; }
.poker-card-court { width: 48%; padding-block: .12em; border-block: 1px solid currentColor; font-size: 1.4em; line-height: .9; }
.poker-card-court b { font-weight: 700; }
.poker-card-court span { font-size: .62em; }
.poker-card-back { border-color: #8da9cc; background: #1e3457; color: #cfdef6; box-shadow: 0 2px 3px #0006, inset 0 0 0 2px #0c1830; }
.poker-card-back::before { content: ''; position: absolute; inset: 6px; border: 1px solid #89a8d380; border-radius: 3px; background: repeating-linear-gradient(45deg, transparent 0 3px, #9dbbec37 3px 4px, transparent 4px 7px), repeating-linear-gradient(-45deg, transparent 0 3px, #9dbbec37 3px 4px, transparent 4px 7px); }
.poker-card-back > span { position: relative; display: grid; place-items: center; width: 1.6em; aspect-ratio: 1; border: 1px solid #a9c9ff; border-radius: 50%; background: #182c4b; font-size: 1.15em; line-height: 1; }
.poker-tile:is([aria-pressed="true"], .marked) .poker-card-back { border-color: #d5e6ff; background: #3a5c88; }
.poker-card-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.poker-rules-title { margin-top: 16px; font-size: .95rem; }
.poker-examples { display: grid; gap: 6px; list-style: none; margin: 10px 0; padding: 0; }
.poker-examples li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px 10px; border-bottom: 1px solid var(--border); padding-bottom: 6px; font-size: .83rem; }
.poker-examples .poker-card { width: 33px; font-size: 9px; }
.poker-shared { margin-top: 10px; }
.poker-shared strong { margin-right: 5px; font-size: .85rem; }
.poker-match, .poker-result { padding-block: 9px; border-top: 1px solid var(--border); margin-top: 10px; }
.poker-result-head, .poker-result-hand { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; }
.poker-result-head { justify-content: space-between; color: var(--accent); }
.poker-result-hand { margin-top: 5px; font-size: .82rem; }
.poker-result-hand small { color: var(--muted); }
.poker-result-hand > span { overflow-wrap: anywhere; }
.poker-review { margin-top: 12px; }
.poker-review summary { color: var(--accent); }
.poker-review .panel-note { margin-top: 8px; }
.poker-best-tile { outline: 2px solid var(--accent); outline-offset: -2px; }
.inline-gap { margin-top: 13px; }
dialog { width: min(470px, calc(100% - 32px)); max-height: 88vh; background: var(--panel); color: var(--text); border: 1px solid #3c5277; border-radius: 13px; padding: 24px; }
dialog::backdrop { background: #060810d9; }
.dialog-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 11px; }
.dialog-title h2 { font-size: 1.22rem; letter-spacing: -.035em; }
.dialog-form { display: grid; gap: 10px; margin-top: 14px; }
.dialog-form label { display: grid; gap: 6px; font-size: .84rem; }
[data-dialog-error] { margin-top: 10px; font-size: .82rem; }
.rules { padding-left: 1.3em; font-size: .87rem; color: #d6deeb; }
.rules li { margin-block: 9px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 9; pointer-events: none; background: #1c2a41; border: 1px solid #46638d; color: var(--text); padding: 10px 15px; border-radius: 8px; max-width: calc(100% - 24px); font-size: .86rem; }
.room-chat { position: fixed; z-index: 5; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); display: grid; justify-items: end; width: min(370px, calc(100% - 24px)); pointer-events: none; }
.room-chat[hidden], .chat-panel[hidden] { display: none; }
.room-chat:has(.chat-panel:not([hidden])) { bottom: 0; }
.chat-panel, .chat-toggle { pointer-events: auto; box-shadow: 0 8px 24px #0008; }
.chat-panel { width: 100%; padding: 0 0 env(safe-area-inset-bottom); overflow: hidden; border-radius: 18px 18px 0 0; background: #111925; }
.chat-panel .chat-header { min-height: 45px; margin: 0; padding: 0 8px 0 16px; border-bottom: 1px solid var(--border); }
.chat-header h2 { font-size: .98rem; }
.chat-channels:not([hidden]) { display: grid; grid-template-columns: .65fr 1fr 1fr; gap: 5px; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.chat-channel { min-width: 0; min-height: 38px; padding: 4px 6px; border-color: transparent; font-size: .75rem; }
.chat-channel span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-channel[aria-pressed="true"] { background: #254772; border-color: #557caf; color: #f4f8ff; }
.chat-channel b { flex: none; color: #ffb4c4; font-size: .65rem; }
.chat-panel { --typing-list-height: 56px; }
.chat-typing { padding: 0; border: 0; color: var(--accent); background: var(--accent-surface); }
.chat-typing-summary { padding: 7px 12px; color: inherit; font-size: .75rem; }
.chat-typing-list { height: var(--typing-list-height); padding: 0 12px 5px; overflow-y: auto; overscroll-behavior: contain; white-space: pre-line; overflow-wrap: anywhere; font-size: .75rem; }
.chat-toggle, .chat-close, .chat-send { display: grid; place-items: center; flex: none; padding: 0; }
.chat-toggle svg, .chat-close svg, .chat-send svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.chat-toggle { position: relative; width: 54px; height: 54px; border: 1px solid #557caf; border-radius: 50%; background: #254772; color: #f4f8ff; }
.chat-toggle:hover { background: #315788; }
.chat-toggle[aria-expanded="true"] { display: none; }
.chat-toggle svg { width: 28px; height: 28px; }
.chat-icon-dots { stroke-width: 2.3; }
.chat-unread { position: absolute; top: -4px; right: -3px; min-width: 20px; padding: 0 4px; border: 2px solid #111925; border-radius: 12px; color: #fff; background: var(--action); font: 750 .65rem/1.45 system-ui, sans-serif; }
.chat-close { width: 44px; height: 44px; border: 0; background: transparent; }
.chat-close svg { width: 18px; height: 18px; }
.chat-messages { height: min(40dvh, 300px); overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 12px; background: #0d1420; list-style: none; }
.chat-panel:has(.chat-typing[open]:not([hidden])) .chat-messages { height: max(56px, calc(min(40dvh, 300px) - var(--typing-list-height))); }
.chat-empty { padding-top: 16px; text-align: center; color: var(--muted); font-size: .82rem; }
.chat-message { margin-bottom: 11px; }
.chat-message.is-grouped { margin-top: -7px; }
.chat-message strong { display: block; margin: 0 0 3px 4px; color: #c1cde0; font-size: .73rem; overflow-wrap: anywhere; }
.chat-message-line { display: flex; align-items: flex-end; gap: 5px; }
.chat-bubble { max-width: 77%; min-width: 0; padding: 7px 10px; border-radius: 12px 12px 12px 3px; background: #202d41; color: var(--text); font-size: .87rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.is-mine .chat-message-line { flex-direction: row-reverse; }
.is-mine .chat-bubble { border-radius: 12px 12px 3px 12px; background: #315788; color: #fff; }
.is-spectator-message .chat-bubble { background: rgb(126 153 196 / 14%); color: #c7d3e5; }
.is-spectator-message.is-mine strong { text-align: right; margin-right: 4px; }
.chat-spectator-tag { padding-inline: 4px; border: 1px solid #455570; border-radius: 4px; color: var(--muted); font-size: .65rem; font-weight: 650; }
.chat-message time { flex: none; color: var(--muted); font-size: .64rem; white-space: nowrap; }
.chat-system { margin-inline: auto; max-width: 92%; padding: 7px 10px; border: 1px solid #50463c; border-radius: 8px; background: #241f23; color: #f4dbb5; text-align: center; font-size: .75rem; }
.chat-message.chat-system strong { margin: 0 0 3px; color: inherit; }
.chat-form { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 7px; padding: 8px 10px; border-top: 1px solid var(--border); }
.chat-form input { min-height: 44px; border-radius: 22px; font-size: 16px; }
.chat-send { width: 44px; height: 44px; border-radius: 50%; background: #315788; }
.chat-send:hover:not(:disabled) { background: #42699a; }
.chat-error { padding: 0 12px 8px; font-size: .8rem; }
.squares-target { color: var(--accent); }
.squares-panel h2.squares-target { font: 800 2.2rem/1.1 Consolas, monospace; }
.squares-board { display: grid; width: min(100%, 440px); margin: 12px auto; }
.squares-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.squares-row span { display: grid; place-items: center; aspect-ratio: 1; background: #152238; color: #f4f7ff; box-shadow: inset 0 0 0 1px #415b81; font: 750 clamp(1rem, 4vw, 1.75rem)/1 Consolas, monospace; }
.squares-row span:empty { background: #101a2a; }
.squares-row span.squares-outside { background: transparent; box-shadow: none; }
.squares-status { min-height: 1.5em; color: var(--muted); font-size: .87rem; }
.squares-answer { margin-top: 8px; color: var(--accent); }
.squares-buzzer { margin-top: 12px; }
.squares-form input { font-size: 16px; }
.cube-stage {
  overflow: hidden;
  border: 1px solid #283d5b;
  border-radius: 10px;
  background: radial-gradient(ellipse at 48% 42%, #223656, #0b1220 74%);
}
.cube-canvas { display: block; width: 100%; height: clamp(255px, 45vw, 445px); }
.cube-answer { color: var(--muted); font-size: .86rem; }
.cube-answer strong { margin-left: 5px; color: var(--accent); font-size: 1.28rem; }
.cube-form label { display: block; margin-bottom: 8px; font-weight: 750; }
.cube-form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.cube-form-row input { font-size: 16px; }
.cube-retry { margin-top: 9px; color: var(--red); font-size: .85rem; font-variant-numeric: tabular-nums; }
.cube-entry h2 + .panel-note { margin-top: 6px; }
.cube-results ol { display: grid; gap: 5px; padding: 0; margin: 0; list-style: none; }
.cube-results li { display: flex; align-items: baseline; gap: 12px; padding: 8px 9px; border-radius: 7px; background: #172237; overflow-wrap: anywhere; }
.cube-rank { flex: 0 0 3em; color: var(--accent); font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cube-rank.unfinished { color: var(--muted); }

@media (max-width: 760px) {
  .room-chat:has(.chat-panel:not([hidden])) { width: 100%; right: 0; }
  .lobby-grid > .stack { display: contents; }
  .lobby-ready { grid-row: 1; }
  .lobby-roster { grid-row: 2; }
  .lobby-invite { grid-row: 3; }
  .frame { width: calc(100% - 32px); }
  .header-inner { height: 60px; }
  .brand { gap: 8px; font-size: 1rem; white-space: nowrap; }
  .brand-mark { width: 29px; height: 29px; }
  .profile-icon { display: none; }
  .home-grid, .room-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .home-grid { margin-top: 17px; }
  .panel { padding: 13px; }
  .stack { gap: 12px; }
  .page-head { margin-block: 12px; }
  .title-row { gap: 5px 10px; }
  .title-row h1 { font-size: 1.65rem; }
  .title-row .actions { gap: 5px; }
  .game-head { margin-block: 7px 10px; }
  .game-nav { margin-bottom: 3px; }
  .game-status { padding-bottom: 8px; }
  .game-time { min-width: 79px; padding: 5px 8px; }
  .trays { gap: 6px; margin-top: 7px; }
  .tray { padding: 5px; }
  .tray-stage { min-height: 78px; }
  .pedestal { height: 33px; border-top-width: 5px; margin-bottom: 5px; }
  .pedestal::before { inset-block: 4px; }
  .pedestal::after { height: 3px; }
  .hand-group .choices { gap: 4px; }
  .choice, .primary, .secondary, .quiet { min-height: 44px; }
  .card-choices .choice { min-height: 44px; }
  .chip-choices .choice { font-size: .85rem; padding-inline: 4px; }
  .join-form input:not([name="digit"]), .dialog-form input, .settings select { font-size: 16px; }
  .seat { gap: 7px; }
  .seat-end { font-size: .75rem; }
  dialog { max-height: 88dvh; padding: 16px; }
  .footer { margin-top: 30px; }
}

@media (max-width: 380px) {
  .frame { width: calc(100% - 22px); }
  .trays { gap: 5px; }
}

@media (max-width: 460px) {
  .chip-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
