:root {
  --station-accent: #78a6db;
  --station-panel: rgba(18, 29, 34, 0.94);
  --station-soft: rgba(255, 255, 255, 0.035);
  --active-color: var(--station-accent);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(
      circle at 60% -10%,
      rgba(77, 137, 216, 0.16),
      transparent 38rem
    ),
    var(--page-bg);
}

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

.station-header {
  min-height: 76px;
  padding: 12px clamp(16px, 3vw, 34px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--board-edge);
  background: rgba(13, 21, 25, 0.9);
  backdrop-filter: blur(16px);
}

.station-brand,
.station-nav,
.workspace-heading,
.workspace-actions,
.panel-heading,
.seed-input-row,
.turns-control-heading,
.generation-actions,
.dialog-actions {
  display: flex;
  align-items: center;
}

.station-brand {
  gap: 18px;
}

.station-wordmark {
  color: #fff;
  font-size: 1.15rem;
  letter-spacing: -0.05em;
  text-decoration: none;
}

.station-brand h1 {
  margin-top: 2px;
  font-size: clamp(1.1rem, 2.2vw, 1.65rem);
  font-weight: 520;
}

.station-nav {
  gap: 8px;
}

.station-nav a {
  padding: 8px 11px;
  border: 1px solid var(--board-edge);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  text-decoration: none;
}

.station-nav a:hover,
.station-nav a:focus-visible {
  color: #fff;
  border-color: #78909e;
}

.station-layout {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(480px, 1fr) minmax(
      270px,
      330px
    );
  min-height: calc(100dvh - 76px);
}

.station-panel {
  background: var(--station-panel);
}

.station-sidebar,
.station-inspector {
  min-width: 0;
}

.station-sidebar {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--board-edge);
}

.station-inspector {
  border-left: 1px solid var(--board-edge);
  background: var(--panel-bg);
  overflow-y: auto;
}

.station-inspector .station-panel {
  padding: 20px;
  border-bottom: 1px solid var(--board-edge);
}

.panel-heading {
  gap: 12px;
}

.panel-heading.compact {
  margin-bottom: 16px;
}

.panel-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  border: 1px solid rgba(120, 166, 219, 0.4);
  border-radius: 50%;
  color: var(--station-accent);
  font:
    0.68rem ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}

.station-panel h2,
.workspace-panel h2,
.station-dialog h2 {
  font-size: 1.05rem;
  margin-top: 3px;
}

.parameter-list {
  display: grid;
  gap: 9px;
  padding: 0;
  margin: 0;
  border: 0;
}

.parameter-list label {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--board-edge);
  border-radius: 9px;
  background: var(--station-soft);
  cursor: pointer;
}

.parameter-list label:has(input:checked) {
  border-color: rgba(120, 166, 219, 0.6);
  background: rgba(77, 137, 216, 0.09);
}

.parameter-list label:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.55;
}

.parameter-list input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--station-accent);
}

.parameter-list span {
  display: grid;
  gap: 2px;
}

.parameter-list strong {
  font-size: 0.8rem;
  font-weight: 600;
}

.parameter-list small {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.starting-paths-panel {
  display: grid;
  gap: 8px;
}

.starting-paths-panel[hidden] {
  display: none;
}

.starting-paths-intro {
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 0.66rem;
}

#startingPlayerConfigs {
  display: grid;
  gap: 8px;
}

.starting-player-config {
  --player-color: var(--station-accent);
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--board-edge);
  border-left: 3px solid var(--player-color);
  border-radius: 8px;
  background: var(--station-soft);
}

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

.starting-player-heading label {
  color: var(--player-color);
  font-size: 0.75rem;
  font-weight: 700;
}

.starting-player-heading select {
  min-width: 0;
  width: 100%;
  padding: 7px 25px 7px 8px;
  font-size: 0.68rem;
}

.custom-starting-hand {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.custom-starting-hand[hidden] {
  display: none;
}

.custom-starting-hand label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.59rem;
  text-align: center;
}

.custom-starting-hand input {
  width: 100%;
  min-width: 0;
  padding: 6px 3px;
  text-align: center;
}

.starting-hand-validation {
  min-height: 1.15em;
  margin: 0;
  color: var(--muted);
  font-size: 0.62rem;
}

.starting-hand-validation.invalid {
  color: #efa3a3;
}

.turns-control {
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 1px solid var(--board-edge);
  border-radius: 9px;
  background: var(--station-soft);
}

.turns-control-heading {
  justify-content: space-between;
  gap: 12px;
}

.turns-output-group {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.mode-badge {
  padding: 3px 6px;
  border: 1px solid rgba(120, 166, 219, 0.45);
  border-radius: 999px;
  color: var(--station-accent);
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mode-badge.experimental {
  border-color: rgba(239, 163, 163, 0.5);
  color: #efa3a3;
}

.turns-control-heading label {
  font-size: 0.8rem;
  font-weight: 600;
}

.turns-control-heading output {
  min-width: 2.1em;
  color: var(--station-accent);
  font:
    700 0.86rem ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  text-align: right;
}

.turns-control input[type="range"] {
  width: 100%;
  margin: 1px 0;
  accent-color: var(--station-accent);
}

.turn-totals,
.turn-mode-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1.4;
}

.turn-totals strong {
  color: var(--ink);
}

.turn-mode-note.experimental {
  color: #e6bd72;
}

.seed-control {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.seed-input-row,
.generation-actions,
.workspace-actions,
.dialog-actions {
  gap: 8px;
}

.seed-input-row input {
  width: 100%;
  min-width: 0;
  text-transform: none;
}

.generation-actions > *,
.workspace-actions > * {
  flex: 1;
}

.station-status,
.station-boundary {
  font-size: 0.74rem;
  line-height: 1.5;
}

.station-status {
  min-height: 2.3em;
  color: var(--muted);
}

.station-status.error,
.dialog-error,
#savedBoardsStatus.error {
  color: #efa3a3;
}

.station-status.success {
  color: #8bd4a4;
}

.station-boundary {
  margin-top: auto;
  padding: 12px;
  border-left: 2px solid var(--station-accent);
  background: rgba(77, 137, 216, 0.07);
}

.station-boundary p {
  margin-top: 4px;
  color: var(--muted);
}

.workspace-panel {
  min-width: 0;
  padding: clamp(16px, 2vw, 28px);
  display: grid;
  grid-template-rows: auto auto minmax(420px, 1fr);
  gap: 14px;
  background: #0a1216;
}

.workspace-heading {
  justify-content: space-between;
  gap: 16px;
}

.workspace-actions {
  min-width: 260px;
}

.board-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.board-summary span {
  padding: 6px 9px;
  border: 1px solid var(--board-edge);
  border-radius: 999px;
  color: var(--muted);
  font:
    0.67rem ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}

.station-board-frame {
  position: relative;
  min-width: 0;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--board-edge);
  border-radius: 12px;
  background-color: #0b1418;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.28);
}

.station-board-viewport {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.station-board-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.station-board-empty > span {
  font-size: 3.2rem;
  color: rgba(120, 166, 219, 0.45);
}

.station-board-empty p {
  font-size: 0.76rem;
}

.station-board-world {
  --station-card-size: 92px;
  --card-size: var(--station-card-size);
  pointer-events: none;
}

.station-board-grid {
  box-sizing: border-box;
}

.station-board-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.station-camera-controls {
  position: absolute;
  z-index: 4;
  right: 12px;
  bottom: 34px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.station-camera-controls button,
.station-camera-controls output {
  min-width: 38px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--board-edge);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(19, 33, 43, 0.94);
  font:
    700 0.7rem/1 Inter,
    sans-serif;
  text-align: center;
}

.station-camera-controls output {
  display: grid;
  place-items: center;
  min-width: 52px;
}

.station-board-help {
  z-index: 3;
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 11px;
  color: #a2b6c3;
  font-size: 0.63rem;
  pointer-events: none;
}

.station-tile {
  position: absolute;
  transform: translate(-50%, -50%);
  width: var(--station-card-size);
  height: var(--station-card-size);
  border-radius: max(3px, calc(var(--station-card-size) * 0.06));
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.22));
}

.station-tile .card-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.station-tile[data-card-type="center"] {
  z-index: 2;
  filter: drop-shadow(0 0 8px rgba(238, 244, 248, 0.24));
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0;
  border: 1px solid var(--board-edge);
  border-radius: 9px;
  overflow: hidden;
  background: var(--board-edge);
}

.metric-grid > div {
  min-width: 0;
  padding: 10px;
  background: #111c21;
}

.metric-grid dt {
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.25;
}

.metric-grid dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font:
    0.84rem ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}

.color-diagnostics {
  margin-top: 12px;
  font-size: 0.72rem;
}

.color-diagnostics summary {
  color: var(--muted);
  cursor: pointer;
}

#colorDiagnosticRows {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.resolved-starting-hands {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.resolved-hand-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border-left: 3px solid var(--row-color);
  background: var(--station-soft);
}

.resolved-hand-row span {
  color: var(--muted);
  text-align: right;
}

.color-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border-left: 3px solid var(--row-color);
  background: var(--station-soft);
}

.saved-board-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.saved-board-empty {
  padding: 16px;
  border: 1px dashed var(--board-edge);
  border-radius: 9px;
  color: var(--muted);
  font-size: 0.74rem;
  text-align: center;
}

.saved-board-card {
  display: grid;
  gap: 7px;
  padding: 11px;
  border: 1px solid var(--board-edge);
  border-radius: 9px;
  background: var(--station-soft);
}

.saved-board-card.current {
  border-color: rgba(120, 166, 219, 0.58);
}

.saved-board-card h3 {
  overflow-wrap: anywhere;
  font-size: 0.82rem;
}

.saved-board-card p {
  color: var(--muted);
  font:
    0.63rem/1.5 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
}

.saved-board-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 5px;
}

.saved-board-actions button {
  min-height: 34px;
  padding: 5px;
  font-size: 0.68rem;
}

.station-dialog {
  width: min(420px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--board-edge);
  border-radius: 12px;
  color: #edf3f7;
  background: #142127;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.station-dialog::backdrop {
  background: rgba(3, 8, 10, 0.72);
  backdrop-filter: blur(4px);
}

.station-dialog form {
  display: grid;
  gap: 13px;
  padding: 22px;
}

.station-dialog label {
  color: var(--muted);
  font-size: 0.72rem;
}

.station-dialog input {
  width: 100%;
}

.dialog-error {
  min-height: 1.2em;
  font-size: 0.72rem;
}

.dialog-actions {
  justify-content: flex-end;
}

@media (max-width: 1120px) {
  .station-layout {
    grid-template-columns: 270px minmax(0, 1fr);
  }

  .station-inspector {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--board-edge);
    border-left: 0;
  }

  .station-inspector .station-panel {
    border-right: 1px solid var(--board-edge);
  }
}

@media (max-width: 720px) {
  .station-header,
  .workspace-heading {
    align-items: flex-start;
  }

  .station-header {
    flex-direction: column;
    gap: 10px;
  }

  .station-brand {
    align-items: flex-start;
  }

  .station-layout,
  .station-inspector {
    display: block;
  }

  .station-sidebar,
  .station-inspector,
  .station-inspector .station-panel {
    border: 0;
    border-bottom: 1px solid var(--board-edge);
  }

  .workspace-panel {
    min-height: 680px;
    grid-template-rows: auto auto minmax(480px, 1fr);
  }

  .workspace-heading {
    flex-direction: column;
  }

  .workspace-actions {
    width: 100%;
    min-width: 0;
  }

  .station-board-frame {
    min-height: 484px;
  }
}

@media (max-width: 430px) {
  .station-brand {
    gap: 10px;
  }

  .station-wordmark {
    display: none;
  }

  .station-nav,
  .generation-actions,
  .workspace-actions {
    width: 100%;
  }

  .station-nav a,
  .generation-actions button,
  .workspace-actions button {
    flex: 1;
    text-align: center;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}
