:root {
  color-scheme: light;
  --ink: #1f2520;
  --muted: #617063;
  --paper: #fff8e7;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(44, 54, 43, 0.18);
  --sea: #6eb6c9;
  --deep-sea: #2f7894;
  --accent: #cb6f37;
  --accent-dark: #833e50;
  --forest: #3f8455;
  --shadow: 0 18px 48px rgba(44, 54, 43, 0.18);
}

html { scroll-padding-top: 120px; }
.flying-resource { position: fixed; top: 0; left: 0; z-index: 10; pointer-events: none; padding: 8px 12px; border-radius: 6px; background: var(--resource-color); border: 2px solid white; color: white; font-size: 18px; font-weight: 800; text-shadow: 0 1px 2px #0008; box-shadow: 0 4px 14px #0004; }
.turn-guide { border-left: 4px solid #278473; padding: 10px 12px; margin-bottom: 12px; color: #1f2520; background: #edf8f5; }
.turn-guide h3 { font-size: 17px; line-height: 1.4; }
.guide-owner { font-weight: 700; border-bottom: 1px solid #bdd8d2; padding-bottom: 6px; }
#guideOptionsLabel { display: block; font-size: 13px; margin-top: 8px; }
#guidePrimary { margin: 8px 0; }
.turn-guide p { font-size: 14px; line-height: 1.6; margin: 6px 0; }
#guideOptions { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 6px 0 10px; padding-left: 18px; font-size: 14px; }
#guideOptions:empty { display: none; }
#endTurn { margin-top: 6px; background: #216e61; }
#endTurn.next-step { outline: 2px solid #216e61; outline-offset: 3px; }
.production-result { grid-column: 1 / -1; font-size: 14px; line-height: 1.6; padding: 8px; background: #f4f7f6; border-left: 3px solid #488f7d; }

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", system-ui, sans-serif;
  background: #eaf0ef;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0.65rem 0.95rem;
  color: white;
  background: var(--accent-dark);
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.secondary {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
}

button.auth-text-button {
  min-height: 44px;
  padding: 0.35rem 0;
  border: 0;
  color: var(--accent-dark);
  background: transparent;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.hidden {
  display: none !important;
}

.hand-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 12px 16px;
  background: #f6fbfa;
  border-top: 1px solid #c2d3ce;
  border-bottom: 2px solid #54766d;
  box-shadow: 0 4px 12px #13352a12;
}
.hand-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.hand-heading h2 { font-size: 16px; line-height: 1.4; }
#handTotal { font-size: 14px; color: #435e55; }
.resource-hand { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 0; gap: 12px; }
.hand-resource { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; padding-right: 12px; border-right: 1px solid #cadbd6; }
.hand-resource:last-child { border-right: 0; padding-right: 0; }
.hand-resource dt { display: flex; align-items: center; gap: 8px; font-size: 16px; white-space: nowrap; }
.hand-resource dd { margin: 0; font-size: 26px; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
.resource-swatch { display: inline-block; width: 12px; height: 12px; flex: 0 0 12px; border-radius: 2px; background: var(--resource-color); }
.hand-brick { --resource-color: #bd5b43; }
.hand-wood { --resource-color: #377b55; }
.hand-wheat { --resource-color: #c39522; }
.hand-sheep { --resource-color: #85aa42; }
.hand-ore { --resource-color: #737d94; }
@media (max-width: 640px) {
  .hand-bar { padding: 10px 8px; }
  .resource-hand { gap: 4px; }
  .hand-resource { flex-direction: column; gap: 3px; padding-right: 4px; }
  .hand-resource dt { font-size: 14px; gap: 4px; }
  .hand-resource dd { font-size: 24px; }
  .resource-swatch { width: 8px; height: 8px; flex-basis: 8px; }
}

[hidden] { display: none !important; }
.edge.legal .edge-hit { stroke: #ffffff90; stroke-width: 14; pointer-events: all; }
.vertex.legal .vertex-hit { fill: #ffffffa0; stroke: #165862; stroke-width: 2; }
.vertex.legal:hover .vertex-hit, .vertex.legal:focus .vertex-hit { fill: #ffe48b; }
.edge.legal:hover .edge-hit, .edge.legal:focus .edge-hit { stroke: #fff2b0; }
.robber-target { cursor: pointer; }
.robber-target:hover .hex, .robber-target:focus .hex { stroke: white; stroke-width: 6; }
dialog { width: min(620px, calc(100% - 28px)); max-height: 85vh; overflow: auto; border: 1px solid #b8ccca; border-radius: 8px; padding: 24px; color: var(--ink); background: #f7fcfb; }
dialog::backdrop { background: #102d35a0; }
dialog p { margin: 16px 0; line-height: 1.65; }
#victimChoices { display: flex; gap: 12px; margin: 20px 0; flex-wrap: wrap; }
#discardInputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
#gameStatus { min-height: 24px; font-size: 14px; color: #546965; }
#discardForm:has([hidden]) { display: none; }
button:focus-visible { outline: 3px solid #24738b; outline-offset: 3px; }
.development-section { padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.development-heading { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.development-heading h2 { font-size: 22px; }
#deckCount { font-size: 14px; color: #465b52; }
.development-hand { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.development-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 16px; border: 1px solid var(--line); border-top: 4px solid #65787c; border-radius: 8px; color: #1f2520; background: #fbfdfc; }
.development-card h3 { font-size: 18px; }
.development-card p { font-size: 14px; line-height: 1.6; flex: 1; }
.development-card button { padding: 8px 4px; font-size: 14px; }
.dev-knight { border-top-color: #ba5845; }
.dev-roads { border-top-color: #387894; }
.dev-plenty { border-top-color: #46905e; }
.dev-monopoly { border-top-color: #976192; }
.dev-victory { border-top-color: #b89021; }
#developmentForm { display: grid; gap: 16px; margin-top: 16px; }
.development-actions { display: flex; gap: 12px; }
@media (max-width: 900px) { .development-hand { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 540px) { .development-hand { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.lobby {
  min-height: calc(100vh - 58px);
  display: grid;
  place-items: center;
  gap: 24px;
}
.lobby:not(.hidden) { animation: view-enter 220ms ease-out both; }
.auth-stage { grid-template-columns: minmax(280px, .9fr) minmax(340px, 520px); align-content: center; column-gap: clamp(32px, 7vw, 96px); }
.auth-stage .auth-brand { align-self: center; }
.auth-stage .auth-brand h1 { max-width: 7ch; font-size: clamp(3rem, 7vw, 5.4rem); }
.auth-stage .auth-brand p:last-child { max-width: 30ch; margin-top: 14px; font-size: 1.05rem; line-height: 1.7; }
.auth-stage .auth-card { grid-column: 2; }
.auth-register .back-link { width: fit-content; }
.platform-stage { align-content: center; grid-template-rows: auto auto auto; }
.catan-stage { align-content: center; grid-template-rows: auto auto auto; }
.stage-path { margin-bottom: 6px; color: #536c65; font-size: 13px; font-weight: 700; }
@keyframes view-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.platform-header { width:min(900px,100%); display:flex; align-items:center; justify-content:space-between; gap:16px; }
.game-catalog { width:min(900px,100%); }
.platform-meta-grid { width:min(1100px,100%); display:grid; grid-template-columns:minmax(260px,.9fr) minmax(260px,1fr) minmax(280px,1.1fr); gap:14px; align-items:stretch; }
.platform-meta-grid .lobby-card { min-width:0; align-self:stretch; }
.platform-profile-card { display:grid; gap:18px; }
.platform-profile-card #metaAccountType { margin-top:5px; color:var(--muted); }
.platform-stat-grid,.platform-future-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.platform-future-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
.platform-stat-grid > div,.platform-future-grid > div { padding:10px; border:1px solid var(--line); background:var(--surface); min-width:0; }
.platform-stat-grid span,.platform-future-grid span { display:block; color:var(--muted); font-size:12px; }
.platform-stat-grid strong,.platform-future-grid strong { display:block; margin-top:4px; font-size:18px; overflow-wrap:anywhere; }
.platform-future-grid strong { font-size:13px; }
.platform-meta-list { margin:0; padding-left:22px; display:grid; gap:8px; max-height:220px; overflow:auto; }
.platform-meta-list li { padding:8px 4px; line-height:1.45; }
.game-entry { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:20px; padding:22px; border:1px solid var(--line); background:var(--panel); }
.game-entry h2 { font-size:1.6rem; }
.game-entry p { margin-top:6px; color:var(--muted); }
.auth-card h2 { font-size:1.4rem; }
.auth-hint { color:var(--muted); font-size:.88rem; line-height:1.5; }
.auth-password-hint { margin:-.45rem 0 .8rem; }
.profile-name-editor { display:grid; gap:10px; margin-top:10px; padding-top:12px; border-top:1px solid var(--line); }
.profile-name-editor .join-row { grid-template-columns:1fr 1fr; }
.profile-name-editor[hidden] { display:none; }
#editProfileName { margin-top:10px; }
#profileNameStatus { color:var(--muted); font-size:.86rem; line-height:1.4; }
.auth-divider { display:flex; align-items:center; gap:12px; color:var(--muted); }
.auth-divider::before,.auth-divider::after { content:""; height:1px; flex:1; background:var(--line); }
.google-login { display:flex; align-items:center; justify-content:center; gap:10px; min-height:48px; background:#fff; color:#1f2520; border:1px solid #c9cfcb; transition:transform 160ms ease, background-color 160ms ease, border-color 160ms ease; }
.google-login:hover:not(:disabled) { background:#f3f6f4; border-color:#a6b2ac; filter:none; }
.google-login:active:not(:disabled) { transform:translateY(0); background:#e8eeee; border-color:#808f89; }
.google-login:focus-visible { outline:3px solid #24738b; outline-offset:3px; }
.google-login img { display:block; width:20px; height:20px; flex:none; object-fit:contain; }
.email-login-details { border-top:1px solid var(--line); padding-top:12px; }
.email-login-details summary { color:var(--muted); cursor:pointer; font-size:.9rem; }
.email-login-details[open] summary { margin-bottom:14px; }
.email-login-details label { margin-top:10px; }
.email-login-details .auth-text-button { margin-top:4px; }
.auth-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.back-link { justify-self:start; display:flex; align-items:center; gap:7px; }
.back-link svg { width:18px; }
@media(max-width:980px){.platform-meta-grid{grid-template-columns:1fr 1fr}.platform-profile-card{grid-column:1/-1}}
@media(max-width:760px){.auth-stage{grid-template-columns:1fr;align-content:start;padding-top:28px}.auth-stage .auth-card{grid-column:1}.auth-stage .auth-brand{width:min(560px,100%)}.auth-stage .auth-brand h1{font-size:2.8rem}.platform-header,.game-entry{grid-template-columns:1fr;display:grid}.platform-meta-grid{grid-template-columns:1fr}.platform-profile-card{grid-column:auto}.platform-stat-grid{grid-template-columns:repeat(3,minmax(0,1fr))}.auth-actions{grid-template-columns:1fr}}
@media(max-width:420px){.platform-stat-grid{grid-template-columns:1fr}.platform-future-grid{grid-template-columns:1fr 1fr}}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  text-align: left;
}

.mark {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 16px;
  color: #f5ca73;
  background: var(--deep-sea);
  border: 7px solid #d4eee6;
  font-size: 2.6rem;
  box-shadow: var(--shadow);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 5.8rem);
  line-height: 0.95;
}

.brand p,
.hint,
.eyebrow {
  color: var(--muted);
}

.lobby-card,
.panel,
.side-panel,
.topbar {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.lobby-card {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  border-radius: 12px;
  padding: 22px;
}

.lobby-identity-summary {
  display:grid;
  gap:4px;
  padding:12px 14px;
  border:1px solid var(--line);
  background:var(--surface);
}
.lobby-identity-summary span,
.lobby-identity-summary small { color:var(--muted); }
.lobby-identity-summary strong { font-size:1.15rem; }
.lobby-identity-summary small { font-size:.82rem; line-height:1.4; }

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.join-row {
  display: grid;
  grid-template-columns: 1fr 0.55fr 0.6fr;
  gap: 10px;
}

.hint {
  font-size: 0.9rem;
}

.game {
  display: grid;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-radius: 12px;
  padding: 16px;
}

.eyebrow {
  font-size: 0.86rem;
}

.topbar h2 {
  margin-top: 3px;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.board-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: stretch;
}

.board-panel {
  min-height: 580px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 14px;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.3), transparent 20rem),
    linear-gradient(145deg, var(--sea), var(--deep-sea));
  box-shadow: inset 0 0 80px rgba(9, 58, 74, 0.34), var(--shadow);
  overflow: hidden;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 580px;
}

.hex {
  stroke: rgba(42, 37, 25, 0.38);
  stroke-width: 3;
}

.hex.desert {
  fill: #d6a764;
}

.hex.wood {
  fill: #4f965f;
}

.hex.sheep {
  fill: #93c86a;
}

.hex.wheat {
  fill: #e5bd4f;
}

.hex.brick {
  fill: #be6044;
}

.hex.ore {
  fill: #8d8f96;
}

.hex-label {
  fill: rgba(255, 255, 255, 0.95);
  font-size: 16px;
  font-weight: 700;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.35);
  stroke-width: 3px;
}

.number-token {
  fill: rgba(255, 248, 231, 0.92);
  stroke: rgba(54, 41, 25, 0.2);
  stroke-width: 2;
}

.number-text {
  fill: #5c271c;
  font-weight: 800;
  font-size: 18px;
  text-anchor: middle;
  dominant-baseline: central;
}

.vertex,
.edge {
  cursor: pointer;
}

.vertex-hit {
  fill: transparent;
}

.identity-strip { padding: 6px 0; }
.identity-strip > h3 { display: none; }
.identity-strip .players { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
.identity-strip .player { border-radius: 4px; padding: 6px; min-width: 0; gap: 3px; }
.identity-strip .resources { display: none; }
.identity-strip .player-name { overflow-wrap: anywhere; }
.identity-strip .player-head strong { min-width: 0; overflow-wrap: anywhere; }
.identity-strip .player-head > span { white-space: nowrap; font-size: 13px; }
.identity-strip .chip { display: inline-block; vertical-align: middle; }
@media (max-width: 760px) {
  .identity-strip .players { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .identity-strip .player-head { flex-wrap: wrap; gap: 3px; }
}
@media (min-width: 761px) {
  body.playing-view { height: 100dvh; overflow: hidden; }
  .playing-view .shell { height: 100%; padding: 8px 16px; }
  .playing-view #game { height: 100%; display: flex; flex-direction: column; gap: 6px; }
  .playing-view .board-wrap { flex: 1; min-height: 0; }
  .playing-view .board-panel { height: 100%; }
  .playing-view .side-panel { height: 100%; max-height: none; overflow-y: auto; }
  .playing-view .info-grid { display: block; }
  .playing-view .info-grid > .panel, .playing-view #log { max-height: none; overflow: visible; }
  .playing-view #chatMessages { max-height: 180px; overflow-y: auto; }
  .playing-view .development-heading { flex-wrap: wrap; }
  .playing-view #rollDice, .playing-view #endTurn { display: none; }
}
.placement-ring { fill: #153d40; stroke-width: 4; }
.placement-plus { fill: white; text-anchor: middle; dominant-baseline: central; font-size: 20px; pointer-events: none; }
.placement-road { stroke-width: 9; stroke-linecap: round; stroke-dasharray: 10 5; opacity: .36; transition: opacity 120ms ease, stroke-width 120ms ease, filter 120ms ease; }
.edge.legal:hover .placement-road,
.edge.legal:focus .placement-road { opacity: 1; stroke-width: 11; filter: drop-shadow(0 0 5px #fff2b0); }
.edge.legal:active .placement-road { opacity: 1; stroke-width: 12; filter: drop-shadow(0 0 7px #fff2b0); }
.legal:hover .placement-ring, .legal:focus .placement-ring { stroke-width: 6; }

.vertex-piece {
  stroke: #fff8e7;
  stroke-width: 3;
}

.edge-hit {
  stroke: transparent;
  stroke-width: 18;
}

.road-piece {
  stroke-width: 8;
  stroke-linecap: round;
  opacity: 1;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.28));
}

.side-panel {
  display: grid;
  gap: 14px;
  border-radius: 12px;
  padding: 14px;
}

.dice-card,
.mode-card,
.trade-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.54);
}

.dice-card strong {
  font-size: 3rem;
  line-height: 1;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode {
  min-height: 38px;
  padding: 0.45rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.mode.active {
  color: white;
  background: var(--forest);
}

.wide {
  width: 100%;
}

.trade-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.harbor-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
}

.harbor-chip {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffffa8;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.harbor-chip.active {
  color: #fff;
  background: #2f755d;
  border-color: #2f755d;
}

.harbor-chip.muted,
.trade-rate-reason {
  color: var(--muted);
}

.trade-rate-reason {
  font-size: 13px;
}

.info-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
}

.panel {
  border-radius: 12px;
  padding: 16px;
}

.panel h3 {
  margin-bottom: 12px;
}

.players {
  display: grid;
  gap: 10px;
}

.player {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.5);
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 0 1px var(--line);
}

.resources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.resource {
  border-radius: 999px;
  padding: 0.22rem 0.48rem;
  background: rgba(44, 54, 43, 0.08);
  font-size: 0.86rem;
}

.log {
  display: grid;
  gap: 7px;
  max-height: 238px;
  overflow: auto;
  padding-right: 4px;
}

.log-item {
  border-left: 3px solid var(--accent);
  padding-left: 9px;
  color: #3d463e;
}
.time {
  color: #6d7d76;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.chat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 28px));
  border-radius: 10px;
  padding: 12px 14px;
  color: white;
  background: rgba(45, 34, 25, 0.94);
  box-shadow: var(--shadow);
  z-index: 5;
}

@media (max-width: 900px) {
  .board-wrap,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trade-card, #discardForm { grid-column: 1 / -1; }

  .board-panel,
  #board {
    min-height: 520px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .join-row,
  .topbar,
  .side-panel,
  .trade-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions button {
    flex: 1;
  }

  .board-panel,
  #board {
    min-height: 440px;
  }
}

/* Keep the board and turn controls together within the working viewport. */
.board-panel { position: relative; overflow: hidden; }
#board3d { position: absolute; inset: 0; }
#board3d canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.board-toolbar { position: absolute; top: 10px; left: 10px; z-index: 2; display: flex; gap: 6px; }
.board-toolbar button { width: 38px; height: 38px; min-height: 38px; padding: 7px; display: grid; place-items: center; }
.board-toolbar svg { width: 20px; height: 20px; }
.hand-art { width: 32px; height: 32px; display: inline-block; }
.hand-art svg { width: 100%; height: 100%; }
#connectionStatus { font-size: 12px; color: #427969; margin: 4px 0 0; }
#chatMessages { max-height: 240px; min-height: 100px; overflow-y: auto; overflow-wrap: anywhere; }
#chatMessages p { margin: 8px 0; font-size: 14px; }
#chatMessages strong { color: #286c62; }
.chat-latest { position: sticky; bottom: 4px; width: 100%; padding: 7px; z-index: 1; }
@media(max-width: 600px) { .hand-art { width: 23px; height: 23px; } .hand-resource dt { flex-direction: column; gap: 0; } }
.number-text.high-production { fill: #b13232; }
.trade-resource-row { display: grid; grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 1fr)); gap: 10px; align-items: center; margin: 10px 0; }
.trade-resource-row input { width: 100%; min-width: 0; }
#tradeDialog { width: min(480px, calc(100vw - 24px)); max-height: 90dvh; overflow-y: auto; }
#tradeError { color: #a02c2c; }
#playerTradeStatus { font-size: 14px; overflow-wrap: anywhere; margin: 0; }
.flying-resource { width: 54px; height: 68px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px solid white; border-radius: 6px; box-shadow: 0 6px 16px #0005; }
.flying-resource svg { width: 38px; height: 38px; flex-shrink: 0; }
.flying-resource span { font-size: 13px; line-height: 18px; white-space: nowrap; }
.shell { padding-top: 12px; }
.game { gap: 12px; }
.topbar { padding: 10px 14px; border-radius: 0; box-shadow: none; }
.topbar h2 { font-size: 22px; line-height: 1.4; }
.board-wrap { grid-template-columns: minmax(0, 1fr) 288px; gap: 12px; align-items: start; }
.board-panel { height: clamp(400px, calc(100dvh - 224px), 620px); min-height: 0; border-radius: 8px; }
#board { height: 100%; min-height: 0; }
.side-panel { display: flex; flex-direction: column; gap: 0; padding: 14px; border-radius: 0; box-shadow: none; }
.side-panel > * { flex-shrink: 0; }
@media (min-width: 761px) { .side-panel { max-height: clamp(400px, calc(100dvh - 224px), 620px); overflow-y: auto; } }
.dice-card, .mode-card, .trade-card { border: 0; border-radius: 0; background: none; padding: 12px 0; gap: 10px; }
.dice-card { padding-top: 0; display: grid; grid-template-columns: 1fr auto; align-items: center; }
.dice-card > span { font-size: 14px; }
.dice-card strong { font-size: 30px; text-align: right; }
.dice-card button { grid-column: 1 / -1; }
.mode-card, .trade-card { border-top: 1px solid var(--line); }
.mode-grid { grid-template-columns: 1fr; gap: 6px; }
.mode { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; min-height: 42px; }
.mode small { font-size: 13px; white-space: nowrap; }
.trade-row { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.trade-row button { grid-column: 1 / -1; }
.trade-row select { padding: 8px; }
.info-grid > .panel { border-radius: 0; box-shadow: none; }
@media (min-width: 761px) {
  .info-grid { grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); }
  .info-grid > .panel { max-height: 210px; overflow-y: auto; }
  .players { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .log { max-height: 148px; }
  #chatMessages { max-height: 150px; overflow-y: auto; padding-right: 4px; }
}
@media (max-width: 760px) {
  .turn-guide { grid-column: 1 / -1; }
  .board-wrap { grid-template-columns: 1fr; }
  .board-panel { height: auto; aspect-ratio: 760 / 660; }
  .side-panel { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .mode-card { grid-column: 2; grid-row: 2 / span 2; border: 0; padding: 0; }
  .dice-card { grid-column: 1; }
  .trade-card { grid-column: 1; }
  #discardForm { grid-column: 1 / -1; }
  .side-panel:has(#discardPanel:not([hidden])) .mode-card { grid-row: auto; }
}
@media (max-width: 460px) {
  .side-panel { grid-template-columns: 1fr; }
  .mode-card { grid-column: 1; grid-row: auto; border-top: 1px solid var(--line); padding-top: 12px; }
  .topbar h2 { font-size: 18px; }
  .top-actions button { padding: 8px; font-size: 14px; }
}

.platform-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.room-browser { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-heading h2 { font-size: 1rem; }
.icon-button { width: 38px; height: 38px; min-height: 38px; padding: 7px; display: inline-grid; place-items: center; }
.icon-button svg { width: 18px; height: 18px; }
.public-rooms { display: grid; gap: 8px; max-height: 220px; overflow-y: auto; }
.room-row { display: flex; align-items: center; justify-content: space-between; width: 100%; text-align: left; }
.room-row span:first-child { display: grid; gap: 2px; }
.room-row small, .empty-state { color: var(--muted); }
.waiting-room { display: grid; gap: 14px; padding: 16px; border-block: 1px solid var(--line); background: rgba(255,255,255,.54); }
.waiting-room[hidden] { display: none; }
.result-panel[hidden] { display: none; }
.result-panel.victory-panel {
  --winner-color: #d4a64f;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  width: min(980px, calc(100% - 24px));
  margin: 2px auto 4px;
  padding: clamp(26px, 4vw, 42px);
  display: grid;
  gap: 24px;
  border: 1px solid color-mix(in srgb, var(--winner-color) 58%, #d8c79f);
  border-radius: 20px;
  color: #eef4f2;
  background:
    radial-gradient(circle at 50% 4%, color-mix(in srgb, var(--winner-color) 24%, transparent), transparent 34rem),
    linear-gradient(160deg, #183038 0%, #0d1d23 58%, #08151b 100%);
  box-shadow: 0 24px 70px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,255,255,.06);
}
.victory-panel::before { content:""; position:absolute; z-index:-1; inset:0; background:linear-gradient(115deg,transparent 24%,rgba(255,255,255,.025) 41%,transparent 57%),radial-gradient(circle at 50% -8%,rgba(246,214,144,.16),transparent 28%); pointer-events:none; }
.victory-atmosphere { position:absolute; inset:0; z-index:-1; pointer-events:none; overflow:hidden; }
.victory-atmosphere span { position:absolute; width:7px; height:7px; border-radius:50%; background:#f4d58a; opacity:.36; box-shadow:0 0 16px rgba(244,213,138,.48); }
.victory-atmosphere span:nth-child(1){left:15%;top:22%}.victory-atmosphere span:nth-child(2){right:17%;top:30%;width:4px;height:4px;opacity:.24}.victory-atmosphere span:nth-child(3){left:73%;bottom:18%;width:5px;height:5px;opacity:.2}
.victory-hero { display:grid; justify-items:center; gap:8px; text-align:center; }
.victory-kicker { color:#d6c39b; font-size:12px; font-weight:800; letter-spacing:.22em; }
.victory-emblem { width:72px; height:72px; display:grid; place-items:center; margin:2px 0 4px; border:1px solid rgba(247,220,158,.52); border-radius:50%; color:#f5d78e; background:radial-gradient(circle at 40% 28%,rgba(255,245,210,.20),transparent 25%),linear-gradient(145deg,rgba(204,164,89,.32),rgba(77,56,28,.22)); box-shadow:0 0 34px color-mix(in srgb,var(--winner-color) 32%,transparent); }
.victory-emblem svg { width:34px; height:34px; stroke-width:1.8; }
.result-panel.victory-panel .victory-title { max-width:19ch; color:#fff9e9; font-size:clamp(30px,4.8vw,52px); line-height:1.04; text-wrap:balance; text-shadow:0 3px 20px rgba(0,0,0,.34); }
.victory-score-block { display:grid; justify-items:center; gap:1px; margin-top:4px; }
.victory-score { color:#f4d181; font-size:clamp(42px,6vw,68px); line-height:.95; font-variant-numeric:tabular-nums; }
.victory-score-block>span { color:#aebcba; font-size:10px; font-weight:800; letter-spacing:.24em; }
.victory-subtitle { margin-top:2px; color:#c7d2d0; font-size:14px; font-weight:700; }
.victory-ranking { display:grid; gap:12px; width:min(760px,100%); margin:0 auto; }
.victory-rank-card { --player-color:#7b8a8d; display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:14px; min-width:0; padding:14px 16px; border:1px solid rgba(222,209,176,.18); border-radius:14px; color:#e8efed; background:rgba(19,34,40,.82); }
.victory-rank-card.rank-first { min-height:112px; padding:20px 22px; border-color:color-mix(in srgb,var(--winner-color) 65%,#ecd59b); background:linear-gradient(135deg,color-mix(in srgb,var(--winner-color) 18%,rgba(24,41,46,.94)),rgba(13,28,34,.96) 56%); box-shadow:0 14px 38px rgba(0,0,0,.28),0 0 26px color-mix(in srgb,var(--winner-color) 16%,transparent); }
.victory-rank-number { min-width:54px; color:#d5c59f; font-size:12px; font-weight:900; letter-spacing:.08em; text-transform:uppercase; }
.rank-first .victory-rank-number { color:#f5d78e; font-size:14px; }
.victory-rank-player { display:flex; align-items:center; gap:10px; min-width:0; }
.victory-rank-player strong { overflow:hidden; color:#f2f6f5; font-size:16px; text-overflow:ellipsis; white-space:nowrap; }
.rank-first .victory-rank-player strong { font-size:clamp(19px,2.8vw,26px); }
.victory-player-orb { flex:0 0 auto; width:13px; height:13px; border:2px solid rgba(255,255,255,.66); border-radius:50%; box-shadow:0 0 14px color-mix(in srgb,var(--player-color) 54%,transparent); }
.rank-first .victory-player-orb { width:18px; height:18px; }
.victory-rank-score { color:#dbe4e2; font-size:16px; white-space:nowrap; }
.rank-first .victory-rank-score { color:#f5d78e; font-size:24px; }
.victory-secondary-ranks { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.result-actions.victory-actions { display:flex; justify-content:center; flex-wrap:wrap; gap:10px; }
.victory-actions button { min-width:150px; min-height:46px; }
.victory-actions #rematchChoice { font-weight:850; }
.victory-panel[data-result-state="aborted"] .victory-emblem,.victory-panel[data-result-state="aborted"] .victory-score-block{display:none}
.victory-panel[data-result-state="aborted"] .victory-title{font-size:clamp(26px,4vw,40px)}
.victory-panel[data-result-state="aborted"]{--winner-color:#75888a}
.victory-panel:not([hidden]) .victory-emblem{animation:victory-emblem-in 520ms cubic-bezier(.2,.8,.2,1) both}
.victory-panel:not([hidden]) .victory-title,.victory-panel:not([hidden]) .victory-score-block{animation:victory-rise-in 560ms 90ms cubic-bezier(.2,.75,.2,1) both}
.victory-panel:not([hidden]) .rank-first{animation:victory-rise-in 560ms 220ms cubic-bezier(.2,.75,.2,1) both}
.victory-panel:not([hidden]) .victory-secondary-ranks{animation:victory-rise-in 520ms 360ms ease-out both}
.victory-panel:not([hidden]) .victory-actions{animation:victory-rise-in 420ms 520ms ease-out both}
@keyframes victory-emblem-in{from{opacity:0;transform:translateY(10px) scale(.76)}to{opacity:1;transform:none}}
@keyframes victory-rise-in{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}
@media (max-width:640px){.result-panel.victory-panel{width:calc(100% - 12px);padding:24px 16px 20px;gap:18px;border-radius:16px}.victory-emblem{width:60px;height:60px}.victory-secondary-ranks{grid-template-columns:1fr}.victory-rank-card{gap:9px;padding:12px}.victory-rank-card.rank-first{min-height:96px;padding:16px}.victory-rank-number{min-width:44px}.result-actions.victory-actions{display:grid;grid-template-columns:1fr}.victory-actions button{width:100%}}
@media (prefers-reduced-motion:reduce){.victory-panel *,.victory-panel::before,.victory-panel::after{animation:none!important;transition:none!important}}
.seat-list { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
.seat { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.64); }
.seat strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-status { width: 9px; height: 9px; border-radius: 50%; background: #999; }
.seat-status.online { background: #298557; }
.seat-status.offline { background: #b14a3c; }
.seat .icon-button { grid-column: 1 / -1; width: 100%; }
.seat-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.seat-actions .icon-button { flex: 1; }
.waiting-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.runtime-bar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; color: #fff; background: #184e58; }
.runtime-bar[hidden] { display: none; }
#reclaimSeat { min-height: 34px; padding: 5px 10px; font-size: 13px; white-space: nowrap; }
#decisionTimer { font-variant-numeric: tabular-nums; font-weight: 800; }
.system-message { color: var(--muted); font-style: italic; }
.danger { color: #8c2f25; }
@media (max-width: 760px) {
  .seat-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .runtime-bar { position: fixed; inset: auto 0 0 0; flex-wrap: wrap; }
  .game { padding-bottom: 48px; }
}
@media (max-width: 460px) {
  .platform-options, .seat-list { grid-template-columns: 1fr; }
  .waiting-actions > button { flex: 1; }
  .result-standings li { grid-template-columns: 28px minmax(0, 1fr); }
  .result-standings em { grid-column: 2; }
}

/* Phase 7 board-first gameplay layout. */
.game-brand,
.status-cluster,
.timer-value,
.sheet-heading,
.dock-actions button {
  display: flex;
  align-items: center;
}

.game-brand { min-width: 0; gap: 10px; }
.game-mark { color: #e5b54f; font-size: 28px; line-height: 1; }
.game-brand > div { min-width: 0; }
.status-cluster { min-width: 0; flex: 1; justify-content: center; gap: 10px; }
.status-cluster p { min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-workspace {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr) 310px;
  gap: 10px;
  min-height: 0;
  flex: 1;
}
.board-stage,
.board-panel { min-width: 0; min-height: 0; height: 100%; }
.board-panel { border-radius: 6px; }
.player-rail,
.context-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(250, 253, 252, 0.94);
  box-shadow: 0 6px 20px rgba(27, 48, 42, 0.11);
}
.player-rail { padding: 10px; overflow-y: auto; }
.player-rail > h3 { display: block; margin-bottom: 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; }
.identity-strip .players { display: grid; grid-template-columns: 1fr; gap: 8px; }
.identity-strip .player { padding: 9px 8px; gap: 6px; border-radius: 4px; background: #fff; }
.identity-strip .player-head { display: grid; gap: 4px; }
.identity-strip .player-head strong { font-size: 14px; line-height: 1.3; }
.identity-strip .player-head > span { font-size: 12px; }
.identity-strip .resources { display: flex; gap: 4px 7px; color: var(--muted); font-size: 12px; }
.identity-strip .resource { padding: 2px 5px; font-size: 12px; }
.context-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.context-panel .turn-guide {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px;
  border: 0;
  border-bottom: 1px solid #c8ded8;
  background: #edf8f5;
}
.action-pane { min-height: 0; overflow-y: auto; }
.context-panel #discardForm { padding: 12px; border-bottom: 1px solid var(--line); overflow-y: auto; }
.activity-panel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.activity-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); }
.activity-tab {
  min-height: 38px;
  padding: 6px;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
}
.activity-tab.active { color: #1f6459; background: #e8f3f0; box-shadow: inset 0 -3px #277c6d; }
.activity-view { min-height: 0; padding: 10px; flex: 1; overflow: hidden; }
.activity-view.active { display: flex; flex-direction: column; }
.activity-view-title { margin: 0 0 7px; color: #435d56; font-size: 12px; line-height: 1.2; text-transform: uppercase; }
.activity-view .log,
.activity-view #chatSection,
.activity-view #chatMessages { min-height: 0; max-height: none; flex: 1; overflow-y: auto; }
.activity-view #chatSection { display: flex; flex-direction: column; }
.activity-view #chatMessages { max-height: 150px; }
.activity-view .chat { flex: 0 0 auto; margin-top: 8px; }
.activity-view .chat button { width: 42px; padding: 8px; }
.activity-view .chat svg { width: 18px; }

.board-feedback {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  width: min(270px, calc(100% - 24px));
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 5px 10px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 6px;
  background: rgba(247,252,251,.96);
  box-shadow: 0 8px 24px rgba(13,48,57,.28);
}
.dice-title { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.dice-visual { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 102px; }
.dice-fallback { display: flex; align-items: center; justify-content: center; gap: 6px; }
#dice3d { display: block; width: 148px; height: 72px; }
#dice3d canvas { display: block; width: 100%; height: 100%; }
.dice-visual.has-3d { min-width: 148px; }
.dice-visual.has-3d .dice-fallback { display: none; }
.dice-visual.has-3d #dice3d[data-state="empty"] { display: none; }
.dice-visual.has-3d #dice3d[data-state="empty"] + .dice-fallback { display: flex; }
.dice-visual.is-rolling #dice3d canvas { filter: saturate(.9) drop-shadow(0 3px 4px rgba(23,53,46,.18)); }
.die {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 42px;
  height: 42px;
  padding: 6px;
  border: 1px solid #b8c9c4;
  border-radius: 7px;
  background: #fff;
  box-shadow: inset 0 -3px 0 #dbe4e1, 0 3px 7px rgba(20,48,41,.18);
  transform-origin: center;
}
.die i { align-self: center; justify-self: center; width: 7px; height: 7px; border-radius: 50%; background: #26352f; opacity: 0; }
.die i.visible { opacity: 1; }
.die[data-value="0"]::after { content: "?"; grid-area: 1 / 1 / 4 / 4; place-self: center; color: #81918c; font-size: 20px; font-style: normal; }
.dice-plus { color: #6f7f7a; font-weight: 800; }
.dice-total { min-width: 28px; font-size: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.dice-visual.is-rolling .die { animation: dice-tumble 400ms ease-in-out infinite alternate; }
.dice-visual.is-rolling .die:last-child { animation-delay: -180ms; animation-direction: alternate-reverse; }
.dice-visual.is-rolling .die i { opacity: .2; }
@keyframes dice-tumble {
  from { transform: translateY(-3px) rotate(-9deg) scale(.96); box-shadow: inset 0 -2px 0 #dbe4e1, 0 5px 9px rgba(20,48,41,.2); }
  to { transform: translateY(2px) rotate(8deg) scale(1.04); box-shadow: inset 0 -4px 0 #dbe4e1, 0 2px 4px rgba(20,48,41,.16); }
}
.board-feedback #rollDice { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; font-weight: 800; box-shadow: 0 4px 0 #572d3a, 0 7px 14px rgba(55,29,38,.18); }
.board-feedback #rollDice:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 0 #572d3a, 0 9px 16px rgba(55,29,38,.2); }
.board-feedback #rollDice:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #572d3a; }
.board-feedback #rollDice svg { width: 19px; height: 19px; }
.board-feedback .production-result { grid-column: 1 / -1; padding: 5px 7px; max-height: 58px; overflow-y: auto; }
.playing-view #game[data-phase="roll"] .board-feedback { width: min(300px, calc(100% - 24px)); }
.playing-view #game[data-phase="roll"] .board-feedback #rollDice { display: flex; }

.action-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  height: 58px;
  min-height: 58px;
  border: 1px solid #bdcfca;
  border-radius: 6px;
  background: #f8fbfa;
  box-shadow: 0 -5px 18px rgba(32,51,45,.1);
}
.action-dock .hand-bar { position: static; display: grid; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 10px; min-width: 0; padding: 5px 10px; border: 0; box-shadow: none; }
.action-dock .hand-heading { display: grid; gap: 0; margin: 0; }
.action-dock .hand-heading h2 { font-size: 12px; white-space: nowrap; }
.action-dock #handTotal { color: #72817c; font-size: 11px; white-space: nowrap; }
.action-dock .resource-hand { gap: 7px; align-items: center; }
.action-dock .hand-resource { padding-right: 7px; }
.action-dock .hand-resource dt { gap: 4px; font-size: 12px; }
.action-dock .hand-resource dd { font-size: 19px; }
.action-dock .hand-art { width: 25px; height: 25px; }
.dock-actions { display: grid; grid-template-columns: repeat(var(--dock-action-count, 4), minmax(0,1fr)); border-left: 1px solid var(--line); }
.dock-actions button {
  position: relative;
  min-width: 0;
  min-height: 100%;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 7px 4px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  font-size: 12px;
}
.dock-actions button:first-child { border-left: 0; }
.dock-actions button:disabled { color: #71807c; background: #edf1f0; opacity: 1; }
.dock-actions svg { width: 20px; height: 20px; }
.dock-actions small { position: absolute; top: 6px; right: 7px; min-width: 18px; padding: 1px 4px; border-radius: 9px; color: white; background: #246f64; }

.audio-settings { display: grid; gap: 1px; padding: 16px; background: #d7e1de; }
.audio-setting { display: grid; gap: 13px; padding: 15px; background: #fbfdfc; }
.audio-toggle,
.audio-volume { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.audio-toggle span { display: grid; gap: 2px; }
.audio-toggle small { color: var(--muted); }
.audio-toggle input { width: 42px; min-height: 24px; accent-color: #267568; }
.audio-volume { display: grid; grid-template-columns: 20px minmax(0,1fr) 42px; }
.audio-volume svg { width: 18px; }
.audio-volume input { min-height: 24px; padding: 0; accent-color: #267568; }
.audio-volume output { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

.mobile-overflow-trigger,
.mobile-sheet-heading,
.mobile-sheet-backdrop { display: none; }
.game-sheet { width: min(560px, calc(100vw - 24px)); max-height: 88dvh; padding: 0; overflow-x: hidden; overflow-y: auto; }
.game-sheet.wide-sheet { width: min(920px, calc(100vw - 24px)); }
.sheet-heading { justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: #edf5f3; }
.sheet-heading h2 { font-size: 20px; }
.game-sheet .mode-card,
.game-sheet .trade-card,
.game-sheet .development-section { padding: 16px; border: 0; background: #f8fbfa; }
.game-sheet .mode-grid { grid-template-columns: repeat(3, 1fr); }
.game-sheet .mode { min-height: 74px; flex-direction: column; justify-content: center; }
.game-sheet .trade-row { grid-template-columns: minmax(0,1fr) auto minmax(0,1fr) auto; }
.game-sheet .trade-row button { grid-column: auto; }
.game-sheet .development-section { max-height: none; overflow: visible; }
.game-sheet .development-card,
.game-sheet .development-card * { writing-mode: horizontal-tb; }

@media (min-width: 761px) {
  body.playing-view { height: 100dvh; overflow: hidden; }
  .playing-view .shell { width: calc(100vw - 20px); max-width: none; height: 100%; padding: 8px 0; }
  .playing-view #game { height: 100%; display: flex; flex-direction: column; gap: 7px; }
  .playing-view .topbar { flex: 0 0 58px; min-height: 58px; padding: 7px 10px; }
  .playing-view .topbar h2 { max-width: 450px; margin: 0; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .playing-view .top-actions { flex-wrap: nowrap; gap: 5px; }
  .playing-view .top-actions button { min-height: 36px; padding: 6px 9px; }
  .playing-view .top-actions .icon-button { width: 36px; padding: 6px; }
  .playing-view .runtime-bar { position: static; flex: 0 0 38px; min-height: 38px; padding: 5px 10px; border-radius: 4px; }
  .playing-view .runtime-bar svg { width: 16px; }
  .playing-view .board-panel,
  .playing-view #board { height: 100%; min-height: 0; }
  .playing-view #rollDice,
  .playing-view #endTurn { display: none; }
  .playing-view .context-panel { display: grid; grid-template-rows: minmax(0, 2fr) minmax(0, 3fr); }
  .playing-view .activity-panel { display: grid; grid-template-rows: minmax(106px, 5fr) minmax(120px, 7fr); }
  .playing-view .activity-tabs { display: none; }
  .playing-view .activity-view { display: flex; flex-direction: column; padding: 9px 10px; }
  .playing-view .activity-view + .activity-view { border-top: 1px solid var(--line); }
  .playing-view .activity-view #chatMessages { max-height: none; }
  .playing-view.is-waiting .game-workspace,
  .playing-view.is-waiting .action-dock { display: none; }
}

@media (max-width: 980px) and (min-width: 761px) {
  .game-workspace { grid-template-columns: 150px minmax(0,1fr) 270px; }
  .action-dock { grid-template-columns: minmax(0,1fr) 300px; }
  .identity-strip .resources { display: none; }
}

@media (max-width: 760px) {
  body.playing-view { background: #dfe9e7; }
  .playing-view .shell { width: 100%; padding: 0 8px 8px; }
  .playing-view #game { display: flex; flex-direction: column; gap: 6px; padding-bottom: 0; }
  .playing-view .topbar,
  .playing-view .context-panel { backdrop-filter: none; }
  .playing-view .topbar { position: sticky; top: 0; z-index: 4; min-height: 58px; padding: 6px 8px; border-inline: 0; }
  .playing-view .topbar:has(.top-actions.mobile-open) { z-index: 11; }
  .playing-view .game-mark,
  .playing-view .status-cluster { display: none; }
  .playing-view .topbar h2 { max-width: 230px; margin: 0; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-overflow-trigger { display: inline-flex; width: 36px; min-height: 36px; padding: 7px; }
  .playing-view .top-actions {
    display: none;
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    max-height: 72dvh;
    padding: 12px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    overflow-y: auto;
    border-radius: 10px 10px 0 0;
    background: #f8fbfa;
    box-shadow: 0 -12px 36px rgba(14, 37, 34, .24);
  }
  .playing-view .top-actions.mobile-open { display: grid; }
  .playing-view .top-actions button { width: 100%; min-height: 44px; }
  .playing-view .top-actions .icon-button { width: 100%; padding: 8px; }
  .mobile-sheet-heading { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; min-height: 38px; }
  .mobile-sheet-heading .icon-button { width: 36px; min-height: 36px; padding: 6px; }
  .mobile-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 8;
    width: 100%;
    min-height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(14, 35, 32, .42);
  }
  .mobile-sheet-backdrop:not([hidden]) { display: block; }
  .playing-view .runtime-bar { position: static; order: 0; min-height: 36px; padding: 5px 8px; }
  .game-workspace { display: flex; flex-direction: column; gap: 6px; }
  .player-rail { order: 0; overflow: hidden; padding: 6px; }
  .player-rail > h3 { display: none; }
  .identity-strip .players { display: flex; gap: 6px; overflow-x: auto; }
  .identity-strip .player { flex: 0 0 148px; padding: 6px; }
  .identity-strip .player-head { gap: 1px; }
  .identity-strip .resources { display: none; }
  .board-stage { order: 1; height: auto; }
  .board-panel { height: auto; aspect-ratio: 760 / 660; }
  .board-panel #board { min-height: 0; height: 100%; }
  .board-toolbar { top: 6px; left: 6px; }
  .board-toolbar button { width: 34px; height: 34px; min-height: 34px; }
  .board-feedback { right: 7px; bottom: 7px; grid-template-columns: 1fr auto; width: 158px; padding: 6px 8px; gap: 4px 6px; }
  .board-feedback .dice-title { display: none; }
  .board-feedback .dice-visual { min-width: 0; gap: 3px; }
  .board-feedback #dice3d { width: 104px; height: 52px; }
  .board-feedback .dice-visual.has-3d { min-width: 104px; }
  .board-feedback .die { width: 34px; height: 34px; padding: 5px; }
  .board-feedback .die i { width: 6px; height: 6px; }
  .board-feedback .dice-total { font-size: 20px; }
  .board-feedback #rollDice,
  .board-feedback .production-result { display: none; }
  .playing-view #game[data-phase="roll"] .board-feedback { width: 174px; }
  .playing-view #game[data-phase="roll"] .board-feedback #rollDice { display: flex; min-height: 36px; }
  .context-panel { order: 2; overflow: visible; }
  .action-pane { overflow: visible; }
  .context-panel .turn-guide { padding: 10px; }
  .activity-panel { display: none; }
  .activity-panel.mobile-open {
    display: flex;
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    width: 100%;
    max-height: 72dvh;
    min-height: min(390px, 58dvh);
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    overflow: hidden;
    border-radius: 10px 10px 0 0;
    background: #f8fbfa;
    box-shadow: 0 -12px 36px rgba(14, 37, 34, .24);
  }
  .activity-panel .mobile-sheet-heading { padding: 8px 10px; border-bottom: 1px solid var(--line); }
  .activity-view-title { display: none; }
  .activity-view { min-height: 190px; }
  .activity-view #chatMessages { max-height: 150px; }
  .action-dock { position: sticky; bottom: 0; z-index: 4; grid-template-columns: 1fr; min-height: 0; }
  .action-dock { height: auto; }
  .action-dock .hand-bar { padding: 5px 7px; }
  .action-dock .hand-heading { margin-bottom: 2px; }
  .action-dock .resource-hand { gap: 2px; }
  .action-dock .hand-resource { flex-direction: row; padding-right: 3px; gap: 2px; }
  .action-dock .hand-resource dt { flex-direction: column; font-size: 11px; gap: 0; }
  .action-dock .hand-resource dd { font-size: 19px; }
  .action-dock .hand-art { width: 20px; height: 20px; }
  .dock-actions { min-height: 48px; border-top: 1px solid var(--line); border-left: 0; }
  .dock-actions button { min-height: 48px; flex-direction: row; gap: 4px; }
  .dock-actions svg { width: 17px; }
  .dock-actions small { top: 3px; right: 4px; }
  .game-sheet[open] { width: 100%; max-width: none; max-height: 82dvh; margin: auto 0 0; border-radius: 10px 10px 0 0; }
  .game-sheet .mode-grid { grid-template-columns: 1fr; }
  .game-sheet .mode { min-height: 58px; flex-direction: row; justify-content: space-between; }
  .game-sheet .trade-row { grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); }
  .game-sheet .trade-row button { grid-column: 1 / -1; }
  .game-sheet .development-hand { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .lobby:not(.hidden) { animation: none; }
  .dice-visual.is-rolling .die { animation: none; }
  .placement-road { transition: none; }
}

@media (max-width: 390px) {
  .playing-view .shell { padding-inline: 5px; }
  .playing-view .topbar h2 { max-width: 205px; }
  .playing-view .board-panel { aspect-ratio: 800 / 620; }
  .context-panel .turn-guide { padding: 5px 8px; }
  .turn-guide h3 { font-size: 16px; line-height: 1.25; }
  .turn-guide p { margin: 3px 0; line-height: 1.35; }
  .guide-owner { padding-bottom: 3px; }
  #guideOptionsLabel { margin-top: 4px; }
  #guideOptions { margin: 3px 0 5px; }
  #guidePrimary { margin: 5px 0; }
  .dock-actions button span { font-size: 11px; }
  .game-sheet .development-hand { grid-template-columns: 1fr; }
}


/* Phase 8 Test Dice multi-game acceptance surface */
.test-dice-stage,
.test-dice-game-stage {
  width: min(920px, 100%);
  margin-inline: auto;
}
.test-dice-lobby-card,
.test-dice-room-card {
  display: grid;
  gap: 16px;
}
.test-dice-note {
  margin: 0;
  line-height: 1.7;
}
.test-dice-room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: .9rem;
  font-weight: 700;
}
.test-dice-players {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.test-dice-player {
  min-height: 112px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(200, 165, 106, .4);
  background: rgba(20, 38, 43, .94);
  color: #edf3f2;
  box-shadow: 0 10px 24px rgba(0,0,0,.12);
}
.test-dice-player.is-self {
  outline: 2px solid #c8a56a;
  outline-offset: 2px;
}
.test-dice-player > div {
  display: flex;
  align-items: center;
  gap: 8px;
}
.test-dice-player em {
  margin-left: auto;
  color: #f0d7a6;
  font-style: normal;
  font-size: .82rem;
}
.test-dice-player p {
  margin: 12px 0 0;
  color: #d9e4e2;
}
.test-dice-result {
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(39, 65, 69, .96);
  border: 1px solid rgba(200, 165, 106, .42);
  color: #edf3f2;
}
.test-dice-result h2,
.test-dice-result p {
  color: #edf3f2;
}
.test-dice-result ol {
  display: grid;
  gap: 6px;
  padding-left: 22px;
}
.test-dice-result li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.test-dice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.test-dice-stage .secondary,
.test-dice-game-stage .secondary {
  background: rgba(20, 38, 43, .94);
  color: #edf3f2;
  border-color: rgba(200, 165, 106, .34);
}
@media (max-width: 640px) {
  .test-dice-actions > button { flex: 1 1 140px; }
  .test-dice-room-meta { flex-direction: column; }
}

/* Mobile usability hardening: portrait + short landscape phones.
   Primary actions stay reachable; secondary information moves to sheets. */
.waiting-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.waiting-heading > div { min-width: 0; }
.waiting-heading #startGame { flex: 0 0 auto; min-height: 44px; }
.robber-marker { pointer-events: none; }
.robber-blocked-tile { stroke: #141b23; stroke-width: 3px; vector-effect: non-scaling-stroke; }

.mobile-action-label,
.mobile-primary-action { display: none; }

dialog.result-panel.victory-panel {
  width: min(920px, calc(100vw - 24px));
  max-width: 920px;
  max-height: min(92dvh, 760px);
  margin: auto;
  overflow: hidden;
}
dialog.result-panel.victory-panel::backdrop {
  background: rgba(2, 8, 12, .82);
  backdrop-filter: blur(4px);
}

.log-item {
  display: grid;
  grid-template-columns: auto minmax(0,1fr);
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border-left: 3px solid #c8a56a;
  border-radius: 0 7px 7px 0;
}
.log-item .time { white-space: nowrap; }

@media (max-width: 760px) {
  .playing-view .topbar {
    grid-template-columns: minmax(0,1fr) auto;
    align-items: center;
    gap: 8px;
  }
  .playing-view .game-brand { min-width: 0; }
  .playing-view .game-brand .eyebrow { font-size: 11px; }
  .playing-view .topbar h2 { max-width: none; }
  .mobile-overflow-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: auto;
    min-width: 70px;
    min-height: 38px;
    padding: 7px 10px;
    font-weight: 800;
  }
  .mobile-overflow-trigger svg { width: 18px; height: 18px; }
  .playing-view .top-actions .mobile-action-label { display: inline; }
  .playing-view .top-actions .icon-button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
  }
  .playing-view .top-actions .icon-button svg { flex: 0 0 auto; }

  .identity-strip .players {
    display: grid;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 4px;
    overflow: visible;
  }
  .identity-strip .players:has(.player:nth-child(4)) {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
  .identity-strip .player {
    min-width: 0;
    flex: none;
    padding: 6px;
  }
  .identity-strip .player-head strong {
    font-size: 12px;
    line-height: 1.2;
  }
  .identity-strip .player-head > span { font-size: 11px; }

  .board-feedback {
    width: 148px;
    padding: 5px 7px;
  }
  .board-feedback #rollDice { display: none !important; }

  .dock-actions .mobile-primary-action:not([hidden]) {
    display: flex;
    color: #172329;
    background: linear-gradient(180deg, #f3d58f, #c69b57);
    border-color: rgba(255,235,185,.34);
    font-weight: 900;
    box-shadow: inset 0 1px rgba(255,255,255,.2);
  }
  .dock-actions .mobile-primary-action:not([hidden]) svg {
    width: 22px;
    height: 22px;
  }

  .activity-panel.mobile-open {
    min-height: min(430px, 64dvh);
  }
  .activity-tabs {
    padding: 0 8px;
    gap: 6px;
    border-bottom: 1px solid var(--line);
  }
  .activity-tab {
    min-height: 42px;
    border-radius: 7px 7px 0 0;
    font-weight: 800;
  }
  .activity-view {
    padding: 10px 12px;
  }
  .activity-view .log {
    gap: 8px;
  }
  .activity-view .log-item {
    padding: 9px 10px;
    font-size: 13px;
    line-height: 1.45;
  }

  dialog.result-panel.victory-panel {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    padding: 18px 14px 16px;
    gap: 14px;
    border-radius: 16px;
  }
  dialog.result-panel.victory-panel .victory-emblem {
    width: 52px;
    height: 52px;
  }
  dialog.result-panel.victory-panel .victory-title {
    font-size: clamp(26px, 9vw, 38px);
  }
  dialog.result-panel.victory-panel .victory-score {
    font-size: clamp(38px, 13vw, 54px);
  }
  dialog.result-panel.victory-panel .victory-ranking {
    gap: 8px;
  }
  dialog.result-panel.victory-panel .victory-rank-card {
    padding: 10px 12px;
  }
  dialog.result-panel.victory-panel .victory-rank-card.rank-first {
    min-height: 82px;
    padding: 13px 14px;
  }
  dialog.result-panel.victory-panel .victory-secondary-ranks {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  dialog.result-panel.victory-panel .victory-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  dialog.result-panel.victory-panel .victory-actions button {
    min-width: 0;
    width: 100%;
  }
}

/* iPhone-class landscape: width exceeds the portrait breakpoint, but height is
   still phone-sized. Collapse secondary panels and preserve board + current action. */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 950px) {
  body.playing-view {
    height: 100dvh;
    overflow: hidden;
  }
  .playing-view .shell {
    width: 100%;
    height: 100%;
    padding: 4px 6px;
  }
  .playing-view #game {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .playing-view .topbar {
    flex: 0 0 48px;
    min-height: 48px;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    padding: 4px 7px;
  }
  .playing-view .game-mark,
  .playing-view .status-cluster { display: none; }
  .playing-view .topbar h2 {
    max-width: none;
    font-size: 13px;
  }
  .mobile-overflow-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 68px;
    min-height: 36px;
    padding: 6px 9px;
  }
  .playing-view .top-actions {
    display: none;
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    grid-template-columns: repeat(3, minmax(0,1fr));
    gap: 7px;
    width: 100%;
    max-height: 78dvh;
    padding: 10px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    overflow-y: auto;
    border-radius: 10px 10px 0 0;
  }
  .playing-view .top-actions.mobile-open { display: grid; }
  .playing-view .top-actions .mobile-action-label { display: inline; }
  .playing-view .top-actions .icon-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    padding: 7px 9px;
  }
  .mobile-sheet-heading {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: space-between;
  }
  .mobile-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 8;
    width: 100%;
    min-height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(4,12,15,.64);
  }
  .mobile-sheet-backdrop:not([hidden]) { display: block; }

  .playing-view .runtime-bar {
    flex: 0 0 32px;
    min-height: 32px;
    padding: 3px 8px;
  }
  .game-workspace {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 122px minmax(0,1fr) 232px;
    gap: 5px;
  }
  .player-rail {
    padding: 5px;
    overflow-y: auto;
  }
  .identity-strip .players {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    overflow: visible;
  }
  .identity-strip .player {
    min-width: 0;
    padding: 5px;
  }
  .identity-strip .player-head strong { font-size: 11px; }
  .identity-strip .player-head > span { font-size: 10px; }
  .board-stage,
  .board-panel {
    height: 100%;
    min-height: 0;
  }
  .board-panel {
    aspect-ratio: auto;
  }
  .board-panel #board {
    height: 100%;
    min-height: 0;
  }
  .board-feedback {
    right: 5px;
    bottom: 5px;
    width: 132px;
    padding: 4px 6px;
  }
  .board-feedback #dice3d {
    width: 86px;
    height: 44px;
  }
  .board-feedback #rollDice { display: none !important; }

  .context-panel {
    display: block;
    min-height: 0;
    overflow-y: auto;
  }
  .context-panel .turn-guide {
    min-height: 100%;
    padding: 8px 9px;
  }
  .context-panel .turn-guide h3 { font-size: 14px; }
  .context-panel .turn-guide p,
  .context-panel .turn-guide li { font-size: 12px; line-height: 1.35; }
  .activity-panel { display: none; }
  .activity-panel.mobile-open {
    display: flex;
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    width: 100%;
    min-height: min(270px, 72dvh);
    max-height: 78dvh;
    overflow: hidden;
    border-radius: 10px 10px 0 0;
  }

  .action-dock {
    flex: 0 0 auto;
    position: static;
    display: grid;
    grid-template-columns: minmax(0,1fr) 330px;
    min-height: 52px;
  }
  .action-dock .hand-bar {
    min-height: 52px;
    padding: 4px 8px;
  }
  .dock-actions .mobile-primary-action:not([hidden]) {
    display: flex;
    color: #172329;
    background: linear-gradient(180deg, #f3d58f, #c69b57);
    font-weight: 900;
  }

  dialog.result-panel.victory-panel {
    width: min(900px, calc(100vw - 16px));
    max-height: calc(100dvh - 12px);
    padding: 10px 14px;
    display: grid;
    grid-template-columns: .9fr 1.1fr;
    grid-template-areas:
      "hero ranking"
      "actions actions";
    gap: 8px 14px;
  }
  dialog.result-panel.victory-panel .victory-hero { grid-area: hero; gap: 2px; }
  dialog.result-panel.victory-panel .victory-ranking { grid-area: ranking; gap: 5px; align-content: center; }
  dialog.result-panel.victory-panel .victory-actions { grid-area: actions; }
  dialog.result-panel.victory-panel .victory-emblem { width: 38px; height: 38px; margin: 0; }
  dialog.result-panel.victory-panel .victory-emblem svg { width: 22px; height: 22px; }
  dialog.result-panel.victory-panel .victory-title { font-size: 23px; }
  dialog.result-panel.victory-panel .victory-score { font-size: 34px; }
  dialog.result-panel.victory-panel .victory-subtitle { font-size: 11px; }
  dialog.result-panel.victory-panel .victory-rank-card,
  dialog.result-panel.victory-panel .victory-rank-card.rank-first {
    min-height: 0;
    padding: 7px 9px;
  }
  dialog.result-panel.victory-panel .victory-rank-player strong { font-size: 12px; }
  dialog.result-panel.victory-panel .rank-first .victory-rank-player strong { font-size: 14px; }
  dialog.result-panel.victory-panel .victory-rank-score { font-size: 13px; }
  dialog.result-panel.victory-panel .rank-first .victory-rank-score { font-size: 16px; }
  dialog.result-panel.victory-panel .victory-secondary-ranks {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  dialog.result-panel.victory-panel .victory-actions {
    display: flex;
    justify-content: center;
  }
  dialog.result-panel.victory-panel .victory-actions button {
    min-height: 36px;
  }
}

/* Lobby / waiting-room responsive correction from device acceptance screenshots. */
dialog.result-panel.victory-panel:not([open]) {
  display: none !important;
}
dialog.result-panel.victory-panel[open] {
  display: grid;
}

.game-view #game.is-waiting .game-workspace,
.game-view #game.is-waiting .action-dock {
  display: none !important;
}
.game-view #game.is-waiting .runtime-bar {
  display: none !important;
}

@media (max-width: 760px) {
  body:not(.playing-view) .shell {
    width: min(100% - 16px, 1180px);
    padding: 8px 0 18px;
  }

  .lobby.auth-stage,
  .lobby.platform-stage,
  .lobby.catan-stage {
    min-height: calc(100dvh - 26px);
    align-content: start;
    place-items: stretch;
    gap: 16px;
  }

  .platform-stage {
    padding-top: 10px;
  }
  .platform-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
  }
  .platform-header > div {
    min-width: 0;
  }
  .platform-header h1 {
    font-size: clamp(2.2rem, 10vw, 3rem);
    line-height: 1;
  }
  .platform-header #signOut {
    flex: 0 0 auto;
    width: auto;
    min-width: 82px;
    margin-top: 2px;
  }
  .platform-stage .game-catalog,
  .platform-stage .game-entry {
    width: 100%;
  }
  .platform-stage .game-entry {
    gap: 14px;
    padding: 18px;
  }
  .platform-stage .game-entry button {
    width: 100%;
  }

  .auth-stage {
    padding-top: 10px;
  }
  .auth-stage .auth-brand {
    width: 100%;
    justify-content: center;
  }
  .auth-stage .auth-brand h1 {
    max-width: none;
    font-size: clamp(2.2rem, 11vw, 3rem);
    white-space: nowrap;
  }
  .auth-stage .auth-brand p:last-child {
    margin-top: 6px;
    font-size: .95rem;
    line-height: 1.4;
  }
  .auth-stage .auth-card {
    width: 100%;
    padding: 18px;
    gap: 12px;
  }

  .catan-stage {
    padding-top: 6px;
  }
  .catan-stage > .back-link {
    width: fit-content;
  }
  .catan-stage > .brand {
    width: 100%;
    justify-content: center;
    gap: 14px;
  }
  .catan-stage > .brand .mark {
    width: 62px;
    height: 62px;
    border-width: 6px;
    font-size: 2rem;
  }
  .catan-stage > .brand h1 {
    font-size: clamp(2.4rem, 11vw, 3.2rem);
  }
  .catan-stage > .brand p:last-child {
    font-size: .9rem;
  }
  .catan-stage > .lobby-card {
    width: 100%;
    padding: 18px;
    gap: 12px;
  }
  .catan-stage .join-row {
    grid-template-columns: 1fr;
  }

  /* Waiting rooms are game views even before a match starts. */
  .game-view:not(.playing-view) .topbar {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 58px;
    padding: 6px 8px;
  }
  .game-view:not(.playing-view) .status-cluster {
    display: none;
  }
  .game-view:not(.playing-view) .game-brand {
    min-width: 0;
  }
  .game-view:not(.playing-view) .game-brand .eyebrow {
    font-size: 11px;
  }
  .game-view:not(.playing-view) .topbar h2 {
    max-width: 100%;
    margin: 0;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .game-view:not(.playing-view) .mobile-overflow-trigger {
    display: inline-flex;
    width: auto;
    min-width: 70px;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 10px;
    white-space: nowrap;
  }
  .game-view:not(.playing-view) .top-actions {
    display: none;
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 8px;
    width: 100%;
    max-height: 72dvh;
    padding: 12px max(12px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left));
    overflow-y: auto;
    border-radius: 10px 10px 0 0;
  }
  .game-view:not(.playing-view) .top-actions.mobile-open {
    display: grid;
  }
  .game-view:not(.playing-view) .top-actions .mobile-action-label {
    display: inline;
  }
  .game-view:not(.playing-view) .top-actions .icon-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 10px;
  }
  .game-view:not(.playing-view) .top-actions button {
    width: 100%;
    min-height: 44px;
  }

  .game-view #game.is-waiting {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .game-view #game.is-waiting .waiting-room {
    display: grid;
    gap: 12px;
    padding: 14px;
  }
  .game-view #game.is-waiting .seat-list {
    grid-template-columns: 1fr;
  }
  .game-view #game.is-waiting .waiting-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .game-view #game.is-waiting .waiting-actions > * {
    width: 100%;
  }
}

/* Short landscape phones need compact lobby layouts instead of a scaled desktop. */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 950px) {
  body:not(.playing-view) {
    overflow-y: auto;
  }
  body:not(.playing-view) .shell {
    width: calc(100% - 16px);
    max-width: none;
    padding: 8px 0 10px;
  }

  .lobby.auth-stage,
  .lobby.platform-stage,
  .lobby.catan-stage {
    min-height: calc(100dvh - 18px);
    place-items: stretch;
    align-content: start;
    gap: 10px 16px;
  }

  .auth-stage {
    grid-template-columns: minmax(220px,.75fr) minmax(360px,1.25fr);
    align-items: center;
  }
  .auth-stage .auth-brand {
    grid-column: 1;
    gap: 12px;
  }
  .auth-stage .auth-brand .mark {
    width: 58px;
    height: 58px;
    border-width: 6px;
    font-size: 1.9rem;
  }
  .auth-stage .auth-brand h1 {
    max-width: none;
    font-size: clamp(2rem,5vw,2.55rem);
    white-space: nowrap;
  }
  .auth-stage .auth-brand p:last-child {
    margin-top: 5px;
    font-size: .86rem;
    line-height: 1.35;
  }
  .auth-stage .auth-card {
    grid-column: 2;
    width: 100%;
    max-height: calc(100dvh - 18px);
    overflow-y: auto;
    padding: 14px 16px;
    gap: 9px;
  }
  .auth-stage .auth-card h2 {
    font-size: 1.15rem;
  }
  .auth-stage .auth-card label {
    gap: 4px;
    font-size: .82rem;
  }
  .auth-stage .auth-card input,
  .auth-stage .auth-card button {
    min-height: 38px;
  }

  .platform-stage {
    grid-template-rows: auto 1fr auto;
  }
  .platform-header {
    display: flex;
    align-items: center;
  }
  .platform-header h1 {
    font-size: 2rem;
  }
  .platform-stage .game-entry {
    grid-template-columns: minmax(0,1fr) auto;
    padding: 14px 16px;
  }
  .platform-stage .game-entry h2 {
    font-size: 1.25rem;
  }
  .platform-stage .game-entry button {
    width: auto;
  }

  .catan-stage {
    grid-template-columns: minmax(220px,.72fr) minmax(380px,1.28fr);
    grid-template-rows: auto 1fr;
  }
  .catan-stage > .back-link {
    grid-column: 1;
    grid-row: 1;
    width: fit-content;
  }
  .catan-stage > .brand {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    margin-top: 8px;
    gap: 12px;
  }
  .catan-stage > .brand .mark {
    width: 58px;
    height: 58px;
    border-width: 6px;
    font-size: 1.9rem;
  }
  .catan-stage > .brand h1 {
    font-size: 2.45rem;
    white-space: nowrap;
  }
  .catan-stage > .brand .stage-path,
  .catan-stage > .brand p:last-child {
    font-size: .78rem;
  }
  .catan-stage > .lobby-card {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 100%;
    max-height: calc(100dvh - 18px);
    overflow-y: auto;
    padding: 14px 16px;
    gap: 9px;
  }
  .catan-stage > .lobby-card label {
    gap: 4px;
    font-size: .82rem;
  }
  .catan-stage > .lobby-card input,
  .catan-stage > .lobby-card select,
  .catan-stage > .lobby-card button {
    min-height: 38px;
  }
  .catan-stage .platform-options {
    gap: 8px;
  }
  .catan-stage .join-row {
    grid-template-columns: 1fr .75fr .6fr;
    gap: 7px;
  }

  .game-view:not(.playing-view) .shell {
    height: 100dvh;
    overflow: hidden;
  }
  .game-view:not(.playing-view) #game {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .game-view:not(.playing-view) .topbar {
    flex: 0 0 50px;
    min-height: 50px;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    padding: 4px 7px;
  }
  .game-view:not(.playing-view) .game-mark,
  .game-view:not(.playing-view) .status-cluster {
    display: none;
  }
  .game-view:not(.playing-view) .mobile-overflow-trigger {
    display: inline-flex;
    min-width: 72px;
    min-height: 36px;
    white-space: nowrap;
  }
  .game-view:not(.playing-view) .top-actions {
    display: none;
    position: fixed;
    inset: auto 0 0;
    z-index: 10;
    grid-template-columns: repeat(3,minmax(0,1fr));
    gap: 7px;
    width: 100%;
    max-height: 78dvh;
    padding: 10px 12px 12px;
    overflow-y: auto;
    border-radius: 10px 10px 0 0;
  }
  .game-view:not(.playing-view) .top-actions.mobile-open {
    display: grid;
  }
  .game-view:not(.playing-view) .top-actions .mobile-action-label {
    display: inline;
  }
  .game-view:not(.playing-view) .top-actions .icon-button {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    gap: 7px;
  }
  .game-view #game.is-waiting .waiting-room {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 12px;
    gap: 9px;
  }
  .game-view #game.is-waiting .waiting-room h2 {
    font-size: 1.15rem;
  }
  .game-view #game.is-waiting #waitingSummary {
    font-size: .82rem;
  }
  .game-view #game.is-waiting .seat-list {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .game-view #game.is-waiting .seat {
    padding: 7px 8px;
  }
  .game-view #game.is-waiting .waiting-actions {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 7px;
  }
}

/* Compact phone gameplay feedback: keep the board visible and remove duplicated
   instructional lists that are already represented by the action dock. */
@media (max-width: 760px) {
  .playing-view .board-feedback {
    width: 118px;
    min-width: 0;
    padding: 4px 6px;
    gap: 2px 5px;
    border-radius: 6px;
  }
  .playing-view .board-feedback .dice-visual {
    min-width: 78px;
    min-height: 34px;
    gap: 2px;
  }
  .playing-view .board-feedback #dice3d {
    width: 78px;
    height: 40px;
  }
  .playing-view .board-feedback .dice-visual.has-3d {
    min-width: 78px;
  }
  .playing-view .board-feedback .die {
    width: 32px;
    height: 32px;
    padding: 4px;
    border-radius: 5px;
  }
  .playing-view .board-feedback .die i {
    width: 5px;
    height: 5px;
  }
  .playing-view .board-feedback .dice-total {
    min-width: 22px;
    font-size: 18px;
  }
  .playing-view #game[data-phase="roll"] .board-feedback {
    width: 118px;
  }

  .playing-view .context-panel .turn-guide {
    margin-bottom: 0;
    padding: 8px 10px;
  }
  .playing-view .turn-guide h3 {
    margin-top: 3px;
    font-size: 16px;
    line-height: 1.25;
  }
  .playing-view .turn-guide p {
    margin: 4px 0;
    font-size: 13px;
    line-height: 1.4;
  }
  .playing-view .guide-owner {
    padding-bottom: 4px;
    font-size: 12px;
  }
  .playing-view #guideOptionsLabel,
  .playing-view #guideOptions {
    display: none !important;
  }
  .playing-view #guidePrimary {
    margin: 6px 0 2px;
  }
  .playing-view #endTurn {
    margin-top: 6px;
  }
}

@media (max-height: 500px) and (orientation: landscape) and (max-width: 950px) {
  .playing-view .board-feedback {
    width: 104px;
    padding: 3px 5px;
    gap: 2px 4px;
  }
  .playing-view .board-feedback #dice3d {
    width: 68px;
    height: 34px;
  }
  .playing-view .board-feedback .dice-visual.has-3d {
    min-width: 68px;
  }
  .playing-view .board-feedback .die {
    width: 25px;
    height: 25px;
    padding: 3px;
  }
  .playing-view .board-feedback .dice-total {
    min-width: 20px;
    font-size: 17px;
  }
  .playing-view #game[data-phase="roll"] .board-feedback {
    width: 104px;
  }

  .playing-view .context-panel .turn-guide {
    padding: 6px 8px;
  }
  .playing-view .turn-guide h3 {
    font-size: 13px;
    line-height: 1.2;
  }
  .playing-view .turn-guide p {
    margin: 2px 0;
    font-size: 11px;
    line-height: 1.3;
  }
  .playing-view .guide-owner {
    padding-bottom: 3px;
    font-size: 10px;
  }
  .playing-view #guidePrimary,
  .playing-view #endTurn {
    min-height: 34px;
    margin-top: 4px;
    padding-block: 5px;
    font-size: 12px;
  }
}
.big-two-lobby,.big-two-game { max-width:1100px; margin:0 auto; padding:20px clamp(12px,3vw,28px) 40px; }
.big-two-catalog-art { display:flex; align-items:center; justify-content:center; gap:8px; width:100%; height:100%; background:#27664f; }
.big-two-catalog-art span { display:grid; align-content:space-between; width:56px; height:82px; border-radius:5px; background:#fff; color:#202923; padding:7px; font-size:24px; box-shadow:0 4px 12px #12332355; }
.big-two-catalog-art span:nth-child(2) { color:#b33d48; transform:rotate(8deg); }
.big-two-catalog-art span:first-child { transform:rotate(-8deg); }
.big-two-catalog-art b { font-size:19px; justify-self:end; }
.big-two-lobby-layout { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:24px; margin-top:24px; }
.big-two-lobby.lobby { display:block; min-height:0; place-items:stretch; }
.big-two-hero,.big-two-lobby-layout { width:100%; }
.big-two-lobby .room-browser { max-width:none; width:100%; }
.big-two-lobby,.big-two-game { --panel:#122b35; --line:#36525b; --muted:#adc3ca; color:#eef5f6; background:#102530; border-radius:6px; }
.big-two-lobby input,.big-two-game input { background:#173641; color:#f2f7f8; border-color:#52737c; }
.big-two-lobby .secondary,.big-two-game .secondary { background:#1c3d46; color:#f2f7f8; border-color:#52737c; }
.big-two-lobby button:not(.secondary),.big-two-game .big-two-waiting-actions button:not(.secondary) { background:#e3bb65; color:#172e35; }
.big-two-lobby button:focus-visible,.big-two-game button:focus-visible { outline:3px solid #f4d991; outline-offset:3px; }
.big-two-hero { display:flex; justify-content:space-between; align-items:center; gap:16px; margin-top:16px; padding-bottom:18px; border-bottom:1px solid var(--line); }
.big-two-hero h1 { font-size:32px; margin:0; }
.big-two-hero button { min-height:48px; display:flex; align-items:center; justify-content:center; gap:8px; }
.big-two-entry h2,.big-two-public h2,.big-two-waiting-heading h2 { font-size:20px; margin:0; }
.big-two-public { margin-top:24px; }
.big-two-public .room-row { width:100%; min-width:0; }
.big-two-public .room-row strong { overflow-wrap:anywhere; }
.big-two-public .room-row small { color:var(--muted); }
.big-two-visibility { border:0; padding:0; margin:0; min-width:0; }
.big-two-visibility legend { margin-bottom:5px; }
.big-two-visibility > div { display:grid; grid-template-columns:1fr 1fr; }
.big-two-visibility button { border-radius:0; padding:10px 4px; background:#1c3d46!important; color:#f2f7f8!important; }
.big-two-visibility button[aria-pressed="true"] { background:#e3bb65!important; color:#172e35!important; }
.big-two-waiting-heading { display:flex; align-items:center; justify-content:space-between; margin-top:20px; gap:10px; }
.big-two-seat { position:relative; padding-right:42px!important; }
.big-two-seat .icon-button { position:absolute; right:4px; top:8px; }
.big-two-seat.is-ready { border-color:#70ba9b; }
.big-two-seat.is-empty { border-style:dashed; }
#bigTwoJoinError { color:#ffb9ad; font-size:14px; margin:0; }
.big-two-top h1 { overflow-wrap:anywhere; }
@media(max-width:700px) { .big-two-hero { align-items:flex-start; flex-direction:column; gap:12px; } .big-two-hero button { width:100%; } .big-two-hero h1 { font-size:28px; } .big-two-top { flex-wrap:wrap; } .big-two-top-actions { flex-wrap:wrap; } }
.big-two-entry { border:1px solid var(--line); border-radius:12px; align-self:start; background:#15313b; }
.big-two-entry summary { padding:18px; cursor:pointer; font-size:19px; font-weight:700; min-height:48px; }
.big-two-entry summary span { display:block; font-size:14px; font-weight:400; color:var(--muted); margin-top:5px; }
.big-two-entry-form { display:grid; gap:12px; padding:0 18px 18px; }
.big-two-entry label { display:grid; gap:5px; }
.big-two-top { display:flex; justify-content:space-between; align-items:center; gap:16px; border-bottom:1px solid var(--line); padding-bottom:14px; }
.big-two-top h1 { margin:0; font-size:32px; line-height:1.2; }
.big-two-connection { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:8px 0; color:#ba443f; font-size:13px; }
.big-two-connection span { min-width:0; }
.big-two-top-actions,.big-two-waiting-actions,.big-two-actions,.big-two-quick { display:flex; gap:8px; align-items:center; }
.big-two-top-actions { flex:none; }
.big-two-top-actions button { white-space:nowrap; }
.big-two-seats { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; margin:18px 0; }
.big-two-seat { border:1px solid var(--line); border-radius:6px; padding:10px; min-height:62px; display:grid; align-content:center; gap:2px; }
.big-two-seat strong,.big-two-opponent strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.big-two-seat small,.big-two-opponent small { color:var(--muted); }
.big-two-waiting-actions { flex-wrap:wrap; }
.big-two-result { margin:18px auto; padding:20px; max-width:600px; border:1px solid #e3bb6570; border-radius:16px; background:linear-gradient(145deg,#193b43,#122b35); text-align:center; scroll-margin-top:12px; animation:big-two-result-in 260ms ease-out; }
.big-two-result h2 { margin:4px 0; color:#f4d991; font-size:clamp(24px,4vw,32px); }
.big-two-result p { margin:8px 0; }
.big-two-result-emblem { font-size:42px; line-height:1.2; }
.big-two-result-players { list-style:none; padding:0; margin:16px 0; text-align:left; }
.big-two-result-players li { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:10px; border-bottom:1px solid var(--line); }
.big-two-result-players span { overflow-wrap:anywhere; min-width:0; }
.big-two-result-players small { display:block; color:var(--muted); }
.big-two-result-players strong { white-space:nowrap; }
.big-two-result-players .is-winner { background:#e3bb6515; border-radius:8px; color:#f4d991; }
.big-two-result-actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.big-two-result-actions button { min-height:48px; }
#bigTwoRematch { background:#e3bb65; color:#172e35; }
.big-two-rematch-seats { display:flex; flex-wrap:wrap; justify-content:center; gap:6px 12px; font-size:12px; color:var(--muted); }
@keyframes big-two-result-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
@media(prefers-reduced-motion:reduce) { .big-two-result { animation:none; } }
@media(max-width:700px) { .big-two-result { padding:14px; } .big-two-hero button { min-height:58px; font-size:20px; } }
.big-two-table { min-width:0; min-height:min(700px,75vh); display:grid; grid-template-columns:minmax(0,1fr); grid-template-rows:auto auto minmax(160px,1fr) auto auto; gap:14px; padding-top:16px; }
.big-two-status { display:flex; align-items:center; gap:12px; min-height:40px; }
.big-two-status strong { flex:1; }
#bigTwoTimer { font-variant-numeric:tabular-nums; font-weight:700; }
.big-two-opponents { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.big-two-opponent { display:grid; gap:2px; border-bottom:3px solid var(--line); padding:8px; }
.big-two-opponent.is-acting { border-color:#c45b45; }
.big-two-center { min-height:150px; display:grid; align-content:center; justify-items:center; gap:8px; background:#e4eee6; color:#1f2520; border:1px solid #c0d4c6; border-radius:6px; padding:12px; }
.big-two-center p { margin:0; text-align:center; }
.big-two-current-play { display:flex; justify-content:center; gap:3px; min-height:78px; }
.big-two-card { display:grid; grid-template-rows:auto 1fr auto; width:50px; height:74px; flex:none; border:1px solid #bcc5be; border-radius:5px; background:#fff; color:#1f2520; padding:4px; font-size:16px; font-weight:700; line-height:1; box-shadow:0 2px 4px #223b2630; }
.big-two-card.is-red { color:#be4047; }
.big-two-current-play .big-two-card:disabled { opacity:1; }
.big-two-card .suit { align-self:center; justify-self:center; font-size:24px; }
.big-two-card .corner-suit { justify-self:end; font-size:12px; }
.big-two-hand-heading { display:flex; justify-content:space-between; padding-bottom:8px; }
.big-two-hand { display:flex; gap:3px; max-width:100%; overflow-x:auto; padding:12px 4px 18px; min-height:101px; scrollbar-width:thin; }
.big-two-hand .big-two-card { cursor:pointer; transition:transform 120ms ease,border-color 120ms ease; }
.big-two-hand .big-two-card.is-selected { transform:translateY(-10px); border:2px solid #24738b; }
.big-two-hand .big-two-card:focus-visible { outline:3px solid #24738b; outline-offset:2px; }
.big-two-actions { display:grid; grid-template-columns:1fr 1.4fr; }
.big-two-actions button { min-height:48px; }
.big-two-chat { border-top:1px solid var(--line); margin-top:16px; padding-top:12px; }
.big-two-chat summary { cursor:pointer; font-weight:700; }
.big-two-chat-messages { max-height:190px; overflow:auto; display:grid; align-content:start; gap:5px; padding:10px 0; }
.big-two-chat-messages p { margin:0; overflow-wrap:anywhere; }
.big-two-quick { flex-wrap:wrap; margin:8px 0; }
.big-two-chat form { display:flex; gap:8px; }
.big-two-chat form input { flex:1; min-width:0; }
#bigTwoMuteList { display:flex; flex-wrap:wrap; gap:8px; margin-top:8px; }
@media(prefers-reduced-motion:reduce) { .big-two-hand .big-two-card { transition:none; } }
@media(max-width:700px) {
  .big-two-lobby-layout { grid-template-columns:1fr; }
  .big-two-top { align-items:flex-start; }
  .big-two-top h1 { font-size:24px; }
  .big-two-seats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .big-two-table { min-height:0; grid-template-rows:auto auto minmax(120px,180px) auto auto; gap:8px; }
  .big-two-opponent { padding:5px; }
  .big-two-center { min-height:120px; }
  .big-two-card { width:42px; height:65px; font-size:14px; }
  .big-two-card .suit { font-size:20px; }
  .big-two-hand { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:5px 3px; overflow:visible; min-height:140px; }
  .big-two-hand .big-two-card { width:100%; }
  .big-two-current-play { min-height:65px; }
  .big-two-actions { position:sticky; bottom:0; z-index:5; background:var(--panel); padding:6px 0 max(8px,env(safe-area-inset-bottom)); }
}
@media(max-height:500px) and (orientation:landscape) and (max-width:950px) {
  .big-two-game { padding-top:8px; }
  .big-two-top { padding-bottom:6px; }
  .big-two-top h1 { font-size:24px; }
  .big-two-top .stage-path { margin:0 0 3px; }
  .big-two-table { min-height:0; padding-top:6px; gap:6px; grid-template-columns:minmax(0,1fr) minmax(0,1fr); grid-template-rows:32px 48px 100px 48px; }
  .big-two-status { grid-column:1 / -1; grid-row:1; min-height:32px; }
  .big-two-opponents { grid-column:1; grid-row:2; gap:3px; }
  .big-two-opponent { padding:2px; font-size:12px; }
  .big-two-center { grid-column:1; grid-row:3; min-height:0; padding:4px; gap:3px; font-size:12px; }
  .big-two-own { grid-column:2; grid-row:2 / 4; min-width:0; }
  .big-two-hand { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:5px 3px; overflow:visible; min-height:0; padding:10px 3px 3px; }
  .big-two-hand .big-two-card { width:100%; }
  .big-two-card { height:56px; width:38px; font-size:13px; }
  .big-two-card .suit { font-size:18px; }
  .big-two-current-play { min-height:56px; }
  .big-two-actions { grid-column:1 / -1; grid-row:4; position:static; padding:0; }
  .big-two-chat { margin-top:8px; padding-top:8px; }
}

/* UX V2.1: opponents and real card counts belong on the playing surface. */
.big-two-table { min-height:0; grid-template-rows:auto auto auto auto; gap:8px; }
.big-two-arena { display:grid; grid-template-rows:auto 1fr; gap:10px; min-height:280px; padding:12px; border:5px solid #41666a; border-radius:70px; background:radial-gradient(ellipse at center,#267064,#144c47 70%,#103b39); box-shadow:inset 0 0 0 2px #90b2a139,inset 0 0 48px #041b2670,0 8px 20px #0003; }
.big-two-opponents { gap:clamp(8px,3vw,38px); align-items:start; max-width:750px; width:100%; margin:0 auto; }
.big-two-opponent { display:grid; justify-items:center; gap:3px; padding:6px 8px; border:1px solid #79a89b60; border-radius:14px; background:#0d2a32e8; box-shadow:0 3px 10px #0003; min-width:0; position:relative; }
.big-two-opponent strong { max-width:100%; color:#f4f8f6; font-size:15px; }
.big-two-avatar { display:grid; place-items:center; width:34px; height:34px; border-radius:50%; background:#365d68; border:1px solid #74999d; color:#f5d592; font-size:22px; }
.big-two-opponent.is-acting { border:2px solid #f4d991; box-shadow:0 0 0 3px #e3bb6525; }
.big-two-card-count { display:flex; align-items:center; justify-content:center; gap:5px; color:#fff; line-height:1; }
.big-two-card-count b { font-size:28px; font-variant-numeric:tabular-nums; }
.big-two-card-count small { color:#d9e9e4; }
.big-two-card-back { width:17px; height:24px; border:2px solid #d5dfeb; border-radius:3px; background:repeating-linear-gradient(45deg,#2a4a72 0 3px,#456895 3px 5px); box-shadow:-3px 0 0 #6086ad; }
.big-two-opponent.is-low-cards .big-two-card-count { color:#ffd888; }
.big-two-player-state { min-height:16px; }
.big-two-opponent.is-acting .big-two-player-state { color:#f4d991; font-weight:700; }
.big-two-center { background:transparent; border:0; color:#e7f3ee; min-height:120px; padding:0; }
.big-two-center #bigTwoLead { font-weight:700; }
.big-two-center #bigTwoRound { font-size:12px; opacity:.7; }
.big-two-table-mark { align-self:center; color:#b5d1bc35; font-size:32px; letter-spacing:10px; }
.big-two-current-play .big-two-card { width:62px; height:88px; animation:big-two-deal-in 180ms ease-out; box-shadow:0 4px 10px #0005; }
.big-two-current-play .big-two-card + .big-two-card { margin-left:-10px; }
.big-two-own { padding:12px 14px 0; border:1px solid #36525b; border-radius:14px; background:#112c35; }
.is-own-turn .big-two-own { border-color:#e3bb65; box-shadow:0 0 0 2px #e3bb6515; }
#bigTwoOwnName { font-size:13px; font-weight:400; color:var(--muted); }
#bigTwoHandCount { font-size:19px; font-weight:700; color:#f4d991; }
.big-two-hand { justify-content:center; }
.big-two-hand .big-two-card { width:60px; height:88px; font-size:20px; }
.big-two-hand .big-two-card + .big-two-card { margin-left:-14px; }
.big-two-hand .big-two-card.is-selected { border-color:#e3bb65; box-shadow:0 4px 12px #e3bb6545; }
#bigTwoSelectionStatus { margin:0 0 8px; min-height:18px; color:#b9d3ce; font-size:13px; text-align:center; }
.big-two-status { padding:6px 10px; border-radius:10px; background:#173641; }
#bigTwoTimer { display:inline-block; padding:5px 10px; border:1px solid #e3bb6570; border-radius:20px; color:#f4d991; font-size:19px; }
#bigTwoPlay { background:#e3bb65; color:#172e35; font-size:18px; }
@keyframes big-two-deal-in { from { opacity:.4; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@media(max-width:700px) {
  .big-two-arena { min-height:230px; padding:10px 8px 6px; gap:6px; border-width:3px; border-radius:28px; }
  .big-two-opponents { gap:5px; }
  .big-two-opponent { padding:6px 3px; gap:3px; border-radius:10px; }
  .big-two-opponent strong { font-size:12px; }
  .big-two-card-count b { font-size:24px; }
  .big-two-avatar { width:27px; height:27px; font-size:18px; }
  .big-two-player-state { font-size:11px; }
  .big-two-center { min-height:115px; font-size:13px; gap:6px; }
  .big-two-current-play .big-two-card { width:44px; height:65px; font-size:16px; }
  .big-two-own { padding:8px 6px 0; }
  .big-two-hand { min-height:145px; padding:10px 0 10px; gap:5px 3px; }
  .big-two-hand .big-two-card { width:100%; height:65px; font-size:16px; }
  .big-two-hand .big-two-card + .big-two-card { margin-left:0; }
  #bigTwoSelectionStatus { font-size:12px; margin-bottom:4px; }
}
@media(max-height:500px) and (orientation:landscape) and (max-width:950px) {
  .big-two-table { grid-template-rows:36px 184px 48px; }
  .big-two-arena { grid-column:1; grid-row:2; min-height:0; padding:5px; gap:2px; border-radius:20px; border-width:2px; }
  .big-two-opponents { gap:3px; }
  .big-two-opponent { padding:3px 2px; grid-template-columns:auto 1fr; gap:2px; border-radius:6px; }
  .big-two-avatar { display:none; }
  .big-two-opponent strong { grid-column:1 / -1; font-size:11px; }
  .big-two-card-count b { font-size:20px; }
  .big-two-card-back { width:12px; height:17px; }
  .big-two-player-state { font-size:10px; }
  .big-two-center { grid-column:auto; grid-row:auto; min-height:0; gap:2px; padding:0; font-size:11px; }
  .big-two-current-play .big-two-card { width:35px; height:50px; font-size:13px; }
  .big-two-current-play { min-height:50px; }
  .big-two-own { grid-column:2; grid-row:2; padding:5px; }
  .big-two-hand { padding:10px 0 0; min-height:0; }
  .big-two-hand .big-two-card { width:100%; height:54px; font-size:13px; }
  .big-two-hand .big-two-card + .big-two-card { margin-left:0; }
  #bigTwoSelectionStatus { font-size:10px; }
  .big-two-actions { grid-row:3; }
}
@media(prefers-reduced-motion:reduce) { .big-two-current-play .big-two-card { animation:none; } }
