/* ============================================
   POWER GRID - Industrial Design System
   Theme: Infrastructure, Energy Markets, Grid Logic
   ============================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Primary Colors - Industrial Palette */
  --color-bg-primary: #0d1117;
  --color-bg-secondary: #161b22;
  --color-bg-tertiary: #21262d;
  --color-bg-panel: #1c2128;

  /* Surface Colors */
  --color-surface: #22272e;
  --color-surface-hover: #2d333b;
  --color-surface-active: #373e47;

  /* Border Colors */
  --color-border: #30363d;
  --color-border-emphasis: #484f58;
  --color-border-active: #f39c12;

  /* Text Colors */
  --color-text-primary: #e6edf3;
  --color-text-secondary: #8b949e;
  --color-text-muted: #6e7681;
  --color-text-heading: #ffffff;

  /* Accent Colors - Energy Theme */
  --color-electric: #ffd93d;
  --color-electric-dim: #b8860b;
  --color-copper: #b87333;
  --color-amber: #f39c12;
  --color-warning: #e67e22;

  /* Status Colors */
  --color-success: #238636;
  --color-success-emphasis: #2ea043;
  --color-danger: #da3633;
  --color-danger-emphasis: #f85149;
  --color-info: #1f6feb;

  /* Resource Colors */
  --color-coal: #5d4e37;
  --color-oil: #1a1a1a;
  --color-garbage: #cc7000;
  --color-uranium: #8b0000;

  /* Typography */
  --font-primary: 'IBM Plex Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', 'Consolas', monospace;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;

  /* Border Radius - Sharp industrial feel */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(243, 156, 18, 0.3);
}

/* --- Base Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Body & Root --- */
body {
  font-family: var(--font-primary);
  background: var(--color-bg-primary);
  min-height: 100vh;
  color: var(--color-text-primary);
  line-height: 1.5;
  zoom: 0.67;
}

/* Grid pattern background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(rgba(243, 156, 18, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(243, 156, 18, 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: -1;
}

/* --- Collapsible Sections --- */
.collapsible-section {
  position: relative;
}

.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: var(--space-xs) 0;
  transition: opacity 0.15s;
}

.collapsible-header:hover h2 {
  opacity: 0.8;
}

.collapsible-header .map-controls {
  display: flex;
  gap: var(--space-sm);
  cursor: default;
}

.collapsible-header h2 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
}

.collapse-caret {
  display: inline-block;
  font-size: 0.7em;
  transition: transform 0.2s ease;
  color: var(--color-text-secondary);
}

.collapsible-section.collapsed .collapse-caret {
  transform: rotate(-90deg);
}

.collapsible-content {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  max-height: 2000px;
  opacity: 1;
}

/* Map collapsible content - don't force fill, let content determine height */
.map-container .collapsible-content {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
}

.collapsible-section.collapsed .collapsible-content {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* --- Screen States --- */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* Login screen background */
#login-screen {
  background: url('/assets/backgrounds/powergrid_background_realistic.webp') center center / cover no-repeat;
  position: relative;
}

#login-screen::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 17, 23, 0.85);
  z-index: 0;
}

#login-screen > .container {
  position: relative;
  z-index: 1;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl);
}

/* --- Typography --- */
h1 {
  text-align: center;
  color: var(--color-electric);
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--space-xl);
  text-transform: uppercase;
  letter-spacing: 4px;
  text-shadow: 0 0 30px rgba(255, 217, 61, 0.4);
}

h1::before {
  content: '//';
  margin-right: 0.5rem;
  color: var(--color-text-muted);
  font-weight: 400;
}

h2 {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

h3 {
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-sm);
}

/* --- Login Screen --- */
.login-options {
  display: flex;
  gap: 0;
  align-items: stretch;
  justify-content: center;
  flex-wrap: nowrap;
}

.option-card {
  background: var(--color-bg-secondary);
  padding: var(--space-xl);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  min-width: 320px;
  position: relative;
  transition: all 0.3s ease;
}

.option-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-amber), var(--color-electric));
}

.option-card:hover {
  border-color: var(--color-border-emphasis);
  box-shadow: var(--shadow-glow);
}

.option-card h2 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: var(--space-lg);
}

/* Create Game Form */
.create-game-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.create-game-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.option-group {
  flex: 1 1 auto;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.option-group label {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.form-select {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.form-select:hover {
  border-color: var(--color-border-emphasis);
}

.form-select:focus {
  outline: none;
  border-color: var(--color-electric);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checkbox-text {
  color: var(--color-text);
}

.checkbox-tooltip {
  position: relative;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  cursor: help;
}

.checkbox-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: normal;
  width: 240px;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--color-border);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 100;
  pointer-events: none;
  margin-bottom: 8px;
}

.checkbox-tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

.create-game-rules {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.quick-test-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.quick-test-checkbox input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.quick-test-checkbox span {
  white-space: nowrap;
}

.quick-test-checkbox .checkbox-tooltip {
  font-size: 0.7rem;
  margin-left: 2px;
}

.divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-xl);
  position: relative;
}

.divider::before {
  content: '';
  position: absolute;
  top: var(--space-xl);
  bottom: var(--space-xl);
  left: 50%;
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent,
    var(--color-border-emphasis) 20%,
    var(--color-amber) 50%,
    var(--color-border-emphasis) 80%,
    transparent
  );
  transform: translateX(-50%);
}

/* --- Form Inputs --- */
input[type="text"],
input[type="number"] {
  width: 100%;
  padding: 0.875rem 1rem;
  margin: var(--space-sm) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: var(--font-mono);
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  transition: all 0.2s ease;
}

input[type="text"]::placeholder,
input[type="number"]::placeholder {
  color: var(--color-text-muted);
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--color-amber);
  box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.15);
}

/* --- Buttons --- */
.primary-btn {
  width: 100%;
  padding: 0.875rem var(--space-lg);
  margin-top: var(--space-md);
  background: linear-gradient(135deg, var(--color-amber) 0%, var(--color-warning) 100%);
  color: #000;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 700;
  font-family: var(--font-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.primary-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s ease;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(243, 156, 18, 0.4);
}

.primary-btn:hover:not(:disabled)::before {
  left: 100%;
}

.primary-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--color-bg-tertiary);
  color: var(--color-text-muted);
}

.secondary-btn {
  padding: 0.75rem 1.25rem;
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.secondary-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-emphasis);
}

.danger-btn {
  padding: 0.875rem 1.5rem;
  min-height: 44px;
  background: rgba(220, 53, 69, 0.2);
  color: #ff6b6b;
  border: 1px solid rgba(220, 53, 69, 0.4);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.danger-btn:hover:not(:disabled) {
  background: rgba(220, 53, 69, 0.3);
  border-color: rgba(220, 53, 69, 0.6);
}

.danger-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pass-btn {
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, var(--color-danger) 0%, var(--color-danger-emphasis) 100%);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(218, 54, 51, 0.3);
}

.pass-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(218, 54, 51, 0.4);
}

/* --- Lobby Screen --- */
.game-info {
  background: var(--color-bg-secondary);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xl);
  text-align: center;
  border: 1px solid var(--color-border);
}

.game-id {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-electric);
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255, 217, 61, 0.3);
}

.players-list {
  background: var(--color-bg-secondary);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xl);
  border: 1px solid var(--color-border);
}

#players-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.player-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-amber);
}

.player-item.is-me {
  background: var(--color-bg-secondary);
  border-left-color: var(--color-electric);
}

.player-color {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background-image: url('/assets/icons/transparent_background/player/meeple_marker_icon.webp');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}

.host-badge {
  display: inline-block;
  background: linear-gradient(135deg, #ffd700 0%, #ffb800 100%);
  color: #1a1a1a;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  margin-left: 0.5rem;
}

.host-name {
  color: var(--color-amber);
  font-weight: 600;
}

/* Color Picker in Lobby */
.color-picker-section {
  margin-top: var(--space-xl);
  text-align: center;
}

.color-picker-section h3 {
  margin-bottom: var(--space-md);
  font-size: 1rem;
  color: var(--color-text-secondary);
}

.color-palette {
  display: flex;
  justify-content: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.color-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.color-btn:hover:not(.taken):not(.selected) {
  transform: scale(1.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-btn.selected {
  border-color: var(--color-electric);
  box-shadow: 0 0 0 2px var(--color-bg-primary), 0 0 12px var(--color-electric);
  transform: scale(1.15);
}

.color-btn.taken {
  opacity: 0.4;
  cursor: not-allowed;
}

.color-btn.taken::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* --- Lobby Buttons --- */
.lobby-buttons {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  margin-top: var(--space-lg);
}

.lobby-buttons button {
  flex: 0 0 220px;
  height: 48px;
  padding: 0 var(--space-lg);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent !important;
  margin: 0;
}

.lobby-buttons #leave-lobby-btn {
  background: transparent;
  border-color: var(--color-border) !important;
  color: var(--color-text-secondary);
}

.lobby-buttons #leave-lobby-btn:hover {
  background: rgba(244, 67, 54, 0.1);
  border-color: var(--color-danger) !important;
  color: var(--color-danger);
}

/* --- Game Screen --- */
.game-header {
  background: var(--color-bg-secondary);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

.game-header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent,
    var(--color-amber) 20%,
    var(--color-amber) 80%,
    transparent
  );
}

.game-title h1 {
  font-size: 1.25rem;
  color: var(--color-text-primary);
  text-shadow: none;
  margin: 0;
  letter-spacing: 2px;
}

.game-title h1::before {
  content: '>';
  color: var(--color-amber);
}

/* Game Header Right - groups trackers and controls on the right */
.game-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  margin-left: auto;
}

.game-status {
  display: flex;
  gap: var(--space-xl);
  font-size: 0.9rem;
  font-family: var(--font-mono);
}

.game-status span {
  color: var(--color-text-muted);
}

.game-status strong {
  color: var(--color-electric);
}

/* Debug View Selector */
.debug-view-selector {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.4rem 0.8rem;
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.15), rgba(230, 126, 34, 0.1));
  border: 1px solid rgba(243, 156, 18, 0.3);
  border-radius: var(--radius-md);
  margin-right: var(--space-md);
}

.debug-view-selector label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.debug-view-selector select {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  font-family: var(--font-primary);
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-width: 150px;
}

.debug-view-selector select:hover {
  border-color: var(--color-amber);
}

.debug-view-selector select:focus {
  outline: none;
  border-color: var(--color-amber);
  box-shadow: 0 0 0 2px rgba(243, 156, 18, 0.2);
}

/* Game Controls (Leave/End Game) */
.game-controls {
  display: flex;
  gap: var(--space-sm);
}

.game-control-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.game-control-btn.leave-btn {
  background: var(--color-surface);
  color: var(--color-text-secondary);
  border-color: var(--color-border);
}

.game-control-btn.leave-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
  border-color: var(--color-amber);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(243, 156, 18, 0.2);
}

.game-control-btn.end-btn {
  background: linear-gradient(135deg, var(--color-danger), var(--color-danger-emphasis));
  color: white;
  border-color: transparent;
}

.game-control-btn.end-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(231, 76, 60, 0.4);
}

/* Status Tracker Tooltips */
.status-tracker {
  position: relative;
  cursor: help;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.status-tracker:hover {
  background: var(--color-surface-hover);
}

.tracker-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  padding-top: var(--space-sm);
  width: 400px;
  z-index: 100;
}

.tracker-tooltip::before {
  content: '';
  display: block;
  height: var(--space-sm);
}

.tracker-tooltip-content {
  max-height: 350px;
  overflow-y: auto;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border-emphasis);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-lg);
  font-size: 1rem;
  line-height: 1.5;
  text-align: left;
}

.status-tracker:hover .tracker-tooltip {
  display: block;
}

.tracker-tooltip-content > strong {
  display: block;
  color: var(--color-electric);
  font-size: 1.125rem;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
}

.tracker-tooltip-content p {
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-sm) 0;
}

.tracker-tooltip-content p:last-child {
  margin-bottom: 0;
}

.tracker-tooltip-content em {
  color: var(--color-amber);
  font-style: normal;
  font-weight: 600;
}

/* Endgame tracker specific styles */
.endgame-indicator {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.endgame-indicator.warning {
  background: rgba(243, 156, 18, 0.15);
  border-color: var(--color-amber);
  animation: pulse-warning 2s ease-in-out infinite;
}

.endgame-indicator.triggered {
  background: rgba(46, 160, 67, 0.2);
  border-color: var(--color-success);
  animation: pulse-triggered 1s ease-in-out infinite;
}

@keyframes pulse-warning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes pulse-triggered {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(46, 160, 67, 0.4);
  }
  50% {
    opacity: 0.9;
    box-shadow: 0 0 8px 2px rgba(46, 160, 67, 0.3);
  }
}

/* --- Game Content Layout --- */
.game-content {
  display: grid;
  grid-template-columns: 1fr 2.4fr 1fr;
  gap: var(--space-md);
  padding: var(--space-md);
  max-height: calc(100vh - 120px);
  background: var(--color-bg-primary);
}

.left-panel, .center-panel, .right-panel {
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  overflow-y: auto;
  border: 1px solid var(--color-border);
  min-width: 0;
}

.left-panel, .right-panel {
  display: flex;
  flex-direction: column;
}

.center-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* During auction phase, show Power Plant Market above Map */
.center-panel.auction-phase {
  flex-direction: column-reverse;
  justify-content: flex-end; /* Push items to visual top when reversed */
}

.center-panel-top {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.center-panel-bottom {
  flex: 0 0 auto;
  margin-top: var(--space-md);
}

/* Adjust margins when order is reversed */
.center-panel.auction-phase .center-panel-bottom {
  margin-top: 0;
  margin-bottom: var(--space-md);
}

/* --- Panel Drag-and-Drop --- */
.panel-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs) 0;
  margin: calc(-1 * var(--space-md)) calc(-1 * var(--space-md)) var(--space-sm) calc(-1 * var(--space-md));
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
  cursor: grab;
  user-select: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.panel-drag-handle:hover {
  background: var(--color-surface-hover);
  box-shadow: inset 0 0 0 1px var(--color-amber);
}

.panel-drag-handle:active {
  cursor: grabbing;
}

.drag-grip {
  color: var(--color-text-muted);
  font-size: 14px;
  letter-spacing: 2px;
  font-weight: bold;
}

.panel-drag-handle:hover .drag-grip {
  color: var(--color-text-secondary);
}

/* Dragging state */
.left-panel.dragging,
.center-panel.dragging,
.right-panel.dragging {
  opacity: 0.6;
  border: 2px dashed var(--color-amber);
  transform: scale(0.98);
  z-index: 100;
}

/* Drop target indicator */
.left-panel.drag-over,
.center-panel.drag-over,
.right-panel.drag-over {
  border: 2px solid var(--color-electric);
  box-shadow: 0 0 20px rgba(255, 217, 61, 0.3);
}

/* Drop position indicators */
.left-panel.drop-left::before,
.center-panel.drop-left::before,
.right-panel.drop-left::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--color-electric);
  border-radius: 2px;
  z-index: 10;
}

.left-panel.drop-right::after,
.center-panel.drop-right::after,
.right-panel.drop-right::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--color-electric);
  border-radius: 2px;
  z-index: 10;
}

/* Make panels position relative for drop indicators */
.left-panel,
.center-panel,
.right-panel {
  position: relative;
}

/* --- Power Plant Market --- */
.market-section {
  margin-bottom: var(--space-xl);
}

.plant-market {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.retry-market-btn {
  width: 100%;
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-danger, #dc3545);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.retry-market-btn:hover {
  background: #c82333;
  transform: translateY(-1px);
}

.retry-market-btn:active {
  transform: translateY(0);
}

.plant-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

/* Step 3 market - 6 plants in one row (or 3x2 on smaller screens) */
.plant-grid.step3-market {
  grid-template-columns: repeat(6, 1fr);
}

@media (max-width: 1200px) {
  .plant-grid.step3-market {
    grid-template-columns: repeat(3, 1fr);
  }
}

.power-plant-card {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-xs);
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--color-bg-tertiary);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.power-plant-card:hover {
  transform: translateY(-6px) scale(1.05);
  box-shadow: var(--shadow-lg), 0 0 20px rgba(243, 156, 18, 0.2);
  border-color: var(--color-amber);
  z-index: 10;
}

.power-plant-card.discount {
  position: relative;
  overflow: visible;
}

.power-plant-card.discount:hover {
  z-index: 100;
}

.discount-wrapper {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 5;
  cursor: help;
}

.discount-icon {
  width: 110px;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  transition: transform 0.15s ease;
}

.discount-wrapper:hover .discount-icon {
  transform: scale(1.05);
}

.discount-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  padding-top: var(--space-sm);
  width: 260px;
  z-index: 100;
}

.discount-wrapper:hover .discount-tooltip {
  display: block;
}

.discount-tooltip-content {
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border-emphasis);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: left;
}

.discount-tooltip-content strong {
  display: block;
  color: var(--color-electric);
  font-size: 0.9rem;
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--color-border);
}

.discount-tooltip-content p {
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-sm) 0;
}

.discount-tooltip-content p:last-child {
  margin-bottom: 0;
}

.discount-tooltip-content em {
  color: var(--color-amber);
  font-style: normal;
  font-weight: 600;
}

/* Discount token overlay for auction/detail modals */
.discount-overlay-wrapper {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  cursor: help;
}

.discount-overlay-icon {
  width: 80px;
  height: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  transition: transform 0.15s ease;
}

.discount-overlay-wrapper:hover .discount-overlay-icon {
  transform: scale(1.05);
}

.discount-overlay-tooltip {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  padding-top: var(--space-sm);
  width: 220px;
  z-index: 100;
}

.discount-overlay-wrapper:hover .discount-overlay-tooltip {
  display: block;
}

.plant-card-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

/* --- Resource Market --- */
.resource-market {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.resource-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.resource-label {
  width: 90px;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-weight: 700;
  text-align: center;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.resource-label.coal {
  background: var(--color-coal);
  border-left: 3px solid #8b7355;
}
.resource-label.oil {
  background: var(--color-oil);
  border-left: 3px solid #333;
}
.resource-label.garbage {
  background: var(--color-garbage);
  border-left: 3px solid #ff9500;
}
.resource-label.uranium {
  background: var(--color-uranium);
  border-left: 3px solid #cc0000;
}

.resource-spaces {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.resource-token {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

.resource-token.coal { background-image: url('/assets/icons/transparent_background/resources/coal-brown-removebg-preview-nohexagon.webp'); }
.resource-token.oil { background-image: url('/assets/icons/transparent_background/resources/oil-removebg-preview-nohexagon.webp'); }
.resource-token.garbage { background-image: url('/assets/icons/transparent_background/resources/garbage-removebg-preview-nohexagon.webp'); }
.resource-token.uranium { background-image: url('/assets/icons/transparent_background/resources/uranium-removebg-preview-nohexagon.webp'); }

/* SVG Resource Market tokens */
.resource-token-svg {
  cursor: pointer;
  transition: all 0.2s;
}

.resource-token-svg:hover {
  r: 10;
  filter: brightness(1.2);
}

/* --- Map Container --- */
.map-container {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  box-sizing: border-box;
}

.map-resize-wrapper {
  position: relative;
  display: inline-block;
}

.map-resize-handle {
  position: absolute;
  bottom: -8px;
  right: -8px;
  width: 16px;
  height: 16px;
  background: var(--color-amber);
  border: 2px solid var(--color-bg-secondary);
  border-radius: var(--radius-sm);
  cursor: nwse-resize;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.map-resize-handle:hover {
  background: var(--color-electric);
  transform: scale(1.2);
}

.map-resize-handle::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--color-bg-secondary);
  border-bottom: 2px solid var(--color-bg-secondary);
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.map-header h2 {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.map-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.map-controls label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.map-controls select {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
  cursor: pointer;
}

.map-controls select:hover {
  border-color: var(--color-border-emphasis);
}

.map-controls select:focus {
  outline: none;
  border-color: var(--color-amber);
}

/* --- Map Dropdown Styles --- */
.map-style-dropdown,
.map-visuals-dropdown {
  position: relative;
}

.map-visuals-dropdown {
  margin-left: var(--space-md);
}

.dropdown-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.dropdown-toggle:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-emphasis);
}

.dropdown-arrow {
  font-size: 0.6rem;
  transition: transform 0.2s;
}

.map-style-dropdown.open .dropdown-arrow,
.map-visuals-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-xs);
  padding: var(--space-sm);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  min-width: 250px;
}

.map-style-dropdown.open .dropdown-menu,
.map-visuals-dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-menu label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.dropdown-menu label:hover {
  background: var(--color-surface-hover);
}

.dropdown-menu input[type="checkbox"],
.dropdown-menu input[type="radio"] {
  cursor: pointer;
  accent-color: var(--color-amber);
}

/* #game-map is the SVG element itself */
#game-map {
  background: var(--color-bg-tertiary);
  box-shadow: var(--shadow-md);
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  flex: 1;
  width: 100%;
  height: auto;
  min-height: 0;
}

.map-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Inactive Discount Token (positioned based on YAML unused_state_map_location) */
.inactive-discount-token {
  position: absolute;
  /* Default fallback position - overridden by JS with YAML coordinates */
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  cursor: help;
  z-index: 10;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  opacity: 0.9;
  transition: opacity 0.2s;
}

.inactive-discount-token:hover {
  opacity: 1;
}

.inactive-discount-token img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.inactive-discount-token.hidden {
  display: none;
}

.inactive-discount-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-bottom: var(--space-sm);
  width: 260px;
  z-index: 100;
}

.inactive-discount-token:hover .inactive-discount-tooltip {
  display: block;
}

/* SVG-based inactive discount token */
.inactive-discount-token-svg {
  opacity: 0.9;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
  transition: opacity 0.2s;
}

.inactive-discount-token-svg:hover {
  opacity: 1;
}

.inactive-discount-token-svg .inactive-discount-tooltip-fo {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.inactive-discount-token-svg:hover .inactive-discount-tooltip-fo {
  opacity: 1;
}

/* --- City Styling --- */
.city-icon {
  cursor: pointer;
  transition: all 0.2s;
  transform-origin: center;
  transform-box: fill-box;
}

.city-node:hover .city-icon {
  transform: scale(1.2);
  filter: brightness(1.2) drop-shadow(0 0 8px rgba(243, 156, 18, 0.8));
}

.city-node:hover rect {
  filter: brightness(1.2) drop-shadow(0 0 4px rgba(243, 156, 18, 0.6));
  transform: scale(1.1);
  transform-origin: center;
  transform-box: fill-box;
}

.city-label {
  font-size: 14px;
  font-weight: bold;
  fill: #000;
  pointer-events: none;
  text-anchor: middle;
  user-select: none;
  stroke: white;
  stroke-width: 3px;
  paint-order: stroke fill;
}

.city-label.steampunk {
  font-family: 'Telegraph Operator', 'Courier New', monospace;
}

/* "NOT IN PLAY" label for non-selected regions */
.not-in-play-label {
  font-size: 28px;
  font-weight: bold;
  fill: #c0392b;
  pointer-events: none;
  text-anchor: middle;
  user-select: none;
  stroke: white;
  stroke-width: 4px;
  paint-order: stroke fill;
  opacity: 0.9;
}

/* --- Connection Lines --- */
.connection-line {
  stroke: #000;
  stroke-width: 8;
  stroke-dasharray: 8, 8;
  opacity: 0.7;
}

.connection-cost {
  font-size: 12px;
  font-weight: bold;
  fill: #d00;
  pointer-events: auto;
  text-anchor: middle;
  user-select: none;
  stroke: white;
  stroke-width: 3px;
  paint-order: stroke fill;
  cursor: pointer;
  transition: transform 0.15s ease, font-size 0.15s ease;
}

.connection-cost:hover {
  font-size: 16px;
  stroke-width: 4px;
}

/* --- Right Panel --- */
.panel-section {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.panel-section:last-child {
  border-bottom: none;
}

#player-order-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.player-order-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  font-size: 0.85rem;
}

.player-order-item.active {
  background: rgba(35, 134, 54, 0.15);
  border-left-color: var(--color-success);
}

/* Player Order Header Row */
.player-order-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-sm);
}

.player-order-left {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  min-width: 0;
  flex: 1;
}

.player-order-position {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  min-width: 16px;
  padding-top: 2px;
}

.player-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

.player-name-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-order-item .player-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-order-item .player-tagline {
  font-size: 0.7rem;
  font-style: italic;
  color: var(--color-text-muted);
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Shot Clock Timer */
.shot-clock-timer {
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  margin-left: 8px;
  white-space: nowrap;
}

.shot-clock-timer.warning {
  background: var(--color-warning);
  color: #000;
}

.shot-clock-timer.danger {
  background: var(--color-danger);
  color: #fff;
  animation: pulse-danger 1s ease-in-out infinite;
}

@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Player Status Badges */
.player-status-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.player-status-badge.bought-plant {
  background: rgba(180, 130, 255, 0.25);
  color: #c9a0ff;
}

.player-status-badge.bought-resources {
  background: rgba(0, 210, 210, 0.25);
  color: #00e5e5;
}

.player-status-badge.built-city {
  background: rgba(70, 140, 255, 0.25);
  color: #6ba3ff;
}

.player-status-badge.done {
  background: rgba(35, 134, 54, 0.3);
  color: var(--color-success-emphasis);
}

.player-status-badge.passed {
  background: rgba(139, 148, 158, 0.3);
  color: var(--color-text-muted);
}

.player-status-badge.in-progress {
  background: rgba(227, 179, 65, 0.25);
  color: #f0c040;
}

/* Player Order Details Row */
.player-order-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-left: 24px; /* Align with name after position number */
}

/* Power Plant Slots */
.player-plants-row {
  display: flex;
  gap: var(--space-xs);
}

.plant-slot {
  flex: 1;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--color-bg-secondary);
  border: 1px dashed var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.plant-slot.filled {
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  padding: 0;
  overflow: hidden;
}

.plant-slot.filled:hover {
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.plant-slot.filled img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.plant-slot.empty .plant-slot-number {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

/* Inventory Row (houses + resources) */
.player-inventory-row {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  align-items: center;
}

/* Inventory Items (money, houses) */
.inventory-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  padding: 2px 6px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
}

.inventory-emoji {
  font-size: 0.85rem;
  line-height: 1;
}

.inventory-amount {
  font-weight: 500;
}

/* Resource Display */
.resource-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  padding: 2px 6px;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
}

.resource-count .resource-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.resource-count .resource-amount {
  font-weight: 500;
}

.resource-count.over-capacity {
  color: var(--color-danger-emphasis);
  background: rgba(218, 54, 51, 0.15);
}

.resource-count.over-capacity .resource-amount {
  font-weight: 700;
}

/* --- Game Log --- */
#log-content {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  min-height: 100px;
  max-height: 600px;
  height: 300px;
  overflow-y: auto;
  background: var(--color-bg-tertiary);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  resize: vertical;
}

.log-entry {
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-timestamp {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  margin-right: 0.5rem;
}

/* --- Modal --- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--color-bg-secondary);
  padding: var(--space-xl);
  border-radius: var(--radius-md);
  max-width: 500px;
  width: 90%;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(243, 156, 18, 0.1);
  position: relative;
}

.modal-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-amber), var(--color-electric));
}

.modal-content h2 {
  color: var(--color-text-primary);
  border-bottom: none;
  font-size: 1rem;
  margin-bottom: var(--space-lg);
}

/* Step 3 Transition Modal */
.step3-modal {
  text-align: center;
  max-width: 400px;
}

.step3-card-image {
  max-width: 180px;
  margin-bottom: var(--space-md);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

.step3-modal h2 {
  color: var(--color-electric);
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

.step3-description {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
}

.step3-changes {
  text-align: left;
  margin: 0 auto var(--space-lg);
  padding-left: var(--space-lg);
  max-width: 300px;
}

.step3-changes li {
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
  line-height: 1.4;
}

.step3-changes li::marker {
  color: var(--color-amber);
}

/* Game Over Modal */
.game-over-modal .modal-content {
  max-width: 1400px;
  width: 98%;
}

.game-over-content {
  text-align: center;
}

.game-over-title {
  color: var(--color-electric);
  font-size: 1.75rem;
  margin-bottom: var(--space-lg);
}

.game-over-winner {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.12), rgba(255, 215, 0, 0.03));
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.game-over-winner h3 {
  color: gold;
  font-size: 1.25rem;
  margin-bottom: var(--space-xs);
  font-weight: 600;
}

.game-over-winner .winner-name {
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: var(--space-xs);
}

.game-over-winner .winner-stats {
  color: var(--color-text-secondary);
  font-size: 1rem;
}

.game-over-standings {
  text-align: left;
  overflow-x: auto;
}

.game-over-standings h4 {
  color: var(--color-text-primary);
  font-size: 1rem;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.standings-table th,
.standings-table td {
  padding: var(--space-xs) var(--space-sm);
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}

.standings-table th {
  color: var(--color-text-secondary);
  font-weight: 600;
  font-size: 0.7rem;
  white-space: nowrap;
}

.standings-table td {
  color: var(--color-text-primary);
}

.standings-table tr:last-child td {
  border-bottom: none;
}

.standings-table tbody tr:hover {
  background: var(--color-bg-tertiary);
}

.standings-rank {
  font-size: 1.1rem;
  width: 30px;
  text-align: center;
}

.standings-rank.first {
  color: gold;
}

.standings-rank.second {
  color: silver;
}

.standings-rank.third {
  color: #cd7f32;
}

.standings-player {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 4px 0;
}

.standings-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
  margin-top: 3px;
}

.standings-name {
  font-weight: 600;
  white-space: nowrap;
}

.standings-name-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.standings-quip {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--color-text-secondary);
  min-width: 280px;
  text-align: left;
}

.standings-time {
  font-family: var(--font-mono);
  font-weight: 600;
  text-align: center;
  color: var(--color-electric);
}

.standings-powered,
.standings-built,
.standings-money {
  text-align: center;
  font-weight: 600;
}

.standings-resources {
  display: inline-flex;
  justify-content: center;
  gap: 3px;
  flex-wrap: nowrap;
}

.standings-resource {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 1.1rem;
  padding: 3px 6px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
}

.standings-resource img {
  width: 15px;
  height: 15px;
}

.standings-plants {
  display: inline-flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.standings-plant {
  font-size: 0.75rem;
  padding: 2px 5px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
}

.standings-plant-img {
  width: 32px;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.2s ease;
  cursor: pointer;
}

.standings-plant-img:hover {
  transform: scale(2);
  z-index: 10;
  position: relative;
}

.standings-spent {
  text-align: center;
  font-weight: 600;
}

.game-over-buttons {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.game-over-buttons .primary-btn,
.game-over-buttons .secondary-btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  width: 220px;
  height: 48px;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  margin-top: 0;
}

.game-over-buttons .secondary-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.game-over-buttons .secondary-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-emphasis);
  color: var(--color-text-primary);
}

.auction-controls {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-md);
}

.auction-info {
  background: var(--color-bg-tertiary);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  margin: var(--space-md) 0;
  border-left: 3px solid var(--color-amber);
  font-family: var(--font-mono);
}

.auction-info strong {
  color: var(--color-electric);
}

/* --- Sidepanel Auction (Active Auction in Actions Panel) --- */
/* Wrapper to contain the auction overlay styles in the sidepanel */
.sidepanel-auction-wrapper {
  background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg-tertiary) 100%);
  border-radius: var(--radius-md);
  overflow: hidden; /* Clip the header gradient to border radius */
}

/* Header keeps original gradient styling, just adjusted padding */
.sidepanel-auction-wrapper .auction-overlay-header {
  padding: var(--space-sm) var(--space-md);
  padding-right: var(--space-md); /* No need for close button space */
  margin: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

/* Body content needs padding since wrapper doesn't have it */
.sidepanel-auction-wrapper .auction-overlay-body {
  padding: var(--space-md);
  flex-direction: column;
  align-items: center;
}

/* Adjust plant showcase for sidepanel (slightly smaller) */
.sidepanel-auction-wrapper .auction-plant-showcase {
  padding: var(--space-sm);
  flex: none;
}

.sidepanel-auction-wrapper .auction-plant-image {
  width: 100%;
  max-width: 100%;
  height: auto;
  position: relative;
}

.sidepanel-auction-wrapper .auction-plant-image img {
  width: 100%;
  max-width: 100%;
}

/* Discount token overlay in sidepanel - proportional to image size */
.sidepanel-auction-wrapper .auction-plant-image .discount-overlay-wrapper {
  top: 8px;
  right: 8px;
}

.sidepanel-auction-wrapper .auction-plant-image .discount-overlay-icon {
  width: 95px;
}

.sidepanel-auction-wrapper .overlay-plant-flavor-text {
  max-width: 100%;
  width: 100%;
}

/* Make bid info more compact in sidepanel */
.sidepanel-auction-wrapper .auction-bid-info {
  width: 100%;
  padding: var(--space-sm) 0;
}

.sidepanel-auction-wrapper .bid-info-row {
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
}

/* Auction controls styling */
.sidepanel-auction-wrapper .auction-overlay-controls {
  padding: var(--space-md);
  padding-top: 0;
}

.sidepanel-auction-wrapper .bid-input-group {
  margin-bottom: var(--space-sm);
}

.sidepanel-auction-wrapper .auction-buttons {
  gap: var(--space-sm);
}

.sidepanel-auction-wrapper .auction-btn {
  padding: 10px 16px;
  font-size: var(--text-sm);
}

/* Waiting message styling */
.sidepanel-auction-wrapper .auction-waiting-message {
  padding: var(--space-md);
}

/* --- Sidepanel Scrap Selection (Replace Power Plant) --- */
.sidepanel-scrap-wrapper {
  background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg-tertiary) 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.sidepanel-scrap-wrapper .auction-overlay-header {
  background: linear-gradient(90deg, var(--color-danger), #c0392b);
  padding: var(--space-md) var(--space-lg);
}

.sidepanel-scrap-wrapper .auction-overlay-header h2 {
  color: #fff;
  margin: 0;
  font-size: 1rem;
}

.sidepanel-scrap-wrapper .auction-overlay-body {
  padding: var(--space-md);
  padding-bottom: var(--space-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* Green highlighted title for won plant */
.scrap-won-title {
  background: rgba(35, 134, 54, 0.15);
  border: 1px solid var(--color-success);
  border-radius: var(--radius-md);
  padding: var(--space-xs) var(--space-md);
  margin-bottom: 0;
  text-align: center;
  color: var(--color-success-emphasis);
  font-weight: 600;
  font-size: 0.9rem;
  width: 100%;
}

/* Use same auction plant image styles */
.sidepanel-scrap-wrapper .auction-plant-showcase {
  padding: 0;
  flex: none;
  gap: var(--space-xs);
}

.sidepanel-scrap-wrapper .auction-plant-image {
  width: 100%;
  max-width: 100%;
  height: auto;
}

.sidepanel-scrap-wrapper .auction-plant-image img {
  width: 100%;
  max-width: 100%;
}

.sidepanel-scrap-wrapper .overlay-plant-flavor-text {
  max-width: 100%;
  width: 100%;
}

.scrap-options-section {
  width: 100%;
  margin-top: var(--space-sm);
}

.scrap-options-section h3 {
  margin: 0 0 var(--space-xs) 0;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: center;
}

.sidepanel-scrap-wrapper .scrap-options-list {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: var(--space-sm);
}

.sidepanel-scrap-wrapper .scrap-option {
  flex: 1;
  max-width: 33%;
  padding: var(--space-xs);
  background: var(--color-bg-tertiary);
  border: 3px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.sidepanel-scrap-wrapper .scrap-option:hover {
  border-color: var(--color-border-emphasis);
  background: var(--color-surface-hover);
}

.sidepanel-scrap-wrapper .scrap-option.selected {
  border-color: var(--color-danger);
  background: rgba(218, 54, 51, 0.15);
  box-shadow: 0 0 8px rgba(218, 54, 51, 0.4);
}

.sidepanel-scrap-wrapper .scrap-option img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  display: block;
}

.scrap-sidepanel-buttons {
  padding: var(--space-md);
  padding-top: var(--space-sm);
}

.scrap-sidepanel-buttons .auction-btn {
  width: 100%;
}

.scrap-warning-inline {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  text-align: center;
  color: var(--color-danger-emphasis);
  font-size: 0.8rem;
  font-weight: 600;
}

.scrap-warning-inline.hidden {
  display: none;
}

/* --- Sidepanel City Build (Build Phase) --- */
.sidepanel-city-build-wrapper {
  background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg-tertiary) 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.sidepanel-city-build-wrapper .auction-overlay-header {
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(90deg, var(--color-success), #1a8a3c);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.sidepanel-city-build-wrapper .auction-overlay-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #fff;
  border: none;
  padding: 0;
}

.city-build-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  padding-bottom: 0;
}

.city-build-icon-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}

.city-build-icon {
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.city-build-houses {
  display: flex;
  gap: 6px;
  position: absolute;
  bottom: -50px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg-panel);
  padding: 5px 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 1;
}

/* Smaller house slots for sidepanel */
.city-build-houses .city-click-house-slot {
  width: 40px;
  height: 40px;
}

.city-build-houses .city-click-house {
  width: 32px;
  height: 32px;
}

.city-build-houses .city-click-slot-cost {
  font-size: 0.75rem;
}

.city-build-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  margin-top: 3rem;
}

.city-build-title h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.city-build-flavor {
  font-style: italic;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  text-align: center;
  padding: 0 var(--space-md);
  margin: var(--space-xs) 0;
}

.city-build-connections {
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-xs);
}

.city-build-connections h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-xs) 0;
}

.city-build-connections .city-connections-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.inline-connection-chip {
  cursor: pointer;
  transition: all 0.15s;
}

.inline-connection-chip:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-amber);
}

.city-build-status {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.85rem;
  color: var(--color-warning);
  text-align: center;
}

.city-build-status:empty {
  display: none;
}

.city-build-cost-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-sm) var(--space-md);
}

.city-build-cost-section .cost-row {
  display: flex;
  align-items: center;
  padding: 0.35rem 0;
  gap: 0.5rem;
}

.city-build-cost-section .cost-row .cost-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.city-build-cost-section .cost-row .cost-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-primary);
  min-width: 35px;
  text-align: right;
}

.city-build-cost-section .cost-row .cost-currency {
  color: var(--color-text-muted);
  min-width: 24px;
}

.city-build-cost-section .cost-row .zone-badge {
  margin-left: 0.25rem;
}

.city-build-cost-section .cost-row.total {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-xs);
  padding-top: var(--space-sm);
}

.city-build-cost-section .cost-row.total .cost-value {
  font-size: 1rem;
  color: var(--color-amber);
}

.city-build-cost-section .cost-row.remaining .cost-value {
  color: var(--color-success);
}

.city-build-cost-section .cost-row.remaining .cost-value.negative {
  color: var(--color-danger);
}

.city-build-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
}

.city-build-buttons .primary-btn,
.city-build-buttons .secondary-btn,
.city-build-buttons .danger-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.city-build-buttons .primary-btn {
  background: linear-gradient(135deg, var(--color-success) 0%, #1a8a3c 100%);
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(46, 160, 67, 0.3);
}

.city-build-buttons .primary-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(46, 160, 67, 0.4);
}

.city-build-buttons .primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.city-build-buttons .secondary-btn {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.city-build-buttons .secondary-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-secondary);
}

.city-build-buttons .danger-btn {
  background: linear-gradient(135deg, var(--color-danger) 0%, #a82a2a 100%);
  color: #fff;
  border: none;
}

.city-build-buttons .danger-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #e04444 0%, var(--color-danger) 100%);
}

.city-build-buttons .danger-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Sidepanel Power Cities (Bureaucracy Phase) --- */
.sidepanel-power-cities-wrapper {
  background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg-tertiary) 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.sidepanel-power-cities-wrapper .power-header {
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(90deg, #9b59b6, #8e44ad);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidepanel-power-cities-wrapper .power-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #fff;
  border: none;
  padding: 0;
}

.power-cities-body {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.power-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.power-summary-row .power-value {
  font-weight: 700;
  color: var(--color-electric);
}

.power-plant-selection-inline {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.no-plants-message {
  color: var(--color-text-muted);
  font-style: italic;
  text-align: center;
  padding: var(--space-md);
}

.power-plant-option {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  transition: all 0.2s;
}

.power-plant-option:hover:not(.disabled) {
  border-color: var(--color-electric);
  background: var(--color-surface-hover);
}

.power-plant-option.disabled {
  opacity: 0.5;
  background: var(--color-bg-tertiary);
}

.power-plant-option label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.power-plant-option.disabled label {
  cursor: not-allowed;
}

.inline-power-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--color-electric);
  cursor: pointer;
}

.inline-power-checkbox:disabled {
  cursor: not-allowed;
}

.plant-option-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
}

.plant-option-image {
  width: 50px;
  height: 50px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--color-bg-tertiary);
}

.plant-option-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.plant-option-details .plant-number {
  font-weight: 700;
  color: var(--color-text-primary);
  font-size: 0.95rem;
}

.plant-option-details .plant-cities {
  font-size: 0.85rem;
  color: var(--color-success);
}

.plant-option-details .plant-resources {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

/* Hybrid resource selector controls */
.hybrid-resource-selector {
  margin-top: var(--space-sm);
  padding: var(--space-sm);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.hybrid-label {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.hybrid-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.hybrid-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.hybrid-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-electric);
}

.hybrid-amount {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 40px;
  justify-content: center;
}

.hybrid-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.hybrid-coal-value,
.hybrid-oil-value {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-text-primary);
}

.hybrid-separator {
  color: var(--color-text-muted);
  margin: 0 4px;
}

/* Power calculation section */
.power-calculation-inline {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
}

.power-calc-row {
  display: flex;
  align-items: center;
  padding: 0.35rem 0;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.power-calc-row span:first-child {
  flex: 1;
  color: var(--color-text-secondary);
}

.power-calc-row .power-value {
  font-weight: 700;
  color: var(--color-text-primary);
  min-width: 24px;
  text-align: right;
}

.power-calc-row .power-value.highlight {
  color: var(--color-electric);
  font-size: 1rem;
}

.power-calc-row.earnings {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-xs);
  padding-top: var(--space-sm);
}

.power-calc-row .earnings-value {
  color: var(--color-amber);
  font-size: 1.1rem;
}

/* Power cities buttons */
.power-cities-buttons {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.power-cities-buttons .primary-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(155, 89, 182, 0.3);
  transition: all 0.2s;
}

.power-cities-buttons .primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(155, 89, 182, 0.4);
}

/* --- Sidepanel Resource Market (Buy Resources Phase) --- */
.sidepanel-resource-wrapper {
  background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg-tertiary) 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.resource-market-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: linear-gradient(90deg, var(--color-amber), var(--color-warning));
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.resource-market-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #000;
  border: none;
  padding: 0;
}

.resource-status-badge {
  background: rgba(0, 0, 0, 0.2);
  color: #000;
  padding: var(--space-xs) var(--space-md);
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 600;
}

.resource-market-body {
  padding: var(--space-md);
}

.sidepanel-resource-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sidepanel-resource-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.sidepanel-resource-row.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.sidepanel-resource-row .resource-info {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sidepanel-resource-row .resource-info .resource-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.sidepanel-resource-row .resource-info .resource-name {
  font-weight: 600;
  color: var(--color-text);
  font-size: var(--text-sm);
}

.sidepanel-resource-row .resource-market-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.7rem;
}

.sidepanel-resource-row .resource-availability,
.sidepanel-resource-row .resource-unit-price {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.sidepanel-resource-row .available-label,
.sidepanel-resource-row .unit-label {
  color: var(--color-text-muted);
}

.sidepanel-resource-row .available-count {
  font-weight: 700;
  color: var(--color-text);
}

.sidepanel-resource-row .unit-value {
  font-weight: 700;
  color: var(--color-amber);
}

.sidepanel-resource-row .resource-input-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.sidepanel-resource-row .resource-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.sidepanel-resource-row .resource-btn:hover:not(:disabled) {
  background: var(--color-amber);
  color: #000;
  border-color: var(--color-amber);
}

.sidepanel-resource-row .resource-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.sidepanel-resource-row .resource-amount {
  width: 28px;
  text-align: center;
  padding: 0.1rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

.sidepanel-resource-row .resource-cost {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  font-weight: 600;
  min-width: 50px;
}

.sidepanel-resource-row .cost-value {
  color: var(--color-amber);
  font-size: 0.95rem;
}

.sidepanel-resource-row .cost-currency {
  font-size: 0.85rem;
}

.sidepanel-resource-summary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.sidepanel-resource-summary .summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  font-size: var(--text-sm);
}

.sidepanel-resource-summary .summary-label {
  color: var(--color-text-secondary);
}

.sidepanel-resource-summary .summary-value {
  font-weight: 600;
  color: var(--color-text);
}

.sidepanel-resource-summary .summary-row.total .summary-value {
  color: var(--color-amber);
  font-size: 1rem;
}

.sidepanel-resource-summary .summary-row.remaining .summary-value {
  color: var(--color-success);
}

.sidepanel-resource-buttons {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.sidepanel-resource-buttons .primary-btn,
.sidepanel-resource-buttons .secondary-btn {
  flex: 1;
  padding: 10px 16px;
  margin: 0;
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.sidepanel-resource-buttons .primary-btn {
  background: linear-gradient(135deg, var(--color-amber), #cd7f32);
  border: 1px solid transparent;
  color: #000;
}

.sidepanel-resource-buttons .primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(218, 165, 32, 0.4);
}

.sidepanel-resource-buttons .primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.sidepanel-resource-buttons .secondary-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.sidepanel-resource-buttons .secondary-btn:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

#sidepanel-resource-error {
  margin-bottom: 0.75rem;
}

/* --- Debug Controls --- */
.debug-section {
  margin-bottom: var(--space-md);
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-emphasis);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-amber);
}

/* --- Selection --- */
::selection {
  background: rgba(243, 156, 18, 0.3);
  color: var(--color-text-primary);
}

/* --- Focus States --- */
:focus-visible {
  outline: 2px solid var(--color-amber);
  outline-offset: 2px;
}

/* ============================================
   AUCTION BIDDING OVERLAY
   ============================================ */

.auction-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  border-radius: var(--radius-md);
}

.auction-overlay.hidden {
  display: none;
}

.auction-overlay-content {
  position: relative;
  background: linear-gradient(135deg, var(--color-bg-secondary) 0%, var(--color-bg-panel) 100%);
  border: 2px solid var(--color-amber);
  border-radius: var(--radius-lg);
  box-shadow:
    0 0 40px rgba(243, 156, 18, 0.3),
    0 20px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  max-width: 480px;
  width: 95%;
  overflow: hidden;
  animation: auctionSlideIn 0.3s ease-out;
}

.overlay-close-btn {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: rgba(0, 0, 0, 0.5);
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  transition: color 0.2s, transform 0.2s;
  z-index: 10;
}

.overlay-close-btn:hover {
  color: rgba(0, 0, 0, 0.8);
  transform: scale(1.1);
}

@keyframes auctionSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- Overlay Header --- */
.auction-overlay-header {
  background: linear-gradient(90deg, var(--color-amber), var(--color-warning));
  padding: var(--space-md) var(--space-lg);
  padding-right: calc(var(--space-lg) + 32px); /* Make room for close button */
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.auction-overlay-header h2 {
  color: #000;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0;
  border: none;
  padding: 0;
}

.auction-status-badge {
  background: rgba(0, 0, 0, 0.2);
  color: #000;
  padding: var(--space-xs) var(--space-md);
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- Overlay Body --- */
.auction-overlay-body {
  padding: var(--space-lg);
  display: flex;
  gap: var(--space-lg);
}

/* --- Plant Showcase --- */
.auction-plant-showcase {
  flex: 0 0 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.auction-plant-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-electric);
  font-weight: 600;
}

.auction-plant-image {
  position: relative;
  width: 140px;
  height: auto;
  border: 2px solid var(--color-border-emphasis);
  border-radius: var(--radius-md);
  background: var(--color-bg-tertiary);
  box-shadow: var(--shadow-md);
  overflow: visible;
}

.auction-plant-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* Smaller discount token for auction overlay */
.auction-plant-image .discount-overlay-wrapper {
  top: 4px;
  right: 4px;
}

.auction-plant-image .discount-overlay-icon {
  width: 35px;
}

.overlay-plant-flavor-text {
  font-style: italic;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  text-align: center;
  line-height: 1.3;
  padding: var(--space-xs) var(--space-sm);
  max-width: 160px;
}

/* --- Bid Info Section --- */
.auction-bid-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.bid-info-row {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-border);
}

.bid-info-row.waiting-for {
  border-left-color: var(--color-amber);
  background: rgba(243, 156, 18, 0.1);
}

.bid-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  flex: 0 0 100px;
}

.bid-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.bid-value.highlight {
  color: var(--color-electric);
}

.bid-currency {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-left: var(--space-xs);
}

/* --- Bidding Controls --- */
.auction-overlay-controls {
  padding: var(--space-lg);
  background: var(--color-bg-tertiary);
  border-top: 1px solid var(--color-border);
}

.your-turn-indicator {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-success-emphasis);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: var(--space-md);
  padding: var(--space-sm);
  background: rgba(46, 160, 67, 0.15);
  border-radius: var(--radius-sm);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.bid-input-group {
  margin-bottom: var(--space-md);
}

.bid-input-group label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-xs);
}

.bid-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.bid-input-wrapper input {
  flex: 1;
  margin: 0;
  font-size: 1.25rem;
  padding: var(--space-md);
  text-align: center;
}

.input-suffix {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.auction-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.auction-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auction-btn .btn-icon {
  font-size: 1.1rem;
}

.auction-btn.bid-btn {
  background: linear-gradient(135deg, var(--color-success) 0%, var(--color-success-emphasis) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(35, 134, 54, 0.3);
}

.auction-btn.bid-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(35, 134, 54, 0.4);
}

.auction-btn.pass-btn {
  background: linear-gradient(135deg, var(--color-danger) 0%, var(--color-danger-emphasis) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(218, 54, 51, 0.3);
}

.auction-btn.pass-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(218, 54, 51, 0.4);
}

/* --- Waiting Message --- */
.auction-waiting-message {
  padding: var(--space-xl);
  text-align: center;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
}

.auction-waiting-message.hidden {
  display: none;
}

.waiting-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-md);
  border: 3px solid var(--color-border);
  border-top-color: var(--color-amber);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.auction-waiting-message p {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.auction-waiting-message #overlay-waiting-player {
  color: var(--color-electric);
  font-weight: 600;
}

/* Make market section position relative for overlay positioning */
.market-section {
  position: relative;
}

/* ============================================
   SCRAP PLANT MODAL
   ============================================ */

/* Plant Detail Modal */
.plant-detail-modal-content {
  max-width: 400px;
  text-align: center;
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  line-height: 1;
  transition: color 0.2s;
}

.modal-close-btn:hover {
  color: var(--color-text-primary);
}

.plant-detail-image-container {
  position: relative;
  margin: var(--space-lg) 0;
}

.plant-detail-image-container img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.plant-detail-info {
  text-align: left;
  background: var(--color-bg-tertiary);
  padding: var(--space-md);
  border-radius: var(--radius-md);
}

.plant-detail-info p {
  margin: var(--space-xs) 0;
  font-size: 0.9rem;
}

.plant-detail-info strong {
  color: var(--color-electric);
}

.inline-resource-icon {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin: 0 2px;
}

.plant-detail-actions {
  margin-top: var(--space-md);
  text-align: center;
}

.plant-detail-actions .btn {
  min-width: 150px;
}

.auction-disabled-message {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-style: italic;
  margin: 0;
  padding: var(--space-sm);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  text-align: center;
}

.plant-detail-flavor-text {
  font-style: italic;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-sm) 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
  border-left: 3px solid var(--color-electric);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  text-align: left;
  line-height: 1.4;
}

/* Power Cities Modal (Phase 5 Bureaucracy) */
.power-cities-modal-content {
  max-width: 600px;
}

.power-cities-subtitle {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
}

.power-plant-selection {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  max-height: 300px;
  overflow-y: auto;
}

.power-plant-option {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm);
  transition: all 0.2s ease;
}

.power-plant-option:hover:not(.disabled) {
  border-color: var(--color-electric);
}

.power-plant-option.disabled {
  opacity: 0.5;
}

.power-plant-option label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.power-plant-option.disabled label {
  cursor: not-allowed;
}

.power-plant-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.plant-option-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex: 1;
}

.plant-option-image {
  width: 60px;
  height: auto;
  border-radius: var(--radius-sm);
}

.plant-option-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.plant-number {
  font-weight: bold;
  color: var(--color-electric);
}

.plant-cities {
  font-size: 0.9rem;
  color: var(--color-text-primary);
}

.plant-resources {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

/* Hybrid Resource Selector */
.hybrid-resource-selector {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  margin-left: 28px;
}

.hybrid-label {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.hybrid-controls {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.hybrid-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: bold;
  transition: all 0.15s;
}

.hybrid-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

.hybrid-btn:active {
  transform: scale(0.95);
}

.hybrid-amount {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 40px;
  justify-content: center;
}

.hybrid-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.hybrid-coal-value,
.hybrid-oil-value {
  font-weight: bold;
  font-size: 0.9rem;
  min-width: 16px;
  text-align: center;
}

.hybrid-separator {
  color: var(--color-text-muted);
  font-weight: bold;
  margin: 0 var(--space-md);
}

.power-summary {
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.power-summary-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--color-border);
}

.power-summary-row:last-child {
  border-bottom: none;
}

.power-summary-row.highlight {
  background: rgba(243, 156, 18, 0.1);
  margin: var(--space-xs) calc(-1 * var(--space-md));
  padding: var(--space-xs) var(--space-md);
}

.power-summary-row.earnings {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--color-electric);
}

.power-value {
  font-weight: bold;
}

.power-cities-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  align-items: stretch;
}

.power-cities-actions .btn {
  flex: 1;
  min-width: 120px;
  max-width: 180px;
  height: 48px;
  margin: 0;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Sidepanel Power Cities (Phase 5) */
.sidepanel-power-cities-wrapper {
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.sidepanel-power-cities-wrapper .power-cities-body {
  padding: var(--space-md);
  padding-bottom: var(--space-lg);
}

.sidepanel-power-cities-wrapper .power-cities-subtitle {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  font-size: 0.9rem;
  text-align: center;
}

.sidepanel-power-cities-wrapper .power-plant-selection-inline {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.sidepanel-power-cities-wrapper .power-summary {
  margin-bottom: var(--space-md);
}

.sidepanel-power-cities-wrapper .power-cities-buttons {
  display: flex;
  justify-content: center;
}

.sidepanel-power-cities-wrapper .power-cities-buttons .primary-btn {
  min-width: 200px;
}

/* Power queue mode buttons - side by side */
.sidepanel-power-cities-wrapper .power-cities-buttons.queue-actions {
  flex-direction: row;
  gap: var(--space-sm);
  flex-wrap: nowrap;
  padding-bottom: var(--space-sm);
}

.sidepanel-power-cities-wrapper .power-cities-buttons.queue-actions button {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  padding: 0.75rem 0.5rem;
}

.sidepanel-power-cities-wrapper .power-cities-buttons.queue-actions .primary-btn {
  min-width: 0;
}

/* Scrap Plant Modal */
.scrap-modal-content {
  max-width: 600px;
}

.scrap-modal-subtitle {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-lg);
  font-size: 0.9rem;
}

.scrap-new-plant {
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  background: rgba(35, 134, 54, 0.1);
  border: 1px solid var(--color-success);
  border-radius: var(--radius-md);
}

.scrap-new-plant h3 {
  color: var(--color-success-emphasis);
  margin-bottom: var(--space-sm);
}

.scrap-plant-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.scrap-plant-card img {
  width: 80px;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.scrap-plant-info {
  font-size: 0.85rem;
}

.scrap-plant-info .plant-type {
  text-transform: capitalize;
  color: var(--color-text-secondary);
}

.scrap-plant-info .plant-stats {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.scrap-options-container {
  margin-bottom: var(--space-lg);
}

.scrap-options-container h3 {
  margin-bottom: var(--space-md);
}

.scrap-options-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.scrap-option {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--color-bg-tertiary);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.scrap-option:hover {
  border-color: var(--color-border-emphasis);
  background: var(--color-surface-hover);
}

.scrap-option.selected {
  border-color: var(--color-danger);
  background: rgba(218, 54, 51, 0.1);
}

.scrap-option img {
  width: 60px;
  height: auto;
  border-radius: var(--radius-sm);
}

.scrap-option-info {
  flex: 1;
}

.scrap-option-name {
  font-weight: 600;
  margin-bottom: 2px;
}

.scrap-option-details {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.scrap-option-loss {
  text-align: right;
}

.scrap-option-loss.has-loss {
  color: var(--color-danger-emphasis);
  font-weight: 600;
}

.scrap-option-loss.no-loss {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

/* Resource icons in scrap plant modal */
.scrap-resource-icon {
  width: 13.6px;
  height: 13.6px;
  vertical-align: middle;
  margin: 0 1px;
}

.scrap-option-loss .scrap-resource-icon {
  width: 13.6px;
  height: 13.6px;
}

.scrap-warning {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: rgba(218, 54, 51, 0.15);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  color: var(--color-danger-emphasis);
  font-size: 0.9rem;
}

.scrap-warning.hidden {
  display: none;
}

.warning-icon {
  font-size: 1.2rem;
}

.scrap-modal-buttons {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
}

.scrap-modal-buttons .primary-btn {
  width: auto;
  margin-top: 0;
}

.scrap-modal-buttons .secondary-btn {
  background: transparent;
  border-color: var(--color-text-muted);
}

/* Cancel/Back button for auction overlay */
.auction-btn.cancel-btn {
  background: linear-gradient(135deg, var(--color-bg-tertiary) 0%, var(--color-surface) 100%);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.auction-btn.cancel-btn:hover {
  background: linear-gradient(135deg, var(--color-surface-hover) 0%, var(--color-surface-active) 100%);
  border-color: var(--color-border-emphasis);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ============================================
   ADMIN TOOLS (Login Screen)
   ============================================ */

.admin-tools {
  margin-top: 2rem;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 520px;
}

.admin-tools h3 {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  text-align: center;
}

.admin-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.admin-btn {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

.admin-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.admin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.quick-test-group {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.player-count-select,
.map-select {
  padding: 0.75rem 0.5rem;
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.player-count-select:focus,
.map-select:focus {
  outline: none;
  border-color: var(--color-amber);
}

.admin-or {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.admin-hint {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  margin-top: 1rem;
  text-align: center;
}

/* Save Replay Button (under Game Log) */
.save-replay-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  box-shadow: 0 2px 8px rgba(155, 89, 182, 0.3);
  margin-top: var(--space-md);
}

.save-replay-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(155, 89, 182, 0.4);
  background: linear-gradient(135deg, #a569bd 0%, #9b59b6 100%);
}

.save-replay-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(155, 89, 182, 0.3);
}

/* Power Generation Payment Table */
.payment-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.payment-table thead {
  background: linear-gradient(135deg, var(--color-electric) 0%, var(--color-amber) 100%);
}

.payment-table th {
  padding: 0.6rem 0.8rem;
  text-align: center;
  font-weight: 600;
  color: #000;
  font-size: 0.8rem;
}

.payment-table td {
  padding: 0.4rem 0.8rem;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
}

.payment-table tbody tr:nth-child(even) {
  background: var(--color-surface);
}

.payment-table tbody tr:hover {
  background: var(--color-surface-hover);
}

.payment-table tbody tr:last-child td {
  border-bottom: none;
}

.payment-table td:first-child {
  font-weight: 600;
  color: var(--color-text-secondary);
}

.payment-table td:last-child {
  font-weight: 700;
  color: var(--color-electric);
}

.game-title {
  display: flex;
  align-items: center;
}

/* Replay Viewer Modal */
.replay-viewer-modal .modal-content {
  max-width: 800px;
  max-height: 80vh;
}

.replay-content {
  background: var(--color-bg-tertiary);
  padding: 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-y: auto;
  max-height: 60vh;
  border: 1px solid var(--color-border);
}

/* Replay Metadata Modal */
.replay-metadata-content {
  max-width: 500px;
  width: 95%;
}

.replay-metadata-content h2 {
  margin: 0 0 1.5rem 0;
  color: var(--color-amber);
}

.replay-metadata-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.metadata-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.metadata-row:last-child {
  border-bottom: none;
}

.metadata-label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.metadata-value {
  color: var(--color-text);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.metadata-section {
  margin-top: 0.5rem;
}

.metadata-section .metadata-label {
  display: block;
  margin-bottom: 0.5rem;
}

.metadata-players-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--color-bg-tertiary);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.metadata-player-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.metadata-player-name {
  color: var(--color-text);
}

.metadata-player-stats {
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.replay-metadata-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.replay-metadata-actions button {
  padding: 0.75rem 1rem;
  text-align: center;
}

.replay-metadata-actions #replay-create-resumable-btn {
  width: 100%;
}

.replay-metadata-actions #replay-load-debug-btn,
.replay-metadata-actions #replay-metadata-cancel-btn {
  flex: 1;
}

/* Replay File Explorer Modal */
.replay-explorer-content {
  max-width: 600px;
  width: 95%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.replay-explorer-content h2 {
  margin: 0 0 1rem 0;
  color: var(--color-amber);
}

.replay-explorer-tree {
  flex: 1;
  overflow-y: auto;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  min-height: 300px;
  max-height: 60vh;
}

.replay-explorer-tree .loading-text {
  color: var(--color-text-muted);
  text-align: center;
  padding: 2rem;
}

.replay-explorer-tree .empty-text {
  color: var(--color-text-muted);
  text-align: center;
  padding: 2rem;
}

/* Tree folder structure */
.tree-folder {
  margin-bottom: 0.25rem;
}

.tree-folder-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
  user-select: none;
}

.tree-folder-header:hover {
  background: var(--color-bg-secondary);
}

.tree-folder-icon {
  font-size: 1rem;
  transition: transform 0.15s ease;
}

.tree-folder.collapsed .tree-folder-icon {
  transform: rotate(-90deg);
}

.tree-folder-name {
  font-weight: 600;
  color: var(--color-text);
}

.tree-folder-count {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin-left: auto;
}

.tree-folder-children {
  margin-left: 1.25rem;
  border-left: 1px solid var(--color-border);
  padding-left: 0.75rem;
}

.tree-folder.collapsed .tree-folder-children {
  display: none;
}

/* Tree file (replay item) */
.tree-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
  font-size: 0.85rem;
}

.tree-file:hover {
  background: var(--color-bg-secondary);
}

.tree-file-icon {
  color: var(--color-text-muted);
}

.tree-file-name {
  color: var(--color-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-file-badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg-secondary);
  color: var(--color-text-muted);
}

.tree-file-badge.autosave {
  background: rgba(58, 178, 206, 0.2);
  color: var(--color-electric);
}

.tree-file-badge.manual {
  background: rgba(76, 175, 80, 0.2);
  color: var(--color-success);
}

.tree-file-badge.map {
  background: rgba(255, 193, 7, 0.2);
  color: #ffc107;
  font-weight: 600;
}

.tertiary-btn {
  padding: 0.6rem 1.2rem;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.tertiary-btn:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text);
}

.save-type-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.save-type-badge.autosave {
  background: rgba(46, 160, 67, 0.2);
  color: var(--color-success);
}

.save-type-badge.manual {
  background: rgba(243, 156, 18, 0.2);
  color: var(--color-amber);
}

/* Reload code display in player list */
.metadata-player-code {
  color: var(--color-electric);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.75rem;
  background: rgba(58, 178, 206, 0.15);
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-xs);
}

/* Rejoin Game Modal */
.rejoin-modal-content {
  max-width: 400px;
  width: 95%;
}

.rejoin-modal-content h2 {
  margin: 0 0 0.5rem 0;
  color: var(--color-amber);
}

.rejoin-description {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.rejoin-game-info {
  background: var(--color-bg-tertiary);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
}

.rejoin-info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
}

.rejoin-label {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.rejoin-value {
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.85rem;
}

.rejoin-code-input {
  margin-bottom: 1.5rem;
}

.rejoin-code-input label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

.rejoin-code-input input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1.2rem;
  font-family: var(--font-mono);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.rejoin-code-input input:focus {
  outline: none;
  border-color: var(--color-electric);
}

.rejoin-actions {
  display: flex;
  gap: 1rem;
}

/* Name Prompt Modal */
.name-prompt-modal-content {
  max-width: 360px;
  width: 95%;
}

.name-prompt-modal-content h2 {
  margin: 0 0 0.5rem 0;
  color: var(--color-electric);
}

.name-prompt-description {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.name-prompt-input {
  margin-bottom: 1.5rem;
}

.name-prompt-input input {
  width: 100%;
  padding: 0.75rem;
  font-size: 1.1rem;
  background: var(--color-bg-tertiary);
  color: var(--color-text);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.name-prompt-input input:focus {
  outline: none;
  border-color: var(--color-electric);
}

.name-prompt-actions {
  display: flex;
  gap: 1rem;
  align-items: stretch;
}

.name-prompt-actions button {
  flex: 1;
  height: 44px;
  min-height: 44px;
  padding: 0 1.5rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.name-prompt-error {
  color: var(--color-danger);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  display: none;
}

.rejoin-actions button {
  flex: 1;
  padding: 0.75rem 1.5rem;
}

/* Resumed game indicator in game browser */
.game-card.resumed-game {
  border-left: 3px solid var(--color-electric);
}

.resumed-badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  background: rgba(58, 178, 206, 0.2);
  color: var(--color-electric);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-xs);
  margin-left: 0.5rem;
}

.waiting-players-info {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

/* Rejoin button styling */
.rejoin-btn {
  background: linear-gradient(135deg, var(--color-electric) 0%, #2d8fa0 100%) !important;
}

.rejoin-btn:hover {
  background: linear-gradient(135deg, #4ac0d4 0%, #3aa8b8 100%) !important;
}

/* Resumed game row styling */
.game-row.resumed-game {
  border-left: 3px solid var(--color-electric);
  background: rgba(58, 178, 206, 0.05);
}

/* Disabled button in modal */
#replay-create-resumable-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--color-bg-tertiary);
}

/* ==================== Resource Purchase Modal ==================== */
.resource-purchase-modal-content {
  max-width: 600px;
  width: 95%;
}

.resource-purchase-modal-content h2 {
  margin: 0 0 0.5rem 0;
  color: var(--color-amber);
}

.resource-purchase-subtitle {
  color: var(--color-text-secondary);
  margin: 0 0 1.5rem 0;
  font-size: 0.9rem;
}

.resource-purchase-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.resource-purchase-row {
  display: grid;
  grid-template-columns: 100px 180px 110px 1fr;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.resource-purchase-row.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.resource-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.resource-info .resource-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.resource-info .resource-name {
  font-weight: 600;
  color: var(--color-text);
}

.resource-availability {
  display: flex;
  font-size: 0.8rem;
}

.resource-availability .available-label {
  color: var(--color-text-muted);
}

.resource-availability .available-count {
  font-weight: 700;
  color: var(--color-text);
}

.resource-market-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.75rem;
}

.resource-market-info .resource-availability,
.resource-market-info .resource-unit-price,
.resource-market-info .resource-replenish {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.resource-unit-price .unit-label,
.resource-replenish .replenish-label {
  color: var(--color-text-muted);
}

.resource-unit-price .unit-value {
  font-weight: 700;
  color: var(--color-amber);
}

.resource-replenish .replenish-value {
  font-weight: 600;
  color: var(--color-success);
}

.resource-replenish .replenish-icon {
  width: 14px;
  height: 14px;
  object-fit: contain;
}

.resource-input-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.resource-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.resource-btn:hover:not(:disabled) {
  background: var(--color-amber);
  color: #000;
  border-color: var(--color-amber);
}

.resource-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.resource-input-group .resource-amount,
.resource-input-group input.resource-amount {
  width: 28px;
  text-align: center;
  padding: 0.1rem;
  margin: 0;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

.resource-cost {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
  font-weight: 600;
}

.resource-cost .cost-label {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  font-weight: 400;
}

.resource-cost .cost-value {
  color: var(--color-amber);
  font-size: 1.1rem;
}

.resource-cost .cost-currency {
  font-size: 1rem;
}

.resource-purchase-summary {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.summary-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0;
}

.summary-row .summary-label {
  color: var(--color-text-secondary);
  text-align: right;
  min-width: 5rem;
}

.summary-row .summary-value {
  font-weight: 600;
  color: var(--color-text);
}

.summary-row .summary-currency {
  color: var(--color-text-muted);
  margin-left: 0.25rem;
}

.summary-row .summary-value-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.summary-row.total {
  border-top: 1px solid var(--color-border);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.summary-row.total .summary-value {
  color: var(--color-amber);
  font-size: 1.1rem;
}

.summary-row.remaining .summary-value {
  color: var(--color-success);
}

.resource-purchase-error {
  background: rgba(231, 76, 60, 0.2);
  border: 1px solid var(--color-error);
  color: var(--color-error);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.resource-purchase-error.hidden {
  display: none;
}

.resource-purchase-buttons {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin-top: 1rem;
}

.resource-purchase-buttons .primary-btn,
.resource-purchase-buttons .secondary-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 48px;
  padding: 0.75rem 1rem;
  margin-top: 0;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.resource-purchase-buttons .primary-btn {
  background: linear-gradient(135deg, var(--color-amber), var(--color-warning));
  border: 1px solid transparent;
  color: #000;
}

.resource-purchase-buttons .primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.resource-purchase-buttons .primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.resource-purchase-buttons .secondary-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.resource-purchase-buttons .secondary-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

/* Resource Action Buttons (in actions panel) */
.resource-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.resource-action-buttons .primary-btn,
.resource-action-buttons .secondary-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

/* Game Over Actions */
.game-over-actions {
  text-align: center;
  padding: var(--space-md);
}

.game-over-actions h3 {
  color: gold;
  margin-bottom: var(--space-sm);
}

.game-over-actions p {
  margin-bottom: var(--space-md);
}

.game-over-actions .primary-btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

/* ==================== Build House Modal (Phase 4) ==================== */
.build-house-modal-content {
  max-width: 550px;
  width: 95%;
}

.build-house-modal-content h2 {
  margin: 0 0 0.5rem 0;
  color: var(--color-amber);
}

.build-house-subtitle {
  color: var(--color-text-secondary);
  margin: 0 0 1.5rem 0;
  font-size: 0.9rem;
}

.build-house-info {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.build-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
}

.build-info-row .build-info-label {
  color: var(--color-text-secondary);
}

.build-info-row .build-info-value {
  font-weight: 600;
  color: var(--color-text);
}

.build-info-row .build-info-currency {
  color: var(--color-text-muted);
  margin-left: 0.25rem;
}

/* Buildable Cities List */
.buildable-cities-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.buildable-cities-list .loading-text {
  color: var(--color-text-muted);
  text-align: center;
  padding: 2rem;
}

.buildable-city-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.buildable-city-item:hover {
  border-color: var(--color-amber);
  background: var(--color-surface-hover);
}

.buildable-city-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.buildable-city-item.disabled:hover {
  border-color: var(--color-border);
  background: var(--color-bg-tertiary);
}

.city-item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.city-item-name {
  font-weight: 600;
  color: var(--color-text);
}

.city-item-area {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.city-item-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.city-item-cost {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.85rem;
}

.city-item-cost .total-cost {
  font-weight: 700;
  color: var(--color-amber);
  font-size: 1rem;
}

.city-item-cost .cost-breakdown {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

/* Zone Badges */
.zone-badge {
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.zone-badge.basic {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.4);
}

.zone-badge.standard {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.4);
}

.zone-badge.premium {
  background: rgba(52, 152, 219, 0.2);
  color: #3498db;
  border: 1px solid rgba(52, 152, 219, 0.4);
}

/* Occupants indicator */
.city-occupants {
  display: flex;
  gap: 0.25rem;
}

.occupant-house {
  width: 16px;
  height: 16px;
  border-radius: 2px;
}

.build-house-error {
  background: rgba(231, 76, 60, 0.2);
  border: 1px solid #e74c3c;
  color: #e74c3c;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.build-house-error.hidden {
  display: none;
}

.build-house-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.build-house-buttons .secondary-btn {
  flex: 1;
  min-height: 48px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.build-house-buttons .secondary-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

/* ==================== Build Confirmation Modal ==================== */
.build-confirm-modal-content {
  max-width: 400px;
  width: 90%;
}

.build-confirm-modal-content h2 {
  margin: 0 0 0.5rem 0;
  color: var(--color-amber);
}

.build-confirm-city {
  color: var(--color-text-secondary);
  margin: 0 0 1.5rem 0;
  font-size: 0.95rem;
}

.build-confirm-city strong {
  color: var(--color-text);
}

.build-cost-breakdown {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.build-cost-breakdown .cost-row {
  display: flex;
  align-items: center;
  padding: 0.4rem 0;
  gap: 0.5rem;
}

.build-cost-breakdown .cost-row .cost-label {
  flex: 1;
  color: var(--color-text-secondary);
}

.build-cost-breakdown .cost-row .cost-value {
  font-weight: 600;
  color: var(--color-text);
  min-width: 40px;
  text-align: right;
}

.build-cost-breakdown .cost-row .cost-currency {
  color: var(--color-text-muted);
  min-width: 50px;
}

.build-cost-breakdown .cost-row .zone-badge {
  margin-left: 0.5rem;
}

.build-cost-breakdown .cost-row.total {
  border-top: 1px solid var(--color-border);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
}

.build-cost-breakdown .cost-row.total .cost-value {
  color: var(--color-amber);
  font-size: 1.1rem;
}

.build-cost-breakdown .cost-row.remaining .cost-value {
  color: var(--color-success);
}

.build-confirm-buttons {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin-top: 1rem;
}

.build-confirm-buttons .primary-btn,
.build-confirm-buttons .secondary-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  padding: 0.75rem 1rem;
  margin-top: 0;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.build-confirm-buttons .primary-btn {
  background: linear-gradient(135deg, var(--color-amber), var(--color-warning));
  border: 1px solid transparent;
  color: #000;
}

.build-confirm-buttons .primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.build-confirm-buttons .primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.build-confirm-buttons .secondary-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.build-confirm-buttons .secondary-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

/* ==================== House Zones on Map ==================== */
.city-houses {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 4px;
}

.house-zone {
  display: flex;
  gap: 2px;
  justify-content: center;
}

.house-slot {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px dashed var(--color-border);
  background: transparent;
}

.house-slot.occupied {
  border-style: solid;
}

.house-slot.basic-zone {
  border-color: rgba(46, 204, 113, 0.5);
}

.house-slot.standard-zone {
  border-color: rgba(231, 76, 60, 0.5);
}

.house-slot.premium-zone {
  border-color: rgba(52, 152, 219, 0.5);
}

.house-slot .house-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ==================== City Click Build Modal (Map Overlay) ==================== */
.city-click-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
  z-index: 50;
  justify-content: center;
  align-items: center;
}

.city-click-overlay.active {
  display: flex;
}

.city-click-modal-content {
  max-width: 480px;
  width: 90%;
  max-height: 90%;
  overflow-y: auto;
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border-emphasis);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-xl, 0 20px 40px rgba(0, 0, 0, 0.5));
  position: relative;
}

.city-click-modal-content .modal-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  transition: color 0.15s;
  z-index: 1;
}

.city-click-modal-content .modal-close-btn:hover {
  color: var(--color-text-primary);
}

.city-click-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.city-click-icon-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  width: 100%;
}

.city-click-icon {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.city-click-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
  margin-top: 4rem;
}

.city-click-title h2 {
  margin: 0;
  color: var(--color-text-primary);
  font-size: 1.4rem;
  font-weight: 700;
  border: none;
  padding: 0;
}

.city-click-separator {
  color: var(--color-text-muted);
  font-size: 1.25rem;
}

.city-click-area {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Region-specific colors for area pill */
.city-click-area.region-purple {
  background: rgba(128, 0, 128, 0.3);
  color: #d8a0d8;
  border: 1px solid rgba(128, 0, 128, 0.5);
}

.city-click-area.region-yellow {
  background: rgba(255, 200, 0, 0.3);
  color: #ffe066;
  border: 1px solid rgba(255, 200, 0, 0.5);
}

.city-click-area.region-brown {
  background: rgba(139, 90, 43, 0.3);
  color: #d4a574;
  border: 1px solid rgba(139, 90, 43, 0.5);
}

.city-click-area.region-red {
  background: rgba(220, 53, 69, 0.3);
  color: #ff8a8a;
  border: 1px solid rgba(220, 53, 69, 0.5);
}

.city-click-area.region-blue {
  background: rgba(0, 123, 255, 0.3);
  color: #7ab8ff;
  border: 1px solid rgba(0, 123, 255, 0.5);
}

.city-click-area.region-green {
  background: rgba(40, 167, 69, 0.3);
  color: #7ddf8a;
  border: 1px solid rgba(40, 167, 69, 0.5);
}

.city-click-houses {
  display: flex;
  gap: 8px;
  position: absolute;
  bottom: -70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg-panel);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 0;
}

.city-click-house-slot {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  border: 3px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.city-click-house-slot.empty {
  background: rgba(0, 0, 0, 0.3);
  border-style: dashed;
}

.city-click-slot-cost {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.city-click-house-slot.occupied {
  background: rgba(0, 0, 0, 0.2);
  border-style: solid;
}

.city-click-house {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.city-click-details {
  background: linear-gradient(135deg, var(--color-bg-tertiary) 0%, var(--color-surface) 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.city-click-flavor {
  font-style: italic;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin: 0 0 1rem 0;
  padding: 0.75rem 1rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
  border-left: 3px solid var(--color-amber);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.5;
  quotes: """ """ "'" "'";
}

.city-click-flavor::before {
  content: open-quote;
  color: var(--color-amber);
  font-size: 1.2em;
}

.city-click-flavor::after {
  content: close-quote;
  color: var(--color-amber);
  font-size: 1.2em;
}

.city-click-flavor:empty {
  display: none;
}

.city-click-stats {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.city-stat {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.city-stat:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.city-stat .stat-icon {
  font-size: 1.25rem;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.city-stat .stat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.city-stat .stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  font-weight: 600;
}

.city-stat .stat-value {
  font-size: 0.95rem;
  color: var(--color-text-primary);
  font-weight: 500;
}

.city-stat .stat-plants-list {
  margin: 0.25rem 0 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.city-stat .stat-plants-list li {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  padding-left: 1rem;
  position: relative;
}

.city-stat .stat-plants-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--color-electric);
}

.city-click-stats:empty {
  display: none;
}

/* Connected Cities Section */
.city-connections-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.connections-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 0 0 0.75rem 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.city-connections-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.connection-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  transition: all 0.2s;
}

.connection-chip:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.connection-chip .city-name {
  color: var(--color-text-primary);
  font-weight: 500;
}

.connection-chip .connection-cost {
  color: var(--color-amber);
  font-weight: 600;
}

.city-click-status {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.4);
  color: #e74c3c;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.city-click-status:empty {
  display: none;
}

.city-click-status.success {
  background: rgba(46, 204, 113, 0.15);
  border-color: rgba(46, 204, 113, 0.4);
  color: #2ecc71;
}

.city-click-cost-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.city-click-cost-section .cost-row {
  display: flex;
  align-items: center;
  padding: 0.4rem 0;
  gap: 0.5rem;
}

.city-click-cost-section .cost-row .cost-label {
  flex: 1;
  color: var(--color-text-secondary);
}

.city-click-cost-section .cost-row .cost-value {
  font-weight: 600;
  color: var(--color-text);
  min-width: 40px;
  text-align: right;
}

.city-click-cost-section .cost-row .cost-currency {
  color: var(--color-text-muted);
  min-width: 50px;
}

.city-click-cost-section .cost-row .zone-badge {
  margin-left: 0.5rem;
}

.city-click-cost-section .cost-row.total {
  border-top: 1px solid var(--color-border);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
}

.city-click-cost-section .cost-row.total .cost-value {
  color: var(--color-amber);
  font-size: 1.1rem;
}

.city-click-cost-section .cost-row.remaining .cost-value {
  color: var(--color-success);
}

.city-click-cost-section .cost-row.remaining .cost-value.negative {
  color: #e74c3c;
}

.city-click-buttons {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin-top: 1rem;
}

.city-click-buttons .primary-btn,
.city-click-buttons .secondary-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 48px;
  padding: 0.75rem 1rem;
  margin: 0;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.city-click-buttons .primary-btn {
  background: linear-gradient(135deg, var(--color-amber), var(--color-warning));
  border: 1px solid transparent;
  color: #000;
}

.city-click-buttons .primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.city-click-buttons .primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.city-click-buttons .secondary-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.city-click-buttons .secondary-btn:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}

/* =====================================
   Undo Action Button
   ===================================== */

.undo-section {
  margin-top: var(--space-md);
}

.undo-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-md) 0;
}

.undo-btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  box-shadow: 0 2px 8px rgba(155, 89, 182, 0.3);
}

.undo-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(155, 89, 182, 0.4);
  background: linear-gradient(135deg, #a569bd 0%, #9b59b6 100%);
}

.undo-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(155, 89, 182, 0.3);
}

.undo-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-xs);
  font-style: italic;
}

/* =====================================
   Button Processing State
   ===================================== */

button.processing {
  opacity: 0.7;
  cursor: wait;
}

button.processing::after {
  content: '...';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* =====================================
   Game Browser (inline on login screen)
   ===================================== */

.game-browser-card {
  min-width: 520px;
}

.game-browser-controls {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.game-browser-controls input {
  flex: 1;
  margin: 0;
}

.icon-btn {
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--color-bg-secondary);
  border-color: var(--color-border-emphasis);
}

.game-browser-list {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
}

.game-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s ease;
}

.game-row:last-child {
  border-bottom: none;
}

.game-row:hover {
  background: var(--color-bg-secondary);
}

.game-row.lobby {
  border-left: 3px solid var(--color-success);
}

.game-row.in-progress {
  border-left: 3px solid var(--color-amber);
}

.game-row-main {
  display: grid;
  grid-template-columns: 160px 110px 55px 90px 40px;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  min-width: 0;
}

.game-row-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-row-host {
  font-size: 0.75rem;
  color: var(--color-amber);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-row-player-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-amber);
  text-align: center;
}

.game-row-players {
  display: flex;
  gap: 2px;
  justify-content: flex-start;
}

.player-chip-mini {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.game-row-status {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-row-observers {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-align: center;
}

.game-row-actions {
  display: flex;
  gap: var(--space-xs);
}

.delete-game-btn {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--color-border, #444);
  color: inherit;
  cursor: pointer;
  opacity: 0.6;
}

.delete-game-btn:hover {
  opacity: 1;
  border-color: #c0392b;
  color: #e74c3c;
}

.clear-test-games-bar {
  display: flex;
  justify-content: center;
  padding: var(--space-sm) 0 0;
}

.clear-test-games-btn {
  font-size: 0.78rem;
  opacity: 0.8;
}

.join-btn-small,
.watch-btn-small {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.join-btn-small {
  background: var(--color-success);
  color: white;
}

.join-btn-small:hover {
  background: var(--color-success-emphasis);
}

.watch-btn-small {
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.watch-btn-small:hover {
  background: var(--color-bg-tertiary);
  color: var(--color-text-primary);
}

.manual-join-section {
  text-align: center;
}

.manual-join-form {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.manual-join-form input {
  flex: 1;
  margin: 0;
}

.manual-join-form button {
  flex: 0 0 auto;
  width: auto;
  margin-top: 0;
  padding: var(--space-sm) var(--space-lg);
}

.no-games-message {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-muted);
}

.no-games-hint {
  font-size: 0.85rem;
  margin-top: var(--space-xs);
}

.no-games-message {
  text-align: center;
  padding: var(--space-xl);
  color: var(--color-text-muted);
  font-style: italic;
}

/* Individual Game Card */
.game-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: all 0.2s ease;
}

.game-card:hover {
  border-color: var(--color-border-emphasis);
  box-shadow: var(--shadow-md);
}

.game-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.game-card-id {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--color-amber);
  font-weight: 600;
}

.game-card-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.lobby {
  background: rgba(52, 152, 219, 0.2);
  color: #3498db;
  border: 1px solid rgba(52, 152, 219, 0.3);
}

.status-badge.in-progress {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.game-card-info {
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.game-card-players {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.player-chip-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.game-card-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.game-card-actions button {
  flex: 1;
  padding: 0.625rem 1rem;
  font-size: 0.85rem;
}

.watch-btn {
  background: linear-gradient(135deg, var(--color-info) 0%, #2980b9 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.watch-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.join-btn {
  background: linear-gradient(135deg, var(--color-success) 0%, #27ae60 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.join-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
}

.join-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* =====================================
   Spectators/Observers Section
   ===================================== */

.observers-section {
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.observers-section h2 {
  margin-bottom: var(--space-sm);
}

.observers-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.observer-item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  background: rgba(52, 152, 219, 0.15);
  border: 1px solid rgba(52, 152, 219, 0.3);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.observer-item::before {
  content: '👁️';
  font-size: 0.7rem;
}

/* =====================================
   Spectator Mode Notice
   ===================================== */

.observer-notice {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-info);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
}

.observer-notice h3 {
  color: var(--color-info);
  margin-bottom: var(--space-sm);
  font-size: 1rem;
}

.observer-notice p {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

/* =====================================
   Region Selection Modal
   ===================================== */

.region-selection-modal-content {
  max-width: 500px;
  width: 95%;
}

.region-selection-modal-content h2 {
  margin: 0 0 0.5rem 0;
  color: var(--color-amber);
}

.region-selection-instructions {
  color: var(--color-text-secondary);
  margin: 0 0 1.5rem 0;
  font-size: 0.95rem;
}

.region-selection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.region-select-btn {
  padding: var(--space-lg);
  border: 3px solid var(--region-color);
  background: transparent;
  color: var(--color-text-primary);
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.region-select-btn:hover {
  background: color-mix(in srgb, var(--region-color) 20%, transparent);
  transform: translateY(-2px);
}

.region-select-btn.selected {
  background: var(--region-color);
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.region-selection-actions {
  display: flex;
  justify-content: center;
  margin-top: var(--space-lg);
}

.region-selection-actions .primary-btn {
  min-width: 200px;
}

/* Inline variant for Actions panel */
.region-selection-inline {
  text-align: center;
}

.region-selection-inline h3 {
  color: var(--color-amber);
  margin-bottom: var(--space-sm);
}

.region-selection-inline .region-selection-instructions {
  margin-bottom: var(--space-md);
}

.region-selection-inline .region-count {
  color: var(--color-amber);
  font-weight: 600;
}

.region-selection-grid.inline {
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
}

.region-selection-grid.inline .region-select-btn {
  padding: var(--space-md);
  font-size: 0.95rem;
}

.region-selection-section {
  text-align: center;
}

.region-selection-section h3 {
  color: var(--color-amber);
  margin-bottom: var(--space-sm);
}

.region-selection-section p {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
}

/* =====================================
   Disabled Region Styling (Map)
   ===================================== */

/* Cities in non-selected regions */
.city-node.region-disabled {
  opacity: 0.25;
  pointer-events: none;
}

.city-node.region-disabled .city-label {
  text-decoration: line-through;
}

/* Connection lines to disabled cities */
.connection-line.region-disabled {
  opacity: 0.15;
  stroke-dasharray: 5, 5;
}

/* Connection costs to disabled cities */
.connection-cost.region-disabled {
  opacity: 0.15;
  text-decoration: line-through;
}

/* =====================================
   Chat Interface
   ===================================== */

.chat-container {
  position: fixed;
  bottom: 0;
  right: 1rem;
  width: 350px;
  max-width: calc(100vw - 2rem);
  background: var(--color-bg-panel);
  border: 1px solid var(--color-border-emphasis);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: none;
  flex-direction: column;
  transition: height 0.2s ease;
}

.chat-container.chat-visible {
  display: flex;
}

.chat-container.chat-minimized {
  height: auto;
}

.chat-container.chat-expanded {
  width: 525px;
  max-width: calc(100vw - 2rem);
  height: 525px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, var(--color-surface) 0%, var(--color-bg-tertiary) 100%);
  border-bottom: 1px solid var(--color-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  cursor: pointer;
  user-select: none;
}

.chat-header:hover {
  background: linear-gradient(135deg, var(--color-surface-hover) 0%, var(--color-surface) 100%);
}

.chat-title {
  font-weight: 600;
  color: var(--color-text-primary);
  font-size: 0.9rem;
}

.chat-unread {
  background: var(--color-danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  border-radius: 10px;
  min-width: 1.2rem;
  text-align: center;
}

.chat-toggle-btn {
  margin-left: auto;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, transform 0.2s;
}

.chat-toggle-btn:hover {
  color: var(--color-text-primary);
}

.chat-toggle-icon {
  display: inline-block;
  transition: transform 0.2s;
}

.chat-minimized .chat-toggle-icon {
  transform: rotate(0deg);
}

.chat-expanded .chat-toggle-icon {
  transform: rotate(180deg);
}

.chat-body {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-expanded .chat-body {
  display: flex;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--player-color, var(--color-border));
}

.chat-message-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.chat-message-author {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--player-color, var(--color-text-primary));
}

.chat-message-time {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-left: auto;
}

.chat-message-content {
  font-size: 0.85rem;
  color: var(--color-text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chat-meme-image {
  max-width: 100%;
  max-height: 150px;
  border-radius: var(--radius-sm);
  margin-top: var(--space-xs);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.chat-meme-image:hover {
  transform: scale(1.02);
}

/* Image Lightbox */
.image-lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.image-lightbox.active {
  display: flex;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  cursor: default;
}

.lightbox-close-btn {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 2.5rem;
  color: white;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 10001;
}

.lightbox-close-btn:hover {
  opacity: 1;
}

.chat-input-container {
  display: flex;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  position: relative;
}

.chat-input {
  flex: 1;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  color: var(--color-text-primary);
  font-size: 0.85rem;
  font-family: var(--font-primary);
}

.chat-input:focus {
  outline: none;
  border-color: var(--color-amber);
}

.chat-input::placeholder {
  color: var(--color-text-muted);
}

.chat-send-btn {
  background: var(--color-amber);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-bg-primary);
  font-size: 1rem;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.chat-send-btn:hover {
  background: var(--color-electric);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-empty {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: var(--space-lg);
}

.chat-hint {
  margin-top: var(--space-sm);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.chat-command-hint {
  background: rgba(241, 196, 15, 0.3);
  color: #f1c40f;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-command-hint:hover {
  background: rgba(241, 196, 15, 0.5);
}

/* Chat autocomplete dropdown */
.chat-autocomplete-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-xs);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.1s;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--color-bg-tertiary);
}

.autocomplete-trigger {
  font-family: monospace;
  color: var(--color-amber);
  font-weight: 600;
  white-space: nowrap;
}

.autocomplete-desc {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chat system message (for :list_commands:) */
.chat-system-message {
  background: var(--color-bg-tertiary);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  margin: var(--space-sm) 0;
}

.chat-system-message .chat-message-author {
  color: var(--color-amber);
}

.chat-system-message .chat-message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-commands-close {
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  padding: 0 var(--space-xs);
  transition: color 0.15s;
}

.chat-commands-close:hover {
  color: var(--color-text-primary);
}

.chat-commands-list {
  padding: var(--space-sm) 0;
}

.commands-category {
  margin-bottom: var(--space-md);
}

.commands-category:last-child {
  margin-bottom: 0;
}

.commands-category strong {
  color: var(--color-text-primary);
  display: block;
  margin-bottom: var(--space-xs);
}

.command-item {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  padding: 2px 0;
}

.command-item.command-clickable {
  cursor: pointer;
  padding: 4px 6px;
  margin: 2px -6px;
  border-radius: 4px;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.command-item.command-clickable:hover {
  background-color: var(--color-bg-tertiary);
}

.command-item.command-clickable:hover code {
  color: var(--color-amber);
  background: var(--color-bg-primary);
}

.command-item.command-clickable:active {
  transform: scale(0.98);
  background-color: var(--color-bg-secondary);
}

.command-item code {
  font-family: monospace;
  color: var(--color-electric);
  background: var(--color-bg-secondary);
  padding: 1px 4px;
  border-radius: 3px;
  margin-right: var(--space-xs);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.command-expand,
.command-collapse {
  cursor: pointer;
  color: var(--color-amber);
  margin-top: var(--space-xs);
}

.command-expand:hover,
.command-collapse:hover {
  color: var(--color-electric);
  text-decoration: underline;
}

/* ==================== ACTION QUEUE UI ==================== */

.queue-builder {
  margin-top: var(--space-md);
  padding: var(--space-sm);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.queue-section-label {
  font-weight: 600;
  color: var(--color-electric);
  margin-bottom: var(--space-sm);
  font-size: 0.9rem;
}

.queue-hint {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.queue-header {
  display: grid;
  grid-template-columns: 1fr 50px 50px 24px;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--color-border);
}

.queue-item {
  display: grid;
  grid-template-columns: 1fr 50px 50px 24px;
  gap: var(--space-xs);
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--border-radius-sm);
  border-left: 3px solid var(--color-electric);
}

.queue-item.submitted {
  border-left-color: var(--color-success);
  background: rgba(46, 204, 113, 0.1);
}

.queue-col-name {
  color: var(--color-text-primary);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-col-build,
.queue-col-conn {
  color: var(--color-amber);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: right;
}

.queue-col-remove {
  width: 24px;
}

.queue-item-num {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  min-width: 20px;
}

.queue-item-name {
  flex: 1;
  color: var(--color-text-primary);
}

.queue-item-remove {
  background: none;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.queue-item-remove:hover {
  opacity: 1;
}

.queue-item-cost {
  color: var(--color-amber);
  font-size: 0.85rem;
  font-weight: 500;
  margin-left: auto;
  margin-right: var(--space-sm);
}

.queue-cost-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius-sm);
  margin-top: var(--space-sm);
  font-size: 0.9rem;
}

.queue-cost-summary.over-budget {
  background: rgba(231, 76, 60, 0.2);
  border: 1px solid rgba(231, 76, 60, 0.4);
}

.queue-money-available {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.queue-warning {
  color: var(--color-danger-emphasis);
  font-size: 0.85rem;
  margin-top: var(--space-xs);
  text-align: center;
}

.queue-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.queue-actions button {
  flex: 1;
  min-width: 0;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  margin-top: 0;
  padding: 0.5rem 1rem;
  box-sizing: border-box;
}

.server-queue-status {
  margin-top: var(--space-md);
  padding: var(--space-sm);
  background: rgba(46, 204, 113, 0.1);
  border-radius: var(--border-radius);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.queue-submitted-label {
  color: var(--color-success-emphasis);
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.queue-estimated-cost {
  color: var(--color-amber);
  font-size: 0.85rem;
  margin-top: var(--space-xs);
}

.other-queues {
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.other-queues ul {
  list-style: none;
  padding: 0;
  margin: var(--space-xs) 0 0 0;
}

.other-queues li {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 2px 0;
}

.other-queues li::before {
  content: "• ";
  color: var(--color-electric);
}

/* Auction Queue Options */
.auction-queue-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.inline-queue-status {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(46, 204, 113, 0.1);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.inline-queue-options {
  margin-top: var(--space-sm);
}

.queue-active-label {
  color: var(--color-success-emphasis);
  font-size: 0.85rem;
  margin: 0;
}

.queue-pass-btn,
.cancel-queue-btn {
  font-size: 0.8rem;
}

/* ==================== RESOURCE QUEUE UI ==================== */

.resource-queue-container {
  padding: var(--space-md);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.resource-queue-container .queue-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.resource-queue-container .queue-title {
  font-weight: 600;
  color: var(--color-electric);
  font-size: 1rem;
}

.resource-queue-container .queue-subtitle {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.queue-turn-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-xs) var(--space-sm);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius-sm);
  margin-bottom: var(--space-md);
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}

.resource-queue-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.resource-queue-row {
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--border-radius);
  padding: var(--space-sm);
  border-left: 3px solid var(--color-border);
  transition: border-color 0.2s;
}

.resource-queue-row:has(.amount-value:not(:empty)) {
  border-left-color: var(--color-electric);
}

.resource-queue-row[data-resource="coal"] { border-left-color: #8b4513; }
.resource-queue-row[data-resource="oil"] { border-left-color: #2c3e50; }
.resource-queue-row[data-resource="garbage"] { border-left-color: #f1c40f; }
.resource-queue-row[data-resource="uranium"] { border-left-color: #e74c3c; }

.resource-queue-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.resource-icon-small {
  width: 20px;
  height: 20px;
}

.resource-icon-medium {
  width: 24px;
  height: 24px;
}

.resource-queue-info .resource-name {
  font-weight: 600;
  color: var(--color-text-primary);
}

.resource-queue-info .resource-available {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.resource-queue-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-sm);
  align-items: center;
}

.amount-control,
.limit-price-control,
.current-cost {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.amount-control label,
.limit-price-control label,
.current-cost .cost-label {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  min-width: 45px;
}

.btn-adjust {
  width: 24px;
  height: 24px;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-primary);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  transition: background 0.2s, border-color 0.2s;
}

.btn-adjust:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: var(--color-electric);
}

.amount-value,
.limit-value {
  min-width: 35px;
  text-align: center;
  font-weight: 600;
  color: var(--color-text-primary);
  font-size: 0.9rem;
}

.current-cost .cost-value {
  font-weight: 600;
  color: var(--color-amber);
}

.current-cost .cost-value.over-limit {
  color: var(--color-danger-emphasis);
}

.resource-queue-summary {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.queue-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius-sm);
  margin-bottom: var(--space-sm);
}

.queue-total .total-value {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-amber);
}

.queue-total .total-value.over-budget {
  color: var(--color-danger-emphasis);
}

.queue-submitted-status {
  background: rgba(46, 204, 113, 0.1);
  border: 1px solid rgba(46, 204, 113, 0.3);
  border-radius: var(--border-radius);
  padding: var(--space-md);
}

.queue-submitted-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-success-emphasis);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.queue-submitted-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.queue-submitted-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.9rem;
  color: var(--color-text-primary);
}

.queue-submitted-item .limit-price-display {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.queue-cancel-btn {
  width: 100%;
}

/* Queue Resource UI - matches Buy Resources styling */
.queue-resource-row {
  border-left: 3px solid var(--color-border);
}

.queue-resource-row[data-resource="coal"] { border-left-color: #8b4513; }
.queue-resource-row[data-resource="oil"] { border-left-color: #2c3e50; }
.queue-resource-row[data-resource="garbage"] { border-left-color: #f1c40f; }
.queue-resource-row[data-resource="uranium"] { border-left-color: #e74c3c; }

.queue-resource-info {
  min-width: auto;
  flex-shrink: 0;
}

.queue-limit-inline {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding-left: var(--space-sm);
  border-left: 1px solid var(--color-border);
  margin-left: var(--space-xs);
}

.queue-limit-inline .limit-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.queue-limit-inline .limit-amount {
  width: 32px;
  text-align: center;
  padding: 0.1rem;
  margin: 0;
}

/* Override general input styles for queue toggles */
.queue-resource-row input.resource-amount,
.queue-limit-inline input.limit-amount {
  width: 36px;
  text-align: center;
  padding: 0.15rem 0.1rem;
  margin: 0;
  border: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
}

.queue-limit-inline input.limit-amount {
  width: 40px;
}

/* Compact queue resource info to make room for larger inputs */
.queue-resource-info {
  flex: 0 0 auto;
  min-width: 24px;
}

.queue-limit-inline .limit-currency {
  font-size: 0.8rem;
}

.resource-queue-warning {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid rgba(231, 76, 60, 0.4);
  color: #e74c3c;
  padding: var(--space-sm);
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: var(--space-sm);
}

.resource-queue-warning.hidden {
  display: none;
}

.queue-badge {
  background: rgba(52, 152, 219, 0.2) !important;
  color: #3498db !important;
}

.waiting-badge {
  background: rgba(241, 196, 15, 0.2) !important;
  color: #f1c40f !important;
}

.queue-skip-message {
  padding: var(--space-md);
  text-align: center;
  color: var(--color-text-muted);
  font-style: italic;
}

.queue-submitted-row {
  justify-content: space-between;
}

.resource-queue-summary-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.queue-amount {
  font-weight: 600;
  color: var(--color-electric);
}

.queue-limit {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Small button variant */
.small-btn {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.85rem;
}

/* ==================== TOAST NOTIFICATIONS ==================== */

#toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius);
  color: white;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: auto;
  max-width: 350px;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  border-left: 4px solid #1e8449;
}

.toast-error {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  border-left: 4px solid #922b21;
}

.toast-info {
  background: linear-gradient(135deg, #2980b9, #3498db);
  border-left: 4px solid #1f618d;
}

.toast-warning {
  background: linear-gradient(135deg, #d68910, #f39c12);
  border-left: 4px solid #b9770e;
}

/* Auto-test status banner: pinned to the bottom so it never covers the
   action panel while the test runs */
#autotest-banner {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  display: flex;
  align-items: center;
  /* Everything scaled 2.5x so the running/passed/failed status is readable
     at a glance while an auto-test plays out. */
  gap: calc(var(--space-md) * 2.5);
  max-width: 95vw;
  padding: calc(var(--space-sm) * 2.5) calc(var(--space-md) * 2.5);
  border-radius: calc(var(--border-radius) * 2.5) calc(var(--border-radius) * 2.5) 0 0;
  background: linear-gradient(135deg, #1a5276, #2980b9);
  border: 5px solid #154360;
  border-bottom: none;
  color: white;
  font-size: 2.25rem;
  font-weight: 600;
  font-family: var(--font-mono, monospace);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
}

#autotest-banner.passed {
  background: linear-gradient(135deg, #196f3d, #27ae60);
  border-color: #145a32;
}

#autotest-banner.failed {
  background: linear-gradient(135deg, #922b21, #c0392b);
  border-color: #7b241c;
}

#autotest-banner #autotest-stop-btn {
  flex-shrink: 0;
  padding: 5px 25px;
  font-size: 2rem;
}

.autotest-group {
  margin-top: var(--space-sm);
}

.autotest-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px dashed var(--color-border, #444);
  border-radius: var(--border-radius, 6px);
  font-size: 0.85rem;
}

.autotest-strategies {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.autotest-label {
  opacity: 0.7;
  font-size: 0.8rem;
}

.autotest-seed {
  display: flex;
  align-items: center;
  gap: 8px;
}

.autotest-seed input {
  width: 130px;
  padding: 3px 8px;
  font-family: var(--font-mono, monospace);
  font-size: 0.85rem;
  background: var(--color-bg-primary, #1a1a1a);
  border: 1px solid var(--color-border, #444);
  border-radius: 4px;
  color: inherit;
}

#autotest-banner #autotest-seed-copy {
  flex-shrink: 0;
  padding: 5px 25px;
  font-size: 2rem;
  font-family: var(--font-mono, monospace);
  opacity: 0.85;
}

/* End-of-run auto-test report modal */
#autotest-report {
  position: fixed;
  inset: 0;
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 24px;
}

.autotest-report-panel {
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px 24px;
  border-radius: var(--border-radius, 8px);
  background: var(--color-bg-secondary, #1e1e1e);
  border-top: 4px solid #2980b9;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
  font-size: 0.9rem;
}

.autotest-report-panel.passed { border-top-color: #27ae60; }
.autotest-report-panel.failed { border-top-color: #c0392b; }

.autotest-report-panel h3 { margin: 0 0 6px; }
.autotest-report-headline { font-weight: 700; margin: 0 0 2px; }
.autotest-report-meta { opacity: 0.75; font-size: 0.82rem; margin: 0 0 14px; }
.autotest-report-meta code { cursor: pointer; padding: 1px 6px; background: rgba(255,255,255,0.08); border-radius: 4px; }

.autotest-report-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.autotest-report-section { margin-bottom: 14px; }
.autotest-report-section h4 {
  margin: 0 0 6px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.65;
}

.autotest-report-section table { width: 100%; border-collapse: collapse; }
.autotest-report-section td {
  padding: 3px 8px 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: top;
}
.autotest-report-section tr.violated td { color: #e74c3c; font-weight: 700; }
.autotest-report-num { text-align: right; font-family: var(--font-mono, monospace); white-space: nowrap; }

.autotest-report-section ul { margin: 4px 0 0 18px; padding: 0; color: #e74c3c; }
.autotest-report-buttons { display: flex; justify-content: flex-end; margin-top: 8px; }

/* Persistent connection-lost banner (shown after several failed polls,
   hidden again on the next successful poll) */
#connection-lost-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -110%);
  z-index: 10001;
  padding: var(--space-sm) var(--space-md);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  border-bottom: 2px solid #922b21;
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
  pointer-events: none;
}

#connection-lost-banner.show {
  transform: translate(-50%, 0);
}
