:root {
  --bg: #000;
  --surface: #0d0f10;
  --surface-strong: #111315;
  --ivory: #eadbc0;
  --ivory-bright: #f1e2c5;
  --muted: #928a7d;
  --muted-strong: #b9ad99;
  --gold: #d7a657;
  --gold-soft: #efc778;
  --ice: #96d8f4;
  --danger: #bd6b5c;
  --line: rgba(234, 219, 192, 0.14);
  --line-strong: rgba(215, 166, 87, 0.5);
  --left-rail: 252px;
  --right-rail: 282px;
  --replay-progress: 0%;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overflow: clip;
  background: var(--bg);
}

body {
  color: var(--ivory);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
output {
  font: inherit;
}

button {
  color: inherit;
}

button:disabled {
  cursor: not-allowed;
}

[hidden] {
  display: none !important;
}

.app-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100dvh;
  min-height: min(580px, 100dvh);
  overflow: hidden;
  overflow: clip;
  background: #000;
}

.app-shell::before {
  display: none;
}

.ambient {
  display: none;
}

.ambient-gold {
  top: -18vw;
  left: 12vw;
  opacity: var(--ambient-gold-opacity, 0.045);
  transform: translate3d(var(--ambient-drift, 0px), 0, 0) scale(var(--ambient-scale, 1));
  background: var(--gold);
}

.ambient-ice {
  right: 4vw;
  bottom: -20vw;
  opacity: var(--ambient-ice-opacity, 0.038);
  transform: translate3d(var(--ambient-drift-inverse, 0px), 0, 0) scale(var(--ambient-scale, 1));
  background: var(--ice);
}

.shell-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: var(--left-rail) minmax(0, 1fr) var(--right-rail);
  min-width: 0;
  min-height: 0;
}

.rail-collapse,
.left-rail-restore {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 8px;
  color: rgba(234, 219, 192, 0.58);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(9, 11, 12, 0.82);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, opacity 220ms ease, transform 320ms cubic-bezier(0.22, 1, 0.36, 1), visibility 220ms;
}

.rail-collapse:hover,
.left-rail-restore:hover {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.56);
  background: rgba(15, 16, 16, 0.94);
}

.rail-collapse svg,
.left-rail-restore svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.left-rail-restore {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 26;
  opacity: 0;
  transform: translateX(-14px);
  visibility: hidden;
  pointer-events: none;
}

.sound-toggle {
  position: absolute;
  top: 18px;
  right: calc(var(--right-rail) + 18px);
  z-index: 27;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 8px;
  color: rgba(234, 219, 192, 0.58);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(9, 11, 12, 0.78);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, right 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.sound-toggle:hover,
.sound-toggle[aria-pressed="true"] {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.48);
}

.sound-toggle.is-muted {
  color: rgba(234, 219, 192, 0.34);
  border-color: rgba(234, 219, 192, 0.1);
}

.sound-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound-off-icon,
.sound-toggle.is-muted .sound-on-icon {
  display: none;
}

.sound-toggle.is-muted .sound-off-icon {
  display: block;
}

.rail {
  position: relative;
  z-index: 20;
  min-width: 0;
  min-height: 0;
  background: linear-gradient(180deg, rgba(10, 12, 13, 0.97), rgba(7, 8, 9, 0.95));
  scrollbar-width: thin;
  scrollbar-color: rgba(234, 219, 192, 0.24) transparent;
}

.game-rail {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 38px 25px 92px;
  border-right: 1px solid var(--line);
}

@media (min-width: 981px) {
  .shell-grid {
    transition: grid-template-columns 360ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .game-rail {
    transition: opacity 220ms ease, transform 360ms cubic-bezier(0.22, 1, 0.36, 1), visibility 360ms;
  }

  .app-shell.left-rail-collapsed {
    --left-rail: 0px;
  }

  .left-rail-collapsed .game-rail {
    opacity: 0;
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
  }

  .left-rail-collapsed .left-rail-restore {
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .left-rail-collapsed .thinking-indicator {
    left: 76px;
  }
}

.match-rail {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 36px 18px 116px;
  border-left: 1px solid var(--line);
}

.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.rail-heading h1,
.mobile-brand {
  margin: 0;
  color: var(--ivory-bright);
  font-family: "Iowan Old Style", Baskerville, "Times New Roman", serif;
  font-size: 42px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.035em;
}

.rail-close {
  display: none;
  width: 38px;
  height: 38px;
  padding: 8px;
  color: var(--muted-strong);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
}

.rail-close svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}

.new-game-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin-top: 28px;
  color: var(--gold-soft);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 17px;
  letter-spacing: 0.01em;
  border: 1px solid rgba(215, 166, 87, 0.66);
  border-radius: 7px;
  background: rgba(215, 166, 87, 0.035);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 150ms ease;
}

.new-game-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.new-game-button:hover {
  color: #f6d48e;
  border-color: var(--gold);
  background: rgba(215, 166, 87, 0.08);
}

.control-section {
  margin-top: 29px;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.section-heading h2 {
  flex: none;
  margin: 0;
  color: rgba(239, 199, 120, 0.9);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.section-heading > span {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.choice-stack {
  display: grid;
  gap: 7px;
}

.choice-button {
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 44px;
  padding: 7px 13px;
  color: rgba(234, 219, 192, 0.78);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 16px;
  line-height: 1;
  text-align: left;
  border: 1px solid rgba(234, 219, 192, 0.17);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.008);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 150ms ease;
}

.choice-button svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
}

.choice-button .piece-mark {
  width: 23px;
  color: rgba(234, 219, 192, 0.44);
  font-size: 25px;
  line-height: 1;
  text-align: center;
}

.choice-button .piece-mark-white {
  color: var(--ivory);
}

.choice-button:hover {
  color: var(--ivory-bright);
  border-color: rgba(215, 166, 87, 0.42);
  background: rgba(215, 166, 87, 0.025);
}

.choice-button.is-selected {
  color: var(--ivory-bright);
  border-color: rgba(215, 166, 87, 0.78);
  background: rgba(215, 166, 87, 0.05);
}

.choice-button.is-selected svg,
.choice-button.is-selected .piece-mark {
  color: var(--gold-soft);
  opacity: 1;
}

.choice-stack.compact .choice-button {
  min-height: 39px;
  padding-block: 5px;
  font-size: 15px;
}

.provider-status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 9px 2px 0;
  color: rgba(234, 219, 192, 0.46);
  font-size: 10px;
  line-height: 1.35;
}

.provider-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.provider-status[data-status="online"] .provider-dot {
  background: var(--ice);
  box-shadow: 0 0 9px rgba(150, 216, 244, 0.42);
}

.provider-status[data-status="fallback"] .provider-dot {
  background: var(--gold);
}

.camera-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.camera-grid button,
.replay-speed button {
  min-height: 36px;
  color: rgba(234, 219, 192, 0.6);
  font-size: 11px;
  letter-spacing: 0.04em;
  border: 1px solid rgba(234, 219, 192, 0.15);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}

.camera-grid button:hover,
.camera-grid button.is-selected,
.replay-speed button:hover,
.replay-speed button.is-selected {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.62);
  background: rgba(215, 166, 87, 0.04);
}

.shortcut-note {
  margin: 21px 0 0;
  color: rgba(234, 219, 192, 0.3);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

[data-game-mode="human"] .ai-only {
  display: none;
}

.stage {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  outline: none;
}

.stage:focus-visible::after {
  position: absolute;
  inset: 8px;
  z-index: 12;
  content: "";
  border: 1px solid rgba(150, 216, 244, 0.5);
  pointer-events: none;
}

.canvas-host,
.canvas-host canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.canvas-host canvas {
  display: block;
  outline: none;
  touch-action: none;
}

.stage-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 4, 5, 0.08), transparent 20%, transparent 80%, rgba(3, 4, 5, 0.18)),
    radial-gradient(ellipse at center, transparent 61%, rgba(3, 4, 5, 0.14) 100%);
}

.board-hint {
  position: absolute;
  bottom: 85px;
  left: 50%;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: rgba(239, 199, 120, 0.66);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 12px;
  font-style: italic;
  letter-spacing: 0.025em;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.board-hint svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
}

.thinking-indicator {
  position: absolute;
  top: 30px;
  left: 30px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 12px;
  color: rgba(150, 216, 244, 0.76);
  border-left: 1px solid rgba(150, 216, 244, 0.44);
  opacity: 0;
  transform: translateY(-5px);
  transition: left 320ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}

.thinking-indicator.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.thinking-indicator > span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  animation: thinking-pulse 1.2s ease-in-out infinite;
}

.thinking-indicator > span:nth-child(2) { animation-delay: 120ms; }
.thinking-indicator > span:nth-child(3) { animation-delay: 240ms; }

.thinking-indicator em {
  margin-left: 5px;
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 12px;
  font-weight: 400;
}

@keyframes thinking-pulse {
  0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

.replay-wash {
  position: absolute;
  top: -35%;
  bottom: -35%;
  left: -48%;
  z-index: 5;
  width: 28%;
  opacity: 0;
  transform: rotate(10deg);
  background: linear-gradient(90deg, transparent, rgba(239, 220, 182, 0.35), rgba(150, 216, 244, 0.12), transparent);
  filter: blur(10px);
  mix-blend-mode: screen;
  pointer-events: none;
}

.replay-wash.is-active {
  animation: replay-wash 850ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes replay-wash {
  0% { left: -48%; opacity: 0; }
  18% { opacity: 0.72; }
  82% { opacity: 0.55; }
  100% { left: 120%; opacity: 0; }
}

.stage-error {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 30;
  margin: 0;
  padding: 14px 18px;
  color: var(--ivory);
  font-size: 13px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  transform: translate(-50%, -50%);
}

.promotion-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 30;
  width: min(420px, calc(100% - 32px));
  padding: 25px;
  border: 1px solid rgba(215, 166, 87, 0.62);
  border-radius: 9px;
  background: rgba(10, 12, 13, 0.98);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.58);
  transform: translate(-50%, -50%);
}

.promotion-dialog h2 {
  margin: 0;
  color: var(--ivory-bright);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 25px;
  font-weight: 400;
}

.promotion-dialog p {
  margin: 6px 0 20px;
  color: var(--muted);
  font-size: 12px;
}

.promotion-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.promotion-options button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 8px 13px;
  color: var(--ivory);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}

.promotion-options button:hover {
  color: var(--gold-soft);
  border-color: var(--line-strong);
}

.promotion-options button span {
  font-size: 26px;
}

.promotion-options button .promotion-label {
  font-size: 15px;
}

.players {
  border-bottom: 1px solid var(--line);
}

.player-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  color: rgba(234, 219, 192, 0.62);
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.player-row.is-active,
.player-row.is-winner {
  color: var(--ivory-bright);
}

.player-row.is-active {
  border-color: rgba(215, 166, 87, 0.25);
  background: linear-gradient(90deg, rgba(215, 166, 87, 0.12), rgba(215, 166, 87, 0.025));
  box-shadow: inset 0 0 20px rgba(215, 166, 87, 0.045), 0 0 20px rgba(215, 166, 87, 0.08);
  animation: player-turn-pulse 1.8s ease-in-out infinite;
}

.player-row.is-active.is-turn-urgent {
  border-color: rgba(245, 190, 91, 0.52);
  animation-duration: 0.9s;
}

.player-row.is-active.is-turn-expired {
  animation: none;
  box-shadow: inset 0 0 22px rgba(215, 166, 87, 0.1), 0 0 20px rgba(215, 166, 87, 0.12);
}

@keyframes player-turn-pulse {
  0%, 100% { transform: scale(1); box-shadow: inset 0 0 18px rgba(215, 166, 87, 0.04), 0 0 14px rgba(215, 166, 87, 0.06); }
  50% { transform: scale(1.018); box-shadow: inset 0 0 26px rgba(215, 166, 87, 0.09), 0 0 24px rgba(215, 166, 87, 0.15); }
}

.player-disc {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(234, 219, 192, 0.22);
  border-radius: 7px;
  background-color: #111214;
  background-position: center;
  background-size: cover;
}

.white-disc {
  border-color: #e9ddc7;
  background-image: url("./assets/factions/dawn-paladins.webp");
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.black-disc {
  background-image: url("./assets/factions/obsidian-templars.webp");
}

.player-row.is-active .player-disc {
  box-shadow: 0 0 0 3px rgba(215, 166, 87, 0.08), 0 0 18px rgba(215, 166, 87, 0.28);
  border-color: var(--gold-soft);
}

.player-copy {
  display: grid;
  gap: 2px;
}

.player-copy strong {
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.1;
}

.player-copy span {
  color: rgba(234, 219, 192, 0.36);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.player-row time {
  color: rgba(234, 219, 192, 0.54);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 13px;
  letter-spacing: 0.15em;
}

.player-row.is-active time {
  color: #f3cc7e;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(215, 166, 87, 0.42);
}

.match-status {
  display: grid;
  gap: 2px;
  min-height: 43px;
  margin: 0;
  padding: 8px 0 8px 52px;
  color: var(--ice);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 15px;
}

.match-status strong {
  color: var(--ivory);
  font-weight: 400;
}

.captured-section {
  padding: 22px 0 18px;
  border-bottom: 1px solid var(--line);
}

.captured-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.captured-label {
  color: rgba(234, 219, 192, 0.35);
  font-size: 8px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.captured-row output {
  min-width: 0;
  overflow: hidden;
  color: rgba(234, 219, 192, 0.75);
  font-family: "Apple Symbols", "Segoe UI Symbol", serif;
  font-size: 18px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.move-section {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 130px;
  padding-top: 22px;
}

.move-list {
  min-height: 0;
  overflow-y: auto;
  padding: 5px 4px 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(234, 219, 192, 0.22) transparent;
}

.empty-moves {
  margin: 18px 0;
  color: rgba(234, 219, 192, 0.32);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 14px;
  font-style: italic;
  text-align: center;
}

.move-row {
  display: grid;
  grid-template-columns: 28px 1fr 1fr;
  align-items: center;
  gap: 4px;
  min-height: 31px;
}

.move-number {
  color: rgba(234, 219, 192, 0.32);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 13px;
  text-align: right;
}

.move-notation {
  min-width: 0;
  height: 27px;
  padding: 0 7px;
  overflow: hidden;
  color: rgba(234, 219, 192, 0.67);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 14px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 0;
  border-left: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}

.move-notation:hover {
  color: var(--ivory);
  background: rgba(234, 219, 192, 0.025);
}

.move-notation.is-active.white-move {
  color: var(--gold-soft);
  border-left-color: var(--gold);
  background: linear-gradient(90deg, rgba(215, 166, 87, 0.08), transparent);
}

.move-notation.is-active.black-move {
  color: var(--ice);
  border-left-color: var(--ice);
  background: linear-gradient(90deg, rgba(150, 216, 244, 0.07), transparent);
}

.replay-entry {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 10px;
  color: rgba(234, 219, 192, 0.62);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}

.replay-entry svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.replay-entry:hover,
.replay-entry.is-ready {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.52);
}

.replay-entry:disabled {
  color: rgba(234, 219, 192, 0.2);
  border-color: rgba(234, 219, 192, 0.08);
}

.context-action-rail {
  display: contents;
}

.mobile-camera-cue {
  display: none;
}

.action-deck,
.replay-deck {
  position: absolute;
  right: calc(var(--right-rail) + 24px);
  bottom: max(18px, env(safe-area-inset-bottom));
  left: calc(var(--left-rail) + 24px);
  z-index: 18;
  transition: left 360ms cubic-bezier(0.22, 1, 0.36, 1), opacity 260ms ease, transform 340ms cubic-bezier(0.22, 1, 0.36, 1), visibility 260ms;
}

.action-deck {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  background: linear-gradient(180deg, rgba(8, 9, 10, 0.06), rgba(8, 9, 10, 0.68));
}

.action-deck button {
  display: flex;
  align-items: center;
  flex: 0 1 210px;
  justify-content: center;
  gap: 9px;
  min-height: 45px;
  padding: 6px 14px;
  color: rgba(239, 199, 120, 0.72);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 15px;
  border: 1px solid rgba(234, 219, 192, 0.12);
  border-radius: 6px;
  background: rgba(9, 11, 12, 0.68);
  cursor: pointer;
}

.action-deck button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-deck button:hover {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.54);
  background: rgba(215, 166, 87, 0.05);
}

.action-deck button:disabled {
  color: rgba(234, 219, 192, 0.2);
}

.replay-deck {
  display: grid;
  grid-template-columns: 108px auto minmax(120px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 10px 15px;
  border: 1px solid rgba(215, 166, 87, 0.34);
  border-radius: 8px;
  background: rgba(9, 11, 12, 0.95);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.38);
  opacity: 0;
  transform: translateY(18px);
  visibility: hidden;
}

.show-replay-deck .action-deck {
  opacity: 0;
  transform: translateY(14px);
  visibility: hidden;
}

.show-replay-deck .replay-deck {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.replay-title {
  display: grid;
  gap: 3px;
  color: var(--gold-soft);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 15px;
}

.replay-title output {
  color: rgba(234, 219, 192, 0.48);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.replay-transport {
  display: flex;
  align-items: center;
  gap: 5px;
}

.icon-control {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 6px;
  color: rgba(239, 199, 120, 0.72);
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.icon-control:hover,
.replay-play {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.44);
}

.icon-control:disabled {
  color: rgba(234, 219, 192, 0.2);
  border-color: transparent;
}

.icon-control svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.replay-play svg {
  fill: currentColor;
  stroke: none;
}

.replay-play .replay-pause-icon,
.replay-play.is-playing .replay-play-icon {
  display: none;
}

.replay-play.is-playing .replay-pause-icon {
  display: block;
}

.replay-timeline-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 34px;
}

#replay-timeline {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 28px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

#replay-timeline::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(90deg, var(--gold) 0 var(--replay-progress), rgba(234, 219, 192, 0.22) var(--replay-progress) 100%);
}

#replay-timeline::-webkit-slider-thumb {
  width: 13px;
  height: 13px;
  margin-top: -6px;
  appearance: none;
  border: 2px solid #dff2fa;
  border-radius: 50%;
  background: var(--ice);
  box-shadow: 0 0 0 3px rgba(150, 216, 244, 0.1), 0 0 12px rgba(150, 216, 244, 0.3);
}

#replay-timeline::-moz-range-track {
  height: 1px;
  background: rgba(234, 219, 192, 0.22);
}

#replay-timeline::-moz-range-progress {
  height: 1px;
  background: var(--gold);
}

#replay-timeline::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid #dff2fa;
  border-radius: 50%;
  background: var(--ice);
}

.replay-markers {
  position: absolute;
  right: 6px;
  left: 6px;
  top: 50%;
  height: 1px;
  pointer-events: none;
}

.replay-markers span {
  position: absolute;
  top: 50%;
  left: var(--marker-position);
  width: 5px;
  height: 5px;
  border: 1px solid rgba(234, 219, 192, 0.3);
  border-radius: 50%;
  background: #151719;
  transform: translate(-50%, -50%);
}

.replay-markers span.is-passed.is-white {
  border-color: var(--gold-soft);
  background: var(--gold-soft);
}

.replay-markers span.is-passed.is-black {
  border-color: var(--ice);
  background: var(--ice);
}

.replay-speed {
  display: flex;
  align-items: center;
  gap: 4px;
}

.replay-speed button {
  min-width: 38px;
  min-height: 30px;
  padding: 0 6px;
  font-size: 10px;
}

.exit-replay {
  min-height: 36px;
  padding: 0 10px;
  color: rgba(234, 219, 192, 0.68);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.exit-replay:hover {
  color: var(--ivory);
  border-color: var(--line-strong);
}

.exit-replay:disabled {
  display: none;
}

.endgame-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  place-items: center;
  padding: 22px;
  overflow: hidden;
  color: var(--ivory);
  border: 0;
  background: rgba(2, 3, 4, 0.76);
  backdrop-filter: blur(15px) saturate(0.68) brightness(0.72);
  overscroll-behavior: contain;
  pointer-events: auto;
  cursor: default;
}

.endgame-overlay[open] {
  display: grid;
  animation: endgame-overlay-in 420ms ease both;
}

.endgame-overlay:not([open]) {
  display: none;
}

.endgame-overlay::backdrop {
  background: rgba(1, 2, 3, 0.82);
}

.endgame-open .shell-grid,
.endgame-open .network-gamebar,
.endgame-open .draw-offer-banner,
.endgame-open .action-deck,
.endgame-open .replay-deck,
.endgame-open .toast {
  pointer-events: none;
  user-select: none;
}

.endgame-open .toast,
.endgame-open .replay-deck,
.endgame-open .match-status {
  opacity: 0 !important;
  visibility: hidden !important;
}

.endgame-dialog {
  position: relative;
  width: min(500px, 100%);
  padding: 34px 34px 30px;
  overflow: hidden;
  text-align: center;
  border: 1px solid rgba(215, 166, 87, 0.5);
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 0%, rgba(215, 166, 87, 0.12), transparent 48%),
    linear-gradient(180deg, rgba(18, 19, 19, 0.985), rgba(8, 10, 11, 0.985));
  box-shadow: 0 38px 100px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.endgame-overlay.is-tutorial-course .endgame-dialog {
  width: min(610px, 100%);
}

.endgame-overlay.is-tutorial-course .endgame-detail {
  max-width: 450px;
}

.endgame-overlay[open] .endgame-dialog {
  animation: endgame-dialog-in 460ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.endgame-emblem {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 15px;
  color: var(--gold-soft);
  border: 1px solid rgba(215, 166, 87, 0.34);
  border-radius: 50%;
  background: rgba(215, 166, 87, 0.045);
  box-shadow: 0 0 40px rgba(215, 166, 87, 0.08);
}

.endgame-emblem svg {
  width: 35px;
  height: 35px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.endgame-eyebrow {
  margin: 0 0 8px;
  color: rgba(215, 166, 87, 0.74);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.endgame-dialog h2 {
  margin: 0;
  color: var(--ivory-bright);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: clamp(34px, 6vw, 46px);
  font-weight: 400;
  letter-spacing: -0.025em;
}

.endgame-detail {
  max-width: 320px;
  margin: 10px auto 27px;
  color: rgba(234, 219, 192, 0.58);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 15px;
  line-height: 1.55;
}

.endgame-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.endgame-actions button {
  min-height: 48px;
  padding: 9px 14px;
  color: rgba(234, 219, 192, 0.76);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 150ms ease;
}

.endgame-actions button:hover {
  color: var(--ivory-bright);
  border-color: rgba(215, 166, 87, 0.5);
  transform: translateY(-1px);
}

.endgame-actions .endgame-primary {
  color: #17130c;
  border-color: var(--gold-soft);
  background: var(--gold-soft);
}

.endgame-actions .endgame-primary:hover {
  color: #0d0b08;
  background: #f3cf87;
}

@keyframes endgame-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes endgame-dialog-in {
  from { opacity: 0; transform: translateY(18px) scale(0.975); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.mobile-topbar,
.rail-scrim,
.mobile-only-heading {
  display: none;
}

.toast {
  position: absolute;
  top: 26px;
  left: 50%;
  z-index: 60;
  margin: 0;
  padding: 9px 13px;
  color: var(--ivory);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 13px;
  border: 1px solid rgba(215, 166, 87, 0.42);
  border-radius: 6px;
  background: rgba(9, 11, 12, 0.94);
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 180ms ease, transform 220ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

button:focus-visible,
input:focus-visible,
.stage:focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--ivory);
  background: var(--bg);
}

@media (max-width: 1190px) {
  :root {
    --left-rail: 224px;
    --right-rail: 250px;
  }

  .game-rail {
    padding-inline: 19px;
  }

  .rail-heading h1 {
    font-size: 36px;
  }

  .choice-button {
    min-height: 41px;
    font-size: 15px;
  }

  .replay-deck {
    grid-template-columns: 90px auto minmax(90px, 1fr) auto;
  }

  .exit-replay {
    display: none;
  }
}

@media (max-width: 1080px) {
  .app-shell {
    min-height: min(520px, 100dvh);
  }

  .shell-grid {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 54px;
  }

  .mobile-topbar {
    position: absolute;
    inset: 0 0 auto;
    z-index: 45;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
    padding: max(8px, env(safe-area-inset-top)) 12px 8px;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 10, 11, 0.96);
  }

  .mobile-brand {
    font-size: 27px;
  }

  .mobile-topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .language-switcher-mobile {
    display: flex;
  }

  .mobile-panel-button {
    min-width: 58px;
    height: 34px;
    color: rgba(234, 219, 192, 0.72);
    font-size: 11px;
    letter-spacing: 0.05em;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: transparent;
  }

  .mobile-panel-button[aria-expanded="true"] {
    color: var(--gold-soft);
    border-color: var(--line-strong);
  }

  .rail-collapse,
  .left-rail-restore {
    display: none;
  }

  .sound-toggle {
    top: 64px;
    right: 12px;
  }

  .stage {
    grid-column: 1;
    grid-row: 1;
  }

  .rail {
    position: fixed;
    top: 54px;
    bottom: 0;
    z-index: 50;
    display: block;
    width: min(350px, 88vw);
    padding: 24px 22px 100px;
    overflow-y: auto;
    background: rgba(9, 11, 12, 0.985);
    transition: transform 300ms cubic-bezier(0.22, 1, 0.36, 1), visibility 300ms;
    visibility: hidden;
  }

  .game-rail {
    left: 0;
    border-right: 1px solid var(--line-strong);
    transform: translateX(-104%);
  }

  .match-rail {
    right: 0;
    border-left: 1px solid var(--line-strong);
    transform: translateX(104%);
  }

  [data-open-rail="game"] .game-rail,
  [data-open-rail="moves"] .match-rail {
    transform: translateX(0);
    visibility: visible;
  }

  .rail-heading h1 {
    font-size: 34px;
  }

  .rail-close,
  .mobile-only-heading {
    display: flex;
  }

  .mobile-only-heading {
    color: var(--ivory-bright);
    font-family: "Iowan Old Style", Baskerville, Georgia, serif;
    font-size: 27px;
  }

  .match-rail .players {
    margin-top: 14px;
  }

  .rail-scrim {
    position: absolute;
    inset: 54px 0 0;
    z-index: 48;
    display: block;
    border: 0;
    background: rgba(0, 0, 0, 0.56);
    opacity: 0;
    visibility: hidden;
    transition: opacity 220ms ease, visibility 220ms;
  }

  [data-open-rail="game"] .rail-scrim,
  [data-open-rail="moves"] .rail-scrim {
    opacity: 1;
    visibility: visible;
  }

  .action-deck,
  .replay-deck {
    right: max(12px, env(safe-area-inset-right));
    left: max(12px, env(safe-area-inset-left));
  }

  .action-deck {
    gap: clamp(14px, 8vw, 70px);
    min-height: 48px;
    border: 1px solid rgba(215, 166, 87, 0.2);
    border-radius: 8px;
    background: rgba(8, 10, 11, 0.9);
  }

  .board-hint {
    bottom: 82px;
  }

  .thinking-indicator {
    top: 22px;
    left: 18px;
  }
}

@media (max-width: 700px) {
  .action-deck {
    justify-content: space-around;
    gap: 4px;
  }

  .action-deck button {
    gap: 6px;
    padding-inline: 7px;
    font-size: 13px;
  }

  .action-deck button svg {
    width: 18px;
    height: 18px;
  }

  .replay-deck {
    grid-template-areas:
      "title transport speed"
      "timeline timeline timeline";
    grid-template-columns: 78px auto 1fr;
    gap: 3px 8px;
    min-height: 106px;
    padding: 9px 10px 6px;
  }

  .replay-title { grid-area: title; font-size: 13px; }
  .replay-transport { grid-area: transport; }
  .replay-timeline-wrap { grid-area: timeline; }
  .replay-speed { grid-area: speed; justify-self: end; }

  .replay-speed button {
    min-width: 34px;
    padding-inline: 4px;
  }

  .show-replay-deck .board-hint {
    bottom: 127px;
  }
}

@media (max-width: 480px) {
  .app-shell {
    min-height: 480px;
  }

  .mobile-topbar {
    padding-inline: 9px;
  }

  .mobile-brand {
    max-width: 36vw;
    overflow: hidden;
    font-size: 22px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-panel-button {
    min-width: 51px;
    padding-inline: 8px;
    font-size: 10px;
  }

  .rail {
    width: min(330px, 92vw);
    padding-inline: 18px;
  }

  .board-hint {
    bottom: 76px;
    font-size: 10px;
  }

  .action-deck {
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .action-deck button {
    display: grid;
    justify-items: center;
    gap: 2px;
    min-width: 64px;
    font-size: 10px;
  }

  .replay-deck {
    right: max(7px, env(safe-area-inset-right));
    bottom: max(7px, env(safe-area-inset-bottom));
    left: max(7px, env(safe-area-inset-left));
    grid-template-columns: 62px auto 1fr;
    padding-inline: 7px;
  }

  .replay-title > span {
    display: none;
  }

  .replay-title output {
    font-size: 10px;
  }

  .replay-transport {
    gap: 1px;
  }

  .icon-control {
    width: 30px;
    height: 30px;
  }

  .replay-speed button {
    min-width: 31px;
    min-height: 28px;
    font-size: 9px;
  }

  .thinking-indicator em {
    display: none;
  }

  .toast {
    top: 65px;
    max-width: calc(100% - 24px);
    white-space: nowrap;
  }

  .endgame-overlay {
    padding: 14px;
  }

  .endgame-dialog {
    padding: 28px 21px 22px;
  }

  .endgame-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 720px) and (min-width: 981px) {
  .game-rail {
    padding-top: 22px;
  }

  .rail-heading h1 {
    font-size: 33px;
  }

  .new-game-button {
    min-height: 39px;
    margin-top: 18px;
  }

  .control-section {
    margin-top: 18px;
  }

  .choice-button,
  .choice-stack.compact .choice-button {
    min-height: 34px;
    font-size: 14px;
  }

  .camera-grid button {
    min-height: 31px;
  }

  .shortcut-note {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 80ms !important;
  }

  .ambient,
  .replay-wash {
    display: none;
  }

  .network-gamebar.is-my-turn #network-room-status,
  .network-gamebar.is-my-turn .network-turn-prompt,
  .player-row.is-active { animation: none !important; opacity: 1; transform: none; }
}

/* Public online room */
.network-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: auto;
  color: var(--ivory);
  background:
    radial-gradient(circle at 12% 4%, rgba(215, 166, 87, 0.12), transparent 31%),
    radial-gradient(circle at 88% 96%, rgba(150, 216, 244, 0.07), transparent 33%),
    linear-gradient(135deg, #0c0e0f, #070809 58%, #050607);
  transition: opacity 260ms ease, visibility 260ms;
}

.network-root::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(234, 219, 192, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(234, 219, 192, 0.025) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, black, transparent 76%);
}

body:not(.network-room) .app-shell {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.network-room .network-root {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.network-room .app-shell {
  opacity: 1;
  visibility: visible;
}

.network-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  padding: 0 clamp(24px, 4vw, 64px);
  border-bottom: 1px solid rgba(234, 219, 192, 0.1);
  background: rgba(8, 10, 11, 0.78);
  backdrop-filter: blur(22px);
}

.network-header-actions,
.language-switcher {
  display: flex;
  align-items: center;
}

.network-header-actions {
  gap: 14px;
}

.admin-entry {
  color: rgba(234, 219, 192, 0.42);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
}

.admin-entry:hover { color: var(--gold-soft); }

.language-switcher {
  gap: 3px;
  padding: 3px;
  border: 1px solid rgba(234, 219, 192, 0.12);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}

.language-switcher button {
  min-width: 37px;
  min-height: 27px;
  padding: 4px 8px;
  color: rgba(234, 219, 192, 0.48);
  font-size: 10px;
  line-height: 1;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.language-switcher button:hover {
  color: var(--ivory-bright);
}

.language-switcher button.is-selected {
  color: #17130c;
  background: var(--gold-soft);
}

.language-switcher-game {
  flex: 0 0 auto;
  text-transform: none;
}

.language-switcher-mobile {
  display: none;
}

.lobby-summary > span > [data-i18n] {
  display: inline;
}

.network-brand,
.network-profile,
.network-room-meta,
.network-room-meta > span {
  display: flex;
  align-items: center;
}

.network-brand {
  gap: 13px;
}

.network-brand-mark {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  color: var(--gold-soft);
  font-family: Georgia, serif;
  font-size: 23px;
  border: 1px solid rgba(215, 166, 87, 0.42);
  border-radius: 50%;
  background: rgba(215, 166, 87, 0.055);
}

.network-brand div {
  display: grid;
  gap: 1px;
}

.network-brand strong {
  color: var(--ivory-bright);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 23px;
  font-weight: 400;
}

.network-brand span:last-child {
  color: rgba(234, 219, 192, 0.46);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.application-version {
  align-self: flex-end;
  margin: 0 0 3px 1px;
  padding: 3px 6px;
  color: rgba(234, 219, 192, 0.46);
  font: 500 9px/1 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.08em;
  border: 1px solid rgba(234, 219, 192, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
}

.network-profile {
  gap: 10px;
}

.presence-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(234, 219, 192, 0.3);
  box-shadow: 0 0 0 3px rgba(234, 219, 192, 0.04);
}

.presence-dot.is-online,
.status-online .presence-dot {
  background: #6ebf91;
  box-shadow: 0 0 0 3px rgba(110, 191, 145, 0.1);
}

.presence-dot.is-unstable,
.status-unstable .presence-dot {
  background: var(--gold-soft);
}

.presence-dot.is-disconnected,
.status-disconnected .presence-dot {
  background: #8a706b;
}

#profile-button {
  display: grid;
  justify-items: start;
  gap: 1px;
  padding: 7px 10px;
  color: var(--ivory);
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

#profile-button:hover {
  background: rgba(234, 219, 192, 0.055);
}

#profile-button span {
  font-size: 13px;
  font-weight: 600;
}

#profile-button small {
  color: rgba(234, 219, 192, 0.4);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lobby-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 400px);
  gap: clamp(34px, 5vw, 80px);
  width: min(1320px, 100%);
  min-height: 100%;
  margin: 0 auto;
  padding: clamp(126px, 16vh, 166px) clamp(24px, 4vw, 64px) 64px;
}

.lobby-intro {
  align-self: center;
  padding-bottom: 10px;
}

.lobby-kicker,
.lobby-section-heading span,
.network-label {
  color: rgba(215, 166, 87, 0.78);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.lobby-intro h1 {
  max-width: 720px;
  margin: 16px 0 18px;
  color: var(--ivory-bright);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: clamp(54px, 6.5vw, 92px);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: -0.045em;
}

.lobby-intro > p:not(.lobby-kicker) {
  max-width: 580px;
  margin: 0;
  color: rgba(234, 219, 192, 0.55);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 18px;
  line-height: 1.58;
}

.lobby-summary {
  display: flex;
  gap: 30px;
  margin-top: 34px;
  color: rgba(234, 219, 192, 0.38);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.lobby-summary span {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.lobby-summary strong {
  color: var(--ivory-bright);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 25px;
  font-weight: 400;
  letter-spacing: 0;
}

.create-table {
  align-self: center;
  padding: 26px;
  border: 1px solid rgba(234, 219, 192, 0.13);
  border-radius: 10px;
  background:
    radial-gradient(circle at 100% 0, rgba(215, 166, 87, 0.08), transparent 44%),
    rgba(12, 14, 15, 0.86);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32);
}

.lobby-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(234, 219, 192, 0.1);
}

.lobby-section-heading h2 {
  margin: 4px 0 0;
  color: var(--ivory-bright);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 28px;
  font-weight: 400;
}

.network-field {
  display: grid;
  gap: 9px;
  margin-top: 19px;
}

.setup-step {
  gap: 11px;
}

.network-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-step-index {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--gold-soft);
  font-style: normal;
  letter-spacing: 0;
  border: 1px solid rgba(215, 166, 87, 0.34);
  border-radius: 50%;
  background: rgba(215, 166, 87, 0.06);
}

.opponent-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.opponent-card {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px 12px;
  color: rgba(234, 219, 192, 0.58);
  text-align: left;
  border: 1px solid rgba(234, 219, 192, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.012);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.opponent-card:hover {
  color: var(--ivory);
  border-color: rgba(215, 166, 87, 0.4);
  background: rgba(215, 166, 87, 0.035);
}

.opponent-card.is-selected {
  color: var(--ivory-bright);
  border-color: rgba(239, 199, 120, 0.84);
  background: linear-gradient(135deg, rgba(215, 166, 87, 0.12), rgba(215, 166, 87, 0.025));
  box-shadow: inset 0 0 0 1px rgba(239, 199, 120, 0.08);
}

.opponent-card.is-selected::after,
.order-card.is-selected::after {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  color: #17130c;
  font-size: 11px;
  content: "✓";
  border-radius: 50%;
  background: var(--gold-soft);
}

.opponent-card-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #14110c;
  font: 26px/1 Georgia, serif;
  border-radius: 50%;
  background: linear-gradient(145deg, #f2e5cd, #b99557);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.opponent-card-mark-ai {
  color: #e8c172;
  background: linear-gradient(145deg, #292b2e, #0e1012);
}

.opponent-card > span:last-child,
.order-card > span:last-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.opponent-card strong,
.order-card strong {
  color: inherit;
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.1;
}

.opponent-card small,
.order-card small {
  color: rgba(234, 219, 192, 0.36);
  font-size: 8px;
  line-height: 1.25;
  letter-spacing: 0.04em;
}

.ai-setup-field {
  padding: 11px 12px 12px;
  border: 1px solid rgba(234, 219, 192, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.network-segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 4px;
  border: 1px solid rgba(234, 219, 192, 0.1);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.22);
}

.network-segment.compact {
  grid-template-columns: repeat(3, 1fr);
}

.network-segment.ai-preset-segment {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
}

.ai-preset-segment button {
  min-width: 0;
  min-height: 32px;
  padding: 4px 3px;
  font-size: 8.5px;
  line-height: 1.16;
}

.ai-preset-note {
  min-height: 30px;
  margin: 0;
  color: rgba(234, 219, 192, 0.43);
  font-size: 10px;
  line-height: 1.48;
}

.network-segment button {
  min-height: 38px;
  padding: 7px 9px;
  color: rgba(234, 219, 192, 0.48);
  font-size: 11px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

.network-segment button:hover {
  color: rgba(234, 219, 192, 0.82);
}

.network-segment button.is-selected {
  color: #19140c;
  border-color: var(--gold-soft);
  background: var(--gold-soft);
}

.order-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 0.72fr;
  gap: 8px;
}

.order-card {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 7px;
  min-width: 0;
  min-height: 116px;
  padding: 9px 7px 10px;
  color: rgba(234, 219, 192, 0.56);
  text-align: center;
  border: 1px solid rgba(234, 219, 192, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.012);
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.order-card:hover {
  color: var(--ivory);
  border-color: rgba(215, 166, 87, 0.42);
  background: rgba(215, 166, 87, 0.035);
}

.order-card.is-selected {
  color: var(--ivory-bright);
  border-color: rgba(239, 199, 120, 0.82);
  background: linear-gradient(180deg, rgba(215, 166, 87, 0.1), rgba(215, 166, 87, 0.02));
  box-shadow: inset 0 0 0 1px rgba(239, 199, 120, 0.07);
}

.order-portrait {
  width: 62px;
  height: 62px;
  border-radius: 7px;
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(234, 219, 192, 0.12);
}

.order-portrait-dawn {
  background-image: url("./assets/factions/dawn-paladins.webp");
}

.order-portrait-obsidian {
  background-image: url("./assets/factions/obsidian-templars.webp");
}

.order-card strong {
  font-size: 11px;
}

.order-card-random {
  align-content: center;
}

.order-random-mark {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  width: 54px;
  height: 54px;
  overflow: hidden;
  color: #17130c;
  border-radius: 10px;
  background: linear-gradient(135deg, #efe2ca 0 49%, #24272b 51% 100%);
  transform: rotate(-3deg);
}

.order-random-mark i {
  font: normal 24px/1 Georgia, serif;
}

.order-random-mark i:last-child {
  color: #e0b45d;
}

.create-game-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 49px;
  margin-top: 24px;
  padding: 10px 17px;
  color: #17130c;
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 15px;
  border: 1px solid var(--gold-soft);
  border-radius: 7px;
  background: var(--gold-soft);
  cursor: pointer;
}

.create-game-action:hover {
  background: #f3cf87;
}

.create-game-action:disabled {
  opacity: 0.48;
}

.create-note {
  margin: 11px 0 0;
  color: rgba(234, 219, 192, 0.3);
  font-size: 9px;
  line-height: 1.5;
}

.live-tables {
  grid-column: 1 / -1;
  margin-top: clamp(28px, 4vh, 54px);
}

.leaderboard-card {
  grid-column: 1 / -1;
  margin-top: 22px;
  padding: 23px 25px 18px;
  border: 1px solid rgba(234, 219, 192, 0.11);
  border-radius: 10px;
  background: rgba(12, 14, 15, 0.7);
}

.leaderboard-note { color: rgba(234, 219, 192, 0.3) !important; letter-spacing: 0.06em !important; }
.leaderboard-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; counter-reset: rank; }
.leaderboard-list li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 7px; align-items: center; min-height: 42px; padding: 7px 9px; border: 1px solid rgba(234, 219, 192, 0.075); border-radius: 6px; background: rgba(255,255,255,.014); counter-increment: rank; }
.leaderboard-list li::before { content: counter(rank); color: rgba(215,166,87,.66); font: 400 18px Georgia,serif; }
.leaderboard-list strong { overflow: hidden; color: rgba(234,219,192,.8); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-list span { color: var(--gold-soft); font: 400 15px Georgia,serif; }
.leaderboard-list small { grid-column: 2 / -1; color: rgba(234,219,192,.28); font-size: 8px; }
.leaderboard-list .leaderboard-empty { grid-column: 1 / -1; display: block; padding: 18px; color: rgba(234,219,192,.35); text-align: center; }
.leaderboard-list .leaderboard-empty::before { content: none; }

.load-more-games { display: block; min-width: 180px; min-height: 38px; margin: 22px auto 0; padding: 8px 16px; color: rgba(234,219,192,.62); border: 1px solid rgba(215,166,87,.3); border-radius: 6px; background: transparent; cursor: pointer; }
.load-more-games:hover { color: var(--gold-soft); border-color: rgba(215,166,87,.6); }

.live-heading {
  padding-bottom: 15px;
}

#refresh-lobby {
  padding: 7px 12px;
  color: rgba(234, 219, 192, 0.48);
  font-size: 10px;
  border: 1px solid rgba(234, 219, 192, 0.12);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

#refresh-lobby:hover {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.44);
}

.table-list {
  display: grid;
  margin-top: 2px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) minmax(170px, 0.8fr) 110px 106px;
  gap: 18px;
  align-items: center;
  min-height: 76px;
  padding: 13px 2px;
  border-bottom: 1px solid rgba(234, 219, 192, 0.08);
}

.table-row:hover {
  background: linear-gradient(90deg, transparent, rgba(234, 219, 192, 0.018), transparent);
}

.table-players {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.table-player {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.table-player:last-child {
  text-align: right;
}

.table-player:last-child .presence-dot {
  order: 2;
}

.table-player strong {
  overflow: hidden;
  color: rgba(234, 219, 192, 0.82);
  font-size: 12px;
  font-weight: 520;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-versus {
  color: rgba(234, 219, 192, 0.22);
  font-family: Georgia, serif;
  font-size: 11px;
}

.table-state,
.table-watch {
  display: grid;
  gap: 4px;
}

.table-state strong,
.table-watch strong {
  color: rgba(234, 219, 192, 0.62);
  font-size: 11px;
  font-weight: 520;
  text-transform: capitalize;
}

.table-state span,
.table-watch span {
  color: rgba(234, 219, 192, 0.28);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.table-action {
  min-height: 36px;
  padding: 7px 12px;
  color: rgba(234, 219, 192, 0.72);
  font-size: 11px;
  border: 1px solid rgba(234, 219, 192, 0.14);
  border-radius: 5px;
  background: rgba(234, 219, 192, 0.025);
  cursor: pointer;
}

.table-action:hover,
.table-action.is-join {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.5);
}

.lobby-empty,
.lobby-loading {
  padding: 36px 0;
  color: rgba(234, 219, 192, 0.38);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 15px;
  text-align: center;
}

.lobby-loading span {
  display: inline-block;
  width: 4px;
  height: 4px;
  margin-right: 3px;
  border-radius: 50%;
  background: var(--gold-soft);
  animation: lobby-pulse 1.2s ease-in-out infinite;
}

.lobby-loading span:nth-child(2) { animation-delay: 120ms; }
.lobby-loading span:nth-child(3) { animation-delay: 240ms; }

@keyframes lobby-pulse {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.network-error {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 8;
  max-width: 420px;
  margin: 0;
  padding: 12px 16px;
  color: #f0d6cf;
  font-size: 12px;
  border: 1px solid rgba(189, 107, 92, 0.5);
  border-radius: 6px;
  background: rgba(52, 24, 21, 0.94);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
}

.profile-dialog {
  width: min(440px, calc(100% - 28px));
  padding: 0;
  color: var(--ivory);
  border: 1px solid rgba(215, 166, 87, 0.46);
  border-radius: 10px;
  background: #0e1011;
  box-shadow: 0 36px 100px rgba(0, 0, 0, 0.78);
}

.profile-dialog::backdrop {
  background: rgba(1, 2, 3, 0.76);
  backdrop-filter: blur(12px);
}

.profile-dialog form {
  padding: 29px;
}

.profile-dialog h2 {
  margin: 8px 0 7px;
  color: var(--ivory-bright);
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 30px;
  font-weight: 400;
}

.profile-dialog form > p:not(.lobby-kicker, .profile-message) {
  margin: 0 0 21px;
  color: rgba(234, 219, 192, 0.46);
  font-size: 11px;
  line-height: 1.55;
}

.profile-dialog label {
  display: block;
  margin-bottom: 7px;
  color: rgba(234, 219, 192, 0.56);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-dialog input {
  width: 100%;
  height: 46px;
  padding: 10px 12px;
  color: var(--ivory-bright);
  border: 1px solid rgba(234, 219, 192, 0.16);
  border-radius: 6px;
  outline: 0;
  background: rgba(0, 0, 0, 0.26);
}

.profile-dialog input:focus {
  border-color: rgba(215, 166, 87, 0.62);
  box-shadow: 0 0 0 3px rgba(215, 166, 87, 0.08);
}

.profile-message {
  min-height: 17px;
  margin: 6px 0 0;
  color: #d78f80;
  font-size: 10px;
}

.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 15px;
}

.profile-actions button {
  min-height: 43px;
  color: rgba(234, 219, 192, 0.7);
  border: 1px solid rgba(234, 219, 192, 0.13);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.profile-actions .endgame-primary {
  color: #17130c;
  border-color: var(--gold-soft);
  background: var(--gold-soft);
}

.account-entry-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(234,219,192,.1); }
.account-entry-actions button { min-height: 38px; color: var(--gold-soft); border: 1px solid rgba(215,166,87,.28); border-radius: 6px; background: transparent; cursor: pointer; }
.account-dialog label + input + label { margin-top: 15px; }
.account-confirm-field { margin-top: 15px; }
.account-dialog input[aria-invalid="true"] { border-color: rgba(215, 94, 80, 0.82); box-shadow: 0 0 0 3px rgba(215, 94, 80, 0.1); }
.account-center-dialog section, .tutorial-dialog section { padding: 29px; }
.account-center-dialog h2, .tutorial-dialog h2 { margin: 8px 0 12px; }
.account-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin: 16px 0 22px; }
.account-stats article { display: grid; gap: 3px; padding: 10px; text-align: center; border: 1px solid rgba(234,219,192,.1); border-radius: 5px; }
.account-stats strong { color: var(--ivory-bright); font: 400 21px Georgia,serif; }.account-stats span { color: rgba(234,219,192,.36); font-size: 8px; text-transform: uppercase; }
.account-history-heading { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 9px; border-bottom: 1px solid rgba(234,219,192,.1); }.account-history-heading span { color: rgba(234,219,192,.3); font-size: 9px; }
.account-history { max-height: 280px; overflow: auto; }
.history-row { display: grid; grid-template-columns: 1fr auto auto; gap: 9px; align-items: center; padding: 10px 1px; border-bottom: 1px solid rgba(234,219,192,.07); }
.history-row div { display: grid; gap: 2px; }.history-row strong { font-size: 11px; }.history-row small { color: rgba(234,219,192,.3); font-size: 8px; }.history-row em { color: rgba(234,219,192,.54); font-size: 10px; font-style: normal; }.history-row a { padding: 5px 7px; color: var(--gold-soft); font-size: 9px; border: 1px solid rgba(215,166,87,.26); border-radius: 4px; text-decoration: none; }
.tutorial-topics { display: flex; flex-wrap: wrap; gap: 7px; margin: 18px 0; }.tutorial-topics span { padding: 6px 9px; color: rgba(234,219,192,.58); font-size: 9px; border: 1px solid rgba(234,219,192,.12); border-radius: 999px; }

.tutorial-course-dialog {
  width: min(1040px, calc(100vw - 48px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 48px));
  padding: 0;
  overflow: auto;
  color: var(--ivory);
  border: 1px solid rgba(215, 166, 87, 0.52);
  border-radius: 14px;
  background:
    radial-gradient(circle at 100% 0, rgba(215, 166, 87, 0.12), transparent 36%),
    linear-gradient(150deg, #121415, #090b0c 72%);
  box-shadow: 0 42px 130px rgba(0, 0, 0, 0.82);
}

.tutorial-course-dialog[open] {
  animation: course-dialog-in 340ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.tutorial-course-dialog::backdrop {
  background: rgba(1, 2, 3, 0.82);
  backdrop-filter: blur(16px) saturate(0.74);
}

.tutorial-course-dialog > section {
  padding: clamp(24px, 3.5vw, 38px);
}

.tutorial-course-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.tutorial-course-header h2 {
  margin: 8px 0 0;
  color: var(--ivory-bright);
  font: 400 clamp(31px, 4vw, 44px)/1.05 "Iowan Old Style", Baskerville, Georgia, serif;
  letter-spacing: -0.025em;
}

.tutorial-course-close {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: rgba(234, 219, 192, 0.48);
  border: 1px solid rgba(234, 219, 192, 0.12);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

.tutorial-course-close:hover {
  color: var(--ivory-bright);
  border-color: rgba(215, 166, 87, 0.44);
}

.tutorial-course-description {
  max-width: 690px;
  margin: 13px 0 12px;
  color: rgba(234, 219, 192, 0.54);
  font: 400 15px/1.55 "Iowan Old Style", Baskerville, Georgia, serif;
}

.tutorial-course-private {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 10px;
  color: rgba(150, 216, 244, 0.74);
  font-size: 9px;
  letter-spacing: 0.05em;
  border: 1px solid rgba(150, 216, 244, 0.2);
  border-radius: 999px;
  background: rgba(150, 216, 244, 0.045);
}

.tutorial-course-private > span:first-child {
  color: var(--ice);
  font-size: 7px;
}

.tutorial-course-progress {
  display: grid;
  gap: 8px;
  margin: 24px 0 18px;
}

.tutorial-course-progress > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  color: rgba(234, 219, 192, 0.38);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tutorial-course-progress strong {
  color: var(--gold-soft);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.tutorial-course-progress-track {
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(234, 219, 192, 0.08);
}

.tutorial-course-progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b9843d, var(--gold-soft));
  box-shadow: 0 0 16px rgba(215, 166, 87, 0.32);
  transition: width 360ms ease;
}

.tutorial-chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tutorial-chapter-grid > button {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  min-height: 174px;
  padding: 18px;
  color: rgba(234, 219, 192, 0.64);
  text-align: left;
  border: 1px solid rgba(234, 219, 192, 0.11);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.018);
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.tutorial-chapter-grid > button:hover:not(:disabled) {
  color: rgba(234, 219, 192, 0.82);
  border-color: rgba(215, 166, 87, 0.34);
  background: rgba(215, 166, 87, 0.05);
  transform: translateY(-2px);
}

.tutorial-chapter-grid > button.is-selected {
  border-color: rgba(215, 166, 87, 0.72);
  background: linear-gradient(145deg, rgba(215, 166, 87, 0.11), rgba(215, 166, 87, 0.025));
  box-shadow: inset 0 0 0 1px rgba(215, 166, 87, 0.12);
}

.tutorial-chapter-grid > button.is-completed {
  border-color: rgba(110, 191, 145, 0.24);
}

.tutorial-chapter-grid > button.is-locked {
  color: rgba(234, 219, 192, 0.48);
  border-color: rgba(234, 219, 192, 0.1);
  background: rgba(0, 0, 0, 0.14);
  opacity: 0.82;
  cursor: not-allowed;
}

.tutorial-chapter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tutorial-chapter-number {
  color: rgba(215, 166, 87, 0.58);
  font: 400 18px/1 Georgia, serif;
}

.tutorial-chapter-status {
  padding: 4px 7px;
  color: rgba(234, 219, 192, 0.38);
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(234, 219, 192, 0.1);
  border-radius: 999px;
}

.is-completed .tutorial-chapter-status {
  color: #91d7ad;
  border-color: rgba(110, 191, 145, 0.28);
  background: rgba(110, 191, 145, 0.055);
}

.is-current .tutorial-chapter-status,
.is-selected .tutorial-chapter-status {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.3);
  background: rgba(215, 166, 87, 0.055);
}

.tutorial-chapter-grid strong {
  color: var(--ivory-bright);
  font: 400 21px/1.2 "Iowan Old Style", Baskerville, Georgia, serif;
}

.tutorial-chapter-grid > button > span:not(.tutorial-chapter-top) {
  font-size: 10px;
  line-height: 1.5;
}

.tutorial-chapter-grid small {
  margin-top: auto;
  color: rgba(234, 219, 192, 0.34);
  font-size: 9px;
  line-height: 1.45;
}

.tutorial-course-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(234, 219, 192, 0.1);
}

.tutorial-course-actions > div {
  display: flex;
  gap: 8px;
}

.tutorial-course-actions button {
  min-height: 42px;
  padding: 8px 14px;
  color: rgba(234, 219, 192, 0.62);
  border: 1px solid rgba(234, 219, 192, 0.13);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.tutorial-course-actions #tutorial-course-restart {
  color: rgba(215, 166, 87, 0.68);
  border-color: transparent;
}

.tutorial-course-actions .endgame-primary {
  min-width: 148px;
  color: #17130c;
  border-color: var(--gold-soft);
  background: var(--gold-soft);
}

@keyframes course-dialog-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 760px) {
  .tutorial-course-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
  }

  .tutorial-course-dialog > section { padding: 22px 17px; }
  .tutorial-chapter-grid { grid-template-columns: 1fr; }
  .tutorial-course-actions { align-items: stretch; flex-direction: column; }
  .tutorial-course-actions > div { display: grid; grid-template-columns: 1fr 1fr; }
  .tutorial-course-actions #tutorial-course-restart { order: 2; }
}

@media (prefers-reduced-motion: reduce) {
  .tutorial-course-dialog[open] { animation: none; }
  .tutorial-course-progress-track i,
  .tutorial-chapter-grid > button { transition: none; }
}

.network-gamebar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 60;
  display: grid;
  grid-template-columns: 150px 1fr auto;
  align-items: center;
  min-height: 58px;
  padding: 7px 18px;
  border-bottom: 1px solid rgba(234, 219, 192, 0.11);
  background: rgba(8, 10, 11, 0.92);
  backdrop-filter: blur(17px);
}

.network-gamebar.is-my-turn {
  border-bottom-color: rgba(215, 166, 87, 0.34);
  box-shadow: inset 0 -18px 40px rgba(215, 166, 87, 0.045), 0 10px 36px rgba(0, 0, 0, 0.16);
}

.network-gamebar > button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: start;
  padding: 7px 10px;
  color: rgba(234, 219, 192, 0.56);
  font-size: 11px;
  border: 1px solid rgba(234, 219, 192, 0.11);
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
}

.network-gamebar > button svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.network-gamebar > button:hover {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.44);
}

.network-room-copy {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.network-room-copy strong {
  font-family: "Iowan Old Style", Baskerville, Georgia, serif;
  font-size: 15px;
  font-weight: 400;
}

.network-room-copy span,
.network-room-meta {
  color: rgba(234, 219, 192, 0.36);
  font-size: 9px;
  letter-spacing: 0.05em;
}

.network-turn-prompt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 148px;
  padding: 3px 11px;
  color: rgba(234, 219, 192, 0.72);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.065em;
  border: 1px solid rgba(215, 166, 87, 0.2);
  border-radius: 999px;
  background: rgba(215, 166, 87, 0.055);
}

.network-turn-prompt[hidden] { display: none; }

.network-room-copy .network-turn-prompt > span {
  color: currentColor;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.065em;
}

.network-turn-prompt time {
  min-width: 34px;
  color: #f4cc7b;
  font: 750 12px/1 ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: 0.04em;
  text-align: right;
  text-shadow: 0 0 10px rgba(215, 166, 87, 0.38);
}

.network-gamebar.is-my-turn .network-turn-prompt {
  border-color: rgba(232, 184, 96, 0.48);
  background: rgba(215, 166, 87, 0.12);
  box-shadow: 0 0 18px rgba(215, 166, 87, 0.13);
  animation: turn-prompt-pulse 1.55s ease-in-out infinite;
}

.network-turn-prompt.is-urgent {
  border-color: rgba(255, 202, 103, 0.68);
  box-shadow: 0 0 22px rgba(231, 177, 77, 0.2);
}

.network-turn-prompt.is-expired { opacity: 0.82; }

@keyframes turn-prompt-pulse {
  0%, 100% { transform: scale(1); filter: brightness(0.94); }
  50% { transform: scale(1.045); filter: brightness(1.13); }
}

.network-gamebar.is-my-turn #network-room-status {
  color: #ffe0a0;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-shadow: 0 0 8px rgba(255,205,112,.75), 0 0 22px rgba(215,166,87,.55);
  animation: turn-callout 1.05s ease-in-out infinite;
}

@keyframes turn-callout { 0%,100% { opacity: .72; transform: scale(1); } 50% { opacity: 1; transform: scale(1.075); } }

.tutorial-coach { position: absolute; top: 24px; left: 50%; z-index: 22; width: min(420px, calc(100% - 34px)); padding: 15px 17px; border: 1px solid rgba(215,166,87,.48); border-radius: 8px; background: rgba(10,12,13,.94); box-shadow: 0 20px 70px rgba(0,0,0,.5); transform: translateX(-50%); }
.tutorial-coach > span { color: rgba(215,166,87,.68); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }.tutorial-coach h2 { margin: 5px 0 3px; color: var(--ivory-bright); font: 400 19px Georgia,serif; }.tutorial-coach p { margin: 0; color: rgba(234,219,192,.58); font-size: 10px; line-height: 1.5; }.tutorial-coach strong { display: inline-flex; margin-top: 8px; color: #f4ca78; font: 400 15px Georgia,serif; }.tutorial-coach button { float: right; margin-top: 7px; padding: 4px 7px; color: rgba(234,219,192,.42); font-size: 8px; border: 0; background: transparent; cursor: pointer; }
.study-coach { border-color: rgba(215,166,87,.6); background: linear-gradient(145deg, rgba(23,18,11,.96), rgba(10,12,13,.96)); }
.study-coach strong { font-size: 12px; letter-spacing: .06em; }

.special-move-deck {
  position: absolute;
  right: calc(var(--right-rail) + 24px);
  bottom: 77px;
  left: calc(var(--left-rail) + 24px);
  z-index: 19;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
  transition: left 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.special-rule-kicker {
  color: rgba(234, 219, 192, 0.35);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.special-rule-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: min(720px, 100%);
  pointer-events: auto;
}

.special-rule-card {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 48px;
  padding: 6px 10px;
  color: rgba(234, 219, 192, 0.32);
  border: 1px solid rgba(234, 219, 192, 0.1);
  border-radius: 6px;
  background: rgba(9, 11, 12, 0.82);
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.special-rule-icon {
  color: rgba(234, 219, 192, 0.28);
  font: 21px/1 Georgia, serif;
  text-align: center;
}

.special-rule-card > span:nth-child(2) {
  display: grid;
  min-width: 0;
}

.special-rule-card strong {
  overflow: hidden;
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.special-rule-card small {
  overflow: hidden;
  color: rgba(234, 219, 192, 0.24);
  font: 11px/1.2 "Iowan Old Style", Baskerville, Georgia, serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.special-rule-card.is-available {
  color: #f3d494;
  border-color: rgba(231, 189, 110, 0.72);
  background: linear-gradient(135deg, rgba(215, 166, 87, 0.16), rgba(9, 11, 12, 0.88));
  box-shadow: 0 0 18px rgba(215, 166, 87, 0.12);
}

.special-rule-card.is-available .special-rule-icon {
  color: var(--gold-soft);
}

.special-rule-card.is-available > span:nth-child(2) {
  display: none;
}

.special-rule-actions {
  display: none;
  grid-column: 2;
  gap: 4px;
}

.special-rule-card.is-available .special-rule-actions {
  display: flex;
}

.special-rule-actions button {
  min-height: 32px;
  padding: 5px 9px;
  color: #1a140a;
  font: 600 10px/1.15 Georgia, serif;
  border: 1px solid #e7bd6e;
  border-radius: 5px;
  background: #d7a657;
  box-shadow: 0 0 18px rgba(215, 166, 87, 0.18);
  cursor: pointer;
}

.special-move-visible .board-hint { opacity: 0; visibility: hidden; }
.show-replay-deck .special-move-deck, .endgame-open .special-move-deck { display: none; }

.network-room-meta {
  justify-content: flex-end;
  gap: 17px;
  text-transform: uppercase;
}

.network-room-meta > span {
  gap: 6px;
}

.draw-offer-banner {
  position: absolute;
  top: 66px;
  left: 50%;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 8px 14px;
  color: rgba(234, 219, 192, 0.72);
  font-size: 11px;
  border: 1px solid rgba(215, 166, 87, 0.42);
  border-radius: 7px;
  background: rgba(16, 15, 12, 0.96);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.45);
  transform: translateX(-50%);
}

.draw-offer-banner button {
  min-height: 28px;
  padding: 5px 9px;
  color: rgba(234, 219, 192, 0.65);
  font-size: 10px;
  border: 1px solid rgba(234, 219, 192, 0.14);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.draw-offer-banner .draw-accept {
  color: #17130c;
  border-color: var(--gold-soft);
  background: var(--gold-soft);
}

body.network-room .shell-grid {
  inset: 52px 0 0;
}

@media (min-width: 1081px) {
  body.network-room .app-shell {
    --left-rail: 116px;
    --right-rail: 300px;
  }

  body.network-room .game-rail {
    padding: 20px 12px 104px;
  }

  body.network-room .game-rail .rail-heading {
    justify-content: center;
  }

  body.network-room .game-rail .rail-heading h1 {
    display: none;
  }

  body.network-room .game-rail .new-game-button {
    width: 44px;
    margin: 20px auto 24px;
    padding: 0;
  }

  body.network-room .game-rail .new-game-button span {
    display: none;
  }

  body.network-room .game-rail .camera-section {
    margin-top: 18px;
  }

  body.network-room .game-rail .camera-section .section-heading {
    justify-content: center;
  }

  body.network-room .game-rail .camera-section .section-heading > span {
    display: none;
  }

  body.network-room .game-rail .camera-grid {
    grid-template-columns: 1fr;
  }

}

body.network-room .sound-toggle,
body.network-room .left-rail-restore {
  top: 68px;
}

body.network-room .game-rail .control-section:not(.camera-section),
body.network-room .provider-status,
body.network-room .shortcut-note {
  display: none;
}

body.network-room .new-game-button {
  margin-bottom: 25px;
}

.online-player-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.endgame-actions.has-rematch {
  grid-template-columns: repeat(3, 1fr);
}

.endgame-actions button.is-waiting {
  color: var(--gold-soft);
  border-color: rgba(215, 166, 87, 0.48);
}

@media (min-width: 901px) and (max-height: 800px) {
  .lobby-view {
    padding-top: 94px;
    padding-bottom: 32px;
  }

  .create-table {
    padding: 18px 20px;
  }

  .lobby-section-heading {
    padding-bottom: 12px;
  }

  .lobby-section-heading h2 {
    font-size: 25px;
  }

  .network-field {
    gap: 7px;
    margin-top: 12px;
  }

  .opponent-card {
    min-height: 58px;
    padding-block: 7px;
  }

  .opponent-card-mark {
    width: 34px;
    height: 34px;
    font-size: 23px;
  }

  .order-card {
    min-height: 98px;
  }

  .order-portrait {
    width: 50px;
    height: 50px;
  }

  .create-game-action {
    min-height: 44px;
    margin-top: 14px;
  }

  .create-note {
    margin-top: 7px;
  }
}

@media (max-width: 900px) {
  .lobby-view {
    grid-template-columns: 1fr;
    padding-top: 112px;
  }

  .lobby-intro,
  .create-table {
    align-self: auto;
  }

  .lobby-intro h1 {
    font-size: clamp(48px, 12vw, 72px);
  }

  .table-row {
    grid-template-columns: 1fr 96px;
  }

  .table-state,
  .table-watch {
    display: none;
  }

  .network-gamebar {
    grid-template-columns: auto 1fr;
  }

  .network-room-copy {
    justify-items: end;
  }

  .network-room-meta {
    display: none;
  }

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

  .special-move-deck { right: 12px; left: 12px; }

  body.network-room .mobile-topbar {
    top: 58px;
  }

  body.network-room .shell-grid {
    padding-top: 60px;
  }
}

@media (max-width: 560px) {
  .network-header {
    height: 66px;
    padding-inline: 14px;
  }

  .network-brand div span,
  .application-version,
  #profile-button small,
  .network-header .admin-entry {
    display: none;
  }

  .network-brand {
    gap: 8px;
  }

  .network-brand strong,
  #profile-button span {
    white-space: nowrap;
  }

  .network-header-actions {
    gap: 6px;
  }

  .network-profile {
    gap: 3px;
  }

  .language-switcher button {
    min-width: 32px;
    padding-inline: 6px;
  }

  .network-brand strong {
    font-size: 18px;
  }

  .lobby-view {
    gap: 32px;
    padding: 96px 15px 34px;
  }

  .lobby-intro h1 {
    font-size: 47px;
  }

  .lobby-intro > p:not(.lobby-kicker) {
    font-size: 15px;
  }

  .lobby-summary {
    gap: 16px;
  }

  .create-table {
    padding: 20px;
  }

  .ai-preset-segment {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .ai-preset-segment button {
    grid-column: span 2;
  }

  .ai-preset-segment button:nth-child(n + 4) {
    grid-column: span 3;
  }


  .leaderboard-card { padding: 18px 14px 13px; }
  .leaderboard-list { grid-template-columns: 1fr; }
  .leaderboard-note { display: none; }
  .account-stats { grid-template-columns: repeat(2, 1fr); }
  .tutorial-coach { top: 64px; }
  .special-move-deck { bottom: 75px; flex-direction: column; gap: 5px; }

  .table-row {
    grid-template-columns: 1fr 82px;
    gap: 10px;
  }

  .table-players {
    gap: 7px;
  }

  .table-player strong {
    font-size: 10px;
  }

  .endgame-actions.has-rematch {
    grid-template-columns: 1fr;
  }
}

/* Android and short landscape screens keep the board dominant while all
   secondary controls stay reachable from the two short edges. */
.touch-move-prompt {
  display: none;
}

@media (orientation: landscape) and (max-height: 620px) and (max-width: 1280px) {
  .app-shell {
    min-height: 0;
  }

  .network-header {
    height: 52px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .network-brand {
    gap: 8px;
  }

  .network-brand-mark {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }

  .network-brand strong {
    font-size: 18px;
  }

  .network-brand div span,
  .application-version,
  body .network-header .admin-entry,
  .network-profile small {
    display: none;
  }

  .network-header-actions {
    gap: 7px;
  }

  .language-switcher button,
  #profile-button {
    min-height: 40px;
  }

  .lobby-view {
    grid-template-columns: minmax(220px, 0.72fr) minmax(460px, 1.28fr);
    align-items: start;
    gap: 18px;
    min-height: 100dvh;
    padding: 66px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  }

  .lobby-intro {
    position: sticky;
    top: 66px;
  }

  .lobby-intro h1 {
    margin-block: 8px;
    font-size: clamp(34px, 5.8vw, 50px);
  }

  .lobby-intro > p:not(.lobby-kicker) {
    max-width: 34ch;
    font-size: 12px;
    line-height: 1.55;
  }

  .lobby-summary {
    gap: 12px;
    margin-top: 14px;
  }

  .create-table {
    padding: 15px 17px;
  }

  .lobby-section-heading {
    padding-bottom: 9px;
  }

  .lobby-section-heading h2 {
    font-size: 23px;
  }

  .network-field {
    gap: 7px;
    margin-top: 10px;
  }

  .opponent-card,
  .order-card,
  .ai-preset-segment button,
  .create-game-action,
  .table-row button,
  .tutorial-chapter-grid button {
    min-height: 48px;
  }

  .opponent-card {
    padding-block: 7px;
  }

  .order-card {
    min-height: 92px;
  }

  .create-game-action {
    margin-top: 12px;
  }

  .create-note {
    margin-top: 6px;
    font-size: 9px;
  }

  .network-gamebar {
    grid-template-columns: 78px minmax(0, 1fr) 48px;
    min-height: 48px;
    height: 48px;
    padding: 3px max(6px, env(safe-area-inset-right)) 3px max(6px, env(safe-area-inset-left));
  }

  .network-gamebar > button {
    min-width: 68px;
    min-height: 42px;
    padding: 5px 7px;
  }

  body.network-room #leave-room-button {
    position: absolute;
    top: 40dvh;
    left: max(6px, env(safe-area-inset-left));
    z-index: 1;
    display: grid;
    place-items: center;
    width: 56px;
    min-width: 56px;
    height: clamp(48px, 15dvh, 56px);
    min-height: 48px;
    padding: 5px 4px;
    color: rgba(239, 199, 120, 0.82);
    font-size: 10px;
    line-height: 1.15;
    text-align: center;
    border-color: rgba(215, 166, 87, 0.55);
    border-radius: 10px;
    background: rgba(8, 10, 11, 0.91);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    transform: translateY(-50%);
  }

  .network-room-copy {
    gap: 0;
  }

  .network-room-copy strong {
    font-size: 13px;
  }

  .network-room-copy > #network-room-status {
    display: none;
  }

  .network-turn-prompt {
    min-width: 136px;
    padding-block: 2px;
  }

  .network-room-meta {
    display: none;
  }

  body.network-room .shell-grid {
    inset: 0;
    padding-top: 0;
  }

  body.network-room .mobile-topbar {
    position: absolute;
    inset: 0;
    z-index: 45;
    display: block;
    width: auto;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    pointer-events: none;
  }

  body.network-room .mobile-brand,
  body.network-room .language-switcher-mobile {
    display: none;
  }

  body.network-room .mobile-topbar-actions {
    display: block;
  }

  body.network-room .mobile-panel-button {
    position: absolute;
    width: 56px;
    min-width: 56px;
    height: clamp(48px, 15dvh, 56px);
    min-height: 48px;
    padding: 5px 4px;
    color: rgba(239, 199, 120, 0.82);
    font-size: 10px;
    line-height: 1.15;
    border-color: rgba(215, 166, 87, 0.55);
    border-radius: 10px;
    background: rgba(8, 10, 11, 0.91);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    transform: translateY(-50%);
    pointer-events: auto;
  }

  body.network-room #game-panel-toggle {
    top: 60%;
    left: max(6px, env(safe-area-inset-left));
  }

  body.network-room #moves-panel-toggle,
  body.network-room .sound-toggle,
  #flip-button {
    display: none;
  }

  .rail {
    top: 48px;
    width: min(320px, 74vw);
    padding: 14px 16px 70px;
  }

  .rail-heading h1,
  .mobile-only-heading {
    font-size: 24px;
  }

  .rail-close,
  .new-game-button,
  .choice-button,
  .choice-stack.compact .choice-button,
  .camera-grid button,
  .replay-entry,
  .promotion-options button {
    min-height: 48px;
  }

  .rail-scrim {
    inset: 48px 0 0;
  }

  .action-deck {
    inset: 0;
    display: block;
    min-height: 0;
    padding: 0;
    border: 0;
    background: transparent;
    transform: none;
    pointer-events: none;
  }

  .action-deck button {
    position: absolute;
    display: grid;
    place-items: center;
    gap: 2px;
    width: 56px;
    min-width: 56px;
    height: clamp(48px, 15dvh, 56px);
    min-height: 48px;
    padding: 5px 4px;
    font-size: 10px;
    line-height: 1.1;
    border-color: rgba(215, 166, 87, 0.5);
    border-radius: 10px;
    background: rgba(8, 10, 11, 0.92);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
  }

  #undo-button,
  #resign-button {
    right: max(6px, env(safe-area-inset-right));
    transform: translateY(-50%);
  }

  #undo-button {
    top: 12%;
  }

  #resign-button {
    top: 31%;
  }

  .action-deck button svg {
    width: 19px;
    height: 19px;
  }

  .board-hint {
    display: none;
  }

  .touch-move-prompt:not([hidden]) {
    position: absolute;
    bottom: max(6px, env(safe-area-inset-bottom));
    left: 50%;
    z-index: 20;
    display: block;
    max-width: calc(100% - 160px);
    margin: 0;
    padding: 5px 13px;
    overflow: hidden;
    color: #f6d48e;
    font-family: "Iowan Old Style", Baskerville, Georgia, serif;
    font-size: 13px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px solid rgba(215, 166, 87, 0.42);
    border-radius: 8px;
    background: rgba(8, 10, 11, 0.88);
    transform: translateX(-50%);
    pointer-events: none;
  }

  .thinking-indicator {
    top: 9px;
    left: 68px;
  }

  .tutorial-coach {
    top: 8px;
    width: min(390px, calc(100% - 150px));
    padding: 10px 13px;
  }

  .tutorial-coach h2 {
    margin-block: 2px;
    font-size: 16px;
  }

  .tutorial-coach p {
    font-size: 9px;
  }

  .tutorial-coach strong {
    margin-top: 4px;
    font-size: 13px;
  }

  .special-move-deck {
    display: block;
    inset: 0;
    max-height: none;
    pointer-events: none;
  }

  .app-shell.special-move-visible .special-move-deck {
    display: block;
  }

  .special-rule-kicker {
    display: none;
  }

  .special-rule-grid {
    display: block;
    width: auto;
    pointer-events: none;
  }

  .special-rule-card {
    position: absolute;
    right: max(6px, env(safe-area-inset-right));
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    gap: 1px;
    width: 56px;
    min-width: 56px;
    height: clamp(48px, 15dvh, 56px);
    min-height: 48px;
    padding: 4px 3px;
    color: rgba(234, 219, 192, 0.58);
    text-align: center;
    border-color: rgba(234, 219, 192, 0.22);
    background: rgba(8, 10, 11, 0.92);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
    transform: translateY(-50%);
    pointer-events: none;
  }

  [data-special-rule="castle"] {
    top: 50%;
  }

  [data-special-rule="en-passant"] {
    top: 69%;
  }

  [data-special-rule="promotion"] {
    top: 88%;
  }

  .special-rule-icon {
    color: rgba(234, 219, 192, 0.52);
    font-size: 17px;
  }

  .special-rule-card > span:nth-child(2) {
    display: grid;
    place-items: center;
  }

  .special-rule-card strong {
    overflow: visible;
    font-size: 9px;
    line-height: 1.05;
    letter-spacing: 0;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .special-rule-card small {
    display: none;
  }

  .special-rule-card.is-available {
    grid-template-columns: 22px minmax(0, 1fr);
    width: min(220px, calc(100vw - 136px));
    height: auto;
    min-height: clamp(48px, 15dvh, 56px);
    padding: 5px 6px;
    pointer-events: auto;
  }

  .special-rule-card.is-available .special-rule-actions {
    display: grid;
    grid-column: 2;
    grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
    width: 100%;
  }

  .special-rule-actions button {
    min-height: 48px;
    padding: 4px 6px;
    font-size: 9px;
  }

  /* The phone surface is a full-bleed board with two collapsed edge rails. */
  body.network-room .network-gamebar {
    inset: 0;
    min-height: 0;
    height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
    pointer-events: none;
  }

  body.network-room .network-room-copy {
    position: absolute;
    top: max(7px, env(safe-area-inset-top));
    left: 50%;
    display: block;
    width: max-content;
    transform: translateX(-50%);
  }

  body.network-room .network-room-copy > strong,
  body.network-room .network-room-copy > #network-room-status {
    display: none;
  }

  body.network-room .network-turn-prompt {
    min-width: 0;
    padding: 4px 10px;
    border-color: rgba(215, 166, 87, 0.38);
    border-radius: 7px;
    background: rgba(5, 7, 8, 0.78);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(12px);
  }

  body.network-room .network-gamebar.is-my-turn .network-turn-prompt {
    background: rgba(20, 16, 9, 0.82);
  }

  body.network-room #leave-room-button,
  body.network-room .mobile-panel-button {
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    color: rgba(239, 199, 120, 0.86);
    border: 1px solid rgba(215, 166, 87, 0.48);
    border-radius: 8px;
    background: rgba(6, 8, 9, 0.82);
    box-shadow: 0 9px 24px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(12px);
    transform: translateY(-50%);
    pointer-events: auto;
  }

  body.network-room #leave-room-button {
    top: calc(50% - 28px);
    left: max(8px, env(safe-area-inset-left));
  }

  body.network-room #game-panel-toggle {
    top: calc(50% + 28px);
    left: max(8px, env(safe-area-inset-left));
  }

  body.network-room #leave-room-button svg,
  body.network-room .mobile-panel-button svg {
    display: block;
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.55;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  body.network-room #leave-room-button span,
  body.network-room #game-panel-toggle span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  body.network-room #game-panel-toggle[aria-expanded="true"] {
    color: var(--ice);
    border-color: rgba(150, 216, 244, 0.68);
    background: rgba(9, 19, 23, 0.9);
  }

  body.network-room .rail {
    top: 0;
  }

  body.network-room .rail-scrim {
    inset: 0;
  }

  .context-action-rail {
    position: absolute;
    top: 50%;
    right: max(8px, env(safe-area-inset-right));
    z-index: 48;
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 8px;
    width: max-content;
    transform: translateY(-50%);
    pointer-events: none;
  }

  .context-action-rail .action-deck,
  .context-action-rail .special-move-deck,
  .context-action-rail .special-rule-grid {
    position: static;
    inset: auto;
    display: contents;
    min-height: 0;
    max-height: none;
    padding: 0;
    background: transparent;
    transform: none;
  }

  .context-action-rail .action-deck button,
  .context-action-rail .special-rule-card {
    position: static;
    flex: none;
    transform: none;
  }

  .context-action-rail .action-deck button {
    display: grid;
    place-items: center;
    gap: 2px;
    width: 50px;
    min-width: 50px;
    height: 50px;
    min-height: 50px;
    padding: 4px 3px;
    color: rgba(239, 199, 120, 0.88);
    font-size: 9px;
    line-height: 1.05;
    border-color: rgba(215, 166, 87, 0.46);
    border-radius: 8px;
    background: rgba(6, 8, 9, 0.84);
    box-shadow: 0 9px 24px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(12px);
    pointer-events: auto;
  }

  .context-action-rail .action-deck button svg {
    width: 19px;
    height: 19px;
  }

  #undo-button:disabled,
  #resign-button:disabled {
    display: none;
  }

  .special-rule-card:not(.is-available) {
    display: none;
  }

  .context-action-rail .special-rule-card.is-available {
    display: grid;
    grid-template-columns: 21px minmax(0, 1fr);
    width: min(188px, calc(100vw - 136px));
    min-width: 50px;
    min-height: 50px;
    padding: 4px 5px;
    color: #f3d494;
    border-color: rgba(231, 189, 110, 0.66);
    border-radius: 8px;
    background: rgba(9, 10, 10, 0.9);
    box-shadow: 0 9px 24px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(12px);
    pointer-events: auto;
  }

  .context-action-rail .special-rule-card.is-available .special-rule-actions {
    display: grid;
    grid-column: 2;
    grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
    width: 100%;
    gap: 4px;
  }

  .context-action-rail .special-rule-actions button {
    min-height: 42px;
    padding: 4px 6px;
    font-size: 9px;
    line-height: 1.1;
  }

  .mobile-camera-cue {
    position: absolute;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(68px, calc(env(safe-area-inset-left) + 68px));
    z-index: 17;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 5px 8px;
    color: rgba(224, 235, 237, 0.78);
    font-size: 9px;
    line-height: 1;
    letter-spacing: 0.035em;
    border: 1px solid rgba(150, 216, 244, 0.25);
    border-radius: 6px;
    background: rgba(5, 8, 9, 0.68);
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 220ms ease, transform 260ms ease;
    pointer-events: none;
  }

  .mobile-camera-cue svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: var(--ice);
    stroke-width: 1.35;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .camera-cue-player,
  .camera-cue-observe,
  .camera-cue-manual {
    display: none;
  }

  [data-mobile-camera-phase="player"] .camera-cue-player,
  [data-mobile-camera-phase="observe"] .camera-cue-observe,
  [data-mobile-camera-phase="manual"] .camera-cue-manual {
    display: inline;
  }

  .camera-cue-visible .mobile-camera-cue {
    opacity: 1;
    transform: translateY(0);
  }

  .app-shell.show-replay-deck .special-move-deck,
  .app-shell.endgame-open .special-move-deck {
    display: none;
  }

  .promotion-dialog {
    width: min(420px, calc(100% - 160px));
    padding: 14px;
  }

  .promotion-options {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .promotion-options button {
    justify-content: center;
    padding-inline: 6px;
  }

  .replay-deck {
    right: 72px;
    bottom: max(5px, env(safe-area-inset-bottom));
    left: 72px;
    grid-template-columns: 80px auto minmax(100px, 1fr) auto;
    min-height: 58px;
    gap: 8px;
    padding: 5px 8px;
  }

  .replay-deck .exit-replay {
    display: none;
  }
}
