:root {
  color-scheme: light;
  --page: #f3f5f4;
  --surface: #ffffff;
  --surface-muted: #e9edeb;
  --surface-quiet: #f8f9f8;
  --ink: #202827;
  --ink-soft: #65706d;
  --ink-faint: #929b98;
  --line: #d9dfdc;
  --line-strong: #bcc6c2;
  --accent: #176b63;
  --accent-soft: #dcebe7;
  --danger: #a33d3d;
  --danger-soft: #f7e7e5;
  --shadow: 0 16px 40px rgba(36, 47, 44, 0.12);
  --blue: #1b78b5;
  --yellow: #e5b83e;
  --red: #d64f4f;
  --green: #2e946b;
  --magenta: #b958a1;
  --tile-size: 31px;
  --wall-size: 34px;
  --wall-gap: 4px;
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  letter-spacing: 0;
}

button {
  font: inherit;
  letter-spacing: 0;
}

button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 1500px);
  min-height: 100vh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  border-inline: 1px solid var(--line);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  min-height: 66px;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
}

.brand-block {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}

.brand-block h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  line-height: 1;
}

.brand-subtitle {
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 700;
}

.match-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.match-meta strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 650;
}

.meta-divider {
  width: 1px;
  height: 16px;
  background: var(--line);
}

.command-button,
.primary-button,
.secondary-button,
.error-toast button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  cursor: pointer;
}

.command-button {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 7px;
  padding: 0 13px;
  background: var(--surface);
  color: var(--ink);
}

.command-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.command-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.command-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  font-size: 20px;
  font-weight: 300;
  line-height: 1;
}

.opponent-band {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 65px;
  padding: 9px 22px;
  background: var(--surface-quiet);
  border-bottom: 1px solid var(--line);
}

.band-label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.availability-dot,
.turn-dot,
.player-turn-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--line-strong);
}

.availability-dot.is-online {
  background: var(--green);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent);
}

.availability-dot.is-error {
  background: var(--danger);
}

.opponent-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.engine-status {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.engine-status strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-options {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-count-control,
.think-control {
  display: flex;
  align-items: center;
  gap: 7px;
}

.option-label {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 600;
}

.player-count-picker,
.think-picker {
  display: grid;
  gap: 3px;
  padding: 3px;
  border-radius: 7px;
  background: var(--surface-muted);
}

.player-count-picker {
  grid-template-columns: repeat(3, 36px);
}

.think-picker {
  grid-template-columns: repeat(3, 54px);
}

.player-count-option,
.think-option {
  min-width: 0;
  min-height: 36px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 11px;
}

.player-count-option:hover:not(:disabled),
.think-option:hover:not(:disabled) {
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 68%, transparent);
}

.player-count-option[aria-checked="true"],
.think-option[aria-checked="true"] {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(31, 42, 39, 0.08);
}

.player-count-option:disabled,
.think-option:disabled {
  cursor: wait;
  opacity: 0.5;
}

.playfield {
  display: grid;
  grid-template-columns: minmax(245px, 0.85fr) minmax(420px, 1.35fr) minmax(245px, 0.85fr);
  grid-template-areas: "opponent draft human";
  flex: 1;
  min-height: 540px;
}

.player-zone {
  min-width: 0;
  padding: 20px 18px;
  background: var(--surface-quiet);
}

.opponent-zone {
  grid-area: opponent;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--line);
}

.opponent-zone.is-multiplayer .player-panel {
  min-height: 0;
}

.opponent-zone.is-multiplayer .player-panel:not(:last-child) {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.human-zone {
  grid-area: human;
  border-left: 1px solid var(--line);
}

.draft-zone {
  grid-area: draft;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 17px 22px 20px;
}

.turn-status {
  display: flex;
  align-items: center;
  min-height: 28px;
  gap: 8px;
  margin-bottom: 13px;
}

.app-shell[data-phase="human"] .turn-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.app-shell[data-phase="thinking"] .turn-dot,
.app-shell[data-phase="creating"] .turn-dot,
.app-shell[data-phase="booting"] .turn-dot {
  background: var(--yellow);
}

.app-shell[data-phase="done"] .turn-dot {
  background: var(--ink-soft);
}

.turn-label {
  font-weight: 650;
}

.selection-label {
  min-width: 0;
  margin-left: auto;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thinking-dots {
  display: none;
  align-items: center;
  gap: 3px;
}

.app-shell[data-phase="thinking"] .thinking-dots,
.app-shell[data-phase="creating"] .thinking-dots,
.app-shell[data-phase="booting"] .thinking-dots {
  display: inline-flex;
}

.thinking-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: thinking-pulse 1.1s infinite ease-in-out;
}

.thinking-dots i:nth-child(2) { animation-delay: 0.14s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.28s; }

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

.factories {
  display: grid;
  grid-template-columns: repeat(3, 96px);
  justify-content: center;
  gap: 16px 22px;
  min-height: 210px;
  padding: 4px 0 18px;
}

.factory-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
}

.factory-disc {
  display: grid;
  grid-template-columns: repeat(2, var(--tile-size));
  grid-template-rows: repeat(2, var(--tile-size));
  place-content: center;
  gap: 5px;
  width: 92px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #eef1ef;
  box-shadow: inset 0 0 0 6px color-mix(in srgb, var(--surface) 70%, transparent);
}

.factory-number {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.factory-disc.is-empty::after {
  content: "·";
  color: var(--ink-faint);
  font-size: 22px;
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  place-self: center;
}

.tile {
  --tile-color: var(--blue);
  --tile-ink: #ffffff;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--tile-size);
  height: var(--tile-size);
  flex: 0 0 var(--tile-size);
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--tile-color) 72%, #26312e);
  border-radius: 4px;
  background: var(--tile-color);
  color: var(--tile-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 1px 2px rgba(35, 43, 41, 0.16);
  font-size: 12px;
  line-height: 1;
}

button.tile {
  cursor: pointer;
}

button.tile:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 3px 7px rgba(35, 43, 41, 0.22);
}

button.tile:disabled {
  cursor: default;
}

button.tile.is-selectable::before,
button.tile.is-selected::before {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid transparent;
  border-radius: 7px;
  pointer-events: none;
}

button.tile.is-selectable:hover::before {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

button.tile.is-selected::before {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent);
}

.tile-c0 { --tile-color: var(--blue); }
.tile-c1 { --tile-color: var(--yellow); --tile-ink: #403411; }
.tile-c2 { --tile-color: var(--red); }
.tile-c3 { --tile-color: var(--green); }
.tile-c4 { --tile-color: var(--magenta); }

.center-row {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.section-label {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.center-tray {
  display: flex;
  align-items: center;
  align-content: center;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-quiet);
}

.center-tray.is-empty::after {
  content: "—";
  color: var(--ink-faint);
}

.start-token,
.floor-token {
  display: inline-grid;
  place-items: center;
  width: var(--tile-size);
  height: var(--tile-size);
  flex: 0 0 var(--tile-size);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  box-shadow: 0 1px 2px rgba(35, 43, 41, 0.11);
}

.player-panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.player-heading {
  display: flex;
  align-items: center;
  min-height: 42px;
  margin-bottom: 19px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.player-identity {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 2px 7px;
  min-width: 0;
}

.player-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-role {
  grid-column: 1 / -1;
  color: var(--ink-faint);
  font-size: 10px;
}

.player-turn-dot {
  opacity: 0;
}

.player-turn-dot.is-active {
  opacity: 1;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.player-score-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 10px;
}

.player-score {
  color: var(--ink);
  font-size: 25px;
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.board-layout {
  display: grid;
  grid-template-columns: minmax(112px, 1fr) auto;
  align-items: end;
  justify-content: center;
  gap: 10px;
  margin: 0 auto;
}

.pattern-lines {
  display: grid;
  grid-template-rows: repeat(5, var(--wall-size));
  align-self: end;
  gap: var(--wall-gap);
  min-width: 0;
  height: calc(5 * var(--wall-size) + 4 * var(--wall-gap));
}

.pattern-row,
.pattern-row-target {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  min-width: 0;
  height: var(--wall-size);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
}

.pattern-row-target {
  color: inherit;
}

.pattern-row-target:disabled {
  opacity: 1;
}

.pattern-row-target.is-legal-target {
  background: color-mix(in srgb, var(--accent-soft) 56%, transparent);
  cursor: pointer;
  outline: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  outline-offset: 2px;
}

.pattern-row-target.is-legal-target:hover {
  outline-color: var(--accent);
}

.pattern-slot,
.wall-cell,
.floor-slot {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--wall-size);
  height: var(--wall-size);
  flex: 0 0 var(--wall-size);
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-muted);
  color: transparent;
  font-size: 11px;
  line-height: 1;
}

.pattern-slot.is-filled,
.floor-slot.is-filled,
.wall-cell.is-filled {
  border-color: color-mix(in srgb, var(--tile-color) 72%, #26312e);
  background: var(--tile-color);
  color: var(--tile-ink, #ffffff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 1px 2px rgba(35, 43, 41, 0.14);
}

.wall-grid {
  display: grid;
  grid-template-columns: repeat(5, var(--wall-size));
  grid-template-rows: repeat(5, var(--wall-size));
  gap: var(--wall-gap);
  width: calc(5 * var(--wall-size) + 4 * var(--wall-gap));
  height: calc(5 * var(--wall-size) + 4 * var(--wall-gap));
}

.wall-cell:not(.is-filled) {
  border-color: color-mix(in srgb, var(--tile-color) 36%, var(--line));
  background: color-mix(in srgb, var(--tile-color) 30%, var(--surface));
}

.wall-cell::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--tile-color);
  opacity: 0.24;
}

.wall-cell.is-filled::after {
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: inherit;
  content: attr(data-mark);
  opacity: 1;
}

.floor-wrap {
  margin-top: auto;
  padding-top: 24px;
}

.floor-head {
  display: flex;
  align-items: baseline;
  margin-bottom: 6px;
}

.floor-title {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.floor-penalties {
  display: grid;
  grid-template-columns: repeat(7, minmax(22px, var(--wall-size)));
  gap: 4px;
  width: 100%;
  margin-bottom: 4px;
  padding: 0 5px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.floor-penalty {
  display: grid;
  min-width: 0;
  place-items: center;
}

.floor-line,
.floor-target {
  display: grid;
  grid-template-columns: repeat(7, minmax(22px, var(--wall-size)));
  gap: 4px;
  width: 100%;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
}

.floor-target:disabled {
  opacity: 1;
}

.floor-target.is-legal-target {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 56%, transparent);
  cursor: pointer;
}

.floor-target.is-legal-target:hover {
  border-color: var(--accent);
}

.floor-slot {
  width: 100%;
  min-width: 0;
}

.floor-slot .floor-token {
  width: 24px;
  height: 24px;
  border: 0;
  box-shadow: none;
}

.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 48px;
  padding: 8px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-quiet);
}

.tile-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--ink-soft);
  font-size: 10px;
}

.tile-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--tile-color);
  color: var(--tile-ink, #ffffff);
  font-size: 8px;
  font-style: normal;
}

.last-move {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boot-overlay {
  position: absolute;
  inset: 132px 0 48px;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: rgba(248, 250, 249, 0.92);
  color: var(--ink-soft);
}

.app-shell[data-phase="booting"] .boot-overlay,
.app-shell[data-phase="creating"] .boot-overlay {
  display: flex;
}

.loader-mark {
  display: flex;
  align-items: center;
  gap: 5px;
}

.loader-mark i {
  display: block;
  width: 17px;
  height: 17px;
  border-radius: 3px;
  background: var(--tile-color);
  animation: loader-wave 1.1s infinite ease-in-out;
}

.loader-mark i:nth-child(2) { animation-delay: 0.08s; }
.loader-mark i:nth-child(3) { animation-delay: 0.16s; }
.loader-mark i:nth-child(4) { animation-delay: 0.24s; }
.loader-mark i:nth-child(5) { animation-delay: 0.32s; }

@keyframes loader-wave {
  0%, 70%, 100% { transform: translateY(0); opacity: 0.45; }
  35% { transform: translateY(-7px); opacity: 1; }
}

.error-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  max-width: min(460px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.error-toast[hidden] {
  display: none;
}

.error-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 750;
}

.error-message {
  min-width: 0;
  overflow-wrap: anywhere;
}

.error-toast button {
  min-height: 30px;
  padding: 0 10px;
  background: var(--surface);
}

.error-toast .toast-close {
  width: 30px;
  padding: 0;
  border-color: transparent;
  color: var(--ink-soft);
  font-size: 18px;
}

.result-dialog {
  width: min(390px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-dialog::backdrop {
  background: rgba(24, 31, 29, 0.42);
}

.result-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 13px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
}

.result-kicker {
  margin: 0 0 4px;
  color: var(--ink-faint);
  font-size: 10px;
}

.result-dialog h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
}

.result-score {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 15px 0 22px;
  font-size: 24px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}

.result-score small {
  margin: 0 2px;
  color: var(--ink-faint);
  font-size: 13px;
  font-weight: 400;
}

.result-score-item {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
}

.result-score-item b {
  max-width: 92px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.primary-button,
.secondary-button {
  padding: 0 14px;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.secondary-button {
  background: var(--surface);
  color: var(--ink);
}

@media (min-width: 1121px) {
  .app-shell[data-players="3"] .playfield,
  .app-shell[data-players="4"] .playfield {
    grid-template-columns: minmax(520px, 1.35fr) minmax(360px, 0.85fr);
    grid-template-areas:
      "opponent opponent"
      "draft human";
  }

  .app-shell[data-players="3"] .opponent-zone,
  .app-shell[data-players="4"] .opponent-zone {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app-shell[data-players="4"] .opponent-zone {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .app-shell[data-players="3"] .opponent-zone.is-multiplayer .player-panel:not(:last-child),
  .app-shell[data-players="4"] .opponent-zone.is-multiplayer .player-panel:not(:last-child) {
    padding-right: 20px;
    padding-bottom: 0;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .app-shell[data-players="3"] .draft-zone,
  .app-shell[data-players="4"] .draft-zone {
    border-right: 1px solid var(--line);
  }

  .app-shell[data-players="3"] .human-zone,
  .app-shell[data-players="4"] .human-zone {
    border-left: 0;
  }
}

@media (max-width: 1120px) {
  .opponent-controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .game-options {
    justify-content: flex-end;
  }

  .think-control {
    justify-content: flex-end;
  }

  .playfield {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "draft draft"
      "opponent human";
  }

  .draft-zone {
    min-height: 390px;
    border-bottom: 1px solid var(--line);
  }

  .factories {
    grid-template-columns: repeat(5, 92px);
    min-height: 116px;
    gap: 12px;
  }

  .factory-wrap {
    width: 92px;
    height: 92px;
  }

  .factory-disc {
    width: 88px;
    height: 88px;
  }

  .opponent-zone {
    border-right: 1px solid var(--line);
  }

  .human-zone {
    border-left: 0;
  }
}

@media (max-width: 760px) {
  :root {
    --tile-size: 25px;
    --wall-size: 25px;
    --wall-gap: 2px;
  }

  .app-shell {
    border-inline: 0;
  }

  .topbar {
    grid-template-columns: minmax(76px, 1fr) auto minmax(76px, 1fr);
    gap: 8px;
    min-height: 52px;
    padding: 7px 12px;
  }

  .brand-block h1 {
    font-size: 17px;
  }

  .match-meta {
    grid-column: 2;
    grid-row: 1;
    gap: 6px;
    margin: 0;
    font-size: 10px;
  }

  .match-meta strong {
    font-size: 13px;
  }

  .command-button {
    grid-column: 3;
    grid-row: 1;
    min-height: 32px;
    padding-inline: 10px;
  }

  .opponent-band {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    min-height: 58px;
    padding: 6px 12px;
  }

  .opponent-controls {
    display: block;
  }

  .game-options {
    align-items: end;
    justify-content: flex-end;
    flex-direction: row;
    gap: 8px;
  }

  .player-count-control,
  .think-control {
    display: grid;
    gap: 3px;
  }

  .player-count-picker,
  .think-picker {
    width: auto;
  }

  .player-count-picker {
    grid-template-columns: repeat(3, 29px);
  }

  .think-picker {
    grid-template-columns: repeat(3, 43px);
  }

  .player-count-option,
  .think-option {
    min-height: 28px;
    padding-inline: 3px;
    font-size: 10px;
  }

  .playfield {
    display: flex;
    flex-direction: column;
  }

  .draft-zone {
    order: 1;
    min-height: 0;
    padding: 7px 12px 9px;
  }

  .opponent-zone {
    order: 3;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .opponent-zone.is-multiplayer .player-panel:not(:last-child) {
    padding-bottom: 10px;
  }

  .human-zone {
    order: 2;
    border-bottom: 1px solid var(--line);
  }

  .player-zone {
    padding: 9px 12px 10px;
  }

  .player-heading {
    min-height: 30px;
    margin-bottom: 7px;
    padding-bottom: 6px;
  }

  .factories {
    grid-template-columns: repeat(5, 60px);
    min-height: 60px;
    gap: 8px;
    padding: 0 0 6px;
  }

  .factory-wrap {
    width: 60px;
    height: 60px;
  }

  .factory-disc {
    width: 58px;
    height: 58px;
    gap: 3px;
    box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--surface) 70%, transparent);
  }

  .factory-number {
    width: 17px;
    height: 17px;
    font-size: 9px;
  }

  .center-row {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 6px;
    padding-top: 7px;
  }

  .center-tray {
    min-height: 40px;
    padding: 5px 7px;
  }

  .player-name {
    font-size: 13px;
  }

  .player-role {
    font-size: 9px;
  }

  .player-score {
    font-size: 20px;
  }

  .board-layout,
  .pattern-row,
  .pattern-row-target {
    gap: 2px;
  }

  .floor-wrap {
    padding-top: 7px;
  }

  .floor-head {
    margin-bottom: 3px;
  }

  .floor-title,
  .floor-penalties {
    font-size: 10px;
  }

  .floor-penalties {
    gap: 3px;
    margin-bottom: 2px;
    padding-inline: 3px;
  }

  .floor-line,
  .floor-target {
    gap: 3px;
    padding: 2px;
  }

  .floor-slot .floor-token {
    width: 21px;
    height: 21px;
  }

  .game-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    padding: 6px 14px;
  }

  .last-move {
    width: 100%;
    text-align: left;
  }

  .boot-overlay {
    inset: 110px 0 62px;
  }

  .turn-status {
    min-height: 24px;
    margin-bottom: 5px;
  }
}

@media (max-width: 390px) {
  .brand-subtitle {
    display: none;
  }

  .command-button {
    padding-inline: 10px;
  }

  .tile-legend {
    gap: 7px 10px;
  }
}

@media (max-width: 350px) {
  :root {
    --tile-size: 24px;
  }

  .factories {
    grid-template-columns: repeat(5, 54px);
    gap: 5px;
  }

  .factory-wrap {
    width: 54px;
    height: 54px;
  }

  .factory-disc {
    width: 52px;
    height: 52px;
  }
}

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