/* ================================================================
   TACTICAL WARZONE — Main Stylesheet
   Vertical smartphone-first layout (reference: 390x844)
   ================================================================ */

/* ── Custom Properties ─────────────────────────────────────────── */
:root {
  --bg:            #0d1117;
  --surface:       #161b22;
  --surface-2:     #1f2937;
  --border:        #30363d;
  --accent:        #2d6a4f;
  --accent-hover:  #3a8f68;
  --accent-light:  #52b788;
  --danger:        #c0392b;
  --danger-hover:  #e74c3c;
  --text:          #e6edf3;
  --text-muted:    #8b949e;
  --gold:          #e9c46a;

  /* Player colours */
  --p1: #e63946;
  --p2: #457b9d;
  --p3: #2a9d8f;
  --p4: #f4a261;

  /* Layout heights */
  --status-h:  56px;
  --unit-h:    100px;
  --action-h:  72px;

  /* Safe area for notch/home bar (iOS) */
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

/* ── App Shell ──────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ── Status Bar ─────────────────────────────────────────────────── */
#status-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--status-h);
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

#status-player {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.player-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}

#status-player-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#status-center {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

#status-round-num {
  color: var(--text);
  font-weight: 700;
}

#status-phase-label {
  color: var(--accent-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
}

.status-sep { opacity: 0.3; }

#status-gold {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.gold-icon { font-size: 14px; }

/* ── Canvas Container ───────────────────────────────────────────── */
#canvas-container {
  flex: 1 1 0;
  overflow: hidden;
  position: relative;
  background: #0a0f14;
  cursor: default;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ── Unit Info Panel ────────────────────────────────────────────── */
#unit-info {
  flex-shrink: 0;
  height: var(--unit-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 8px 12px;
  overflow: hidden;
}

#unit-info-hint {
  color: var(--text-muted);
  font-size: 12px;
  width: 100%;
  text-align: center;
  font-style: italic;
}

#unit-info-details {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#unit-info-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

#unit-portrait {
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

#unit-info-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  max-width: 60px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#unit-info-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
  width: 36px;
  flex-shrink: 0;
}

.stat-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.stat-bar {
  height: 100%;
  background: var(--accent-light);
  border-radius: 3px;
  transition: width 0.2s ease;
  width: 100%;
}

.stat-bar.fuel { background: #e9c46a; }
.stat-bar.ammo { background: #e63946; }

.stat-val {
  font-size: 11px;
  font-weight: 600;
  width: 28px;
  text-align: right;
  flex-shrink: 0;
}

#unit-info-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.unit-stat-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  min-width: 48px;
}

.chip-icon {
  font-size: 10px;
  opacity: 0.7;
}

/* ── Action Bar ─────────────────────────────────────────────────── */
#action-bar {
  flex-shrink: 0;
  height: var(--action-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

#action-bar::-webkit-scrollbar { display: none; }

.action-btn {
  flex-shrink: 0;
  height: 48px;
  min-width: 80px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
}

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

.action-btn:hover {
  background: #2d333b;
  border-color: var(--accent-light);
}

.action-btn.primary {
  background: var(--accent);
  border-color: var(--accent-light);
  color: #fff;
}

.action-btn.primary:hover { background: var(--accent-hover); }

.action-btn.danger {
  background: var(--danger);
  border-color: #e55a4e;
  color: #fff;
}

/* ── Screens (Menu, Settings …) ─────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px 20px;
  padding-top: calc(24px + var(--safe-top));
  padding-bottom: calc(24px + var(--safe-bottom));
  gap: 20px;
}

/* ── Main Menu ──────────────────────────────────────────────────── */
#menu-title {
  text-align: center;
  line-height: 1;
  margin-bottom: 12px;
}

.menu-title-main {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--accent-light);
  text-shadow: 0 0 30px rgba(82,183,136,0.4);
}

.menu-title-sub {
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.4em;
  color: var(--text-muted);
  margin-top: 4px;
}

#menu-lang {
  display: flex;
  gap: 10px;
}

.lang-btn {
  padding: 6px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.lang-btn.active {
  background: var(--accent);
  border-color: var(--accent-light);
  color: #fff;
}

#menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.menu-btn {
  width: 100%;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 0.04em;
}

.menu-btn:hover, .menu-btn:active {
  background: var(--accent);
  border-color: var(--accent-light);
  color: #fff;
}

#menu-version {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.5;
  margin-top: auto;
}

/* ── Overlays ───────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.overlay-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 320px;
  width: 80%;
}

#overlay-phase-player {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#overlay-phase-text {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent-light);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#overlay-pass-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

#overlay-pass-btn {
  width: 100%;
  height: 48px;
  border-radius: 10px;
  background: var(--accent);
  border: 1px solid var(--accent-light);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

#overlay-pass-btn:hover { background: var(--accent-hover); }

#overlay-phase-return {
  margin-top: 4px;
  padding: 10px 28px;
  border: 1px solid var(--accent-light);
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#overlay-phase-return:hover { background: var(--accent-hover); }

/* ── Utilities ──────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Player colour helpers (applied via JS: data-player="1") */
[data-player="1"] .player-dot,
[data-player="1"].player-dot { background: var(--p1); }
[data-player="2"] .player-dot,
[data-player="2"].player-dot { background: var(--p2); }
[data-player="3"] .player-dot,
[data-player="3"].player-dot { background: var(--p3); }
[data-player="4"] .player-dot,
[data-player="4"].player-dot { background: var(--p4); }

/* ── Scrollbar (desktop) ────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ================================================================
   PHASE 6 — Menu System additions
   ================================================================ */

/* ── Flow screens (top-aligned, scrollable body) ────────────────── */
.screen--flow {
  justify-content: flex-start;
  align-items: stretch;
  padding: 0;
  gap: 0;
}

.screen-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 16px;
  padding-top: var(--safe-top);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.back-btn {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border: none;
  background: transparent;
  color: var(--accent-light);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.back-btn:hover, .back-btn:active { background: var(--surface-2); }

.screen-header-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}

.screen-body {
  flex: 1 1 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  -webkit-overflow-scrolling: touch;
}

.screen-footer {
  flex-shrink: 0;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ── Segmented control ──────────────────────────────────────────── */
.seg-control {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-wrap: wrap;
}

.seg-btn {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  padding: 0 8px;
  -webkit-tap-highlight-color: transparent;
}

.seg-btn:last-child { border-right: none; }

.seg-btn:hover:not(.locked):not(.active) {
  background: var(--surface-2);
  color: var(--text);
}

.seg-btn.active {
  background: var(--accent);
  color: #fff;
}

.seg-btn.locked {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Setup section ──────────────────────────────────────────────── */
.setup-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setup-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Player rows ────────────────────────────────────────────────── */
#player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto 20px;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.player-row-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-row-name {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 8px;
  min-width: 0;
  outline: none;
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.player-row-name:focus { border-color: var(--accent-light); }
.player-row-name::placeholder { color: var(--text-muted); font-weight: 400; }

.player-row-badge {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  white-space: nowrap;
}
.player-row-badge.badge-ai { color: var(--gold); }

.player-row-toggle {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.player-row-toggle.is-ai {
  background: rgba(233,196,106,0.12);
  border-color: var(--gold);
  color: var(--gold);
}

.player-row-diff {
  font-size: 12px;
  padding: 6px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--gold);
  outline: none;
  cursor: pointer;
  max-width: 80px;
}

.player-row-diff-spacer,
.player-row-remove-spacer {
  display: block;
}

.player-row-remove {
  width: 20px; height: 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.player-row-remove:hover { color: var(--danger); background: rgba(192,57,43,0.15); }

.add-player-btn {
  align-self: flex-start;
  padding: 8px 16px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.add-player-btn:hover {
  border-color: var(--accent-light);
  color: var(--accent-light);
}

/* ── Map cards ──────────────────────────────────────────────────── */
#map-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.map-card:hover:not(.disabled) {
  border-color: var(--accent-light);
  background: var(--surface-2);
}

.map-card.selected {
  border-color: var(--accent-light);
  background: rgba(45,106,79,0.15);
}

.map-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.map-thumb {
  border-radius: 6px;
  flex-shrink: 0;
  image-rendering: pixelated;
  border: 1px solid var(--border);
}

.map-card-info {
  flex: 1;
  min-width: 0;
}

.map-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.map-card-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.map-card-warn {
  font-size: 10px;
  color: var(--gold);
  margin-top: 3px;
  font-weight: 600;
}

/* ── Start button (full-width inside screen-footer) ─────────────── */
.start-btn {
  width: 100%;
  height: 52px;
  font-size: 16px;
  font-weight: 700;
  background: var(--accent);
  border: 1px solid var(--accent-light);
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.start-btn:hover  { background: var(--accent-hover); }
.start-btn:active { transform: scale(0.97); }

/* ── Settings screen ────────────────────────────────────────────── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }

.settings-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  flex-shrink: 0;
}

.settings-section--danger {
  background: transparent;
  border: none;
  border-radius: 0;
  display: flex;
  justify-content: center;
}

.danger-btn {
  padding: 12px 24px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: transparent;
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.danger-btn:hover, .danger-btn:active {
  background: var(--danger);
  color: #fff;
}

/* ── Toast notifications ────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(340px, 90vw);
}

.toast {
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  opacity: 0;
  transform: translateY(12px) scale(0.94);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  max-width: 100%;
  text-align: center;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast--info  { border-color: var(--accent-light); color: var(--accent-light); }
.toast--warn  { border-color: var(--gold);          color: var(--gold); }
.toast--error { border-color: var(--danger);        color: #ff9f9f; }

/* ================================================================
   PHASE 7 — Lobby Screen
   ================================================================ */

/* ── Text inputs (shared: server URL, player name, room code) ── */
.lobby-text-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  margin-bottom: 8px;
  -webkit-tap-highlight-color: transparent;
}
.lobby-text-input:focus { border-color: var(--accent-light); }
.lobby-text-input::placeholder { color: var(--text-muted); }

/* ── Join row (code input + button side by side) ─────────────── */
.join-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.lobby-code-input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 10px 12px;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.lobby-code-input:focus { border-color: var(--accent-light); }

.join-btn {
  flex-shrink: 0;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--accent-light);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.join-btn:hover { background: var(--accent-hover); }

/* ── Divider ─────────────────────────────────────────────────── */
.lobby-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 10px 0;
}

/* ── Status / feedback line ──────────────────────────────────── */
.lobby-status-area {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lobby-status-msg {
  font-size: 13px;
  color: var(--gold);
  text-align: center;
}

/* ── Waiting room ── room-code banner ────────────────────────── */
.room-code-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  margin-bottom: 8px;
}

.room-code-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.room-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.room-code-value {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: var(--gold);
  font-family: monospace;
}

.copy-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 18px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.copy-btn:hover { color: var(--accent-light); border-color: var(--accent-light); }

/* ── Lobby player list extras ─────────────────────────────────── */
.lobby-player-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.player-row--empty {
  opacity: 0.5;
  border-style: dashed;
}

.badge-ready {
  background: rgba(45,106,79,0.25) !important;
  border-color: var(--accent-light) !important;
  color: var(--accent-light) !important;
}

/* ── Status bar: right cluster ────────────────────────────────── */
#status-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 17px;
  padding: 4px 5px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.status-icon-btn:active { opacity: 1; }

/* ── Save / Load overlay ──────────────────────────────────────── */
.save-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: calc(100% - 32px);
  max-width: 380px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

.save-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.save-modal-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text);
}

.save-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.save-close-btn:hover { color: var(--text); }

.save-slot-list {
  padding: 8px 0;
}

.save-slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.save-slot-row:last-child { border-bottom: none; }

.save-slot-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.save-slot-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.save-slot-detail {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.save-slot-date {
  font-size: 10px;
  color: var(--accent-light);
}

.save-slot-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.save-slot-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.save-slot-btn:hover:not(:disabled) { background: var(--accent-hover); }
.save-slot-btn:disabled { opacity: 0.35; cursor: default; }

.save-slot-del {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s, border-color 0.12s;
}
.save-slot-del:hover { color: var(--danger); border-color: var(--danger); }

/* ── Tutorial card ────────────────────────────────────────────── */
#tutorial-card {
  position: fixed;
  top: calc(var(--status-h) + var(--safe-top) + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 370px;
  background: rgba(22, 27, 34, 0.95);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 14px 16px 12px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
}
#tutorial-card.hidden { display: none; }

.tut-header {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.tut-counter {
  font-size: 11px;
  color: var(--accent-light);
  font-weight: 700;
  white-space: nowrap;
  padding-top: 1px;
}

.tut-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}

.tut-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tut-skip {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tut-skip:hover { border-color: var(--text-muted); color: var(--text); }

.tut-next {
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.tut-next:hover { background: var(--accent-hover); }

/* ================================================================
   PRODUCTION OVERLAY
   ================================================================ */

.prod-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
  z-index: 250;
  animation: slide-up 0.22s ease both;
}

.prod-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.prod-title {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
}
.prod-gold-display {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
}
.prod-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

.prod-unit-list {
  overflow-y: auto;
  padding: 8px 12px;
  padding-bottom: calc(12px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

.prod-unit-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, border-color 0.12s;
}
.prod-unit-btn:hover:not(:disabled) { background: #253040; border-color: var(--accent-light); }
.prod-unit-btn:disabled { opacity: 0.38; cursor: default; }

.prod-unit-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  font-family: monospace;
  color: var(--accent-light);
  flex-shrink: 0;
}
.prod-unit-info { flex: 1; min-width: 0; }
.prod-unit-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}
.prod-unit-stats {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.prod-unit-cost {
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ================================================================
   PHASE 10 — MAP EDITOR
   ================================================================ */

/* Editor screen overrides — no base padding, fills full height */
#screen-editor {
  padding: 0;
  gap: 0;
}

/* Header save button */
.editor-save-hdr-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.editor-save-hdr-btn:hover { background: var(--accent-hover); }

/* Toolbar strip */
.editor-toolbar {
  flex-shrink: 0;
  padding: 8px 12px 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-meta-row { display: flex; gap: 8px; }

.editor-name-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
}
.editor-name-input:focus { outline: none; border-color: var(--accent-light); }

.editor-size-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
}

/* Tile palette */
.editor-palette { display: flex; flex-wrap: wrap; gap: 4px; }

.palette-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 2px solid transparent;
  color: var(--text);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 7px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.12s;
}
.palette-btn.active { border-color: var(--accent-light); }
.palette-btn:hover  { background: var(--surface); }
.palette-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* Player placement panel */
.editor-player-panel { display: flex; flex-direction: column; gap: 6px; }

.editor-count-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.editor-player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.editor-player-dot   { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.editor-player-label { flex: 1; font-weight: 600; }
.editor-player-status { display: flex; gap: 6px; }
.ep-ok   { color: var(--accent-light); font-weight: 700; }
.ep-miss { color: var(--text-muted); }

.editor-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding-bottom: 2px;
}

/* Canvas area */
.editor-canvas-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: #0a0d12;
  touch-action: none;
}
#editor-canvas {
  position: absolute;
  top: 0; left: 0;
  image-rendering: pixelated;
}

/* "Create Map" button in Setup screen map list */
.create-map-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  color: var(--accent-light);
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s, border-color 0.12s;
}
.create-map-btn:hover { background: var(--surface); border-color: var(--accent-light); }

/* Edit button on custom map cards */
.map-card { position: relative; }
.map-card-edit-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 1;
}
.map-card-edit-btn:hover { color: var(--text); border-color: var(--accent-light); }

/* ================================================================
   PHASE 11 — POLISH & PWA
   ================================================================ */

/* ── Screen enter animation ──────────────────────────────────────── */
@keyframes screen-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen:not(.hidden) {
  animation: screen-enter 0.20s ease both;
}

/* ── Focus ring (accessibility) ──────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}

/* ── "About" button — minor style variant ────────────────────────── */
.menu-btn--minor {
  font-size: 13px;
  padding: 10px 20px;
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.menu-btn--minor:hover { color: var(--text); background: var(--surface-2); }

/* ── Loading overlay ─────────────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 32px;
  transition: opacity 0.30s ease;
}
#loading-overlay.fade-out { opacity: 0; pointer-events: none; }
#loading-overlay.gone     { display: none; }

.loading-logo { text-align: center; }
.loading-star {
  font-size: 72px;
  color: var(--accent-light);
  text-shadow: 0 0 40px rgba(82,183,136,0.5);
  animation: loading-pulse 1.6s ease-in-out infinite;
}
@keyframes loading-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
.loading-name {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  margin-top: 8px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Landscape warning ───────────────────────────────────────────── */
#landscape-warn {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
@media (orientation: landscape) and (max-height: 480px) {
  #landscape-warn { display: flex; }
}
.landscape-icon {
  font-size: 56px;
  animation: rotate-hint 2s ease-in-out infinite;
}
@keyframes rotate-hint {
  0%, 80%, 100% { transform: rotate(0deg); }
  40%           { transform: rotate(-90deg); }
}
.landscape-text {
  font-size: 16px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Install banner ──────────────────────────────────────────────── */
#install-banner {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 12px;
  right: 12px;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: slide-up 0.28s ease both;
}
@keyframes slide-up {
  from { transform: translateY(80px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.install-icon { font-size: 22px; flex-shrink: 0; }
#install-banner-text {
  flex: 1;
  font-size: 13px;
  color: var(--text);
  line-height: 1.3;
}
.install-accept-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.install-accept-btn:hover { background: var(--accent-hover); }
.install-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── About screen ────────────────────────────────────────────────── */
.about-logo {
  text-align: center;
  padding: 20px 0 8px;
}
.about-star {
  font-size: 52px;
  color: var(--accent-light);
  text-shadow: 0 0 24px rgba(82,183,136,0.4);
  line-height: 1;
}
.about-game-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--text);
  margin-top: 6px;
}
.about-version {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.about-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 0;
}
.about-section--credits { border-style: dashed; }

.about-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 10px;
}
.about-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-line;
}

.about-steps { display: flex; flex-direction: column; gap: 8px; }
.about-step  { display: flex; align-items: flex-start; gap: 12px; }
.about-step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--accent-light);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.about-step-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.about-control-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  align-items: center;
}
.ctrl-gesture {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}
.ctrl-desc {
  font-size: 12px;
  color: var(--text-muted);
}
