*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0f0f1a;
  --bg-header: #1a1a2e;
  --bg-panel: #16213e;
  --bg-production: #3d2c1e;
  --bg-stock: #1b2a4a;
  --bg-button: #2a2a4a;
  --bg-button-hover: #3a3a5a;
  --bg-button-active: #4a4a6a;
  --bg-overlay: rgba(0,0,0,0.85);
  --text-primary: #e0e0e0;
  --text-dim: #888;
  --text-accent: #ffd700;
  --border-color: #2a2a4a;
  --color-player0: #e53935;
  --color-player1: #1e88e5;
  --color-player2: #43a047;
  --color-player3: #fb8c00;
  --color-player4: #78909c;
  --color-mc: #ffd700;
  --color-steel: #a0522d;
  --color-titanium: #708090;
  --color-plants: #4caf50;
  --color-energy: #ce93d8;
  --color-heat: #ef5350;
  --color-temp: #ff7043;
  --color-oxygen: #42a5f5;
  --color-oceans: #26c6da;
  --color-venus: #e1bee7;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  background-image: radial-gradient(ellipse at 50% 30%, rgba(30, 40, 70, 0.5) 0%, transparent 70%);
  color: var(--text-primary);
  user-select: none;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-header);
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-accent);
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.header-gen {
  font-size: 1rem;
  color: var(--text-primary);
}
.header-gen strong {
  font-size: 1.3rem;
  color: var(--text-accent);
}
.header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  border-left: 1px solid var(--border-color);
  padding-left: 12px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 36px;
  padding: 4px 14px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-button);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.btn:hover { background: var(--bg-button-hover); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); }
.btn:active { background: var(--bg-button-active); transform: scale(0.97); }
.btn .btn-icon { display: none; font-size: 1.05rem; line-height: 1; }
.btn .btn-label { display: inline; }
.btn-history-toggle { display: none; }
.btn-next-gen {
  background: linear-gradient(135deg, #e65100, #ff6d00);
  border-color: #ff6d00;
  color: #fff;
  box-shadow: 0 2px 8px rgba(230, 81, 0, 0.4);
}
.btn-next-gen:hover { background: linear-gradient(135deg, #ff6d00, #ff8f00); box-shadow: 0 3px 12px rgba(255, 109, 0, 0.5); }
.btn-reset {
  background: #4a1111;
  border-color: #7a2222;
  font-size: 0.75rem;
  min-width: 36px;
  padding: 4px 10px;
}
.btn-reset:hover { background: #7a2222; }
.btn-corps {
  background: #1a3a4a;
  border-color: #2a5a6a;
}
.btn-corps:hover { background: #2a5a6a; }
.btn-score {
  background: #1a4a1a;
  border-color: #2a6a2a;
}
.btn-score:hover { background: #2a6a2a; }
.btn-goals {
  background: #3a2f10;
  border-color: #6a5420;
  color: var(--text-accent);
}
.btn-goals:hover { background: #6a5420; }
.btn-badge {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
  margin-left: 4px;
  padding: 2px 5px;
}
.btn-goals-full {
  background: #4a3a10;
  border-color: var(--text-accent);
  box-shadow: 0 0 0 1px rgba(255, 215, 0, 0.35);
}
.btn-wake {
  background: #23233d;
  border-color: #35355a;
  color: var(--text-dim);
  min-width: 36px;
  padding: 4px 10px;
}
.btn-wake:hover { background: #35355a; }
.btn-wake.btn-wake-on {
  color: var(--text-accent);
  border-color: #6a5420;
  background: #33301a;
}
.btn-destructive {
  background: #7a2222;
  border-color: #a33;
  color: #fff;
  font-weight: 700;
}
.btn-destructive:hover { background: #a33; box-shadow: 0 3px 12px rgba(170, 51, 51, 0.45); }
.btn-help {
  min-width: 36px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 1rem;
  background: #2a2a4a;
  color: var(--text-accent);
}
.btn-help:hover { background: #3a3a5a; }

/* ── Global Parameters ─────────────────────────── */
.global-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}
.global-param {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 6px 14px;
}
.global-param-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.global-param-value {
  font-size: 1.3rem;
  font-weight: 700;
  min-width: 48px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.global-param-bar {
  width: 90px;
  height: 12px;
  background: #2a2a3a;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}
.global-param-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s;
  box-shadow: 0 0 6px currentColor;
}
.game-end-glow .global-bar {
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.4);
  border-bottom-color: #4caf50;
}
.game-end-banner {
  display: none;
  text-align: center;
  background: #1b5e20;
  color: #a5d6a7;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 3px;
  letter-spacing: 1px;
}
.game-end-glow .game-end-banner { display: block; }

/* ── Adj Buttons (small +/- for resources) ─────── */
.adj-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-button);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s, box-shadow 0.1s;
  line-height: 1;
  flex-shrink: 0;
}
.adj-btn:hover { background: var(--bg-button-hover); box-shadow: 0 1px 4px rgba(0,0,0,0.3); }
.adj-btn:active { background: var(--bg-button-active); transform: scale(0.93); }
.adj-btn:disabled { opacity: 0.3; cursor: default; }
.adj-btn:disabled:hover { box-shadow: none; }
.adj-btn-lg {
  width: 32px;
  height: 32px;
  font-size: 1.15rem;
}

/* ── Player Grid ───────────────────────────────── */
.player-grid {
  display: grid;
  gap: 8px;
  padding: 8px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.player-panel {
  background: var(--bg-panel);
  border-radius: 12px;
  border-left: 5px solid var(--player-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.03), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: opacity 0.25s, filter 0.25s, box-shadow 0.25s;
}
.player-panel.player-inactive {
  opacity: 0.4;
  filter: saturate(0.3);
}
.player-panel.player-active {
  box-shadow: 0 0 14px var(--player-color), 0 2px 12px rgba(0, 0, 0, 0.3);
}
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(0,0,0,0.3);
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.player-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--player-color);
  cursor: pointer;
  border: 1px solid transparent;
  padding: 2px 6px;
  border-radius: 4px;
  background: transparent;
  min-width: 60px;
  text-decoration: underline dotted color-mix(in srgb, var(--player-color) 50%, transparent);
  text-underline-offset: 3px;
  transition: background 0.15s, border-color 0.15s, text-decoration-color 0.15s;
}
.player-name::after {
  content: ' ✎';
  font-size: 0.75rem;
  opacity: 0;
  margin-left: 2px;
  transition: opacity 0.15s;
  color: var(--text-dim);
}
.player-name:hover {
  border-color: var(--player-color);
  background: rgba(255,255,255,0.05);
  text-decoration-color: var(--player-color);
}
.player-name:hover::after {
  opacity: 1;
}
.player-name-input {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--player-color);
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--player-color);
  border-radius: 4px;
  padding: 2px 6px;
  outline: none;
  width: 120px;
  font-family: inherit;
}
.player-tr {
  display: flex;
  align-items: center;
  gap: 6px;
}
.player-tr-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
}
.player-tr-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-accent);
  min-width: 38px;
  text-align: center;
  text-shadow: 0 0 8px rgba(255,215,0,0.35);
  font-variant-numeric: tabular-nums;
}

/* ── Resource Rows ─────────────────────────────── */
.resources {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(48px, 80px) minmax(80px, 1fr) minmax(80px, 1fr) auto;
  padding: 4px 6px;
  gap: 4px;
  overflow-y: auto;
  min-height: 0;
  align-content: start;
}
.resource-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  gap: 4px;
  padding: 4px 4px 4px 8px;
  border-radius: 5px;
  border-left: 5px solid var(--res-color, transparent);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--res-color) 28%, var(--bg-panel)),
    color-mix(in srgb, var(--res-color) 10%, var(--bg-panel)) 70%);
}
.resource-row:nth-child(even) {
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--res-color) 22%, var(--bg-panel)),
    color-mix(in srgb, var(--res-color) 8%, var(--bg-panel)) 70%);
}
.resource-row + .resource-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.resource-name {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--res-color, var(--text-dim));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resource-group {
  display: flex;
  align-items: center;
  gap: 3px;
  justify-content: center;
  flex-wrap: wrap;
}
.resource-group-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  width: 26px;
  text-align: right;
  letter-spacing: 0.3px;
}
.prod-group .resource-group-label {
  color: color-mix(in srgb, var(--res-color) 70%, #fff);
}
.stock-group .resource-group-label {
  color: color-mix(in srgb, var(--res-color) 60%, #aaa);
}
.resource-value {
  font-size: 1.15rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  font-variant-numeric: tabular-nums;
  border-radius: 4px;
  transition: background-color 0.25s, color 0.25s, transform 0.15s;
}
.value-pulse {
  animation: valuePulse 380ms ease-out;
}
@keyframes valuePulse {
  0%   { background: color-mix(in srgb, var(--res-color) 70%, transparent); transform: scale(1.15); color: #fff; box-shadow: 0 0 12px var(--res-color); }
  60%  { background: color-mix(in srgb, var(--res-color) 35%, transparent); transform: scale(1.05); }
  100% { background: transparent; transform: scale(1); box-shadow: none; }
}
.prod-group {
  background: color-mix(in srgb, var(--res-color) 18%, #1a1a1a);
  border-radius: 6px;
  padding: 3px 4px;
  border: 1px solid color-mix(in srgb, var(--res-color) 30%, transparent);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}
.stock-group {
  background: color-mix(in srgb, var(--res-color) 12%, #1a1a2e);
  border-radius: 6px;
  padding: 3px 4px;
  border: 1px solid color-mix(in srgb, var(--res-color) 25%, transparent);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ── App Wrapper (app + history sidebar) ─────── */
.app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── App Container ─────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

/* ── Move History Panel ───────────────────────── */
.history-panel {
  width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-header);
  border-left: 1px solid var(--border-color);
  height: 100vh;
  overflow: hidden;
  box-shadow: inset 2px 0 8px rgba(0, 0, 0, 0.2);
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.history-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.history-clear-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 0.65rem;
  padding: 2px 8px;
  cursor: pointer;
  font-family: inherit;
}
.history-clear-btn:hover {
  background: var(--bg-button-hover);
  color: var(--text-primary);
}
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.history-entry {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 3px 10px;
  font-size: 0.72rem;
  line-height: 1.3;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.history-entry:hover {
  background: rgba(255, 255, 255, 0.03);
}
.history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}
.history-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.history-entry-auto {
  padding-left: 24px;
  color: var(--text-dim);
  font-style: italic;
}
.history-entry-system {
  color: var(--text-accent);
  font-weight: 600;
  background: rgba(255, 215, 0, 0.05);
  padding-top: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.15);
}
.history-entry-undo {
  color: var(--text-dim);
  text-decoration: line-through;
  opacity: 0.6;
}
.history-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.7rem;
  padding: 20px 10px;
  font-style: italic;
}
.history-entry-jumpable {
  position: relative;
}
.history-jump-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-left: 4px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  font-family: inherit;
}
.history-entry-jumpable:hover .history-jump-btn {
  opacity: 1;
}
.history-jump-btn:hover {
  background: var(--bg-button-hover);
  color: var(--text-accent);
  border-color: var(--border-color);
}

/* ── Score Overlay ─────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.overlay.active { display: flex; }
.score-panel {
  background: var(--bg-header);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  width: 90vw;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
}
.score-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-accent);
  margin-bottom: 16px;
}
.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.score-player {
  background: var(--bg-panel);
  border-radius: 8px;
  padding: 12px;
  border-left: 4px solid var(--player-color);
}
.score-player-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--player-color);
  margin-bottom: 8px;
}
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  font-size: 0.85rem;
  border-radius: 4px;
}
.score-row:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
.score-row:nth-child(even) { background: rgba(0, 0, 0, 0.15); }
.score-row label { color: var(--text-dim); }
.score-input {
  width: 50px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  text-align: center;
  padding: 3px;
  font-size: 0.85rem;
  font-family: inherit;
}

/* Milestone and award VP the Goals dialog fills in — shown, not typed. */
.score-input-locked {
  background: rgba(255,255,255,0.04);
  border-style: dashed;
  color: var(--text-dim, #9aa0a6);
  cursor: not-allowed;
}
.score-total {
  border-top: 2px solid var(--text-accent);
  margin-top: 6px;
  padding-top: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-accent);
  text-align: right;
}
.score-winner {
  text-align: center;
  margin-top: 16px;
  font-size: 1.2rem;
  font-weight: 700;
  padding: 10px;
  border-radius: 8px;
  background: rgba(76,175,80,0.15);
  border: 1px solid #4caf50;
}
.score-close {
  display: block;
  margin: 16px auto 0;
}
.score-ref-section {
  border-top: 1px solid var(--border-color);
  margin-top: 8px;
  padding-top: 6px;
}
.score-ref-title {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  opacity: 0.7;
}
.score-ref-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 8px;
  font-size: 0.75rem;
}
.score-ref-row:nth-child(odd) { background: rgba(255, 255, 255, 0.02); }
.score-ref-label {
  font-weight: 600;
}
.score-ref-vals {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ── Confirm Dialog ────────────────────────────── */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.active { display: flex; }
.confirm-box {
  background: var(--bg-header);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  max-width: 400px;
}
.confirm-box p {
  margin-bottom: 16px;
  font-size: 1rem;
}
.confirm-box .btn { margin: 0 6px; }

/* ── Help Overlay ──────────────────────────────── */
.help-section {
  text-align: left;
  margin-bottom: 12px;
}
.help-heading {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 14px 0 8px;
}
.help-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}
.help-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}
.help-kbd {
  display: inline-block;
  min-width: 96px;
  padding: 3px 8px;
  background: var(--bg-button);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-family: 'Consolas', 'Menlo', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-accent);
  text-align: center;
  flex-shrink: 0;
}
.help-desc {
  color: var(--text-primary);
}
.help-tips {
  list-style: none;
  padding: 0;
  margin: 0;
}
.help-tips li {
  position: relative;
  padding: 4px 0 4px 18px;
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.35;
}
.help-tips li::before {
  content: '\2022';
  position: absolute;
  left: 4px;
  top: 4px;
  color: var(--text-accent);
}

/* ── Corporation Overlay ──────────────────────────── */
.corp-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 150;
  align-items: center;
  justify-content: center;
}
.corp-overlay.active { display: flex; }
.corp-panel {
  background: var(--bg-header);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  width: 90vw;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
}
.corp-panel-setup {
  max-width: 700px;
}
.corp-setup-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-accent);
  margin-bottom: 20px;
}
.corp-setup-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: -12px;
  margin-bottom: 16px;
}
.corp-setup-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.corp-setup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.corp-setup-player-name {
  font-size: 1rem;
  font-weight: 700;
  min-width: 80px;
  text-align: left;
}

/* Player Setup Screen */
.player-setup-count-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}
.player-setup-count-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.player-setup-count {
  font-size: 1.5rem;
  font-weight: 700;
  min-width: 2ch;
  text-align: center;
  color: var(--text-primary);
}
.player-setup-rows {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
.player-setup-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.player-setup-arrows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.player-arrow-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.6rem;
  padding: 1px 6px;
  cursor: pointer;
  line-height: 1;
}
.player-arrow-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}
.player-arrow-btn:hover:not(:disabled) {
  background: rgba(255,255,255,0.18);
}
.player-setup-name-input {
  background: rgba(0,0,0,0.3);
  border: none;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  padding: 6px 4px;
  width: 140px;
  outline: none;
}
.player-setup-name-input:focus {
  border-bottom-color: var(--text-accent);
}
.player-setup-swatches {
  display: flex;
  gap: 8px;
}
.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, opacity 0.15s;
  padding: 0;
  outline: none;
}
.color-swatch:hover:not(.taken) {
  border-color: rgba(255,255,255,0.5);
}
.color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
}
.color-swatch.taken {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

.corp-select {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 6px 8px;
  font-size: 0.85rem;
  font-family: inherit;
  flex: 1;
  max-width: 280px;
}
.corp-select:focus {
  outline: none;
  border-color: var(--text-accent);
}
.corp-select-single {
  width: 100%;
  max-width: 100%;
  margin: 16px 0;
  padding: 10px;
  font-size: 1rem;
}
.corp-start-btn {
  display: block;
  margin: 0 auto 8px;
  min-width: 140px;
}
.btn-randomize-first {
  display: block;
  margin: 0 auto 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  min-width: 200px;
  transition: background 0.2s, color 0.2s;
}
.btn-randomize-first:hover {
  background: rgba(255,255,255,0.12);
}
.btn-randomize-done {
  background: rgba(67,160,71,0.25);
  border-color: rgba(67,160,71,0.5);
}
.corp-cancel-btn {
  display: block;
  margin: 0 auto;
  font-size: 0.8rem;
  opacity: 0.7;
}

/* ── Card Buying ────────────────────────────────────── */
.card-buy-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.card-buy-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-buy-input {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  padding: 6px 8px;
  font-size: 1rem;
  font-family: inherit;
  width: 50px;
  text-align: center;
}
.card-buy-input:focus {
  outline: none;
  border-color: var(--text-accent);
}
.card-buy-cost {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 70px;
  text-align: left;
  transition: color 0.15s;
}
.card-buy-cost-over {
  color: #ff6b6b;
  font-weight: 700;
}
.card-buy-player {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}
.card-buy-player:last-child { border-bottom: none; }
.card-buy-resources {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 4px 0 2px;
  font-size: 0.72rem;
  opacity: 0.85;
}
.card-buy-res-item {
  white-space: nowrap;
}

/* ── Corporation Banner (player panel) ────────────── */
.corp-banner {
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  text-align: center;
  height: 38px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(0,0,0,0.3), rgba(0,0,0,0.45));
  border-top: 1px solid rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.corp-banner:hover {
  filter: brightness(1.2);
  transform: scale(1.01);
}
.corp-banner-empty {
  color: var(--text-accent);
  font-style: italic;
  font-weight: 400;
  text-transform: none;
  background: rgba(255, 215, 0, 0.04);
  border-left-color: var(--text-accent);
  animation: corpBannerPulse 2.2s ease-in-out infinite;
}
.corp-banner-empty:hover {
  background: rgba(255, 215, 0, 0.12);
  filter: none;
  animation-play-state: paused;
}
@keyframes corpBannerPulse {
  0%, 100% { box-shadow: inset 0 0 0 rgba(255, 215, 0, 0); }
  50%      { box-shadow: inset 0 0 12px rgba(255, 215, 0, 0.18); }
}

/* ── Blue Cards Bar (player panel) ──────────────── */
.blue-cards-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px 8px;
  min-height: 0;
}
.blue-card-pill {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(21, 101, 192, 0.35);
  border: 1px solid rgba(21, 101, 192, 0.6);
  color: #90caf9;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.blue-card-pill:hover {
  background: rgba(21, 101, 192, 0.55);
}

/* ── Card Discount Label ────────────────────────── */
.card-discount {
  color: #90caf9;
  font-weight: 600;
}

/* ── Corporation Logo Grid Picker ──────────────── */
.corp-tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}
.corp-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px 8px;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 8px 8px 0 0;
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.corp-tab:hover {
  background: rgba(255,255,255,0.08);
}
.corp-tab-active {
  background: rgba(255,255,255,0.1);
  border-bottom-color: var(--tab-color, var(--text-accent));
}
.corp-tab-name {
  font-size: 0.85rem;
  font-weight: 700;
}
.corp-tab-selection {
  font-size: 0.6rem;
  color: var(--text-dim);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.corp-grid-container {
  margin-bottom: 16px;
}
.corp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 8px;
  margin-top: 6px;
}
.corp-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  min-height: 52px;
  transition: border-color 0.15s, background 0.15s;
}
.corp-tile:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}
.corp-tile-selected {
  border-color: var(--text-accent) !important;
  background: rgba(255,255,255,0.12);
}
.corp-tile-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
}
.corp-tile-mc {
  font-size: 0.6rem;
  color: var(--text-dim);
  margin-top: 3px;
}

/* ── Corporation Logo Styles ───────────────────── */
/* Base styles for all corp logos */
.cl {
  display: inline-block;
  line-height: 1.2;
  white-space: nowrap;
}
.corp-banner .cl { font-size: 14px; }
.corp-tile-logo .cl { font-size: 11px; }
.corp-logo-fallback {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

/* Beginner */
.cl-beginner { color: #aaa; font-style: italic; font-weight: normal; }

/* Aphrodite */
.cl-aphrodite {
  color: orange;
  font-weight: bold;
  text-shadow: -1px 0 #333, 0 1px #333, 1px 0 #333, 0 -1px #333;
}

/* Arcadian Communities */
.cl-arcadian {
  font-size: inherit;
  background: #eee;
  color: #222;
  padding: 1px 5px;
  border-radius: 3px;
  border-top: 1px solid #ddd;
  border-left: 1px solid #ddd;
  border-bottom: 1px solid #888;
  border-right: 1px solid #888;
  font-family: Arial, sans-serif;
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
}
.corp-banner .cl-arcadian { font-size: 11px; }
.corp-tile-logo .cl-arcadian { font-size: 8px; }

/* Aridor */
.cl-aridor {
  font-family: 'Courier New', monospace;
  color: #c5c553;
  letter-spacing: 2px;
  background: #cc3333;
  border: 1px solid #c5c553;
  border-radius: 3px;
  padding: 0 4px;
  text-align: center;
}

/* Arklight */
.cl-arklight {
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  background: linear-gradient(to right, #000089, lightblue, white);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transform: scaleX(1.3);
  display: inline-block;
}

/* Astrodrill */
.cl-astrodrill {
  color: #d8d891;
  letter-spacing: 1px;
  text-shadow: 0 0 2px black;
  border-top: 2px solid orange;
  border-radius: 40% 40% 0 0;
  padding: 0 6px;
  text-align: center;
}

/* Celestic */
.cl-celestic { white-space: nowrap; }
.cl-c1 { background: linear-gradient(to right, rgb(251,192,137), rgb(251,192,137), rgb(23,185,236)); padding-left: 3px; color: #222; }
.cl-c2 { background: linear-gradient(to right, rgb(23,185,236), rgb(251,192,137)); color: #222; }
.cl-c3 { background: rgb(251,192,137); padding-right: 3px; color: #222; }

/* Cheung Shing Mars */
.cl-cheung { white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; }
.cl-cs-icon {
  color: red;
  border: 2px solid red;
  border-radius: 50%;
  padding: 1px 2px;
  font-size: 0.7em;
  line-height: 1;
}
.cl-cs-text {
  font-family: 'Courier New', monospace;
  font-weight: normal;
  font-size: 0.8em;
  line-height: 1.1;
  white-space: nowrap;
}

/* Credicor */
.cl-credicor {
  color: white;
  font-family: 'Times New Roman', serif;
  font-weight: normal;
  border: 1px solid purple;
  padding: 0 4px;
  text-shadow: -1px 0 purple, 0 1px purple, 1px 0 purple, 0 -1px purple;
}

/* Ecoline */
.cl-ecoline {
  color: rgb(0,180,0);
  letter-spacing: 1px;
  font-weight: normal;
  text-shadow: -1px 0 #404040, 0 1px #404040, 1px 0 #404040, 0 -1px #404040;
}
.corp-banner .cl-ecoline { font-size: 18px; }
.corp-tile-logo .cl-ecoline { font-size: 14px; }

/* Ecotec */
.cl-eco1 {
  color: yellow;
  letter-spacing: 1px;
  background-color: green;
  padding: 0 3px;
  border-radius: 3px 0 0 3px;
  font-weight: normal;
}
.cl-eco2 {
  color: green;
  letter-spacing: 1px;
  background-color: yellow;
  padding: 0 3px;
  border-radius: 0 3px 3px 0;
  font-weight: normal;
}

/* Factorum */
.cl-factorum {
  color: #ee792b;
  text-shadow: 0 0 1px black, 0 1px black, 1px 0 black, -1px 0 black, 0 -1px black;
  letter-spacing: 2px;
  transform: scaleX(0.8);
  display: inline-block;
}

/* Helion */
.cl-helion {
  background: #e6e600;
  color: #222;
  border: 1px solid black;
  padding: 0 6px;
  border-radius: 2px;
  text-align: center;
}
.corp-banner .cl-helion { font-size: 16px; }
.corp-tile-logo .cl-helion { font-size: 12px; }

/* Interplanetary Cinematics */
.cl-interplan { text-align: center; line-height: 1; white-space: nowrap; }
.cl-ip1 { font-size: 0.7em; }
.cl-ip-bar {
  height: 3px;
  margin: 1px 0;
  background: linear-gradient(to right, yellow, black, yellow, black, yellow);
  border: 2px solid #cc3333;
}
.cl-ip2 { font-size: 0.55em; transform: scaleY(0.6); display: block; }

/* Inventrix */
.cl-inventrix { white-space: nowrap; }
.cl-inv-x {
  background-color: #6bb5c7;
  padding: 0 3px;
  font-size: 1.1em;
  color: #222;
}

/* Kuiper Cooperative */
.cl-kuiper { text-align: left; line-height: 1.1; white-space: nowrap; }
.cl-ku1 {
  background-color: rgb(98,126,219);
  border: 1px solid #aaa;
  border-bottom: 3px solid rgb(8,8,88);
  color: white;
  padding: 0 4px;
  letter-spacing: 1px;
}
.cl-ku2 {
  color: #cc3333;
  padding: 0 4px;
  letter-spacing: 1px;
  border: 1px solid rgb(146,163,219);
  border-top: none;
  font-size: 0.9em;
}

/* Lakefront Resorts */
.cl-lakefront {
  color: white;
  font-family: Times, serif;
  letter-spacing: 2px;
  text-shadow: 0 1px 0 #444, 0 -1px 0 #444, -1px 0 0 #444, 1px 0 0 #444;
  line-height: 1.1;
  text-align: center;
}

/* Manutech */
.cl-manutech {
  color: #e63900;
}
.cl-ma {
  color: white;
  background: #e63900;
  padding: 0 2px;
}

/* Mining Guild */
.cl-mining {
  color: #c9380e;
  text-shadow: -1px 0 #333, 0 1px #333, 1px 0 #333, 0 -1px #333;
  transform: scaleX(1.3);
  display: inline-block;
  text-align: center;
  line-height: 1.1;
}

/* Mons Insurance */
.cl-mons {
  background: rgb(200,110,35);
  color: white;
  text-align: center;
  padding: 1px 4px;
  line-height: 1;
  white-space: nowrap;
}
.cl-mons0 { font-size: 1.2em; transform: scaleX(2); display: block; }
.cl-mons1 { letter-spacing: 3px; font-size: 0.9em; }
.cl-mons2 { letter-spacing: 1px; font-size: 0.4em; display: block; }

/* Morning Star Inc. */
.cl-morning {
  color: white;
  text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
  font-size: 0.9em;
}

/* Nirgal Enterprises */
.cl-nirgal {
  color: rgb(226,153,17);
  border-bottom: 2px solid rgb(35,35,160);
  padding-bottom: 1px;
  letter-spacing: 1px;
  background: linear-gradient(transparent, rgba(255,255,255,0.2));
}

/* Palladin Shipping */
.cl-palladin {
  background: rgb(218,218,115);
  border-radius: 30%;
  color: #444;
  letter-spacing: 1px;
  text-align: center;
  padding: 2px 8px;
  line-height: 1.1;
  font-size: 0.8em;
}

/* Pharmacy Union */
.cl-pharmacy { color: #ccc; font-size: 0.85em; }

/* Philares */
.cl-philares {
  color: #999;
  text-shadow: 0 1px 1px white, 0 -1px 1px white, -1px 0 1px white, 1px 0 1px white;
  letter-spacing: 2px;
  transform: scaleX(1.3);
  display: inline-block;
}
.cl-phil-a { color: #ff5858; }

/* Phobolog */
.cl-phobolog {
  color: white;
  background: #32004d;
  padding: 1px 5px;
  border: 1px solid #444;
  border-radius: 6px;
  font-family: 'Times New Roman', serif;
  transform: scaleX(1.1);
  display: inline-block;
}

/* Point Luna */
.cl-pointluna {
  font-family: 'Courier New', monospace;
  font-weight: normal;
  text-decoration: underline;
  transform: scaleX(1.3);
  display: inline-block;
}

/* PolderTech Dutch */
.cl-poldertech {
  font-family: 'Arial', sans-serif;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
}
.cl-pt1 { color: #4caf50; letter-spacing: 1px; font-size: 0.85em; }
.cl-pt2 { color: #ff9800; }
.cl-pt3 { color: #ff6600; font-size: 0.7em; letter-spacing: 2px; }

/* Polyphemos */
.cl-polyphemos {
  font-family: 'Courier New', monospace;
  font-weight: normal;
  letter-spacing: 1px;
  border-bottom: 2px solid #cc3333;
  border-top: 2px solid #cc3333;
  padding: 1px 4px;
  text-align: center;
}
.cl-poly2 { color: #cc3333; }

/* Poseidon */
.cl-poseidon {
  font-family: 'Times New Roman', serif;
  font-weight: normal;
  background: linear-gradient(
    rgba(0,0,0,0) 0%, #3633ff 20%, rgba(0,0,0,0) 22%,
    #3633ff 50%, rgba(0,0,0,0) 78%, #3633ff 80%, rgba(0,0,0,0) 100%
  );
  color: #aaa;
  text-shadow: 0 0 1px black, 0 0 3px black;
  letter-spacing: 1px;
  padding: 2px 4px;
  text-align: center;
}

/* Pristar */
.cl-pristar {
  color: #ff5d21;
  text-shadow: 1px 1px 2px black;
  letter-spacing: 1px;
  transform: scaleX(0.9);
  display: inline-block;
}

/* Recyclon */
.cl-recyclon {
  background: red;
  color: white;
  border-radius: 15px;
  padding: 1px 8px;
  font-family: 'Courier New', monospace;
  font-weight: normal;
  text-shadow: 0 0 1px black;
}

/* Robinson Industries */
.cl-robinson {
  font-family: 'Courier New', monospace;
  font-weight: normal;
  background: white;
  color: #222;
  padding: 1px 4px;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
}
.cl-rob1 { letter-spacing: 2px; font-size: 0.9em; }
.cl-rob2 { border-bottom: 2px solid #ccc; font-size: 0.6em; display: block; }
.cl-rob3 { letter-spacing: 1px; font-size: 0.8em; }

/* Sagitta */
.cl-sagitta {
  color: rgb(82,190,82);
  text-shadow: 0 0 2px black;
  font-family: Georgia, serif;
  letter-spacing: 3px;
}

/* Saturn Systems */
.cl-saturn {
  color: white;
  background: #32004d;
  padding: 2px 8px;
  border-radius: 50%;
  font-weight: normal;
  border: 1px solid white;
  font-size: 0.7em;
  white-space: nowrap;
}
.cl-sat-dot { font-size: 0.7em; }

/* Septem Tribus */
.cl-septem {
  color: white;
  font-family: Times, serif;
  text-shadow: 0 0 1px black, 0 2px 2px black;
}

/* Splice */
.cl-splice {
  background: #eee;
  color: #222;
  padding: 1px 4px;
  font-family: Arial, sans-serif;
  font-weight: bold;
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
}
.cl-spl-c { color: red; }
.cl-spl-bar { height: 2px; background: red; margin-top: -1px; }
.cl-spl2 { font-size: 0.4em; font-weight: normal; }

/* Spire */
.cl-spire {
  color: white;
  letter-spacing: 1px;
  border: 1px solid white;
  background: linear-gradient(#222 40%, #aaa 40%, black 90%);
  padding: 3px 6px 1px;
  transform: scaleX(1.3);
  display: inline-block;
  font-family: 'Times New Roman', serif;
}

/* Stormcraft Inc. */
.cl-stormcraft { white-space: nowrap; }
.cl-sc1 {
  color: white;
  background: #ff9900;
  padding: 1px 4px;
  border-radius: 50% 0 30% 0;
  text-shadow: 0 0 4px black;
}
.cl-sc2 {
  padding: 1px 4px;
  text-shadow: 0 3px 5px black;
}

/* Teractor */
.cl-teractor {
  color: orangered;
  font-family: 'Times New Roman', serif;
  font-weight: normal;
  text-shadow: -1px 0 #333, 0 1px #333, 1px 0 #333, 0 -1px #333;
}

/* Terralabs Research */
.cl-terralabs {
  font-family: 'Courier New', monospace;
  font-weight: normal;
  color: #ddd;
  text-align: center;
  line-height: 1;
  white-space: nowrap;
}
.cl-tl1 { transform: scaleX(1.3); display: block; font-size: 1em; }
.cl-tl2 { letter-spacing: 2px; font-size: 0.5em; display: block; }

/* Tharsis Republic */
.cl-tharsis { line-height: 1.1; white-space: nowrap; }
.cl-th-tri {
  display: inline-block;
  background-color: #ff5f00;
  border: 1px solid red;
  padding: 0 2px;
  margin-right: 2px;
}
.cl-th-tri2 { font-size: 0.6em; margin-left: -3px; }

/* Thorgate */
.cl-thorgate {
  font-family: 'Arial Narrow', Verdana, sans-serif;
  font-weight: normal;
  text-shadow: 3px 2px 3px grey;
}
.corp-banner .cl-thorgate { font-size: 16px; }
.corp-tile-logo .cl-thorgate { font-size: 12px; }

/* Tycho Magnetics */
.cl-tycho { line-height: 1.1; white-space: nowrap; }
.cl-ty1 {
  font-family: 'Arial Narrow', Verdana, sans-serif;
  font-weight: normal;
  text-shadow: 3px 2px 3px grey;
  border: 1px solid #aaa;
  border-right: none;
  padding-left: 3px;
  font-size: 1.1em;
}
.cl-ty2 {
  border: 1px solid #aaa;
  border-right: none;
  padding-left: 3px;
  margin-left: 10px;
  font-size: 0.7em;
  display: block;
}

/* UNMI */
.cl-unmi {
  background: linear-gradient(to right, #396d91, #5599cc);
  color: white;
  padding: 2px 6px;
  text-align: center;
  font-weight: normal;
  text-shadow: 0 0 2px black;
  font-size: 0.7em;
  line-height: 1.2;
  white-space: nowrap;
}

/* Utopia Invest */
.cl-utopia {
  background: green;
  color: white;
  font-family: 'Courier New', monospace;
  font-weight: normal;
  text-align: center;
  padding: 1px 6px;
  border-top: 2px solid #09aa09;
  border-left: 2px solid #09aa09;
  border-right: 2px solid #005100;
  border-bottom: 2px solid #005100;
  line-height: 1;
  white-space: nowrap;
}
.cl-ut1 { transform: scaleX(1.3); display: block; letter-spacing: 3px; }
.cl-ut2 { letter-spacing: 6px; font-size: 0.5em; display: block; margin-left: 3px; }

/* Valley Trust */
.cl-valley {
  color: rgb(2,125,195);
  background: linear-gradient(to right, rgb(2,125,195) 10%, white, white, white);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  border-radius: 6px 0 0 6px;
  padding: 0 4px;
}

/* Viron */
.cl-viron {
  font-family: 'Courier New', monospace;
  text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white;
  color: #222;
}
.corp-banner .cl-viron { font-size: 20px; }
.corp-tile-logo .cl-viron { font-size: 14px; }

/* Vitor */
.cl-vitor {
  transform: scaleX(1.5);
  display: inline-block;
}
.cl-vit1 { color: white; background: orangered; padding-left: 2px; }
.cl-vit2 { background: linear-gradient(to right, orangered, white); color: #222; margin-left: -3px; }
.cl-vit3 { background: white; color: #222; padding-right: 2px; margin-left: -3px; }

/* ── Game Mode Button ───────────────────────────── */
.btn-mode {
  background: #2a1a4a;
  border-color: #4a2a7a;
  font-size: 0.75rem;
}
.btn-mode:hover { background: #4a2a7a; }

/* ── Active Player Bar ──────────────────────────── */
.active-player-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 5px 16px;
  background: linear-gradient(180deg, rgba(0,0,0,0.25), rgba(0,0,0,0.35));
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}
.active-player-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.active-player-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 30px;
  padding: 5px 12px;
  border: 2px solid transparent;
  border-radius: 15px;
  background: var(--bg-button);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.active-player-btn:hover {
  background: var(--bg-button-hover);
}
.active-player-selected {
  border-color: var(--ap-color, var(--text-accent));
  background: rgba(255,255,255,0.12);
  box-shadow: 0 0 10px rgba(255,255,255,0.2), 0 0 4px rgba(255,255,255,0.1);
}
.active-player-none.active-player-selected {
  border-color: var(--text-dim);
}

/* ── First Player Badge ─────────────────────────── */
.first-player-badge {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 20px;
  border-radius: 10px;
  background: var(--text-accent);
  color: #000;
  font-size: 0.6rem;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
}
.first-player-badge:hover { opacity: 0.8; }
.first-player-active {
  display: inline-flex;
}

/* ── Income Display ─────────────────────────────── */
.player-income {
  font-size: 0.82rem;
  color: var(--color-mc);
  opacity: 0.75;
  white-space: nowrap;
  margin-left: 4px;
  background: rgba(255,215,0,0.1);
  border-radius: 10px;
  padding: 2px 8px;
  font-variant-numeric: tabular-nums;
}

/* ── Direct Number Input for Resources ──────────── */
.resource-value-tap {
  cursor: pointer;
  border-radius: 3px;
  padding: 1px 3px;
}
.resource-value-tap:hover {
  background: rgba(255,255,255,0.1);
}
.resource-value-input {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--text-accent);
  border-radius: 3px;
  color: var(--text-primary);
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  padding: 1px;
  outline: none;
}

/* ── ±5 Buttons ─────────────────────────────────── */
.mc-quick-btns {
  display: flex;
  gap: 3px;
  align-items: center;
}
.adj-btn-5 {
  font-size: 0.6rem;
  width: 24px;
  height: 20px;
  opacity: 0.7;
}
.adj-btn-5:hover { opacity: 1; }

/* ── Toast Notifications ────────────────────────── */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 500;
}
.param-celebration-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 450;
}
.toast-container {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: 340px;
}
.toast {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  opacity: 0;
  transform: translateX(40px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}
.toast-visible {
  opacity: 1;
  transform: translateX(0);
}
.toast-info {
  background: rgba(30, 136, 229, 0.9);
  border: 1px solid #42a5f5;
}
.toast-tr {
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid #ffd700;
  color: #ffd700;
}
.toast-bonus {
  background: rgba(76, 175, 80, 0.3);
  border: 1px solid #4caf50;
  color: #a5d6a7;
}

/* ── Mobile Responsive ──────────────────────────── */
@media (max-width: 900px) {
  .history-panel {
    width: 180px;
  }
  .player-grid {
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto !important;
    overflow-y: auto;
  }
  .player-panel {
    grid-column: auto !important;
  }
  .score-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  .player-grid {
    gap: 6px;
    padding: 6px;
  }
}

/* ── History drawer (≤768px): off-canvas slide-over ── */
@media (max-width: 768px) {
  .app-wrapper {
    display: block;
    height: 100vh;
    overflow: hidden;
  }
  .app {
    height: 100vh;
  }
  .history-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(320px, 88vw);
    height: 100vh;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 200;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    border-left: 1px solid var(--border-color);
    border-top: none;
  }
  .history-panel.history-open {
    transform: translateX(0);
  }
  .history-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .history-backdrop-active {
    opacity: 1;
    pointer-events: auto;
  }
  .btn-history-toggle {
    display: inline-flex;
  }
}

@media (max-width: 600px) {
  html, body {
    overflow: hidden;
  }
  .app {
    min-height: 100vh;
    overflow: hidden;
  }
  .header {
    padding: 4px 6px;
    gap: 4px;
  }
  .header-title {
    font-size: 0.85rem;
  }
  .header-actions {
    flex-wrap: wrap;
    gap: 4px;
    border-left: none;
    padding-left: 0;
  }
  /* Icons-only header buttons below 600px */
  .btn .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .btn .btn-label {
    display: none;
  }
  .btn {
    min-width: 44px;
    min-height: 40px;
    padding: 6px 8px;
    font-size: 0.95rem;
  }
  .global-bar {
    gap: 6px;
    padding: 4px 6px;
    flex-direction: column;
    align-items: stretch;
  }
  .global-param {
    justify-content: space-between;
    padding: 4px 8px;
  }
  .global-param-bar {
    flex: 1;
    min-width: 50px;
  }
  .active-player-bar {
    gap: 4px;
    padding: 4px 6px;
  }
  .player-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    overflow-y: auto;
    padding: 4px;
  }
  .player-panel {
    grid-column: auto !important;
    min-height: auto;
  }
  .resources {
    grid-template-columns: minmax(40px, 64px) minmax(80px, 1fr) minmax(80px, 1fr);
  }
  .resource-row {
    gap: 4px;
    padding: 4px 4px 4px 6px;
  }
  /* Larger tap targets: keep visible button compact, expand the hit area */
  .adj-btn {
    width: 34px;
    height: 34px;
    position: relative;
  }
  .adj-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }
  .adj-btn-lg {
    width: 40px;
    height: 40px;
  }
  .score-grid {
    grid-template-columns: 1fr !important;
  }
  .score-panel {
    padding: 12px;
    width: 95vw;
  }
  .corp-panel {
    width: 95vw;
    padding: 16px;
  }
  .toast-container {
    max-width: 280px;
    right: 4px;
    top: 4px;
  }
}

@media (max-width: 430px) {
  .header {
    padding: 4px 4px;
  }
  .header-title {
    font-size: 0.78rem;
  }
  .btn {
    min-width: 44px;
    min-height: 40px;
    padding: 4px 6px;
    font-size: 0.9rem;
  }
  .btn .btn-icon {
    font-size: 1rem;
  }
  .btn-help {
    min-width: 44px;
  }
  .global-param-value {
    font-size: 1.1rem;
    min-width: 44px;
  }
  .player-tr-value {
    font-size: 1.4rem;
    min-width: 32px;
  }
  .player-name {
    font-size: 1rem;
  }
}

/* ── Expansion Selector ──────────────────────────── */
.expansion-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.expansion-selector,
.corp-expansion-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}
.corp-expansion-filter {
  margin-top: 4px;
  margin-bottom: 10px;
}
.expansion-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-primary);
  cursor: pointer;
}
.expansion-checkbox input[type="checkbox"] {
  accent-color: var(--text-accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.expansion-checkbox input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── Player Action Buttons ───────────────────────── */
.player-action-btns {
  display: flex;
  gap: 6px;
  padding: 6px 10px;
}
.btn-std-action {
  flex: 1;
  background: linear-gradient(135deg, #3d2c1e, #4d3828);
  border-color: #6d4c2e;
  color: var(--color-mc);
  font-size: 0.78rem;
  min-height: 36px;
  padding: 2px 8px;
  border-radius: 8px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.btn-std-action:hover { background: linear-gradient(135deg, #5d3c2e, #6d4c3e); }
.btn-play-card {
  flex: 1;
  background: linear-gradient(135deg, #1a2e4a, #243a56);
  border-color: #2a4e6a;
  color: #90caf9;
  font-size: 0.78rem;
  min-height: 36px;
  padding: 2px 8px;
  border-radius: 8px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.btn-play-card:hover { background: linear-gradient(135deg, #2a3e5a, #344a66); }

/* ── Standard Actions Overlay ────────────────────── */
.std-action-balance {
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: -8px 0 8px;
}
.std-action-balance strong {
  color: var(--color-mc);
  font-size: 1.05rem;
  letter-spacing: 0.3px;
}
.std-action-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.std-action-conversions { margin-bottom: 4px; }
.std-action-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 14px 2px 2px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}
.std-action-conversions .std-action-cost {
  color: var(--color-plants);
  background: rgba(129,199,132,0.12);
}
.std-action-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--border-color);
  border-radius: 8px;
  background: rgba(0,0,0,0.3);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.std-action-item:hover {
  background: rgba(255,255,255,0.08);
  transform: translateX(2px);
}
.std-action-item:active { transform: translateX(0); }
.std-action-item.std-action-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}
.std-action-item.std-action-disabled:hover {
  background: rgba(0,0,0,0.3);
  transform: none;
}
.std-action-icon {
  grid-row: 1 / 3;
  font-size: 1.5rem;
  text-align: center;
  line-height: 1;
}
.std-action-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.std-action-cost {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-mc);
  text-align: right;
  background: rgba(255,200,0,0.12);
  padding: 2px 10px;
  border-radius: 4px;
  grid-row: 1 / 3;
}
.std-action-cost-free {
  color: #81c784;
  background: rgba(129,199,132,0.12);
}
.std-action-cost-was {
  color: var(--text-dim);
  font-weight: 500;
  margin-right: 2px;
  text-decoration: line-through;
}
.std-action-cost-after {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 0.78rem;
  margin-left: 4px;
}
.std-action-desc {
  grid-column: 2 / 3;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ── Cards Overlay ───────────────────────────────── */
.cards-panel {
  max-width: 700px !important;
  width: 95vw !important;
}
.cards-search {
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.cards-search:focus {
  border-color: var(--text-accent);
}
.cards-search::placeholder {
  color: var(--text-dim);
}
.cards-filter-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.cards-filter-btn {
  padding: 4px 12px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.cards-filter-btn:hover { background: rgba(255,255,255,0.08); }
.cards-filter-active {
  background: var(--text-accent) !important;
  color: #000 !important;
  border-color: var(--text-accent) !important;
}
.cards-list {
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
}
.cards-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
  font-style: italic;
}
.card-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.card-row:hover { background: rgba(255,255,255,0.06); }
.card-row:last-child { border-bottom: none; }
.card-auto-full { border-left-color: #4caf50; }
.card-auto-partial { border-left-color: #ffc107; }
.card-auto-manual { border-left-color: #666; }
.card-cost {
  min-width: 32px;
  font-weight: 700;
  color: var(--color-mc);
  text-align: right;
  font-size: 0.9rem;
}
.card-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-tags {
  font-size: 0.7rem;
  color: var(--text-dim);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-type {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}
.card-type-automated { background: #2e7d32; color: #fff; }
.card-type-active { background: #1565c0; color: #fff; }
.card-type-event { background: #c62828; color: #fff; }
.card-type-prelude { background: #6a1b9a; color: #fff; }

/* ── Card Confirm ────────────────────────────────── */
.card-confirm-info {
  padding: 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  line-height: 1.6;
}
.card-confirm-effects {
  padding: 10px 12px;
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.card-confirm-auto {
  padding: 10px 12px;
  background: rgba(76, 175, 80, 0.15);
  border: 1px solid rgba(76, 175, 80, 0.3);
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: #a5d6a7;
  line-height: 1.5;
}
.card-confirm-manual {
  padding: 10px 12px;
  background: rgba(255, 193, 7, 0.12);
  border: 1px solid rgba(255, 193, 7, 0.3);
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: #ffe082;
  line-height: 1.5;
}
.card-confirm-pay {
  margin-bottom: 12px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-color);
  border-radius: 6px;
}
.card-pay-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.card-pay-row:last-child {
  margin-bottom: 0;
}
.card-pay-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex: 1;
}

/* ── Milestones & Awards ────────────────────────── */
.goals-panel {
  max-width: 620px;
  text-align: left;
}
.goal-board-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.goal-board-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-right: 2px;
}
.goal-board-btn {
  background: var(--bg-button);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 5px 12px;
  min-height: 32px;
}
.goal-board-btn:hover { background: var(--bg-button-hover); }
.goal-board-btn-active {
  background: #3a2f10;
  border-color: var(--text-accent);
  color: var(--text-accent);
  font-weight: 700;
}
.goal-section-heading {
  align-items: baseline;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-accent);
  display: flex;
  flex-wrap: wrap;
  font-size: 1rem;
  font-weight: 700;
  gap: 8px;
  margin: 18px 0 8px;
  padding-bottom: 5px;
}
.goal-count {
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 400;
}
.goal-cost-note {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 400;
  margin-left: auto;
}
.goal-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.goal-row {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
}
.goal-row-taken {
  border-left-color: var(--text-accent);
  background: rgba(255, 215, 0, 0.06);
}
.goal-row-locked { opacity: 0.45; }
.goal-row-head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.goal-name {
  font-size: 0.9rem;
  font-weight: 700;
}
.goal-req {
  color: var(--text-dim);
  font-size: 0.74rem;
}
.goal-owner {
  align-items: center;
  display: flex;
  font-size: 0.8rem;
  font-weight: 700;
  gap: 8px;
  margin-top: 6px;
}
.goal-undo-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  min-height: 24px;
  min-width: 24px;
  padding: 2px 6px;
}
.goal-undo-btn:hover { background: #7a2222; border-color: #a33; color: #fff; }
.goal-locked {
  color: var(--text-dim);
  font-size: 0.74rem;
  margin-top: 6px;
}
.goal-claim-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}
.goal-claim-btn {
  background: var(--bg-button);
  border: 1px solid var(--goal-color, var(--border-color));
  border-radius: 5px;
  color: var(--goal-color, var(--text-primary));
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 600;
  min-height: 32px;
  padding: 5px 10px;
}
.goal-claim-btn:hover:not(:disabled) { background: var(--goal-color); color: #fff; }
.goal-claim-btn:disabled {
  border-color: var(--border-color);
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.4;
}
.goal-place-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 7px;
}
.goal-place-line {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.goal-place-label {
  color: var(--text-dim);
  font-size: 0.72rem;
  min-width: 74px;
}
.goal-place-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 700;
  min-height: 30px;
  min-width: 38px;
  padding: 4px 8px;
}
.goal-place-btn:hover { border-color: var(--goal-color); color: var(--goal-color); }
.goal-place-btn-on {
  background: var(--goal-color);
  border-color: var(--goal-color);
  color: #fff;
}
.goal-footnote {
  border-top: 1px solid var(--border-color);
  color: var(--text-dim);
  font-size: 0.72rem;
  line-height: 1.5;
  margin-top: 16px;
  padding-top: 10px;
}

/* Goal recap inside the final scoring panel */
.score-goal-summary {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  text-align: left;
}
.score-goal-line {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.score-goal-label {
  color: var(--text-accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  min-width: 78px;
  text-transform: uppercase;
}
.score-goal-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--goal-color, var(--border-color));
  border-radius: 999px;
  color: var(--goal-color, var(--text-primary));
  font-size: 0.72rem;
  padding: 3px 9px;
}
.score-goal-pill-todo {
  border-color: #a33;
  border-style: dashed;
  color: #ff8a80;
}
.score-goal-hint {
  color: var(--text-dim);
  font-size: 0.68rem;
  margin-top: 2px;
}

@media (max-width: 600px) {
  .goals-panel { padding: 14px; }
  .goal-cost-note { margin-left: 0; width: 100%; }
  .goal-place-label { min-width: 100%; }
  .goal-claim-btn, .goal-place-btn { min-height: 38px; }
  .score-goal-label { min-width: 100%; }
}

.cards-empty-error {
  color: #ff8a80;
  line-height: 1.6;
}
.cards-empty-error small {
  color: var(--text-dim);
  display: block;
  margin-top: 6px;
}
.cards-empty-error code {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 3px;
  padding: 1px 4px;
}

/* ── Tableside Layout ──────────────────── */
/* The player grid sized its rows to the viewport and let each panel clip what
   would not fit, so the resource rows — the whole point of the tracker — were
   the first thing to disappear. Measured on the deployed build: 93px of 483px
   of resources visible per panel at 1024x768, and 8px of 593px at 375x812.
   Size the panels to their content and let the grid scroll instead. */
.player-grid {
  grid-template-rows: min-content !important;
  grid-auto-rows: min-content !important;
  align-content: start;
  /* Vertical only. A bare overflow-y: auto makes the browser compute overflow-x
     to auto as well, and the panel content that used to be clipped would then
     put a horizontal scrollbar under the grid. */
  overflow-x: hidden;
  overflow-y: auto;
}
/* The panel keeps its own overflow: hidden. With min-content rows it is exactly
   as tall as its contents, so nothing is clipped vertically any more, and the
   clipping still contains a panel whose columns are wider than its track. */
.player-panel { min-height: 0; }
.resources { flex: 0 0 auto; overflow: visible; min-height: auto; }

/* 100vh on iOS Safari counts the space behind the URL bar, and the app never
   scrolls, so the bottom of the layout was simply unreachable on a phone. */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
  .app-wrapper { height: 100dvh; }
  .app { height: 100dvh; min-height: 100dvh; }
}

/* Without this, a fast double tap on a +/- button zooms the page on iOS
   instead of counting as two taps. */
.adj-btn, .btn, button, .resource-value-tap, .corp-tile, .card-row,
.goal-claim-btn, .goal-place-btn, .active-player-btn { touch-action: manipulation; }

@media (max-width: 600px) {
  /* 34px counters on a phone, 120 of them on one screen. */
  .adj-btn { min-width: 40px; min-height: 40px; }
  .resource-value-tap { min-width: 44px; min-height: 32px; }
  /* The fifth colour swatch sat at x=370-400 on a 375px screen, reachable only
     by discovering a horizontal scroll inside the dialog. */
  .player-setup-row { flex-wrap: wrap; }
  .player-setup-swatches { flex-wrap: wrap; justify-content: flex-start; }
}
