:root {
  color-scheme: dark;
  --bg: #070912;
  --panel: rgba(14, 19, 34, 0.9);
  --line: rgba(212, 242, 235, 0.12);
  --text: #f1f5f9;
  --muted: #9aabc2;
  --accent: #5ee0e6;
  --cyan: #5ee0e6;
  --red: #e8383d;
  --team-a: #22d3ee;
  --team-b: #ff8fd6;
  --team-c: #c084fc;
  --team-d: #a3e635;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; overflow: hidden; }
#stage { position: fixed; inset: 0; }
.hidden { display: none !important; }
button { font: inherit; color: var(--text); background: #202a41; border: 1px solid var(--line); border-radius: 12px; padding: 11px 18px; min-height: 44px; cursor: pointer; font-weight: 600; transition: transform .15s, background .15s, border-color .15s; touch-action: manipulation; }
button:hover { background: #2c3959; border-color: #7087a7; }
button:active { transform: scale(.97); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: #111; border-color: transparent; }
button.primary:hover { background: #91eef2; box-shadow: 0 4px 24px #5ee0e618; }
button.danger { background: var(--red); border-color: transparent; }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 6px; }
input, select { font: inherit; font-size: 16px; color: var(--text); background: #0c1120; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; min-height: 46px; max-width: 100%; min-width: 0; }
input::placeholder { color: #718480; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
input:focus, select:focus { border-color: var(--accent); }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; color: var(--muted); }

.screen { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1fr); place-items: safe center; padding: 24px; background: radial-gradient(ellipse at top, #172c5080, #070912c9); overflow-y: auto; overscroll-behavior: contain; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 28px; box-shadow: 0 20px 60px #0003; backdrop-filter: blur(16px); text-align: center; max-width: 100%; }
.home-panel { width: min(1120px, 100%); margin: auto; }
.logo { margin: 0; line-height: 0; }
.logo img { width: 210px; max-width: 60vw; height: auto; filter: drop-shadow(0 8px 24px rgba(94, 224, 230, .25)); }
.tag { margin: 0; color: var(--muted); }
.seg { display: inline-flex; background: #0c1120; border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; justify-content: center; }
.seg button { background: none; border: none; padding: 8px 12px; border-radius: 9px; color: var(--muted); }
.seg button.on { background: #283a53; color: var(--accent); }
.mode-pick { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.join-row input { width: 110px; text-transform: uppercase; text-align: center; letter-spacing: 4px; font-weight: 700; }

.lobby-panel { width: min(640px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 12px; }
.lobby-head { display: flex; justify-content: space-between; align-items: center; text-align: left; }
.code { font: 900 40px/1 "Arial Black", Arial, sans-serif; letter-spacing: 6px; color: var(--accent); }
#hostConfig { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.teams { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.team { border: 2px solid var(--tc); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.team h4 { margin: 0 0 4px; color: var(--tc); }
.seat { display: flex; align-items: center; justify-content: space-between; gap: 6px; background: #0c1120; border-radius: 10px; padding: 6px 8px; min-height: 48px; font-size: 14px; }
.seat.me { outline: 2px solid var(--accent); }
.seat button { padding: 4px 8px; font-size: 12px; }
.seat .empty { color: var(--muted); font-style: italic; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.top-left { position: absolute; top: 12px; left: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; }
#scores div { display: flex; gap: 10px; justify-content: space-between; }
#scores .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.top-center { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none !important; }
#status { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 18px; font-weight: 700; white-space: nowrap; }
#status.mine { background: var(--accent); color: #111; }
.timer { height: 4px; background: rgba(255,255,255,.1); border-radius: 4px; margin: 6px auto 0; width: 160px; overflow: hidden; }
#timerBar { height: 100%; width: 0; background: var(--accent); }
.top-right { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
button.icon { padding: 6px 10px; }
#log { width: 260px; max-height: 40vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 12px; text-align: left; }
#log div { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
#poolLabel { position: absolute; left: 12px; bottom: calc(26vh + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 14px; font-size: 13px; white-space: nowrap; pointer-events: none !important; }
.actions { position: absolute; right: 14px; bottom: calc(26vh + 4px); display: flex; flex-direction: column; gap: 8px; }
.actions button { min-width: 96px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
button.call { background: var(--red); border-color: transparent; font: italic 900 18px "Arial Black", Arial, sans-serif; }
button.call.ready { animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 24px var(--red); } }
.callout { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); font: italic 900 64px "Arial Black", Arial, sans-serif; color: var(--accent); text-shadow: 3px 3px 0 var(--cyan), 6px 6px 0 #111; pointer-events: none !important; animation: pop 1.2s ease-out forwards; white-space: nowrap; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(.3); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(-50%, -60%) scale(1); opacity: 0; } }

.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.45); padding: 16px; z-index: 5; }
.modal h2, .modal h3 { margin: 0 0 10px; }
.colors { display: grid; grid-template-columns: repeat(2, 84px); gap: 10px; justify-content: center; }
.colors button { height: 84px; background: var(--c); border: 3px solid rgba(255,255,255,.6); border-radius: 16px; }
.colors button:hover { filter: brightness(1.15); background: var(--c); }
.rules { max-width: 520px; text-align: left; max-height: 85vh; overflow-y: auto; }
.rules h3 { margin: 14px 0 4px; color: var(--accent); }
#overScores { margin: 10px 0; }
#overScores div { display: flex; justify-content: space-between; gap: 24px; padding: 4px 0; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #2a1215; border: 1px solid var(--red); padding: 10px 16px; border-radius: 10px; z-index: 10; max-width: calc(100% - 32px); }

/* Icon buttons: icon plus label on wide screens, icon only on phones. */
button.icon { display: inline-flex; align-items: center; gap: 6px; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* The scene sets --hand-top to the top edge of the hand, so the pool label and buttons sit right above it. */
#poolLabel { bottom: auto; top: calc(var(--hand-top, 74vh) - 34px); }
.actions { bottom: auto; top: calc(var(--hand-top, 74vh) - 12px); transform: translateY(-100%); }

@media (max-width: 640px), (max-height: 500px) {
  .logo img { width: 160px; }
  .top-left { top: 8px; left: 8px; font-size: 12px; padding: 5px 9px; max-width: calc(100% - 150px); }
  #hudRoom { display: none; }
  #scores { display: flex; flex-wrap: wrap; gap: 2px 12px; }
  #scores div { gap: 5px; }
  #scores .wide { display: none; }
  #scores .nm { display: inline-block; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
  #scores .minor { display: none; }
  #scores .me { text-decoration: underline; text-underline-offset: 3px; }
  .top-right { top: 8px; right: 8px; }
  .top-right .lbl { display: none; }
  button.icon { padding: 8px; border-radius: 10px; }
  #log { width: min(260px, calc(100vw - 16px)); }
  .top-center { top: var(--status-top, 54px); }
  #status { font-size: 13px; padding: 6px 14px; }
  .timer { width: 120px; }
  #poolLabel { left: 8px; font-size: 12px; padding: 4px 10px; top: calc(var(--hand-top, 74vh) - 32px); max-width: calc(100% - 190px); overflow: hidden; text-overflow: ellipsis; }
  #poolLabel .extra { display: none; }
  .actions { right: 8px; flex-direction: row; top: calc(var(--hand-top, 74vh) - 6px); gap: 6px; }
  .actions button { min-width: 0; padding: 8px 12px; font-size: 14px; }
  .callout { font-size: 44px; }
}
/* Phones held sideways: there is room for the turn banner between the scores and the buttons. */
@media (max-height: 500px) and (min-width: 641px) {
  .top-center { top: 8px; }
  #poolLabel .extra { display: inline; }
}

.check { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); }
.host-box { text-align: left; background: #0c1120; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.host-box summary { cursor: pointer; font-weight: 600; }
.host-box[open] { display: flex; flex-direction: column; gap: 10px; }
.browser { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.browser-head { display: flex; justify-content: space-between; align-items: baseline; }
.room-list { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.room-item { display: flex; align-items: center; gap: 10px; background: #0c1120; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.room-item .info { flex: 1; min-width: 0; }
.room-item .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-item .meta { font-size: 12px; color: var(--muted); }
.room-item button { padding: 6px 12px; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: #283152; margin-left: 6px; vertical-align: 1px; }
.pill.live { background: #14532d; color: #bbf7d0; }
.lobby-name { font-size: 20px; font-weight: 700; text-align: left; }
.row.tight { margin: 0; gap: 6px; }
.spectate { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 16px; white-space: nowrap; }
.spectate button { padding: 6px 14px; }

.settings { border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px 12px; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 16px; text-align: left; margin: 0; min-width: 0; }
.settings legend { padding: 0 6px; font-weight: 700; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.settings label.toggle { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.settings input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.settings select:disabled, .settings input:disabled { opacity: .6; }
.settings p { grid-column: 1 / -1; margin: 0; }
.settings label.preset { grid-column: 1 / -1; }
.colors button:disabled { opacity: .25; cursor: not-allowed; }
#teamChoices { justify-content: center; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

/* Card style picker */
.back-strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: thin; min-width: 0; contain: inline-size; }
.back-strip button { flex: 0 0 auto; width: 54px; height: 81px; padding: 0; border: 2px solid transparent; border-radius: 9px; background: none; overflow: hidden; opacity: .75; transition: transform .12s, opacity .12s; }
.back-strip button:hover { opacity: 1; transform: translateY(-2px); background: none; }
.back-strip button.on { border-color: var(--accent); opacity: 1; box-shadow: 0 0 0 2px rgba(255, 159, 220, .25); }
.back-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.back-name { font-weight: 600; color: var(--text); }

/* The game-night landing page. All artwork is local and works offline. */
#home { background: linear-gradient(90deg, #070912a8, #07091275 55%, #070912a3); display: block; padding: 0 40px; }
#home::before { content: none; }
.home-panel { position: relative; }
.home-header { display: flex; align-items: center; gap: 28px; padding: 26px 0; border-bottom: 1px solid var(--line); }
.wordmark { color: var(--text); text-decoration: none; font-size: 46px; line-height: 1; font-weight: 900; letter-spacing: -4px; display: inline-flex; align-items: baseline; gap: 8px; }
.wordmark { letter-spacing: -2px; font-size: 38px; }
.account-button { font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-browser-button { display: flex; align-items: center; justify-content: space-between; background: #24334e; }
.dialog-head { display: flex; align-items: flex-start; gap: 16px; justify-content: space-between; text-align: left; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 6px 0 0; font-size: 28px; letter-spacing: -.8px; }
.dialog-close { flex-shrink: 0; padding: 8px 12px; min-width: 44px; }
.modal > .panel.server-browser-panel { width: min(880px, 100%); text-align: left; }
.server-browser-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.server-browser-grid .browser { padding: 24px 24px 0 0; }
.server-browser-grid h3 { font-size: 15px; margin: 0; display: flex; align-items: center; gap: 10px; }
.server-browser-grid .room-list { max-height: 340px; margin-top: 18px; }
.create-server { border-left: 1px solid var(--line); margin-top: 24px; padding-left: 24px; }
.create-server .field { margin-top: 20px; }
.create-server .check { justify-content: flex-start; margin-top: 16px; color: var(--text); }
.create-server .check input, #lobbyLocked { width: 18px; min-height: 18px; height: 18px; accent-color: var(--accent); }
.create-server p { font-size: 12px; }
.create-server > button { width: 100%; }
.locked-join { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.locked-join summary { font-size: 12px; cursor: pointer; padding: 8px 0; }
.refresh-button { margin-left: auto; padding: 6px 10px; font-size: 20px; background: transparent; }
.empty-servers { display: flex; flex-direction: column; align-items: center; text-align: center; color: var(--muted); padding: 28px 12px; gap: 10px; }
.empty-servers > span { color: var(--cyan); font-size: 38px; }
.empty-servers b { color: var(--text); font-size: 15px; }
.empty-servers p { font-size: 12px; margin: 0; line-height: 1.7; max-width: 260px; }
.access-badge { font-size: 12px; color: var(--accent); text-align: left; }
.login-panel { text-align: left; }
.login-providers { display: flex; flex-direction: column; gap: 10px; margin: 22px 0 16px; }
.login-providers button { display: flex; align-items: center; gap: 12px; text-align: left; font-size: 13px; }
.login-providers small { font-size: 10px; margin-left: auto; color: var(--muted); }
.provider-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: #ffffff10; flex-shrink: 0; overflow: hidden; font-size: 12px; font-weight: 800; }
.provider-mark svg { width: 18px; height: 18px; }
.provider-mark img { width: 100%; height: 100%; object-fit: contain; }
.login-status { color: #c4d1e6; overflow-wrap: anywhere; }
.login-panel > .link { display: block; width: 100%; margin-top: 16px; text-align: center; }
@media (max-width: 740px) {
  .home-header { gap: 10px; }
  .home-header .help-button { margin-left: auto; font-size: 11px; padding: 8px; gap: 5px; }
  .home-header .wordmark { font-size: 30px; }
  .account-button { max-width: 100px; font-size: 11px; padding: 8px 10px; }
  .modal > .server-browser-panel { padding: 20px; }
  .server-browser-grid { grid-template-columns: minmax(0, 1fr); }
  .server-browser-grid .browser { padding: 20px 0; }
  .server-browser-grid .room-list { max-height: 240px; }
  .create-server { margin-top: 0; border-left: 0; border-top: 1px solid var(--line); padding: 20px 0 0; }
  .dialog-head h2 { font-size: 24px; }
}
.brand-dots { display: inline-flex; gap: 4px; }
.brand-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); }
.brand-dots i + i { background: #ffa8d9; }
.header-note { color: var(--muted); font-size: 13px; }
.help-button { margin-left: auto; background: transparent; font-size: 13px; display: flex; align-items: center; gap: 9px; }
.help-button > span { border: 1px solid #718480; border-radius: 50%; width: 18px; height: 18px; line-height: 16px; font-size: 12px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 408px; gap: 56px; padding: 48px 0 40px; align-items: center; }
.hero { min-width: 0; }
.hero-logo { display: block; width: 174px; height: auto; margin: 0 0 24px; filter: drop-shadow(0 5px 20px #5ee0e62b); }
.eyebrow, .section-kicker { font-size: 10px; letter-spacing: 2px; font-weight: 700; color: var(--accent); }
.eyebrow { display: flex; align-items: center; gap: 9px; margin: 0 0 20px; }
.live-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #5ee0e610; flex-shrink: 0; }
.hero h1 { font-size: clamp(42px, 5vw, 66px); font-weight: 750; letter-spacing: -3px; line-height: 1.05; margin: 0; }
.hero h1 > span { color: var(--cyan); }
.hero-copy { color: var(--muted); font-size: 16px; line-height: 1.7; margin: 20px 0 0; }
.card-art { position: relative; height: 258px; max-width: 480px; margin: 12px 0 0; isolation: isolate; }
.orbit { position: absolute; border: 1px solid #9dccba14; border-radius: 50%; width: 350px; height: 170px; top: 60px; left: 35px; transform: rotate(-18deg); z-index: -1; }
.orbit-two { transform: rotate(18deg); width: 390px; left: 15px; }
.art-card { position: absolute; width: 116px; height: 169px; border-radius: 15px; border: 5px solid #e9f1e9; box-shadow: 0 14px 24px #0005; top: 36px; left: calc(50% - 58px); display: grid; place-items: center; }
.art-card::before { content: ""; position: absolute; inset: 19px 9px; border: 2px solid #ffffff80; border-radius: 50%; transform: rotate(28deg); }
.art-card b { font: italic 900 84px/1 system-ui, sans-serif; color: #f3f5e9; text-shadow: 3px 4px 0 #173d3b50; }
.card-corner { position: absolute; top: 1px; left: 6px; color: #f3f5e9; font-size: 19px; font-weight: 850; }
.card-corner.bottom { top: auto; left: auto; bottom: 1px; right: 6px; transform: rotate(180deg); }
.art-cyan { background: #399f9c; transform: translateX(-92px) rotate(-22deg); }
.art-pink { background: #ce729c; transform: translateY(-7px) rotate(-3deg); z-index: 1; }
.art-pink b { font-style: normal; font-size: 76px; }
/* The two face cards use the same card art as the table. */
.art-face { border: 0; height: 174px; background: center / 100% 100% no-repeat; }
.art-face::before { content: none; }
/* Shows the card style the player picked. */
.art-back { transform: translateX(90px) rotate(18deg); background: #111 center / cover no-repeat; }
.art-back::before { content: none; }
.art-spark { position: absolute; font-size: 29px; color: var(--accent); }
.spark-one { left: 25px; top: 36px; transform: rotate(12deg); }
.spark-two { right: 18px; bottom: 40px; color: #ffa8d9; font-size: 22px; }
.art-caption { position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%) rotate(-5deg); font: 9px monospace; letter-spacing: 3px; color: #8ba49b; white-space: nowrap; }
.hero-foot { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 12px; font-size: 12px; color: #bdc9da; }
.hero-foot > span { display: inline-flex; align-items: center; gap: 7px; }
.mini-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.cyan { background: var(--cyan); }.pink { background: #ffa8d9; }.yellow { background: #f4ce77; }
.play-panel { text-align: left; padding: 28px; border-radius: 22px; box-shadow: 0 16px 50px #0002, inset 0 1px 0 #ffffff06; }
.play-panel h2 { font-size: 30px; letter-spacing: -1px; margin: 5px 0 3px; }
.panel-intro { color: var(--muted); font-size: 12px; margin: 0 0 22px; }
.play-panel .field { gap: 8px; font-size: 12px; color: #b9c7dc; }
.play-panel > .field + .field { margin-top: 16px; }
.field-label { font-size: 12px; color: #b9c7dc; }
.mode-pick { margin-top: 18px; align-items: stretch; gap: 9px; }
.mode-seg { border: none; background: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-seg button { border: 1px solid var(--line); background: #0c1120; padding: 12px; display: flex; align-items: center; justify-content: flex-start; gap: 10px; text-align: left; min-width: 0; }
.mode-seg button.on { background: #20374b; border-color: #5ee0e670; }
.mode-seg button > * { pointer-events: none; }
.mode-icon { font-size: 23px; }
.mode-seg strong { display: block; font-size: 14px; letter-spacing: 1px; }
.mode-seg strong { font-size: 12px; letter-spacing: .7px; }
.mode-seg small { display: block; font-size: 10px; line-height: 1.4; color: var(--muted); font-weight: 400; margin-top: 3px; }
.format-seg { display: grid; grid-template-columns: repeat(4, 1fr); background: #0c1120; }
.format-seg button { font-size: 12px; padding: 5px; min-height: 36px; }
.play-panel > .row { flex-direction: column; gap: 8px; margin-top: 20px; }
.play-panel .primary { display: flex; align-items: center; justify-content: space-between; font-size: 15px; padding: 13px 18px; }
.primary > span { font-size: 22px; line-height: 1; }
.practice { background: #ffffff04; text-align: center; font-size: 12px; }
.practice > span { margin-left: 8px; color: var(--muted); }
.play-note { color: #9aabc2; font-size: 10px; margin: 10px 0 18px; text-align: center; }
.host-box { font-size: 12px; background: transparent; padding: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.host-box summary { min-height: 44px; display: flex; align-items: center; justify-content: space-between; list-style: none; color: #c3cfe2; }
.host-box summary::after { content: "+"; color: var(--muted); font-size: 20px; font-weight: 400; }
.host-box[open] summary::after { content: "−"; }
.host-box summary::-webkit-details-marker { display: none; }
.host-box .field { margin: 8px 0; }
.host-box .check { justify-content: flex-start; margin: 12px 0; }
.host-box > button { width: 100%; }
.social-panel { border: 1px solid var(--line); border-radius: 18px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; background: #111a2b88; }
.browser { padding: 22px 26px; min-width: 0; }
.browser-head { gap: 10px; }
.browser-head h2 { font-size: 15px; margin: 0; display: flex; align-items: center; gap: 10px; letter-spacing: -.2px; }
.browser-head .small { font-size: 11px; }
.room-list { margin-top: 10px; max-height: 185px; }
.room-list > p { font-size: 12px; line-height: 1.7; margin: 2px 0; max-width: 420px; }
.invite-panel { border-left: 1px solid var(--line); padding: 22px 26px; }
.invite-panel .section-kicker { font-size: 9px; color: var(--muted); letter-spacing: 1.5px; }
.invite-panel > label { font-size: 12px; display: block; margin-top: 6px; }
.join-row { display: flex; gap: 8px; margin-top: 12px; }
.join-row input { flex: 1; min-width: 0; width: 100px; font-size: 13px; }
.join-row button { font-size: 12px; white-space: nowrap; padding: 10px 14px; }
.join-row button > span { margin-left: 8px; }
.home-footer { display: flex; justify-content: space-between; padding: 23px 0; color: #8b9cb8; font-size: 10px; gap: 16px; }
.home-footer > span:first-child { font-size: 9px; letter-spacing: 1.5px; }

/* Lobby and game controls share the same visual language. */
.lobby-panel { width: min(760px, 100%); min-width: 0; gap: 18px; margin: auto; }
.lobby-head { padding-bottom: 18px; border-bottom: 1px solid var(--line); gap: 16px; }
.lobby-name { font-size: 26px; letter-spacing: -.6px; overflow-wrap: anywhere; }
.team { background: #ffffff02; border-width: 1px; padding: 12px; }
.seat > span:first-child { min-width: 0; overflow-wrap: anywhere; text-align: left; }
.seat > span:last-child { display: flex; flex-shrink: 0; gap: 4px; }
.seat button { min-width: 40px; min-height: 40px; }
.settings { padding: 16px; gap: 14px 20px; }
.settings legend { font-size: 13px; color: #c6d1e4; }
.top-left, #status, #log { backdrop-filter: blur(16px); box-shadow: 0 8px 32px #0002; }
.top-left { top: max(18px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); padding: 12px 16px; }
.top-right { top: max(18px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); }
.top-center { top: max(18px, env(safe-area-inset-top)); max-width: 44%; }
#status { white-space: normal; }
.timer { max-width: 85%; }
.actions { right: max(20px, env(safe-area-inset-right)); }
.actions button { border-radius: 14px; min-height: 48px; }
.colors button { color: #0c1517; font-size: 12px; text-shadow: 0 1px 2px #fff8; }
.modal { background: #050c10b8; backdrop-filter: blur(8px); padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
.modal > .panel { width: min(480px, 100%); max-height: 90dvh; overflow-y: auto; }
.modal .rules { width: min(560px, 100%); font-size: 14px; line-height: 1.7; }
.spectate { max-width: calc(100% - 24px); white-space: normal; border-radius: 16px; }
#poolLabel { max-width: calc(100% - 160px); }
#toast { bottom: max(20px, env(safe-area-inset-bottom)); text-align: center; }

@media (min-width: 1500px) and (min-height: 900px) {
  #home { display: grid; place-items: center; }
  .home-panel { width: min(1200px, 100%); }
  .home-grid { padding: 60px 0; gap: 90px; }
  .card-art { height: 290px; margin-top: 25px; }
}
@media (max-width: 1000px) {
  #home { padding: 0 28px; }
  .home-grid { grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; padding: 36px 0; }
  .hero h1 { font-size: 48px; }
  .hero-copy { font-size: 14px; }
  .play-panel { padding: 24px; }
  .hero-foot { gap: 14px; font-size: 11px; }
  .card-art { transform: scale(.9); transform-origin: center; }
  .social-panel { grid-template-columns: minmax(0, 1fr) 310px; }
  .browser, .invite-panel { padding: 20px; }
  .top-center { top: 94px; max-width: 75%; }
  .top-left { max-height: 74px; overflow-y: auto; scrollbar-width: thin; }
}
@media (max-width: 740px) {
  #home { padding: 0 24px; }
  .home-header { padding: 20px 0; }
  .header-note { display: none; }
  .home-grid { grid-template-columns: 1fr; gap: 28px; padding: 32px 0; }
  .hero { text-align: center; }
  .hero-logo { width: 144px; margin: 0 auto 24px; }
  .eyebrow { justify-content: center; font-size: 9px; letter-spacing: 1.6px; margin-bottom: 16px; }
  .hero h1 { font-size: clamp(40px, 8vw, 60px); letter-spacing: -2px; }
  .hero-copy { font-size: 14px; margin-top: 16px; }
  .card-art { height: 215px; width: min(390px, 100%); margin: 0 auto; transform: scale(.85); transform-origin: center top; margin-bottom: -25px; }
  .orbit { width: 300px; left: calc(50% - 150px); }.orbit-two { width: 340px; left: calc(50% - 170px); }
  .hero-foot { justify-content: center; margin-top: 10px; }
  .play-panel { width: min(480px, 100%); justify-self: center; }
  .social-panel { grid-template-columns: 1fr; }
  .invite-panel { border-left: none; border-top: 1px solid var(--line); }
  .home-footer { flex-wrap: wrap; }
  .home-header .help-button { padding: 8px 12px; }
  .wordmark { font-size: 40px; }
  .screen { padding: 16px; }
  .lobby-panel { padding: 20px; gap: 14px; }
  .lobby-head button { font-size: 12px; padding: 10px 12px; }
  .code { font-size: 32px; }
  .teams { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seat { flex-wrap: wrap; }
  .seat > span:last-child { margin-left: auto; }
  .settings { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; gap: 12px; }
  .settings .toggle { grid-column: 1 / -1; }
  .settings select { padding: 10px; }
  .top-left { top: max(10px, env(safe-area-inset-top)); left: 10px; padding: 8px 10px; max-width: 53%; font-size: 11px; }
  .top-right { top: max(10px, env(safe-area-inset-top)); right: 10px; }
  .top-right .row { gap: 4px; }
  button.icon { font-size: 11px; padding: 6px 8px; min-height: 40px; }
  #status { font-size: 12px; }
  #log { max-width: calc(100vw - 20px); }
  .spectate { bottom: max(12px, env(safe-area-inset-bottom)); width: max-content; font-size: 12px; padding: 8px 12px; }
}
@media (max-width: 380px) {
  #home { padding: 0 16px; }
  .hero h1 { font-size: 39px; }
  .play-panel { padding: 20px; }
  .hero-foot { gap: 12px; font-size: 10px; }
  .mode-seg button { padding: 10px 8px; gap: 6px; }
  .teams { grid-template-columns: 1fr; }
  .top-left { max-width: 48%; font-size: 10px; }
  button.icon { font-size: 10px; padding: 5px 6px; }
}
@media (max-height: 540px) and (orientation: landscape) {
  .top-center { top: 14px; max-width: 35%; }
  .top-left { font-size: 10px; padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* Phones: room for every game link in the header. */
@media (max-width: 520px) {
  .home-header { gap: 8px; }
  .home-header .help-button { font-size: 0; padding: 8px 10px; gap: 0; }
  .home-header .help-button > span { font-size: 12px; }
}

/* ---------- Controller ---------- */
/* While a controller is in use: a bold focus ring, and button hints in the controller's own glyphs. */
.pad-notice { position: fixed; top: 16px; left: 50%; transform: translate(-50%, -12px); z-index: 60; background: #0e1322f2; border: 1px solid var(--accent); color: var(--text); padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center; }
.pad-notice.show { opacity: 1; transform: translate(-50%, 0); }
body.pad-on :focus { outline: 3px solid var(--accent); outline-offset: 3px; box-shadow: 0 0 0 6px #5ee0e633; }
body.pad-on { cursor: none; }
/* The controller hand (hand.js): its fingertip sits on the point it presses. */
.pad-hand { position: fixed; left: 0; top: 0; z-index: 2147483000; pointer-events: none; will-change: transform; }
.pad-hand > span { position: absolute; left: -9px; top: -3px; font-size: 34px; line-height: 1; filter: drop-shadow(0 2px 3px #000c) drop-shadow(0 0 6px #5ee0e688); }
.pad-hand.hidden { display: none !important; }
body.pad-on .pad-hover:not(:focus) { outline: 2px solid #5ee0e6aa; outline-offset: 2px; }
.modal.hand-picker { position: fixed; inset: 0; z-index: 2147482000; display: block; padding: 0; background: #0508105c; backdrop-filter: none; }
.hand-picker .hp-list { position: fixed; display: flex; flex-direction: column; gap: 4px; padding: 8px; overflow-y: auto; background: #0e1322f5; border: 1px solid var(--accent, #5ee0e6); border-radius: 14px; box-shadow: 0 16px 40px #000a; }
.hand-picker .hp-list button { text-align: left; min-height: 38px; padding: 8px 14px; border-radius: 10px; background: #182035; border: 1px solid transparent; color: #eef; font: 600 15px/1.2 "Segoe UI", system-ui, sans-serif; }
.hand-picker .hp-list button.on { border-color: var(--accent, #5ee0e6); background: #1d3346; }
.pad-hint { display: none; }
body.pad-on .pad-hint { display: flex; }
body.pad-on [data-pad]::after, .pad-key::after, body.pad-on .pad-a-focus button:focus:not([data-pad])::after {
  display: inline-grid; place-items: center; min-width: 1.7em; height: 1.7em; padding: 0 .4em; margin-left: .5em; border-radius: 999px;
  background: #ffffff1f; border: 1px solid #ffffff55; font-size: .72em; font-weight: 800; line-height: 1; vertical-align: middle; font-family: "Segoe UI", system-ui, sans-serif;
}
.pad-key { display: inline-flex; }
.pad-key::after { margin-left: 0; }
body:not(.pad-on) [data-pad]::after { content: none; }
[data-pad-type="xbox"] [data-pad="a"]::after { content: "A"; color: #6ee26e; }
[data-pad-type="xbox"] [data-pad="b"]::after { content: "B"; color: #ff6b6b; }
[data-pad-type="xbox"] [data-pad="x"]::after { content: "X"; color: #63a8ff; }
[data-pad-type="xbox"] [data-pad="y"]::after { content: "Y"; color: #ffd84d; }
[data-pad-type="xbox"] [data-pad="lb"]::after { content: "LB"; }
[data-pad-type="xbox"] [data-pad="rb"]::after { content: "RB"; }
[data-pad-type="xbox"] [data-pad="back"]::after { content: "⧉"; }
[data-pad-type="xbox"] [data-pad="start"]::after { content: "☰"; }
[data-pad-type="ps"] [data-pad="a"]::after { content: "✕"; color: #8fb6ff; }
[data-pad-type="ps"] [data-pad="b"]::after { content: "○"; color: #ff7b8a; }
[data-pad-type="ps"] [data-pad="x"]::after { content: "□"; color: #f59ad9; }
[data-pad-type="ps"] [data-pad="y"]::after { content: "△"; color: #5fe0c0; }
[data-pad-type="ps"] [data-pad="lb"]::after { content: "L1"; }
[data-pad-type="ps"] [data-pad="rb"]::after { content: "R1"; }
[data-pad-type="ps"] [data-pad="back"]::after { content: "Create"; }
[data-pad-type="ps"] [data-pad="start"]::after { content: "Options"; }
[data-pad-type="switch"] [data-pad="a"]::after { content: "B"; }
[data-pad-type="switch"] [data-pad="b"]::after { content: "A"; }
[data-pad-type="switch"] [data-pad="x"]::after { content: "Y"; }
[data-pad-type="switch"] [data-pad="y"]::after { content: "X"; }
[data-pad-type="switch"] [data-pad="lb"]::after { content: "L"; }
[data-pad-type="switch"] [data-pad="rb"]::after { content: "R"; }
[data-pad-type="switch"] [data-pad="back"]::after { content: "−"; }
[data-pad-type="switch"] [data-pad="start"]::after { content: "+"; }
[data-pad-type="xbox"] .pad-a-focus button:focus:not([data-pad])::after { content: "A"; color: #6ee26e; }
[data-pad-type="ps"] .pad-a-focus button:focus:not([data-pad])::after { content: "✕"; color: #8fb6ff; }
[data-pad-type="switch"] .pad-a-focus button:focus:not([data-pad])::after { content: "B"; }
[data-pad="dpad"]::after { content: "✥"; }
[data-pad="rstick"]::after { content: "R◎"; }
.pad-hint { position: fixed; left: 50%; transform: translateX(-50%); gap: 14px; flex-wrap: wrap; justify-content: center; align-items: center; padding: 6px 14px; border-radius: 999px; background: #070912cc; border: 1px solid var(--line); font-size: 13px; color: var(--muted); z-index: 6; pointer-events: none; white-space: nowrap; max-width: calc(100% - 24px); }
.pad-hint span { display: inline-flex; align-items: center; gap: 6px; }
.hand-hint { top: calc(var(--hand-top, 74vh) - 40px); }
@media (max-width: 760px) { .hand-hint { top: auto; bottom: max(4px, env(safe-area-inset-bottom)); gap: 8px; font-size: 11px; padding: 4px 10px; flex-wrap: nowrap; opacity: .9; } }

/* GAMES menu (menu.js): pinned top-left on every page and screen, above the game and its dialogs. */
.games-button { position: fixed; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); z-index: 60; display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 6px 12px 6px 9px; border-radius: 12px; background: #0c1120d9; border: 1px solid #5ee0e655; color: var(--text); font: 800 12px/1 "Segoe UI", system-ui, sans-serif; letter-spacing: 1.4px; backdrop-filter: blur(6px); box-shadow: 0 4px 18px #0006; }
.games-button:hover, .games-button[aria-expanded="true"] { background: #16213a; border-color: var(--accent); }
.games-button svg, .gm-head svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.games-button svg circle, .gm-head svg circle { fill: #ff9fdc; stroke: none; }
#gamesMenu.modal { position: fixed; inset: 0; z-index: 70; display: block; padding: 0; background: #0508107a; backdrop-filter: none; }
#gamesMenu.hidden { display: none; }
.games-panel { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); width: min(300px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 6px; padding: 12px; text-align: left; background: #0b1020f5; border: 1px solid #5ee0e640; border-radius: 16px; box-shadow: 0 18px 60px #000a; color: var(--text); font: 15px/1.4 "Segoe UI", system-ui, sans-serif; animation: gm-in .14s ease-out; }
@keyframes gm-in { from { opacity: 0; transform: translateY(-6px); } }
.gm-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 4px; }
.games-panel .gm-head > h2 { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 12px; letter-spacing: 1.4px; }
.gm-head .gm-close { min-height: 34px; padding: 4px 11px; background: transparent; font-size: 14px; }
.gm-top { display: flex; flex-direction: column; gap: 6px; }
.games-panel .gm-row { display: flex; align-items: center; gap: 10px; width: 100%; max-width: none; margin: 0; padding: 10px 12px; font-size: 14px; text-align: left; justify-content: flex-start; }
.games-panel .gm-row.account-button { background: #1d2a44; }
.games-panel .gm-row.account-button::before { content: "👤"; font-size: 14px; }
.games-panel .help-button > span { flex: none; display: inline-grid; place-items: center; }
.gm-label { margin: 8px 4px 0; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase; }
.gm-list { display: flex; flex-direction: column; gap: 4px; }
.gm-item, .gm-arcade { display: grid; grid-template-columns: 26px 1fr; align-items: center; column-gap: 8px; padding: 9px 12px; min-height: 44px; border-radius: 12px; border: 1px solid transparent; color: var(--text); text-decoration: none; }
.gm-item i { grid-row: span 2; font-style: normal; text-align: center; color: var(--muted); font-size: 16px; }
.gm-item b { font-size: 15px; line-height: 1.2; }
.gm-item small { color: var(--muted); font-size: 12px; line-height: 1.2; }
.gm-item:hover, .gm-arcade:hover { background: #18223a; }
.gm-item.on { background: linear-gradient(90deg, #5ee0e626, #ff9fdc14); border-color: #5ee0e699; }
.gm-item.on i, .gm-item.on small { color: var(--accent); }
.gm-arcade { grid-template-columns: 26px 1fr auto; margin-top: 6px; border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; padding-top: 12px; color: var(--muted); font-size: 14px; font-weight: 600; }
.gm-arcade img { width: 20px; height: 20px; border-radius: 5px; justify-self: center; }
.gm-arcade:not(:has(img))::before { content: "↩"; text-align: center; }
.home-header.empty { padding: 0; border: 0; height: 58px; }
.swarm .home-header .header-sound { margin-left: auto; }
#lobby.screen { padding-top: max(60px, env(safe-area-inset-top)); }
/* In-game scoreboards in the top-left sit just under the GAMES button. */
.top-left { top: calc(max(10px, env(safe-area-inset-top)) + 48px); }

/* Liars UNO */
.pile-chip { position: absolute; left: 50%; top: calc(var(--status-top, 96px) + 40px); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: #050c10c8; border: 2px solid var(--accent, #5ee0e6); font-weight: 700; font-size: 14px; pointer-events: none; white-space: nowrap; z-index: 2; }
.pile-chip .sw { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff9; }
.pile-chip small { opacity: .75; font-weight: 500; }
.claim-colors { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; }
.claim-colors button { height: 48px; background: var(--c); color: #0c1517; border: 3px solid rgba(255,255,255,.6); border-radius: 12px; font-weight: 700; }
.claim-colors button.on { outline: 3px solid #fff; }
.claim-colors button:disabled, .claim-values button:disabled { opacity: .25; cursor: not-allowed; }
.claim-values { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0; }
.claim-values button { padding: 8px 2px; font-weight: 700; }
.claim-values button.on { outline: 3px solid var(--accent, #5ee0e6); }
.claim-target { margin: 8px 0; }
.mode-seg button[data-mode="liars"] { grid-column: 1 / -1; }
