@import url("/board-controls.css");

:root {
  color-scheme: light;
  --background: #ede9df;
  --panel: #fffcf6;
  --panel-raised: #f0eadf;
  --ink: #342c23;
  --muted: #6a6154;
  --accent: #30594b;
  --accent-ink: #fffdf5;
  --danger: #9d4034;
  --danger-ink: #fff8f5;
  --line: #d9d0c0;
  --radius: 0.7rem;
  --table-shadow: 0 16px 48px #43341c0a, 0 1px 2px #43341c08;
  --error: #9d4034;
  --board-ink: #fff1d5;
  --board-accent: #edc77e;
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

.replay-notes-dialog {
  width: min(38rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem);
  overflow-y: auto; padding: 1.25rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); color: var(--ink);
}
.replay-notes-dialog::backdrop { background: #0008; }
.replay-note-library-list { display: grid; gap: 0.75rem; list-style: none; padding: 0; }
.replay-note-library-list li { min-width: 0; padding-block: 0.5rem; border-bottom: 1px solid var(--line); }
.replay-note-library-list p { white-space: pre-wrap; overflow-wrap: anywhere; }
.replay-note-library-list button { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.replay-notes-dialog header { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.replay-notes-dialog h2 { margin: 0; }
.replay-notes-dialog textarea {
  display: block; width: 100%; margin-block: 0.5rem; resize: vertical;
  min-height: 7rem; max-height: 35dvh; padding: 0.75rem; font: inherit;
  color: var(--ink); background: var(--panel-raised); border: 1px solid var(--line); border-radius: 0.4rem;
}
.replay-notes-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.replay-variation-list { padding-inline-start: 1.25rem; max-height: 16rem; overflow: auto; }
.replay-variation-list p { overflow-wrap: anywhere; }
.replay-variation-list button { margin: 0 0.4rem 0.5rem 0; }
.replay-note-list { padding-inline-start: 1.25rem; }
.replay-note-list p { white-space: pre-wrap; overflow-wrap: anywhere; }
.replay-note-import { margin-block-start: 1rem; }
.replay-note-import input { display: block; width: 100%; min-width: 0; margin-block: 0.5rem; }

/* Independent of app.js: available on failed boot, absent from a running game. */
:root[data-connection-state] #support-startup { display: none; }

.first-use-hint {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-block: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
}
.first-use-hint > div { flex: 1 1 15rem; min-width: 0; }
.first-use-hint h3 { margin: 0; font-size: 1rem; }
.first-use-hint p { margin-block: 0.5rem 0; line-height: 1.5; }
.first-use-hint .eyebrow { margin-block: 0 0.25rem; }
.first-use-hint button { min-width: 44px; min-height: 44px; }
.first-use-guide { margin-block: 1rem; }
.first-use-guide summary {
  min-height: 44px;
  padding-block: 0.65rem;
  cursor: pointer;
  font-weight: 650;
}
.first-use-guide summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.first-use-guide h4 { margin-block: 1rem 0.3rem; }
.first-use-guide p { margin-block: 0.3rem 0.75rem; line-height: 1.5; }

html {
  min-inline-size: min(320px, 100%);
  overflow-x: clip;
}

body {
  min-height: 100vh;
  margin: 0;
  padding-block: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-bottom));
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  overflow-x: hidden;
  background: radial-gradient(ellipse at 15% 0%, #fffcf6 0%, transparent 65%), var(--background);
  color: var(--ink);
}

button,
input,
select { font: inherit; }

button {
  min-height: 2.75rem;
  border: 1px solid var(--accent);
  border-radius: 0.55rem;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  cursor: pointer;
}

button:hover:not(:disabled) { filter: brightness(1.06); }
button:not(.house button):active:not(:disabled) { box-shadow: inset 0 2px 3px #0002; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
.primary-link:focus-visible {
  outline: 0.2rem solid var(--accent);
  outline-offset: 0.16rem;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.55;
}

button.quiet {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.session-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
}

.session-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 700;
  text-underline-offset: 0.18rem;
}

.session-link:focus-visible {
  outline: 0.2rem solid var(--accent);
  outline-offset: 0.16rem;
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--danger-ink);
}

.primary-link {
  display: inline-block;
  min-height: 2.75rem;
  border: 1px solid var(--accent);
  border-radius: 0.65rem;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 750;
  text-decoration: none;
}

.primary-link:hover { filter: brightness(1.08); }

input,
select {
  min-width: 0;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.65rem 0.8rem;
  background: #fffcf8;
  color: var(--ink);
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  transform: translateY(-200%);
  padding: 0.6rem;
  background: var(--ink);
  color: var(--background);
}

.skip-link:focus { transform: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-header,
main {
  width: min(78rem, 100%);
  margin-inline: auto;
  min-width: 0;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem 0.75rem;
}

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

h1 { margin-bottom: 0; }

.eyebrow {
  margin-bottom: 0.25rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.maintenance-notice { flex: 0 0 auto; border: 1px solid currentColor; border-radius: 0.5rem; padding: 0 0.6rem; margin-block: 0.25rem; overflow-wrap: anywhere; }
.maintenance-notice summary { min-height: 44px; align-content: center; cursor: pointer; }
.maintenance-notice p { margin-block: 0.35rem; }
.maintenance-notice button { margin-block: 0.25rem 0.5rem; }
.maintenance-notice button[aria-disabled="true"] { cursor: progress; }

.status {
  min-height: 2.75rem;
  margin-block: 0.5rem 1rem;
  border-left: 0.2rem solid var(--accent);
  padding: 0.65rem 1rem;
  background: transparent;
  color: var(--muted);
}

.status[data-tone="error"] {
  border-color: var(--error);
  color: var(--error);
}

.panel {
  margin-bottom: 2rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: 0 0.4rem 1.5rem #34302708;
}

.account-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.account-form {
  display: grid;
  align-content: start;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem;
  background: var(--panel-raised);
}

.account-form h3 { margin-bottom: 0.25rem; }
.account-form input { width: 100%; }
#account-recovery { grid-column: 1 / -1; }
#account-recovery > form { margin-top: 1rem; }
#recovery-code-settings { margin-top: 1.5rem; }
#generated-recovery-code { width: 100%; font-family: monospace; }
.account-form button { justify-self: start; margin-top: 0.35rem; }

.landing-actions,
.lobby-actions,
.post-match-actions,
.replay-navigation,
.replay-return-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
}

#join-form { flex: 1 1 19rem; }
#create-form { flex: 1 1 24rem; }

label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-weight: 700;
}

.inline-control {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.inline-control input { flex: 1; }
.inline-control select { flex: 1; }

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading > *,
.participants li > * { min-inline-size: 0; max-inline-size: 100%; overflow-wrap: anywhere; }
#lobby > .section-heading { flex-wrap: wrap; }
#lobby-state { max-inline-size: 100%; white-space: normal; }

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

.badge[data-state="stale"],
.badge[data-state="reconciling"] {
  border-color: #d69e2e;
  background: #4a2f0b;
  color: #fff1c2;
}

.badge[data-state="signed_out"] {
  border-color: var(--muted);
  opacity: 0.8;
}

html[data-connection-state="stale"] .match,
html[data-connection-state="reconciling"] .match {
  outline: 0.15rem solid #d69e2e;
  outline-offset: 0.2rem;
}

#south-clock[data-active="true"],
#north-clock[data-active="true"] {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

#south-clock[data-low="true"],
#north-clock[data-low="true"] { color: var(--error); }

#south-clock[data-paused="true"],
#north-clock[data-paused="true"],
#clock-state[data-phase="paused"] {
  color: #78521c;
  font-variant-numeric: tabular-nums;
}

#clock-state[data-phase="timeout"] { color: var(--error); }

.invite {
  margin-block: 1rem 1.5rem;
  border-radius: 0.75rem;
  padding: 1rem;
  background: var(--panel-raised);
}

.participants {
  display: grid;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.lobby-facts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.65rem;
  margin-block: 1rem 1.5rem;
}

.lobby-facts div {
  min-width: 0;
  border-radius: 0.65rem;
  padding: 0.65rem;
  background: var(--panel-raised);
}

.lobby-facts dt { color: var(--muted); font-size: 0.78rem; }
.lobby-facts dd { margin: 0.2rem 0 0; font-weight: 800; }

/* Waiting-room decisions precede sharing, optional tips and detailed policy. */
#lobby > .section-heading > div { flex: 1 1 12rem; }
#lobby > .section-heading h2 { margin-block: 0.25rem 0; }
#lobby .lobby-facts { margin-block: 0.85rem; gap: 0.5rem; }
#lobby > h3 { margin-block: 0.75rem 0.4rem; font-size: 1rem; }
#lobby .participants { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-block: 0.4rem; }
#lobby .participants li {
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.35rem;
  padding-block: 0.5rem;
}
#lobby-next-action { margin-block: 0.85rem; line-height: 1.45; font-weight: 650; }
#lobby .lobby-actions { gap: 0.5rem; align-items: stretch; }
#lobby .lobby-actions button { flex: 1 1 auto; min-height: 44px; }
#lobby #leave-party-lobby { flex: 0 1 auto; background: transparent; color: var(--danger); }
#lobby-connection-help summary {
  min-height: 44px;
  padding-block: 0.65rem;
  cursor: pointer;
  color: var(--ink);
  font-weight: 650;
}
#lobby-connection-help summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.lifecycle-notice {
  margin-block: 1rem;
  border-left: 0.25rem solid var(--accent);
  padding: 0.85rem 1rem;
  background: var(--panel-raised);
}

.lifecycle-notice h3 { margin-top: 0; color: var(--ink); }

.lifecycle-notice dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0;
}

.lifecycle-notice dl div { min-width: 0; }
.lifecycle-notice dt { color: var(--muted); font-size: 0.78rem; }
.lifecycle-notice dd { margin: 0.2rem 0 0; color: var(--ink); }

.participants li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 0;
}

.recent-matches {
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
}

.social-panel { padding-block: 1rem; }

.social-identity {
  margin-bottom: 0;
  color: var(--muted);
}

.social-identity code {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.social-status {
  min-height: 1.5rem;
  margin-block: 0.75rem;
  color: var(--muted);
}

.social-status[data-tone="error"] { color: var(--error); }
.account-form > [data-account-status] { margin: 0; }

.social-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.social-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.8rem 1rem 1rem;
  background: var(--panel-raised);
}

.social-card summary {
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
}

.social-card[open] summary { margin-bottom: 1rem; }

.account-security-card,
.safety-card { grid-column: 1 / -1; }

.account-security-form,
.profile-form,
.social-request-form,
.safety-report-form { display: grid; gap: 0.65rem; }

.social-request-form { margin-bottom: 1.25rem; }

.account-security-form { margin-top: 1rem; }

.account-security-form input { width: 100%; }

.account-security-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.account-security-status {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.account-security-status[data-tone="error"] { color: var(--error); }

.account-deletion-card { grid-column: 1 / -1; }
.deletion-confirmation { display: flex; align-items: flex-start; gap: 0.7rem; }
.account-security-form .deletion-confirmation input {
  width: 1.25rem; height: 1.25rem; flex: 0 0 auto; margin-top: 0.15rem;
}

.safety-reference-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.safety-reference-grid input,
.safety-report-form select { width: 100%; }

/* Native selects may clip their selected option. Keep a wrapping visual copy;
   assistive technology already receives the full native option name. */
#safety-report-category-summary { margin: 0; min-width: 0; color: var(--ink); overflow-wrap: anywhere; }

.safety-report-form button { justify-self: start; }

.safety-report-status {
  min-height: 1.5rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.safety-report-status[data-tone="error"] { color: var(--error); }

.profile-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.profile-settings-grid select { width: 100%; }

.check-control {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
}

.check-control input {
  min-height: auto;
  margin: 0;
}

.privacy-settings {
  margin: 0.5rem 0 0;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.75rem;
}

.privacy-settings legend { color: var(--muted); font-weight: 800; }

.privacy-settings .action-help { margin-top: 0.75rem; }

.tactile-settings {
  display: grid;
  gap: 0.65rem;
  min-width: 0;
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 0.75rem;
}

.tactile-settings legend { color: var(--muted); font-weight: 800; }
.tactile-settings .check-control { min-height: 44px; }
.tactile-settings > label:not(.check-control) { display: flex; justify-content: space-between; gap: 1rem; }
.tactile-settings input[type="range"] { width: 100%; min-width: 0; min-height: 44px; margin: 0; }
.tactile-settings button { justify-self: start; min-height: 44px; }
.tactile-settings .field-note { margin: 0; }

.coming-later {
  border-left: 0.2rem solid var(--accent);
  padding: 0.65rem 0.8rem;
  background: var(--panel);
  color: var(--muted);
}

.profile-actions,
.social-item-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.social-list {
  display: grid;
  gap: 0.55rem;
  margin-block: 0.65rem 1.25rem;
  padding: 0;
  list-style: none;
}

.social-list li {
  display: grid;
  min-width: 0;
  gap: 0.5rem;
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0;
}

.social-list li:last-child { border-bottom: 0; }

.social-item-label {
  margin: 0;
  overflow-wrap: anywhere;
}

.social-item-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.social-list button { padding: 0.45rem 0.7rem; }

.history-status {
  min-height: 1.5rem;
  color: var(--muted);
}

.history-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 0.75rem;
  margin-block: 0.75rem;
}
.history-filters label { display: grid; gap: 0.35rem; min-width: 0; }
.history-filters select { width: 100%; min-width: 0; min-height: 44px; }

.history-list {
  display: grid;
  gap: 0.75rem;
  margin-block: 1rem;
  padding: 0;
  list-style: none;
}

.history-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
  background: var(--panel-raised);
}

.history-entry p { margin: 0.2rem 0; }
.history-entry-meta { color: var(--muted); font-size: 0.85rem; }
.history-outcome { color: var(--accent); font-weight: 800; }

.post-match-summary {
  margin-block: 1rem 1.5rem;
  border-left: 0.25rem solid var(--accent);
  padding: 0.75rem 1rem;
  background: var(--panel-raised);
  font-weight: 750;
}

.post-match-note {
  margin-block: 1.25rem 0.75rem;
  color: var(--muted);
}

.rematch-status {
  min-height: 2.75rem;
  margin-block: 0.75rem;
  border-left: 0.25rem solid var(--accent);
  padding: 0.75rem 1rem;
  background: var(--panel-raised);
  color: var(--muted);
}

.rematch-slot { flex: 1 1 100%; min-width: 0; }
.rematch-slot:empty, .rematch-slot:has(> [hidden]) { display: none; }
#rematch-controls:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
}
#rematch-controls > button { flex: 0 1 auto; min-height: 44px; }
#rematch-controls .rematch-status {
  flex: 1 1 12rem;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  line-height: 1.3;
}

#history-title:focus,
#social-status:focus,
#post-match-title:focus,
#replay-title:focus,
#replay-range:focus,
#rematch-status:focus,
#turn-instruction:focus {
  outline: 0.2rem solid var(--accent);
  outline-offset: 0.16rem;
}

.replay-range {
  color: var(--muted);
  font-weight: 700;
}

.replay-board {
  margin-block: 1rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem;
  background: var(--panel-raised);
}

.replay-board-stage {
  position: relative;
  min-width: 0;
}

.replay-houses { margin-block: 1rem; }
.replay-houses .house button { cursor: default; opacity: 1; filter: none; }
#replay[data-analysis="true"] .replay-houses .house button:enabled { cursor: pointer; }

.replay-frame-detail {
  min-height: 2.75rem;
  margin-bottom: 0;
  color: var(--muted);
}

.replay-controls,
.replay-settings,
.replay-viewpoint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.replay-controls { margin-block: 1rem; }

.replay-settings {
  margin-block: 1rem 1.5rem;
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: var(--panel-raised);
}

.replay-settings input[type="range"] { flex: 1 1 14rem; }
.replay-settings select { min-height: 2.5rem; }
#replay-board-note { flex: 1 1 100%; margin: 0; }
.replay-viewpoint { margin: 0; border: 0; padding: 0; }
.replay-viewpoint legend { float: left; margin-right: 0.65rem; }
.replay-viewpoint button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.replay-events {
  display: grid;
  gap: 0.75rem;
  margin-block: 1rem 1.5rem;
  padding-left: 2.5rem;
}

.replay-events li {
  border-left: 0.25rem solid var(--line);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--panel-raised);
}

.replay-events li[data-terminal-event="true"] {
  border-color: var(--accent);
}

.replay-events li[data-current-frame="true"] {
  box-shadow: 0 0 0 0.15rem var(--accent);
}

.replay-event-type {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.replay-navigation { margin-bottom: 1rem; }
.replay-return-actions { margin-block: 1rem; }

.match-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-block: 1rem;
}

.match-facts:not(.player-scoreboard) div {
  border-radius: 0.65rem;
  padding: 0.75rem;
  background: var(--panel-raised);
}

.match-facts:not(.player-scoreboard) dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.match-facts:not(.player-scoreboard) dd {
  margin: 0.25rem 0 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.match-facts.replay-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.replay-facts div { padding-inline: 0.4rem; }
#replay-title { font: 400 clamp(1.7rem, 3.4vw, 2.8rem)/1.1 Georgia, serif; }
.replay .post-match-summary { margin-block: 0.6rem 1rem; padding: 0.65rem 0.8rem; font-size: 0.9rem; line-height: 1.5; }
.replay-board { margin-block: 1rem; border: 0; padding: 0; background: transparent; }
.replay-board .section-heading { align-items: center; }
.replay-board .section-heading h3 { margin: 0; }
.replay-board .section-heading .eyebrow { display: none; }
.replay-board .section-heading .badge { font-size: 0.72rem; }
.replay-range { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.replay-record-details { padding-block: 0.75rem; border-block: 1px solid var(--line); }
.replay-record-details summary { min-height: 2.75rem; padding-block: 0.75rem; cursor: pointer; font-weight: 700; }

.match {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
}

.match > * { min-width: 0; }
.match > .match-heading { grid-area: heading; }
.match > .match-facts { grid-area: facts; margin-block: 0; }
.match > .turn-instruction { grid-area: instruction; margin: 0; }
.player-scoreboard > .board-direction { grid-column: 1 / -1; margin: 0; }
.match > .presentation-controls { grid-area: presentation; }
.match > .board-mount { grid-area: board; min-width: 0; }
.match > .result { grid-area: result; }

.match[data-layout-family="compact_portrait"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "heading"
    "facts"
    "instruction"
    "board"
    "presentation"
    "result";
}

.match[data-layout-family="compact_portrait"] > .match-facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.match[data-layout-family="compact_portrait"] > .match-heading {
  flex-wrap: wrap;
}

.match[data-layout-family="compact_portrait"] > .match-heading .badge {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.match[data-layout-family="expanded_portrait"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "heading"
    "facts"
    "instruction"
    "board"
    "presentation"
    "result";
}

.match[data-layout-family="expanded_portrait"] > .match-facts {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.match[data-layout-family="compact_landscape"] {
  grid-template-columns: minmax(0, 1fr) minmax(12rem, 0.4fr);
  grid-template-areas:
    "heading heading"
    "instruction facts"
    "board facts"
    "presentation presentation"
    "result result";
  align-items: start;
}

.match[data-layout-family="compact_landscape"] > .match-facts {
  grid-template-columns: minmax(0, 1fr);
}

.match[data-layout-family="expanded_landscape"] {
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 0.34fr);
  grid-template-areas:
    "heading heading"
    "instruction facts"
    "board facts"
    "presentation presentation"
    "result result";
  align-items: start;
}

.match[data-layout-family="expanded_landscape"] > .match-facts {
  grid-template-columns: minmax(0, 1fr);
}

.turn-instruction,
.board-direction { color: var(--muted); }

.board-direction {
  border-left: 0.2rem solid var(--accent);
  padding-left: 0.65rem;
}

.presentation-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.65rem;
  background: var(--panel-raised);
}

.presentation-status {
  flex: 1 1 13rem;
  align-self: center;
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.presentation-speed {
  display: grid;
  grid-template-columns: max-content minmax(7rem, 1fr);
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.presentation-board {
  display: grid;
  grid-template-columns: max-content minmax(8rem, 1fr);
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.presentation-board-note {
  flex: 1 1 100%;
  margin: 0;
}

.presentation-speed select,
.presentation-board select { min-height: 2.5rem; }
.presentation-controls button { min-height: 2.5rem; }

.board-stage {
  position: relative;
  min-width: 0;
  max-width: 100%;
  isolation: isolate;
  border-radius: 1rem;
  background: #e9e5da;
}

.board-canvas {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.board-stage > .houses {
  position: relative;
  z-index: 1;
}

.board-stage[data-renderer="webgl"] > .board-canvas {
  opacity: 1;
}

.board-stage:is(
  [data-loading="true"],
  [data-renderer="webgl-probe"],
  [data-renderer="webgl"]
) {
  height: clamp(280px, 32vw, 450px);
}

.board-stage:is([data-loading="true"], [data-renderer="webgl-probe"], [data-renderer="webgl"])[data-layout="circular_candidate_b"] {
  --circular-stage-height: clamp(320px, 52vw, 600px);
  height: var(--circular-stage-height);
}


.houses {
  /* Spatial house positions are physical, not the reading direction. */
  direction: ltr;
  --ink: var(--board-ink);
  --muted: #e1cdb4;
  --accent: var(--board-accent);
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0;
  padding: 1rem;
  border: 0.5rem solid #583b2b;
  border-radius: 2rem;
  background: #715039;
  list-style: none;
  max-width: 100%;
  overflow: hidden;
}

#houses {
  grid-template-columns: repeat(6, minmax(44px, 1fr));
}

.houses[data-layout="circular_candidate_b"] {
  position: relative;
  display: block;
  width: min(100%, 44rem);
  aspect-ratio: 1;
  margin-inline: auto;
  padding: 0;
  border-radius: 50%;
  overflow: visible;
}

.houses[data-layout="circular_candidate_b"] .house {
  position: absolute;
  left: var(--circular-house-x);
  top: var(--circular-house-y);
  width: clamp(44px, 16%, 6.5rem);
  height: clamp(44px, 16%, 6.5rem);
  transform: translate(-50%, -50%);
}

.houses[data-layout="circular_candidate_b"] .house button {
  height: 100%;
  min-height: 44px;
  padding: 0.2rem;
  overflow: hidden;
}

.board-stage[data-renderer="webgl"]
  > .houses[data-layout="circular_candidate_b"]
  .house button {
  position: absolute;
  left: var(--renderer-house-hit-left);
  top: var(--renderer-house-hit-top);
  width: var(--renderer-house-hit-width);
  height: var(--renderer-house-hit-height);
  padding: 0;
}

.houses[data-layout="circular_candidate_b"][data-viewpoint="north"] .house {
  left: calc(100% - var(--circular-house-x));
  top: calc(100% - var(--circular-house-y));
}

.circular-board-guide {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: min(100%, 44rem);
  aspect-ratio: 1;
  color: var(--board-ink);
  filter: drop-shadow(0 2px 2px #1f0f08);
  pointer-events: none;
  transform: translate(-50%, -50%);
  user-select: none;
}

.circular-board-guide span { pointer-events: none; }

.circular-territory-label,
.circular-territory-diameter span,
.circular-direction-cue,
.circular-transition-cue {
  position: absolute;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  background: #1f0f08e8;
  font-size: clamp(0.5rem, 1.3vw, 0.72rem);
  font-weight: 850;
  letter-spacing: 0.045em;
  line-height: 1.15;
  text-align: center;
  text-transform: uppercase;
}

.circular-territory-label {
  left: 50%;
  max-width: 30%;
  border-radius: 0;
  border-width: 0 0 1px;
  transform: translateX(-50%);
}

.circular-territory-far { top: 26%; }
.circular-territory-near { bottom: 26%; }

.replay-board-stage .circular-territory-label {
  max-width: 40%;
}

.replay-board-stage .circular-territory-near {
  bottom: 21%;
}

.circular-territory-diameter {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(84%, 32rem);
  transform: translateX(-50%);
  border-top: 1px solid currentColor;
}

.circular-territory-diameter span {
  top: 0;
  left: 50%;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.circular-direction-cue {
  top: 60%;
  left: 50%;
  display: grid;
  min-width: 22%;
  transform: translate(-50%, -50%);
}

.circular-counter-clockwise-symbol {
  font-size: 1.35em;
  line-height: 1;
}

.circular-transition-cue {
  top: 43%;
  display: grid;
  width: 16%;
  min-width: max-content;
  border-radius: 0.55rem;
  transform: translateY(-50%);
}

.circular-transition-cue strong,
.circular-transition-cue span { display: block; }

.circular-transition-cue strong { white-space: nowrap; }

.circular-transition-cue span {
  margin-top: 0.12rem;
  font-size: 0.78em;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-transform: none;
}

@media (max-width: 64rem) {
  /* Keep both explicit crossing arrows; the boundary label and associated
     description already explain the crossing without a cramped second line. */
  .circular-transition-cue > span { display: none; }
}

.circular-transition-cue[data-circular-transition="north-to-south"] {
  left: 27%;
}

.circular-transition-cue[data-circular-transition="south-to-north"] {
  right: 27%;
}

.circular-board-guide[data-viewpoint="north"]
  .circular-transition-cue[data-circular-transition="north-to-south"] {
  right: 27%;
  left: auto;
}

.circular-board-guide[data-viewpoint="north"]
  .circular-transition-cue[data-circular-transition="south-to-north"] {
  right: auto;
  left: 27%;
}

.houses[data-layout="circular_candidate_b"] .house[data-house-id="S1"] {
  --circular-house-x: 11.4%; --circular-house-y: 60.4%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="S2"] {
  --circular-house-x: 21.7%; --circular-house-y: 78.3%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="S3"] {
  --circular-house-x: 39.6%; --circular-house-y: 88.6%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="S4"] {
  --circular-house-x: 60.4%; --circular-house-y: 88.6%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="S5"] {
  --circular-house-x: 78.3%; --circular-house-y: 78.3%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="S6"] {
  --circular-house-x: 88.6%; --circular-house-y: 60.4%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="N1"] {
  --circular-house-x: 88.6%; --circular-house-y: 39.6%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="N2"] {
  --circular-house-x: 78.3%; --circular-house-y: 21.7%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="N3"] {
  --circular-house-x: 60.4%; --circular-house-y: 11.4%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="N4"] {
  --circular-house-x: 39.6%; --circular-house-y: 11.4%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="N5"] {
  --circular-house-x: 21.7%; --circular-house-y: 21.7%;
}
.houses[data-layout="circular_candidate_b"] .house[data-house-id="N6"] {
  --circular-house-x: 11.4%; --circular-house-y: 39.6%;
}

.board-stage[data-renderer="webgl"] > .houses[data-layout="circular_candidate_b"] {
  width: auto;
  aspect-ratio: auto;
  border-radius: 0;
}

.board-stage[data-renderer="webgl"] > .circular-board-guide {
  /* The renderer fits the round board inside the shorter stage dimension.
     Keep annotations on that square, not the wider desktop canvas. */
  width: min(100%, var(--circular-stage-height));
  height: auto;
  aspect-ratio: 1;
}

.board-stage[data-renderer="webgl"] > .circular-board-guide
  .circular-territory-far {
  /* House labels sit below their openings, including the far pair. */
  top: 30%;
}

.board-stage[data-renderer="webgl"] > .houses[data-layout="circular_candidate_b"] .house {
  height: auto;
  transform: none;
}

.houses[data-viewpoint="south"] .house:nth-child(-n + 6),
.houses[data-viewpoint="north"] .house:nth-child(n + 7) { grid-row: 2; }

.houses[data-viewpoint="south"] .house:nth-child(n + 7),
.houses[data-viewpoint="north"] .house:nth-child(-n + 6) { grid-row: 1; }

.houses[data-viewpoint="south"] .house:nth-child(1),
.houses[data-viewpoint="north"] .house:nth-child(7) { grid-column: 1; }
.houses[data-viewpoint="south"] .house:nth-child(2),
.houses[data-viewpoint="north"] .house:nth-child(8) { grid-column: 2; }
.houses[data-viewpoint="south"] .house:nth-child(3),
.houses[data-viewpoint="north"] .house:nth-child(9) { grid-column: 3; }
.houses[data-viewpoint="south"] .house:nth-child(4),
.houses[data-viewpoint="north"] .house:nth-child(10) { grid-column: 4; }
.houses[data-viewpoint="south"] .house:nth-child(5),
.houses[data-viewpoint="north"] .house:nth-child(11) { grid-column: 5; }
.houses[data-viewpoint="south"] .house:nth-child(6),
.houses[data-viewpoint="north"] .house:nth-child(12) { grid-column: 6; }

.houses[data-viewpoint="south"] .house:nth-child(7),
.houses[data-viewpoint="north"] .house:nth-child(1) { grid-column: 6; }
.houses[data-viewpoint="south"] .house:nth-child(8),
.houses[data-viewpoint="north"] .house:nth-child(2) { grid-column: 5; }
.houses[data-viewpoint="south"] .house:nth-child(9),
.houses[data-viewpoint="north"] .house:nth-child(3) { grid-column: 4; }
.houses[data-viewpoint="south"] .house:nth-child(10),
.houses[data-viewpoint="north"] .house:nth-child(4) { grid-column: 3; }
.houses[data-viewpoint="south"] .house:nth-child(11),
.houses[data-viewpoint="north"] .house:nth-child(5) { grid-column: 2; }
.houses[data-viewpoint="south"] .house:nth-child(12),
.houses[data-viewpoint="north"] .house:nth-child(6) { grid-column: 1; }

.board-theme-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-block: 0.5rem 1rem;
}
.board-theme-choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem;
  align-content: start;
  text-align: start;
  min-width: 0;
  padding: 0.5rem;
  font-size: 0.78rem;
}
.board-theme-choice[aria-pressed="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.board-theme-slot { color: var(--muted); font-variant-numeric: tabular-nums; }
.board-theme-swatch {
  grid-column: 1 / -1;
  height: 2.3rem;
  position: relative;
  border-radius: 0.6rem;
  border: 1px solid #ffffff30;
  background: var(--theme-board-relief, none) center / cover, var(--theme-board-texture) center / cover, var(--theme-board);
}
.board-theme-swatch::after {
  content: "";
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-start: calc(50% - 0.6rem);
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: var(--theme-seed-relief, none) center / cover, var(--theme-seed-texture) center / cover, var(--theme-seed);
  box-shadow: 1px 2px 3px #0007;
}
@media (max-width: 380px) {
  .board-theme-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.pit-hotkey-feedback {
  --hotkey-color: #ffe3a1;
  position: absolute;
  inset: 4px;
  z-index: 4;
  border: 2px solid var(--hotkey-color);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--hotkey-color), inset 0 0 10px #ffe3a144;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.board-stage[data-renderer="webgl"] .pit-hotkey-feedback {
  inset: auto;
  top: var(--house-pit-y, 50%);
  left: var(--house-pit-x, 50%);
  width: var(--house-pit-width, 80%);
  height: var(--house-pit-height, 80%);
  transform: translate(-50%, -50%);
}
.house button[data-hotkey-held="legal"] .pit-hotkey-feedback { opacity: 1; }
.house button[data-hotkey-error="true"] .pit-hotkey-feedback {
  animation: pit-invalid-flash 260ms ease-out both;
}
@keyframes pit-invalid-flash {
  from { opacity: 1; }
  to { opacity: 0; }
}
.house button[data-hotkey-tone="invalid"] .pit-hotkey-feedback {
  --hotkey-color: #ff626c;
  background: #e52d4033;
  box-shadow: 0 0 12px #ff626c, inset 0 0 12px #ff626c66;
}
.board-stage[data-renderer="webgl"] .house button .pit-hotkey-feedback {
  border: 0;
  background: none;
  box-shadow: none;
}
.board-stage[data-renderer="webgl"] .house button[data-hotkey-tone="invalid"] .pit-feedback-outline {
  fill: #e52d4033;
}
:root:is([data-motion-mode="reduced"], [data-motion-mode="static"]) .pit-hotkey-feedback {
  transition: none;
}
:root:is([data-motion-mode="reduced"], [data-motion-mode="static"])
  .house button[data-hotkey-error="true"] .pit-hotkey-feedback {
  animation: none;
  opacity: 1;
}
.house-id,
.house-owner,
.house-count,
.house-state,
.house-last-landing { display: block; }
.house-id { color: var(--muted); font-size: 0.78rem; }
.house-owner { font-size: 0.72rem; font-weight: 700; }
.house-count { font-size: 1.5rem; }
.house-state { min-height: 1.8em; color: var(--muted); font-size: 0.68rem; }
.house button[data-legal="true"] .house-state {
  color: var(--accent);
  font-weight: 800;
}

.house[data-last-source="true"] .house-state::before { content: "▲ "; }
.house[data-last-capture="true"] .house-state::before { content: "■ "; }

.house:is(
  [data-presentation-source="true"],
  [data-presentation-destination="true"],
  [data-presentation-candidate="true"],
  [data-presentation-committed="true"]
) {
  --presentation-source-label: "";
  --presentation-destination-label: "";
  --presentation-candidate-label: "";
  --presentation-committed-label: "";
}

.house[data-presentation-source="true"] {
  --presentation-source-label: "▲ Source ";
}

.house[data-presentation-destination="true"] {
  --presentation-destination-label: "● Destination ";
}

.house[data-presentation-candidate="true"] {
  --presentation-candidate-label: "◇ Capture candidate ";
}

.house[data-presentation-committed="true"] {
  --presentation-committed-label: "■ Capture committed";
}

.house[data-presentation-source="true"] button { border-style: dashed; }
.house[data-presentation-destination="true"] button { border-width: 0.3rem; }
.house[data-presentation-candidate="true"] button {
  outline: 0.16rem dotted currentColor;
  outline-offset: 0.12rem;
}
.house[data-presentation-committed="true"] button {
  box-shadow: inset 0 0 0 0.2rem currentColor;
}

.house:is(
  [data-presentation-source="true"],
  [data-presentation-destination="true"],
  [data-presentation-candidate="true"],
  [data-presentation-committed="true"]
) .house-state::after {
  content:
    var(--presentation-source-label)
    var(--presentation-destination-label)
    var(--presentation-candidate-label)
    var(--presentation-committed-label);
  display: block;
  margin-top: 0.12rem;
  color: var(--ink);
  font-weight: 800;
}

.house[data-last-landing="true"] button {
  border-color: #ffe18b;
  box-shadow: inset 0 0 0 0.16rem #ffe18b;
}

.house-last-landing {
  margin-top: 0.18rem;
  color: #ffe18b;
  font-size: 0.66rem;
  font-weight: 800;
}

.house-last-landing::before { content: "● "; }

:root[data-motion-mode="full"] #houses .house:is(
  [data-last-source="true"],
  [data-last-landing="true"],
  [data-last-capture="true"]
) button {
  animation: authoritative-house-emphasis 420ms ease-out;
}

:root[data-motion-mode="reduced"] #houses .house:is(
  [data-last-source="true"],
  [data-last-landing="true"],
  [data-last-capture="true"]
) button {
  animation: authoritative-house-emphasis-reduced 120ms ease-out;
}

:root[data-motion-mode="static"] #houses .house button {
  animation: none;
}

:root[data-motion-mode="full"] #houses .house:is(
  [data-presentation-source="true"],
  [data-presentation-destination="true"],
  [data-presentation-candidate="true"],
  [data-presentation-committed="true"]
) button {
  animation: presentation-house-emphasis 240ms ease-out;
}

:root[data-motion-mode="reduced"] #houses .house:is(
  [data-presentation-source="true"],
  [data-presentation-destination="true"],
  [data-presentation-candidate="true"],
  [data-presentation-committed="true"]
) button {
  animation: presentation-house-emphasis-reduced 100ms ease-out;
}

:root[data-motion-mode="static"] #houses .house:is(
  [data-presentation-source="true"],
  [data-presentation-destination="true"],
  [data-presentation-candidate="true"],
  [data-presentation-committed="true"]
) button {
  animation: none;
}

@keyframes authoritative-house-emphasis {
  0%, 100% { filter: none; }
  38% { filter: brightness(1.28); }
}

@keyframes authoritative-house-emphasis-reduced {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.1); }
}

@keyframes presentation-house-emphasis {
  0%, 100% { filter: none; }
  45% { filter: brightness(1.2); }
}

@keyframes presentation-house-emphasis-reduced {
  0%, 100% { filter: none; }
  50% { filter: brightness(1.08); }
}

.field-note {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.result {
  min-height: 1.5rem;
  margin-top: 1rem;
  font-weight: 750;
}

.action-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

#landing[data-history-only="true"] > :not(.recent-matches) { display: none; }
#landing[data-history-only="true"] > .recent-matches { margin-top: 0; }
.history-current-party {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.5rem 1rem;
  flex-wrap: wrap;
  padding: 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 0.75rem;
  background: var(--panel);
}
.history-current-party p { margin: 0; }
.history-current-party[hidden] { display: none; }
.history-current-party .field-note { flex-basis: 100%; }

.forfeit-dialog,
.leave-party-dialog,
.game-navigation-dialog,
.match-help-dialog {
  width: min(30rem, calc(100% - 2rem));
  border: 1px solid var(--danger);
  border-radius: 1rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1.5rem 4rem #000a;
}

.forfeit-dialog::backdrop,
.leave-party-dialog::backdrop,
.game-navigation-dialog::backdrop,
.match-help-dialog::backdrop { background: #080503cc; }

.game-navigation-dialog {
  border-color: var(--accent);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
}

.friend-action-dialog {
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  overflow-wrap: anywhere;
}

.forfeit-warning {
  border-left: 0.25rem solid var(--danger);
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--danger) 16%, var(--panel-raised));
}

.forfeit-dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.match-help-dialog {
  width: min(64rem, calc(100% - 2rem));
  max-height: calc(100dvh - max(32px, env(safe-area-inset-top)) - max(32px, env(safe-area-inset-bottom)));
  overflow: auto;
  border-color: var(--accent);
}

.match-help-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.match-help-position {
  display: grid;
  grid-template-columns: minmax(13rem, 0.6fr) minmax(0, 1.4fr);
  gap: 1rem;
  margin-block: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1rem;
  background: var(--panel-raised);
}

/* Leave room for mixed-direction glyph extents without clipping the summary. */
#match-help-position-summary { overflow-wrap: anywhere; padding-inline: 0.125em; }

.help-step {
  margin-bottom: 0.25rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.match-help-house-counts {
  direction: ltr;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
  align-content: center;
  margin: 0;
}

.match-help-house-counts > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.4rem 0.1rem;
  background: var(--panel);
  text-align: center;
}

.match-help-house-counts > div[data-near="true"] {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}

.match-help-house-counts dd {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.match-help-lifecycle dl div {
  min-width: 0;
  border-radius: 0.5rem;
  padding: 0.55rem;
  background: var(--panel);
}

.match-help-house-counts dt,
.match-help-lifecycle dt {
  color: var(--muted);
  font-size: 0.78rem;
}

.match-help-house-counts dd,
.match-help-lifecycle dd {
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.match-help-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.match-help-sections section,
.match-help-lifecycle {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.match-help-lifecycle { margin-top: 1rem; }

.match-help-lifecycle dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.replay-context-actions { margin-block: 0.75rem; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--ink);
  text-decoration: none;
}

.brand:focus-visible,
summary:focus-visible {
  outline: 0.2rem solid var(--accent);
  outline-offset: 0.2rem;
}

.brand-logo { display: block; width: clamp(135px, 16vw, 190px); height: auto; }

.board-loading {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1.2rem;
  border-radius: inherit;
  color: #e1cdb4;
  background: radial-gradient(ellipse at center, #342214, #100d0a 80%);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}
.board-stage[data-loading="true"] > :is(.houses, .board-canvas, .circular-board-guide) {
  /* Keep measurable geometry for initialization, but expose no fallback pits
     or focus targets before the selected surface is ready. */
  visibility: hidden;
}
.board-loading-logo { position: relative; width: min(86%, 560px); aspect-ratio: 1340 / 430; overflow: hidden; }
.board-loading-logo img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; }
.board-loading-logo-static { clip-path: inset(0 0 0 33.4%); filter: brightness(1.9); }
.board-loading-logo-o {
  clip-path: circle(21.4% at 15.82% 50%);
  transform-origin: 15.82% 50%;
  animation: board-loading-o-spin 1.15s linear infinite;
}
@keyframes board-loading-o-spin { to { transform: rotate(360deg); } }
:root:not([data-motion-mode="full"]) .board-loading-logo-o { animation: none; }
.board-stage > [hidden] { display: none !important; }
.board-camera-controls {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
}
.board-mount, #replay-board-mount { padding-bottom: var(--board-camera-block-size, 44px); }
.board-camera-controls button { min-width: 44px; min-height: 44px; max-inline-size: 100%; white-space: normal; overflow-wrap: anywhere; padding: 0.4rem; font-size: 0.8rem; }
.camera-touch-handle { min-inline-size: 0; max-inline-size: 100%; overflow-wrap: anywhere; padding: 0.85rem 0.4rem; touch-action: none; user-select: none; cursor: grab; font-size: 0.75rem; }
.board-stage[data-renderer="webgl"] {
  cursor: grab;
  touch-action: pinch-zoom;
  user-select: none;
}
.board-stage .house button:hover { filter: none; }
.board-stage[data-renderer="webgl"] .house button { cursor: default; }
.board-stage[data-renderer="webgl"] .house button[data-legal="true"] { cursor: pointer; }
.board-stage[data-renderer="webgl"] .replay-houses .house button { cursor: default; opacity: 1; }
.board-stage[data-renderer="webgl"] .replay-houses .house button::after { pointer-events: none; }
#replay[data-analysis="true"] .board-stage[data-renderer="webgl"] .replay-houses .house button[data-legal="true"]:enabled::after { pointer-events: auto; }
.board-stage[data-renderer="webgl"][data-layout="circular_candidate_b"] .house-id {
  top: calc(var(--house-pit-y) + var(--house-label-y));
  left: calc(var(--house-pit-x) + var(--house-label-x));
  right: auto;
  bottom: auto;
  transform: translate(-50%, -50%);
  background: transparent;
  padding: 0;
  color: var(--theme-label, #f3dbb3);
  text-shadow: var(--theme-label-shadow, 0 1px 2px #160e07);
}
.board-stage[data-renderer="webgl"][data-layout="circular_candidate_b"] .house-count {
  top: calc(var(--house-pit-y) - var(--house-label-y));
  left: calc(var(--house-pit-x) - var(--house-label-x));
  bottom: auto;
  transform: translate(-50%, -50%);
  font-size: 0.85rem;
  pointer-events: none;
}
.board-stage[data-renderer="webgl"][data-layout="circular_candidate_b"] .house button { overflow: visible; }
.houses[data-layout="circular_candidate_b"]::before {
  content: "";
  position: absolute;
  top: 50%; left: 35%; width: 30%; height: 2px;
  background: #24150d;
  box-shadow: 0 1px 0 #ac7c4855;
}
.board-stage[data-renderer="webgl"] > .houses::before { content: none; }

.brand-name { display: block; font: 700 1.9rem/1 Georgia, serif; letter-spacing: -0.04em; }
.brand-caption { display: block; margin-top: 0.3rem; color: var(--muted); font-size: 0.7rem; }
.site-header { border-bottom: 1px solid var(--line); padding-block: 0.5rem 1.15rem; }
.session-actions { font-size: 0.8rem; }
.session-actions .session-link { padding: 0.75rem 0.65rem; text-decoration: none; }
.session-actions :is(.session-link, button.quiet):hover { background: var(--panel-raised); }
.status { font-size: 0.83rem; margin-block: 0.65rem 1.2rem; }
.panel h1 { font: 400 clamp(1.8rem, 3.4vw, 3rem)/1.12 Georgia, serif; letter-spacing: -0.04em; }
.panel h2 { letter-spacing: -0.025em; }
.signed-out { padding: clamp(1.5rem, 5vw, 4rem); border-top: 3px solid var(--accent); }
.signed-out h1 { font-size: clamp(2.8rem, 5.8vw, 5.4rem); margin-block: 0.75rem 1.5rem; }
.signed-out .account-forms { margin-top: 2.5rem; }
.account-form { background: transparent; padding: 1.25rem; gap: 0.75rem; }
.account-form h3 { color: var(--accent); }
.account-form button { width: 100%; margin-top: 0.75rem; }
.signed-out .primary-link { margin-top: 1.5rem; }
.welcome-copy { align-self: center; }
.welcome-table { display: block; width: 100%; max-width: 32rem; max-height: 13rem; margin: 1.5rem auto 0; }
.welcome-links { margin: 1.5rem 0 0; color: var(--muted); font-size: 0.85rem; }
.welcome-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); text-underline-offset: 0.2em; }
.welcome-links a:focus-visible { outline: 0.2rem solid var(--accent); outline-offset: 0.15rem; }
@media (min-width: 70rem) {
  .welcome-copy { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); column-gap: 2rem; }
  .welcome-copy > :not(.welcome-table) { grid-column: 1; }
  .welcome-table { grid-column: 2; grid-row: 1 / span 4; align-self: center; max-height: none; margin: 0; }
  .signed-out:has(#first-party-auth:not([hidden])) { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 1rem 2.5rem; }
  .signed-out:has(#first-party-auth:not([hidden])) .welcome-copy { display: block; }
  .signed-out:has(#first-party-auth:not([hidden])) .welcome-table { max-height: 13rem; margin-top: 1.5rem; }
  .signed-out .account-forms { margin-top: 0; }
  .signed-out #auth-status { grid-column: 1 / -1; margin: 0; }
}
.landing-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-block: 1rem 2.25rem; }
.landing-heading h1 { margin-block: 0.55rem 1rem; font-size: clamp(2.3rem, 4.5vw, 4rem); }
.intro-copy { max-width: 34rem; margin: 0; line-height: 1.65; color: var(--muted); }
.landing-emblem { flex: 0 0 8rem; height: 8rem; display: grid; place-content: center; text-align: center; border: 1px solid var(--line); border-radius: 50%; box-shadow: inset 0 0 0 7px var(--panel), inset 0 0 0 8px var(--line); background: var(--panel-raised); }
.landing-emblem span { color: var(--accent); font: 3.2rem/1 Georgia, serif; }
.landing-emblem small { max-width: 5rem; margin: 0.4rem auto 0; color: var(--muted); font-size: 0.6rem; line-height: 1.3; letter-spacing: 0.06em; text-transform: uppercase; }
.landing-actions { align-items: stretch; }
.landing-actions > form { position: relative; margin: 0; padding: 1.6rem; border: 1px solid var(--line); border-radius: 0.6rem; background: var(--panel-raised); }
.landing-actions > form h2 { margin-block: 0.5rem 1.4rem; }
.step-number { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.landing-actions .action-help { line-height: 1.6; margin-top: 1rem; }

dialog.social-panel {
  --settings-panel-padding: clamp(1rem, 2.5vw, 1.75rem);
  width: min(62rem, calc(100% - 1.5rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: var(--settings-panel-padding);
  color: var(--ink);
  background: var(--panel);
  overflow: auto;
  overscroll-behavior: contain;
  scroll-padding-block-start: calc(var(--menu-chrome-height, 0px) + 0.5rem);
  box-shadow: 0 1.5rem 5rem #292c2655;
}

dialog.social-panel:not([open]) { display: none; }
.social-panel::backdrop { background: #292c2677; }
.settings-chrome { position: sticky; top: 0; z-index: 3; align-self: start; padding-block: 0.25rem 0.65rem; background: var(--panel); }
/* Sticky positioning stops inside the dialog's padding. Cover that band too,
   so scrolled text and controls cannot peek through or receive clicks there. */
.settings-chrome::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--settings-panel-padding)) calc(-1 * var(--settings-panel-padding)) 0;
  z-index: -1;
  background: var(--panel);
}
.settings-chrome > .section-heading { position: relative; padding-inline-end: 3.25rem; padding-bottom: 0.75rem; margin-bottom: 0; min-height: 44px; border-bottom: 1px solid var(--line); }
.social-panel .social-identity { margin-block: 0 1rem; font-size: 0.72rem; line-height: 1.5; }
.social-panel .social-identity code { user-select: all; }
.settings-navigation { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.35rem; margin-block: 0 1rem; padding-block: 0.5rem; }
.settings-navigation a { display: flex; align-items: center; justify-content: center; min-height: 44px; min-width: 0; padding: 0.5rem 0.3rem; border: 1px solid var(--line); border-radius: 0.55rem; color: var(--accent); font-size: 0.78rem; font-weight: 650; text-align: center; text-decoration: none; overflow-wrap: anywhere; }
.settings-navigation a:is(:hover, :focus-visible) { background: var(--panel-raised); }
.settings-navigation a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.social-panel:has(#account-security[hidden]) a[href="#security-settings-title"] { display: none; }
.social-card :is(summary, h3) { scroll-margin-block-start: 5rem; }
/* A section index beside the content is useful at desktop widths; on a
   narrow or zoomed viewport it becomes an ordinary, wrapping link grid. */
@media (min-width: 64rem) {
  dialog.social-panel[open] {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    grid-template-areas: "chrome chrome" "status status" "navigation content";
    column-gap: 1.25rem;
  }
  .social-panel > .settings-chrome { grid-area: chrome; }
  .social-panel > .social-status { grid-area: status; }
  .social-panel > .settings-navigation {
    grid-area: navigation;
    align-self: start;
    grid-template-columns: minmax(0, 1fr);
    margin: 0;
    padding: 0;
  }
  .social-panel > .settings-navigation a { justify-content: start; padding-inline: 0.75rem; }
  .social-panel > .social-columns { grid-area: content; }
}
#play-settings-title:focus { outline: 2px solid var(--accent); outline-offset: 0.3rem; }
button.settings-icon-button {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-color: transparent;
  border-radius: 50%;
  color: var(--muted);
  line-height: 1;
}
button.settings-icon-button:hover:not(:disabled) {
  background: var(--panel);
  color: var(--accent);
}
#community-close { position: absolute; top: 0; inset-inline-end: 0; font-size: 1.6rem; }
.friends-card { position: relative; }
.friends-card > summary { padding-inline-end: 3.25rem; }
#social-refresh { position: absolute; top: 0.8rem; inset-inline-end: 1rem; }
.settings-refresh-icon { width: 1.25rem; height: 1.25rem; }
#social-refresh[aria-busy="true"] { color: var(--accent); opacity: 1; filter: none; cursor: progress; }
#social-refresh[aria-busy="true"] .settings-refresh-icon {
  animation: settings-refresh-spin 0.85s linear infinite;
}
@keyframes settings-refresh-spin { to { transform: rotate(360deg); } }
:root:is([data-motion-mode="reduced"], [data-motion-mode="static"]) .settings-refresh-icon {
  animation: none !important;
}
.social-columns { align-items: start; gap: 1.25rem; }
.social-card { align-self: start; background: transparent; }
.play-settings-card { grid-column: 1 / -1; background: var(--panel); }
.play-settings-card h3 { margin: 0 0 1.25rem; font: 400 1.5rem/1.2 Georgia, serif; }
.play-settings-card :is(.presentation-board, .presentation-speed) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 0.45rem;
}
.social-panel :is(input:not([type="checkbox"]), select) {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.profile-settings-grid > * { min-width: 0; }
.material-settings { min-width: 0; margin: 1rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 0.6rem; }
.material-settings legend { padding-inline: 0.35rem; font-weight: 650; }
.material-pairings { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.material-pairings button { flex: 1 1 5rem; min-height: 44px; }
.material-pairings button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.profile-settings-grid label { display: block; margin-bottom: 0.4rem; }
.profile-form .check-control { align-items: start; line-height: 1.5; }
.check-control input[type="checkbox"] { flex: 0 0 auto; width: 1.1rem; height: 1.1rem; margin-top: 0.18rem; }
.social-panel .field-note { line-height: 1.5; margin-block: 0.7rem 0; }
.social-card .inline-control { align-items: stretch; flex-wrap: wrap; }
.social-card .inline-control input { flex: 1 1 10rem; }
.social-card .inline-control button { flex: 0 1 auto; }
.match-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; min-width: 0; max-width: 100%; }
.match-toolbar button { font-size: 0.8rem; white-space: normal; overflow-wrap: anywhere; }
.match-toolbar .badge { white-space: normal; overflow-wrap: anywhere; }
.community-match-status { margin-block: 0.65rem 0; padding: 0.6rem 0.75rem; border: 1px solid var(--accent); border-radius: 0.4rem; background: var(--panel); color: var(--accent); font-size: 0.85rem; line-height: 1.4; font-weight: 650; }
.social-card summary { min-height: 2.75rem; padding-block: 0.6rem; }

.match-heading { padding-bottom: 0.7rem; border-bottom: 1px solid var(--line); }
.match-heading .badge { font-size: 0.72rem; }
.match .turn-instruction { color: var(--accent); font-size: 1.05rem; font-weight: 700; line-height: 1.6; }
.player-scoreboard { display: grid; gap: 0.7rem; align-content: start; }
.player-card { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr); align-items: center; gap: 0.6rem; border: 1px solid var(--line); border-radius: 0.65rem; padding: 1rem; background: var(--panel); }
.player-card[data-active="true"] { border-color: var(--accent); box-shadow: inset 0 3px var(--accent); }
.player-avatar { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border-radius: 50%; background: var(--panel-raised); color: var(--accent); font: 1.2rem/1 Georgia, serif; }
.player-identity { min-width: 0; }
.player-identity h2 { margin: 0; font-size: 0.95rem; overflow-wrap: anywhere; }
.player-identity p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.68rem; line-height: 1.45; }
.player-metrics { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 0.5rem 0 0; padding-top: 0.65rem; border-top: 1px solid var(--line); }
.player-metrics dt { color: var(--muted); font-size: 0.68rem; }
.player-metrics dd { margin: 0.2rem 0 0; font-size: 1.35rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.match-facts dd.capture-score {
  display: grid;
  place-items: center;
  position: relative;
  width: 3.4rem;
  height: 3.4rem;
  border: 2px solid var(--theme-accent, #b38a4d);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #fff3d4, #e2c18c 75%, #bc8e53);
  color: #49301b;
  box-shadow: inset 0 0 0 3px #fff4d36b, 0 3px 8px #49301b20;
  font-size: 1.3rem;
  line-height: 1;
}
.capture-score::after {
  content: "";
  position: absolute;
  inset: -5px;
  border: 1px solid var(--theme-accent, #c69b57);
  border-radius: 50%;
  opacity: 0.35;
  pointer-events: none;
}
:root[data-motion-mode="full"] .capture-score.is-capture-receiving {
  animation: capture-score-arrival 180ms ease-out;
}
:root[data-motion-mode="full"] .capture-score.is-capture-receiving::after {
  animation: capture-score-ripple 180ms ease-out;
}
.capture-flight-layer {
  position: fixed;
  z-index: 1000;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.board-theme-status {
  position: fixed;
  z-index: 1001;
  bottom: max(0.5rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.35rem 0.7rem;
  border: 1px solid #ffffff40;
  border-radius: 2rem;
  background: #211d19ed;
  color: #fff3df;
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
}
.board-theme-status[hidden] { display: none; }
.capture-flight-seed {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  border: 1px solid #70461955;
  background-color: var(--theme-seed, #fff0da);
  background-image:
    radial-gradient(circle at 30% 25%, rgb(255 255 255 / var(--theme-seed-sheen, 0.28)), transparent 50%),
    var(--theme-seed-relief, none),
    var(--theme-seed-texture, url("/assets/textures/beech-beads-v2.png"));
  background-size: 100% 100%, 100% 100%, 185% 185%;
  background-position: center;
  background-blend-mode: screen, multiply, multiply;
  box-shadow: inset -2px -2px 3px #5b320b66, inset 1px 1px 2px #fff5d97d, 0 3px 5px #24150b55;
  will-change: transform, opacity;
}
.board-stage[data-renderer="webgl"] .house:is(
  [data-presentation-candidate="true"], [data-presentation-committed="true"], [data-last-capture="true"]
) button {
  box-shadow: none;
}
.board-stage[data-renderer="webgl"] .house[data-presentation-candidate="true"] button:not(:focus-visible) {
  outline: none;
}
.board-stage[data-renderer="webgl"] .house:is(
  [data-presentation-candidate="true"], [data-presentation-committed="true"], [data-last-capture="true"]
) .pit-legal-outline {
  /* Captures, legal moves and invalid contacts share the same projected rim.
     A CSS ellipse drifts away from a well when the camera moves off-axis. */
  display: block;
  opacity: 0.9;
  stroke-width: 1.8px;
  filter: drop-shadow(0 0 3px var(--theme-accent, #efcf86));
}
.board-stage[data-renderer="webgl"] .house[data-presentation-candidate="true"] .pit-legal-outline polygon {
  stroke-dasharray: 2 3;
}
.board-stage[data-renderer="webgl"] .house[data-presentation-committed="true"] .pit-legal-outline polygon {
  stroke-dasharray: none;
}
:root[data-motion-mode="full"] .board-stage[data-renderer="webgl"] .house[data-presentation-committed="true"] .pit-legal-outline {
  animation: capture-well-glow 500ms ease-out;
}
@keyframes capture-score-arrival {
  45% { transform: scale(1.13); box-shadow: 0 0 18px #d3a64c80; }
}
@keyframes capture-score-ripple {
  0% { opacity: 0.8; transform: scale(0.9); }
  100% { opacity: 0; transform: scale(1.35); }
}
@keyframes capture-well-glow {
  from { opacity: 1; filter: drop-shadow(0 0 7px var(--theme-accent, #efcf86)); }
  to { opacity: 0.9; filter: drop-shadow(0 0 3px var(--theme-accent, #efcf86)); }
}
.match-metadata { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem 0.75rem; margin: 0; color: var(--muted); }
.match-metadata > div:last-child { grid-column: 1 / -1; }
.match-metadata div { display: flex; flex-wrap: wrap; gap: 0.3rem; font-size: 0.7rem; }
.match-metadata dd { margin: 0; font-weight: 700; }
.match .board-direction { font-size: 0.75rem; line-height: 1.6; border-left: 0; padding: 0; }
.presentation-controls { border: 0; border-block: 1px solid var(--line); border-radius: 0; background: transparent; padding: 0.75rem 0; font-size: 0.8rem; }
.presentation-status { font-size: 0.75rem; font-weight: 500; }
.presentation-board-note { font-size: 0.72rem; line-height: 1.5; }
.presentation-controls select,
.presentation-controls button { min-height: 2.75rem; }
.match .result:empty { display: none; }

/* A live table uses the available viewport, not a document-sized board.
   Minimum board rows deliberately permit reflow on short/zoomed screens;
   never clip essential controls or shrink the semantic tap targets to fit. */
body:has(#match:not([hidden])) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  padding-block: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-bottom));
}
body:has(#match:not([hidden])) .site-header {
  flex: 0 0 auto;
  gap: 0.4rem;
  padding-block: 0 0.25rem;
}
body:has(#match:not([hidden])) .brand-logo { width: 7rem; }
body:has(#match:not([hidden])) main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}
body:has(#match:not([hidden])) #status {
  flex: 0 0 auto;
  min-height: 0;
  margin-block: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  line-height: 1.3;
}
#match:not([hidden]) {
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0;
  padding: 0.5rem;
  gap: 0.35rem;
}
#match:is([data-layout-family="compact_portrait"], [data-layout-family="expanded_portrait"]) {
  grid-template-rows: auto auto auto minmax(280px, 1fr) 44px auto;
}
#match:is([data-layout-family="compact_landscape"], [data-layout-family="expanded_landscape"]) {
  grid-template-rows: auto auto minmax(240px, 1fr) 44px auto;
}
#match .match-heading { margin: 0; padding-bottom: 0.3rem; gap: 0.35rem; }
#match .match-heading .eyebrow { font-size: 0.65rem; letter-spacing: 0.06em; }
#match .player-scoreboard { gap: 0.35rem; }
#match .player-card {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.4rem;
  padding: 0.5rem;
}
#match .player-avatar { display: none; }
#match .player-identity h2 { font-size: 0.8rem; }
#match .player-identity p { margin-top: 0.2rem; font-size: 0.65rem; line-height: 1.3; }
#match .player-metrics {
  grid-column: auto;
  grid-template-columns: auto;
  justify-items: center;
  gap: 0.2rem;
  margin: 0;
  padding: 0;
  border: 0;
}
#match .player-metrics dd { margin: 0; font-size: 0.8rem; }
#match .player-metrics dd.capture-score { width: 2.4rem; height: 2.4rem; font-size: 1rem; }
#match .player-metrics dt,
#match .match-metadata {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#match .board-direction { font-size: 0.65rem; line-height: 1.3; }
#match .turn-instruction { font-size: 0.9rem; line-height: 1.3; }
#match .presentation-controls { padding: 0; border: 0; min-height: 44px; align-items: center; }
#match .presentation-status { flex: 1 1 0; font-size: 0.7rem; }
#match .presentation-controls button { flex: 0 1 auto; font-size: 0.75rem; }
#match > .board-mount { height: 100%; min-height: 0; padding-bottom: var(--board-camera-block-size, 44px); }
#match #board-stage { height: 100%; min-height: 0; container-type: size; }
#match #board-stage[data-renderer="dom"] > .houses {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(100cqi, calc(100cqb * 2.7));
  height: min(100cqb, calc(100cqi / 2.7));
  margin: 0;
}
#match #board-stage[data-renderer="dom"] > .houses[data-layout="circular_candidate_b"] {
  width: min(100cqi, 100cqb);
  height: min(100cqi, 100cqb);
}
#match .board-camera-controls { gap: 0.15rem; }
#match .camera-touch-handle { padding-block: 0.5rem; }

/* Desktop reading distance deserves readable player names and clocks. Keep
   the already-qualified compact/short-screen measurements independent. */
@media (min-width: 64rem) and (min-height: 37rem) {
  #match:not([hidden]) { padding: 0.85rem; gap: 0.55rem; }
  #match .player-scoreboard { gap: 0.75rem; }
  #match .player-card { padding: 1rem; gap: 0.75rem; }
  #match .player-identity h2 { font-size: 1rem; }
  #match .player-identity p { font-size: 0.75rem; line-height: 1.5; }
  #match .player-metrics dd { font-size: 0.9rem; }
  #match .player-metrics dd.capture-score { width: 3rem; height: 3rem; font-size: 1.25rem; }
  #match .board-direction { font-size: 0.75rem; line-height: 1.5; }
  #match .turn-instruction { font-size: 1rem; }
  #match .match-heading .eyebrow { font-size: 0.72rem; }
}

/* On short landscape screens, reserve the full table height for the board.
   The sidebar keeps match actions, both players and the turn visible without
   shrinking pit targets or changing the camera to compensate for page chrome. */
@media (min-width: 42rem) and (max-height: 36rem) and (orientation: landscape) {
  #match[data-layout-family="compact_landscape"] {
    grid-template-columns: minmax(0, 1fr) 18rem;
    grid-template-areas:
      "board heading"
      "board facts"
      "board instruction"
      "board presentation"
      "board result";
    grid-template-rows: auto auto auto minmax(44px, 1fr) auto;
  }
  #match[data-layout-family="compact_landscape"] .match-heading {
    display: block;
  }
  #match[data-layout-family="compact_landscape"] .match-toolbar {
    margin-top: 0.35rem;
    gap: 0.25rem;
  }
  #match[data-layout-family="compact_landscape"] .match-toolbar .badge {
    letter-spacing: normal;
  }
  #match[data-layout-family="compact_landscape"] .player-card {
    padding: 0.35rem;
  }
  #match[data-layout-family="compact_landscape"] .player-metrics {
    grid-template-columns: auto auto;
    align-items: center;
    gap: 0.35rem;
  }
  #match[data-layout-family="compact_landscape"] > .board-mount {
    min-height: 0;
  }
}

/* Pixel-sized landscape with browser chrome has less than 400 CSS px of
   height. Keep every action at 44px; omit only the repeated match descriptor
   and its gap so the sidebar cannot push the camera row out of the viewport. */
@media (min-width: 42rem) and (max-height: 26rem) and (orientation: landscape) {
  #match[data-layout-family="compact_landscape"] .match-heading .eyebrow {
    display: none;
  }
  #match[data-layout-family="compact_landscape"] .match-toolbar {
    margin-top: 0;
  }
  /* A completed table has three additional actions. Widen its sidebar and
     put the players alongside each other, preserving the board's full height
     so circular 3D still has room for its minimum-size touch targets. */
  #match[data-layout-family="compact_landscape"]:has(#result:not(:empty)) {
    grid-template-columns: minmax(0, 1fr) minmax(26rem, 1.25fr);
    grid-template-areas:
      "board heading"
      "board facts"
      "board instruction"
      "board result"
      "board presentation";
    grid-template-rows: auto auto auto minmax(min-content, 1fr) auto;
  }
  #match[data-layout-family="compact_landscape"]:has(#result:not(:empty)) .player-scoreboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #match[data-layout-family="compact_landscape"]:has(#result:not(:empty)) > .board-mount {
    min-height: 276px;
  }
  #match[data-layout-family="compact_landscape"] > #result:not(:empty) {
    margin: 0;
  }
  #match[data-layout-family="compact_landscape"]:has(#result:not(:empty)) .board-direction,
  #match[data-layout-family="compact_landscape"]:has(#result:not(:empty)) > .presentation-controls:has(#skip-presentation[hidden]) {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Below this width the completed sidebar and camera row cannot both retain
   their targets. Reflow vertically instead of clipping or shrinking them. */
@media (min-width: 42rem) and (max-width: 49.99rem) and (max-height: 26rem) and (orientation: landscape) {
  #match[data-layout-family="compact_landscape"]:has(#result:not(:empty)) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "heading" "facts" "instruction" "board" "result" "presentation";
    grid-template-rows: auto auto auto minmax(280px, 1fr) auto auto;
  }
}

[hidden] { display: none !important; }

@media (max-width: 42rem) {
  /* At browser zoom, a short viewport is not wide enough for the landscape
     sidebar. Reflow before it squeezes the board's 44px pit targets. */
  #match[data-layout-family="compact_landscape"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "heading" "facts" "instruction" "board" "presentation" "result";
    grid-template-rows: auto auto auto minmax(320px, 1fr) 44px auto;
  }
  #match[data-layout-family="compact_landscape"] > .match-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .site-header,
  main { width: 100%; }
  .lobby-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lifecycle-notice dl { grid-template-columns: minmax(0, 1fr); }
  .replay-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel { padding: 1rem; }
  .houses { gap: 0.35rem; padding: 0.5rem; border-width: 0.35rem; }
  .house button { min-height: 4.25rem; padding-inline: 0.2rem; }
  .forfeit-dialog-actions { grid-template-columns: 1fr; }
  .history-entry { grid-template-columns: 1fr; }
  .history-entry button { width: 100%; }
  .social-columns,
  .account-forms,
  .profile-settings-grid,
  .safety-reference-grid { grid-template-columns: minmax(0, 1fr); }
  .social-panel .section-heading { flex-wrap: wrap; }
  .settings-chrome > .section-heading .eyebrow { display: none; }
  .social-panel #social-title { font: 400 1.7rem/1.2 Georgia, serif; margin: 0; }
  .social-panel .social-status { font-size: 0.8rem; line-height: 1.45; }
  .social-panel .social-card { padding: 0.8rem; }
  .settings-navigation a { font-size: 0.72rem; }
  .replay-settings { align-items: stretch; }
  .presentation-controls { align-items: stretch; }
  .presentation-status { flex-basis: 100%; }
  .presentation-speed { flex: 1 1 12rem; }
  .presentation-controls button { flex: 1 1 12rem; }
  .match-help-position,
  .match-help-sections,
  .match-help-lifecycle dl { grid-template-columns: minmax(0, 1fr); }
  .site-header { align-items: center; flex-wrap: wrap; gap: 0.5rem; }
  .brand { gap: 0.45rem; }
  .brand-mark { width: 2rem; height: 2rem; font-size: 2rem; }
  .brand-name { font-size: 1.5rem; }
  .brand-caption { display: none; }
  .session-actions { max-width: 100%; gap: 0.2rem 0.5rem; font-size: 0.7rem; }
  .session-actions button { padding-inline: 0.65rem; }
  .status { margin-block: 0.5rem; padding-block: 0.5rem; }
  .landing-heading { padding-block: 0.5rem 1.5rem; }
  .landing-emblem { display: none; }
  .landing-actions > form { padding: 1.1rem; }
  .player-card { padding: 0.7rem; grid-template-columns: minmax(0, 1fr); gap: 0.35rem; }
  .player-avatar { display: none; }
  .player-identity h2 { font-size: 0.85rem; }
  .player-metrics { margin-top: 0.25rem; }
  .player-metrics dd { font-size: 1.1rem; }
  .match { gap: 0.65rem; }
  .match .turn-instruction { font-size: 0.9rem; }
  .match-heading .badge { font-size: 0.65rem; }
  .board-stage:is([data-loading="true"], [data-renderer="webgl-probe"], [data-renderer="webgl"]) { height: clamp(225px, 60vw, 400px); }
  .presentation-controls { gap: 0.5rem; }
}

@media (max-width: 25rem) {
  body {
    padding-left: max(4px, env(safe-area-inset-left));
    padding-right: max(4px, env(safe-area-inset-right));
  }
  .match.panel { padding-inline: 0.25rem; }
  #houses {
    gap: 4px;
    border-width: 4px;
    border-radius: 1rem;
    padding: 4px;
  }
  /* Six 44px pits still fit at 320px with a document scrollbar. Give up
     decorative padding/gaps first, never the minimum playable target. */
  #match #board-stage[data-renderer="dom"] > #houses:not([data-layout="circular_candidate_b"]) {
    padding: 0;
    column-gap: clamp(0px, calc((100cqi - 272px) / 5), 4px);
  }
  #houses[data-layout="circular_candidate_b"] {
    gap: 0;
    border-radius: 50%;
    padding: 0;
  }
  #houses .house button { padding-inline: 0; }
  .circular-territory-label,
  .circular-territory-diameter span,
  .circular-direction-cue,
  .circular-transition-cue { letter-spacing: 0; }
  .circular-transition-cue span { display: none; }
}

.flat-seed-cloud { display: none; }
.board-stage[data-renderer="dom"] > .houses {
  aspect-ratio: 2.7;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: clamp(4px, 1vw, 12px);
  padding: clamp(4px, 1vw, 16px);
  border-width: 4px;
  border-color: var(--theme-accent, #b38a4d);
  background-color: var(--theme-board, #543728);
  background-image: linear-gradient(145deg, #ffffff12, transparent 60%, #0004), var(--theme-board-relief, none), var(--theme-board-texture, none);
  background-size: 100% 100%, 42% auto;
  background-blend-mode: screen, multiply;
  box-shadow: inset 0 2px 3px #fff3, inset 0 -3px 5px #0006, 0 5px 0 #291d1455;
  overflow: visible;
}
.board-stage[data-renderer="dom"] > .houses[data-layout="circular_candidate_b"] {
  aspect-ratio: 1;
  padding: 0;
}
.board-stage[data-renderer="dom"] .house {
  position: relative;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
}
.board-stage[data-renderer="dom"] .houses[data-layout="circular_candidate_b"] .house { position: absolute; }
.board-stage[data-renderer="dom"] .house button {
  position: relative;
  display: block;
  height: 100%;
  min-height: 44px;
  padding: 0;
  border-width: 2px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 65%, #0007, transparent 70%), var(--theme-bowl, #35251a);
  box-shadow: inset 0 4px 7px #0007, 0 1px 1px #ffffff55;
  /* Labels and cue markers never contribute to pit dimensions. Cosmetic
     emphasis must not move the native hit target during a turn. */
  animation: none !important;
  transform: none !important;
  transition: box-shadow 140ms ease, border-color 140ms ease;
  overflow: visible;
  opacity: 1;
}
.board-stage[data-renderer="dom"] .house button[data-legal="true"] {
  border-color: var(--theme-accent, #ebc379);
  box-shadow: inset 0 4px 7px #0007, inset 0 0 14px #fff1, 0 1px 1px #ffffff55;
}
.board-stage[data-renderer="dom"] .house button[data-legal="true"]:is(:hover, :focus-visible) {
  box-shadow: inset 0 4px 7px #0007, inset 0 0 20px #fff3, 0 1px 1px #ffffff55;
}
.board-stage[data-renderer="dom"] .house button[data-legal="true"]::before {
  inset: 4px;
}
.board-stage[data-renderer="dom"] :is(.house-id, .house-count) {
  position: absolute;
  z-index: 2;
  margin: 0;
  border-radius: 0.3rem;
  padding: 2px 4px;
  background: #241a13eb;
  color: #fff3de;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.board-stage[data-renderer="dom"] .house-id { top: 7%; left: 7%; font-size: clamp(9px, 1vw, 12px); }
.board-stage[data-renderer="dom"] .house-count { right: 6%; bottom: 5%; font-size: clamp(12px, 1.8vw, 22px); }
.board-stage[data-renderer="dom"] :is(.house-state, .house-last-landing) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.board-stage[data-renderer="dom"] .flat-seed-cloud {
  display: block;
  position: absolute;
  inset: 10%;
  pointer-events: none;
}
.flat-seed {
  position: absolute;
  width: 14%;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--theme-seed, #f0d2a2);
  background-image: radial-gradient(circle at 30% 25%, #ffffff88, transparent 55%), var(--theme-seed-relief, none), var(--theme-seed-texture, none);
  background-size: 100% 100%, 185% 185%;
  background-blend-mode: screen, multiply;
  box-shadow: inset -1px -2px 2px #0005, 0 2px 3px #0007;
}
.board-stage[data-renderer="dom"] .house:is([data-last-capture="true"], [data-presentation-committed="true"]) button {
  box-shadow: inset 0 0 0 2px var(--theme-accent, #ebc379), 0 0 12px var(--theme-accent, #ebc379);
}

/* Crafted table: shared live/replay chrome; geometry and native hit targets
   remain renderer-owned. Secondary disclosures reflow rather than clipping. */
.nav-icon { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }
#inbox-open { position: relative; }
.inbox-count {
  position: absolute;
  inset-block-start: -0.15rem;
  inset-inline-end: -0.15rem;
  min-width: 1.25rem;
  padding: 0.1rem 0.25rem;
  border-radius: 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.65rem;
  line-height: 1rem;
  font-weight: 700;
}
@media (max-width: 22.5rem) {
  .settings-navigation { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.session-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; }
.panel { border-radius: 1rem; box-shadow: var(--table-shadow); }
.badge { border-radius: 2rem; letter-spacing: 0.025em; }
.landing-actions > form,
.social-card,
.history-entry { border-radius: var(--radius); }
.landing-actions > form { background: var(--panel); }
.landing-actions > #create-form { background: #e8eddf; border-color: #b4c2a8; }
.landing-actions > form .inline-control { gap: 0.65rem; }
.landing-actions > form :is(input, select) { flex-basis: 100%; }
.landing-actions > form button { width: 100%; }
.history-entry { background: transparent; border-width: 0 0 1px; border-radius: 0; }
.social-card { box-shadow: none; }
:is(input:not([type="checkbox"]):not([type="range"]), select) {
  border-radius: 0.6rem;
}
dialog::backdrop { background: #25282070; backdrop-filter: blur(3px); }
.board-stage {
  border-radius: 0.8rem;
  background: radial-gradient(ellipse at 45% 35%, #f4f0e6 0%, #e1dfd0 78%, #d3d2c3);
  box-shadow: inset 0 0 0 1px #59472f12, inset 0 2px 12px #59472f08;
}
.player-card { border-radius: var(--radius); background: var(--panel); }
.player-card[data-active="true"] {
  border-color: #799071;
  background: #edf1e6;
  box-shadow: inset 3px 0 var(--accent);
}
#match .player-identity h2 { font-weight: 750; letter-spacing: 0.01em; }
#match .turn-instruction { color: var(--accent); font-weight: 750; }
.match-facts dd.capture-score {
  border-color: #b69b72;
  background: radial-gradient(circle at 35% 25%, #fff9e9, #e5cfaa 75%, #b99b70);
  box-shadow: inset 0 0 0 2px #fffbef90, 0 2px 5px #49301b18;
}
.board-camera-controls { border-radius: 0 0 var(--radius) var(--radius); }
.board-camera-controls button { border-color: transparent; border-radius: 0.5rem; }
.board-camera-controls button:hover:not(:disabled) { background: var(--panel-raised); }
.capture-score::after { inset: -4px; opacity: 0.25; }
.replay-controls .replay-transport { border-radius: 50%; }
#replay-play { border-radius: 2rem; }
.flat-seed { background-image: radial-gradient(circle at 30% 25%, #ffffff55, transparent 55%), var(--theme-seed-relief, none), var(--theme-seed-texture, none); box-shadow: inset -1px -1px 2px #0004, 0 2px 3px #0005; }
.board-stage[data-renderer="dom"] > .houses {
  background-size: 100% 100%, 100% 100%;
}

body:has(#replay:not([hidden])) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  /* Do not create a second vertical scroller through overflow-x: hidden.
     Expanded options scroll the document; closing them restores compact fit. */
  overflow-x: clip;
  padding-block: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-bottom));
}
body:has(#replay:not([hidden])) .site-header { flex: 0 0 auto; gap: 0.4rem; padding-block: 0 0.25rem; }
body:has(#replay:not([hidden])) .brand-logo { width: 7rem; }
body:has(#replay:not([hidden])) main { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
body:has(#replay:not([hidden])) #status {
  flex: 0 0 auto;
  min-height: 0;
  margin-block: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  line-height: 1.3;
}
#replay:not([hidden]) {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 0.5rem;
  gap: 0.35rem;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "heading" "returns" "facts" "board" "transport" "timeline" "extras" "validation";
  grid-template-rows: auto auto auto minmax(280px, 1fr) auto auto auto auto;
}
#replay > * { min-width: 0; }
/* Any expanded disclosure may exceed the viewport: contain its grid tracks inside
   the card without changing the compact fit when the details are closed. */
#replay:not([hidden]):has(.replay-extras > details[open]) {
  flex-shrink: 0;
  min-height: min-content;
}
#replay > .section-heading { grid-area: heading; margin: 0; align-items: center; gap: 0.5rem; }
#replay-title { margin: 0; font-size: 1.3rem; }
#replay .eyebrow { margin: 0 0 0.15rem; font-size: 0.6rem; }
.replay-return-actions { grid-area: returns; display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0; }
.replay-return-actions button { min-width: 44px; padding: 0.5rem 0.55rem; font-size: 0.75rem; }
.replay-return-actions .replay-help { border-radius: 50%; font: 1.15rem/1 Georgia, serif; }
.replay-board { display: contents; }
#replay .replay-facts { grid-area: facts; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.35rem; margin: 0; }
#replay .replay-facts > div { display: flex; align-items: center; justify-content: space-between; gap: 0.2rem; padding: 0.35rem 0.5rem; background: transparent; border-bottom: 1px solid var(--line); }
#replay .replay-facts dt { font-size: 0.65rem; }
#replay .replay-facts dd { margin: 0; font-size: 0.85rem; }
#replay .replay-facts dd.capture-score { flex: 0 0 auto; width: 2rem; height: 2rem; }
#replay-board-mount { grid-area: board; min-height: 0; height: 100%; padding-bottom: var(--board-camera-block-size, 44px); }
#replay #board-stage { height: 100%; min-height: 0; container-type: size; }
#replay #board-stage[data-renderer="dom"] > .houses {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(100cqi, calc(100cqb * 2.7));
  height: min(100cqb, calc(100cqi / 2.7));
  margin: 0;
}
#replay #board-stage[data-renderer="dom"] > .houses[data-layout="circular_candidate_b"] {
  width: min(100cqi, 100cqb);
  height: min(100cqi, 100cqb);
}
.replay-frame-detail { min-height: 0; margin: 0; font-size: 0.8rem; line-height: 1.5; }
.replay-controls { grid-area: transport; justify-content: center; flex-wrap: wrap; gap: 0.35rem; margin: 0; }
.replay-controls #replay-play { min-inline-size: 44px; max-inline-size: 100%; white-space: normal; overflow-wrap: anywhere; }
.replay-transport { min-width: 44px; padding: 0.25rem; font: 1.4rem/1 Georgia, serif; }
#replay-play { min-width: 5rem; }
.replay-timeline { grid-area: timeline; display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.75rem; }
#replay-position-counter { max-inline-size: 100%; white-space: normal; overflow-wrap: anywhere; }
#replay-position { flex: 1 1 6rem; width: 6rem; min-width: 0; min-height: 44px; margin: 0; accent-color: var(--accent); }
.replay-options { flex: 0 0 auto; }
.replay-options summary,
.replay-record-details summary { min-height: 44px; padding: 0.75rem 0.5rem; cursor: pointer; font-weight: 650; }
.replay-options[open] { flex: 1 1 100%; }
.replay-settings { margin: 0; gap: 0.5rem; }
.replay-settings select { min-height: 44px; }
.replay-extras { grid-area: extras; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: start; gap: 0.35rem; font-size: 0.75rem; }
.replay-record-details { border: 0; padding: 0; }
.replay-record-details[open] { flex: 1 1 100%; }
.replay-range { grid-area: validation; margin: 0; }
.replay-range[data-validation="error"] { border-left: 3px solid var(--error); padding: 0.5rem; color: var(--error); }
.replay-range[data-validation="verified"]:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#replay .board-camera-controls { gap: 0.15rem; }
#replay .camera-touch-handle { padding-block: 0.5rem; }
@media (max-width: 42rem), (max-height: 26rem) and (orientation: landscape) {
  #replay .replay-facts > .replay-turn { justify-content: center; text-align: center; }
  #replay .replay-turn dt {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  #replay-side-to-move { max-width: 100%; text-wrap: balance; }
}
@media (max-width: 42rem) {
  #replay:not([hidden]) { row-gap: 0.25rem; }
  .session-actions .nav-label { display: none; }
  .session-actions button { min-width: 44px; padding-inline: 0.5rem; }
  .site-header { flex-wrap: nowrap; gap: 0.35rem; }
  .session-actions { flex: 0 1 auto; width: auto; gap: 0.2rem; }
  .brand-logo { width: 7rem; }
}
@media (min-width: 42rem) and (orientation: landscape) {
  #replay:not([hidden]) {
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.4fr);
    grid-template-areas:
      "board heading"
      "board returns"
      "board facts"
      "board timeline"
      "board extras"
      "board transport"
      "board validation";
    grid-template-rows: auto auto auto auto auto minmax(min-content, 1fr) auto;
  }
  #replay-board-mount { min-height: 280px; }
  #replay .replay-facts > div { padding: 0.25rem; }
  #replay .replay-controls { align-self: end; }
}

/* Short landscape keeps the complete camera row inside the viewport. Let the
   board share the available height with the sidebar's 44px controls; the
   repeated eyebrow is not needed beside the replay title. */
@media (min-width: 42rem) and (max-height: 26rem) and (orientation: landscape) {
  .history-current-party { padding: 0.25rem 0.75rem; gap: 0.25rem 0.75rem; }
  .history-current-party .field-note { flex: 1 1 15rem; }
  #replay:not([hidden]) {
    row-gap: 0.1rem;
    grid-template-columns: minmax(0, 1fr) minmax(21rem, 0.4fr);
  }
  #replay .replay-extras { gap: 0 0.35rem; }
  /* Keep playback above optional disclosures when a live-party return strip
     shares the short viewport. Expanded details can still scroll normally. */
  body:has(#history-current-party:not([hidden])) #replay:not([hidden]) {
    grid-template-areas:
      "board heading"
      "board returns"
      "board facts"
      "board timeline"
      "board transport"
      "extras extras"
      "validation validation";
    grid-template-rows: auto auto auto auto minmax(min-content, 1fr) auto auto;
  }
  #replay-board-mount { min-height: 0; }
}

/* Keep all six transport controls and the closed extras in one row on compact
   screens. Open disclosures take the full width and may scroll. */
@media (max-width: 42rem), (max-height: 26rem) and (orientation: landscape) {
  #replay .eyebrow { display: none; }
  #replay .replay-extras {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
    gap: 0.15rem;
  }
  #replay-notes-open {
    min-width: 0;
    min-height: 44px;
    padding: 0.4rem 0.15rem;
    font-size: inherit;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  #replay .replay-extras > details { min-width: 0; }
  #replay .replay-extras > details[open] { grid-column: 1 / -1; }
  #replay .replay-extras summary {
    padding: 0.1rem 0;
    min-height: 44px;
    list-style: none;
    border: 1px solid var(--line);
    border-radius: 0.4rem;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
  }
  #replay .replay-extras summary::-webkit-details-marker { display: none; }
  #replay .replay-extras > details[open] > summary { border-color: var(--accent); }
  #replay .replay-controls { column-gap: 0.15rem; }
  #replay .replay-controls #replay-play { padding-inline: 0; font-size: 0.875rem; }
  /* A temporary scrollbar must not force the rematch note onto an extra row
     and leave the compact screen stuck overflowing after options close. */
  #replay #rematch-controls .rematch-status { flex-basis: 10rem; }
  /* The verified read-only heading already states this success. Keep its
     live-region text available, but give its row back to the circular board.
     Errors, connection notices and explicitly focused status remain visible. */
  body:has(#replay:not([hidden]) #replay-range[data-validation="verified"])
    #status[data-tone="normal"]:not([data-connection-notice="true"]):not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    margin: 0;
    padding: 0;
  }
}

@media (max-width: 42rem) {
  body:has(#replay:not([hidden])) .brand-logo { width: 100px; }
  body:has(#replay:not([hidden])) .session-actions .session-link {
    min-width: 44px;
    justify-content: center;
    padding-inline: 0.3rem;
  }
}

/* Keep the existing four header destinations on one row at 320px. Preserve
   the wordmark's 100px minimum and full 44px navigation targets; do not make
   room by clipping replay controls or shrinking the board's minimum track. */
@media (max-width: 22.5rem) {
  body:has(#replay:not([hidden])) .site-header { gap: 0.2rem; }
  body:has(#replay:not([hidden])) .session-actions { gap: 0.1rem; }
  /* Reclaim the card and page gutters for the board's separated 44px targets.
     Keep the transport, notes and text inside their normal padded column. */
  #replay-board-mount { margin-inline: -0.75rem; }
  /* Six optional replay controls need 276px, including their gaps. Reclaim
     a few gutter pixels, not target size or the board's safe projection area. */
  #replay .replay-extras { margin-inline: -0.25rem; }
  /* Two short labels may wrap within their own target; a second complete
     camera row would take the circular board below its safe projection size. */
  #replay .camera-touch-handle,
  #replay #board-camera-reset {
    flex: 0 0 44px;
    width: 44px;
    min-height: 44px;
    padding-inline: 0.1rem;
    font-size: 0.75rem;
    line-height: 1.1;
    text-align: center;
  }
}

.history-opponent {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-block: 0.75rem;
}
.history-opponent p { margin: 0; overflow-wrap: anywhere; }
.history-opponent .field-note { flex-basis: 100%; }

@media (forced-colors: active) {
  .house button[data-hotkey-held] .pit-hotkey-feedback,
  .house button[data-hotkey-error="true"] .pit-hotkey-feedback { border: 3px solid Highlight; }
  .board-stage[data-renderer="dom"] > .houses,
  .board-stage[data-renderer="dom"] .house button {
    background: Canvas;
    border-color: ButtonText;
    box-shadow: none;
  }
  .board-stage[data-renderer="dom"] :is(.house-id, .house-count) { color: ButtonText; background: Canvas; }
  .board-stage[data-renderer="dom"] .flat-seed-cloud { display: none; }
  .match-facts dd.capture-score { background: Canvas; color: CanvasText; border-color: Highlight; box-shadow: none; }
  .capture-score::after { border-color: Highlight; }
  .forfeit-dialog,
  .leave-party-dialog,
  .game-navigation-dialog,
  .match-help-dialog,
  .social-panel,
  .social-card,
  .forfeit-warning { border: 2px solid ButtonText; }
  .house button[data-legal="true"] {
    border-color: Highlight;
    outline: 2px solid Highlight;
  }
  .house button[data-legal="true"]::before,
  .house button[data-legal="true"] .house-state { color: Highlight; }
  .house button[data-legal="true"]::before {
    border: 2px solid Highlight;
    box-shadow: none;
    opacity: 1;
  }
  .house[data-last-source="true"] button { border-style: dashed; }
  .house[data-last-landing="true"] button { border-color: Highlight; }
  .house[data-presentation-source="true"] button { border-style: dashed; }
  .house[data-presentation-destination="true"] button { border-style: double; }
  .house[data-presentation-candidate="true"] button { outline: 2px dotted ButtonText; }
  .house[data-presentation-committed="true"] button { outline: 3px solid ButtonText; }
  .circular-board-guide {
    color: CanvasText;
    filter: none;
  }
  .circular-territory-label,
  .circular-territory-diameter span,
  .circular-direction-cue,
  .circular-transition-cue {
    border-color: CanvasText;
    background: Canvas;
    color: CanvasText;
    forced-color-adjust: auto;
  }
  .circular-territory-diameter { border-color: CanvasText; }
  .house-last-landing { color: HighlightText; background: Highlight; }
  .house[data-last-source="true"] .house-state::before,
  .house[data-last-capture="true"] .house-state::before { color: ButtonText; }
  .house button:focus-visible {
    outline-color: ButtonText;
    outline-style: double;
    outline-width: 4px;
  }
  :root[data-motion-mode="full"] #houses .house button,
  :root[data-motion-mode="reduced"] #houses .house button,
  :root[data-motion-mode="static"] #houses .house button { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pit-hotkey-feedback { transition: none; }
  .house button[data-legal="true"]::before { transition: none; }
  .settings-refresh-icon { animation: none !important; }
  .capture-score, .capture-score::after,
  .board-stage .house button::before { animation: none !important; }
  *, *::before, *::after { scroll-behavior: auto !important; }
  #houses .house:is(
    [data-presentation-source="true"],
    [data-presentation-destination="true"],
    [data-presentation-candidate="true"],
    [data-presentation-committed="true"]
  ) button { animation: none; }
}
.learning-summary { border-top: 1px solid var(--border, #4d453b); margin-top: 1rem; padding-top: 1rem; }
.learning-summary .account-security-actions { flex-wrap: wrap; }
.guest-locked > :not(header):not([role="status"]):not([data-guest-unlock]) { display: none; }
#correspondence-dialog { width: min(36rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow-y: auto; }
#correspondence-dialog :is(input, select, button) { max-width: 100%; min-width: 0; overflow-wrap: anywhere; }
#correspondence-dialog :is(input, select) { width: 100%; }
#correspondence-games { padding-inline-start: 1.25rem; }
#correspondence-games li { margin-block: 0.8rem; overflow-wrap: anywhere; }
#correspondence-games a { display: block; }
.social-panel .social-columns { display: block; min-width: 0; }
.menu-page { min-width: 0; display: grid; gap: 1rem; }
.menu-page[hidden] { display: none; }
.menu-page:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.settings-navigation button { min-height: 44px; min-width: 0; padding: 0.55rem 0.65rem; font-size: 0.83rem; overflow-wrap: anywhere; background: transparent; color: var(--muted); }
.settings-navigation button[aria-selected="true"] { color: var(--accent); background: var(--panel-raised); border-color: var(--accent); box-shadow: inset 0 -2px var(--accent); }
.settings-navigation { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.social-panel[data-menu-mode="profile"] .settings-navigation { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.menu-search-label { display: block; font-size: 0.75rem; font-weight: 650; margin: 0.75rem 0 0.3rem; color: var(--muted); }
.menu-spaces { display: flex; gap: 0.5rem; margin-top: 0.65rem; }
.menu-spaces button { min-height: 44px; flex: 1; }
.menu-spaces button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--panel-raised); }
@media (max-height: 500px) {
  .settings-chrome .eyebrow { display: none; }
  .settings-chrome #social-title { font-size: 1.25rem; margin: 0; }
  .settings-chrome { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.4rem 1rem; }
  .settings-chrome > .section-heading, .settings-chrome > .community-match-status,
  .settings-chrome > .menu-search-results { grid-column: 1 / -1; }
  .settings-chrome .menu-spaces { margin: 0; }
  .settings-chrome .menu-search-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
.menu-search-results { max-height: 30dvh; overflow: auto; display: grid; gap: 0.35rem; margin-top: 0.5rem; }
.menu-search-results button { text-align: start; min-height: 44px; }
.menu-search-results p { margin: 0.5rem 0; font-size: 0.85rem; }
#inbox-open .nav-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.social-panel .social-status:empty { display: none; }
@media (min-width: 64rem) {
  .social-panel[data-menu-mode] .settings-navigation { grid-template-columns: minmax(0, 1fr); }
  .settings-navigation button { text-align: start; }
  .social-panel[data-menu-mode="inbox"] { grid-template-areas: "chrome chrome" "status status" "content content"; }
}
/* Optional lobby poster; never overlays or receives gameplay input. */
.board-introduction-stage {
  position: relative;
  width: min(100%, 640px);
  height: 260px;
  margin-inline: auto;
  pointer-events: none;
  overflow: hidden;
}
.board-introduction-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.board-introduction-stage [hidden] { display: none; }
.board-introduction .lobby-actions { justify-content: center; flex-wrap: wrap; }
@media (max-height: 480px) {
  .board-introduction-stage { height: 150px; }
}
.game-discussion {
  width: min(36rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  overflow: auto;
  overscroll-behavior: contain;
}
.game-discussion header, .discussion-actions {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
}
.game-discussion form { display: grid; gap: .65rem; margin-block: 1rem; }
.game-discussion textarea { width: 100%; min-height: 5rem; resize: vertical; box-sizing: border-box; }
.game-discussion ol { list-style: none; padding: 0; }
.game-discussion li { border-bottom: 1px solid currentColor; padding-block: .75rem; overflow-wrap: anywhere; }
.game-discussion li p { white-space: pre-wrap; margin-block: .4rem; unicode-bidi: plaintext; }
.game-discussion time { display: block; font-size: .8em; opacity: .8; }
