/*
 * Bewegungskrieg client styles — muted low-resolution field-command palette.
 *
 * Goals (DESIGN.md §4.2): clean, modern, lightweight. No CSS frameworks.
 * The DOM is the pinned markup in index.html; PixiJS owns #viewport's canvas.
 * HUD pieces are absolutely-positioned overlays; they only capture pointer
 * events where interaction is needed so the canvas stays draggable underneath.
 *
 * Palette is kept in CSS custom properties and intentionally mirrors the
 * in-canvas COLORS in config.js so DOM chrome and the rendered world feel like
 * one screen.
 */

:root {
  /* Core surfaces */
  --void: #11110f; /* matches COLORS.bgVoid */
  --panel: #27251f;
  --panel-2: #343024;
  --panel-edge: #5b5341;
  --panel-glow: rgba(199, 208, 122, 0.2);

  /* Text */
  --ink: #e7dfc5;
  --ink-dim: #b6ab88;
  --ink-faint: #786f59;

  /* Accents (mirror in-canvas resource colors) */
  --accent: #c7d07a; /* primary action / command tint */
  --steel: #9a9a9a; /* supply crates (COLORS.steel) */
  --oil: #111111; /* fuel drums (COLORS.oil) */
  --supply: #c0a463;
  --good: #7ca45a; /* COLORS.hpGood */
  --warn: #c7a24a;
  --bad: #b64a3f; /* COLORS.hpLow */

  /* Misc */
  --radius: 4px;
  --radius-sm: 2px;
  --shadow: 6px 6px 0 rgba(0, 0, 0, 0.45);
  --hud-z: 10;
  --overlay-z: 100;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: none;
  text-rendering: geometricPrecision;
  image-rendering: pixelated;
}

#app {
  position: relative;
  height: 100vh;
  width: 100vw;
}

#version {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 180px;
  padding: 6px 8px;
  border: 1px solid rgba(91, 83, 65, 0.7);
  background: rgba(17, 17, 15, 0.78);
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0;
  pointer-events: none;
  user-select: none;
}

.status-badge-build,
.status-badge-metrics,
.status-badge-issues {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.status-badge-build {
  color: var(--ink);
}

.status-badge-metric,
.status-badge-issue,
.status-badge-issue-ok {
  color: var(--ink-faint);
}

.status-badge-metric.is-active,
.status-badge-issue.is-active {
  color: var(--bad);
}

.status-badge-issue-ok {
  color: var(--good);
}

#dev-links {
  position: absolute;
  top: 52px;
  left: 10px;
  z-index: 31;
  min-width: 180px;
  padding: 4px 8px;
  border: 1px solid rgba(91, 83, 65, 0.7);
  background: rgba(17, 17, 15, 0.88);
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.4;
  pointer-events: auto;
  user-select: none;
}

#dev-links summary {
  cursor: pointer;
  color: var(--ink);
  list-style: none;
  outline: none;
}

#dev-links summary::before {
  content: "▶ ";
  font-size: 9px;
}

#dev-links[open] summary::before {
  content: "▼ ";
}

#dev-links ul {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

#dev-links li {
  padding: 1px 0;
}

#dev-links a {
  color: var(--ink-faint);
  text-decoration: none;
}

#dev-links a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.dev-links-section {
  margin-top: 4px;
  font-size: 10px;
  color: rgba(160, 148, 120, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dev-links-note {
  color: rgba(160, 148, 120, 0.5);
  font-size: 10px;
}

#dev-banner {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 30;
  padding: 6px 10px;
  border: 1px solid var(--panel-edge);
  background: rgba(17, 17, 15, 0.92);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  pointer-events: none;
}

/* A full-screen screen container. Only one is visible at a time; the [hidden]
   attribute (toggled from main.js) wins over display. */
.screen {
  position: absolute;
  inset: 0;
}
[hidden] {
  display: none !important;
}

/* ============================ Buttons ============================ */
.btn {
  appearance: none;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease,
    background 0.12s ease, transform 0.04s ease;
}
.btn:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--panel-glow);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn.primary {
  border-color: #e1d790;
  background: var(--accent);
  color: #191710;
}
.btn.primary:hover:not(:disabled) {
  box-shadow: inset 0 0 0 2px rgba(17, 17, 15, 0.25);
}
.btn.danger {
  border-color: #d28a70;
  background: var(--bad);
  color: #fff5ea;
}
.btn.danger:hover:not(:disabled) {
  box-shadow: inset 0 0 0 2px rgba(17, 17, 15, 0.25);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* Toggled "ready" state on the lobby ready button. */
.btn.on,
.btn.active {
  border-color: var(--good);
  box-shadow: 0 0 0 1px rgba(79, 210, 79, 0.4);
  color: var(--good);
}

/* ============================ LOBBY ============================ */
#lobby-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.035) 25%, transparent 25% 75%, rgba(0, 0, 0, 0.08) 75%),
    linear-gradient(45deg, rgba(0, 0, 0, 0.08) 25%, transparent 25% 75%, rgba(255, 255, 255, 0.035) 75%),
    var(--void);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
  padding: 24px;
}

.lobby-box {
  width: min(440px, 100%);
  background: rgba(39, 37, 31, 0.98);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: 28px 28px 22px;
}

.logo {
  margin: 0;
  text-align: center;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-shadow: 2px 2px 0 #191710;
}
.subtitle {
  margin: 2px 0 0;
  text-align: center;
  color: var(--ink-dim);
  font-size: 16px;
  letter-spacing: 0.08em;
}
.tagline {
  margin: 6px 0 22px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 13px;
}

.lobby-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lobby-form label,
.lobby-room h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}
.lobby-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lobby-form .toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.lobby-form .toggle input {
  margin: 0;
  accent-color: var(--accent);
}

input[type="text"] {
  width: 100%;
  background: var(--void);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input[type="text"]::placeholder {
  color: var(--ink-faint);
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(199, 208, 122, 0.22);
}

.lobby-form .btn {
  margin-top: 4px;
}

/* The "room" block (player list + actions) is revealed by removing [hidden]. */
.lobby-room {
  margin-top: 22px;
  border-top: 1px solid var(--panel-edge);
  padding-top: 18px;
}
.lobby-room h2 {
  margin: 0 0 10px;
}

.player-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--void);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
/* Color swatch keyed off each player's assigned color. */
.player-list .swatch {
  width: 14px;
  height: 14px;
  border-radius: 1px;
  flex: 0 0 auto;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.player-list .name {
  flex: 1 1 auto;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-list .host-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--supply);
  border: 1px solid rgba(240, 198, 74, 0.4);
  border-radius: 4px;
  padding: 1px 6px;
}
/* Ready check pill. .ready flips it to the "go" color. */
.player-list .ready-check {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-faint);
}
.player-list .ready-check.ready {
  color: var(--good);
}

.lobby-map-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}
.lobby-map-row select {
  flex: 1 1 auto;
  appearance: none;
  background: var(--void) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23786f59'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  padding: 8px 28px 8px 10px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.lobby-map-row select:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(199, 208, 122, 0.22);
}
.lobby-map-row select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.lobby-map-row #lobby-map-display {
  flex: 1 1 auto;
  font-size: 14px;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}

.lobby-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.lobby-actions .btn {
  flex: 1 1 0;
}
/* The Add AI button is only shown to the host (toggled via [hidden] in lobby.js). */
.lobby-actions #lobby-add-ai {
  flex: 0 0 auto;
}

.lobby-actions .toggle {
  flex: 1 1 100%;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-dim);
  cursor: pointer;
  user-select: none;
}
.lobby-actions .toggle input {
  margin: 0;
  accent-color: var(--accent);
}

/* Player row pieces (class names emitted by lobby.js). */
.player-list .player-color {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex: 0 0 auto;
  box-shadow: 0 0 8px currentColor;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.player-list .player-name {
  flex: 1 1 auto;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-list .player-tags {
  display: inline-flex;
  gap: 6px;
}
.player-list .tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 4px;
  padding: 1px 6px;
}
.player-list .tag.host {
  color: var(--supply);
  border: 1px solid rgba(240, 198, 74, 0.4);
}
.player-list .tag.ai {
  color: var(--ink-faint);
  border: 1px solid var(--panel-edge);
}
.player-list .tag.spectator {
  color: var(--accent);
  border: 1px solid rgba(199, 208, 122, 0.38);
}
.player-list .player-ready {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-faint);
}
.player-list .player-ready.ready {
  color: var(--good);
}
.player-list .player-ready.spectator {
  color: var(--accent);
}
/* Host-only remove control on AI rows. */
.player-list .player-remove {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1;
  color: var(--bad);
}
.player-list li.is-ai {
  opacity: 0.92;
}
.player-list li.is-spectator {
  opacity: 0.9;
}

.status {
  margin: 14px 0 0;
  min-height: 1em;
  text-align: center;
  font-size: 13px;
  color: var(--warn);
}
.status.error {
  color: var(--bad);
}
.hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.5;
}

/* ============================ GAME ============================= */
#game-screen {
  background: var(--void);
}

/* The Pixi canvas mounts here and fills the screen. It sits below the HUD. */
#viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: crosshair;
}
#viewport canvas {
  display: block;
}
#viewport.pointer-locked {
  cursor: none;
}
.pointer-lock-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  margin-top: -9px;
  z-index: 90;
  pointer-events: none;
}
.pointer-lock-cursor::before,
.pointer-lock-cursor::after {
  content: "";
  position: absolute;
  background: #fff5ea;
  box-shadow: 0 0 0 1px rgba(25, 23, 16, 0.85), 0 0 6px rgba(210, 138, 112, 0.65);
}
.pointer-lock-cursor::before {
  left: 8px;
  top: 0;
  width: 2px;
  height: 18px;
}
.pointer-lock-cursor::after {
  left: 0;
  top: 8px;
  width: 18px;
  height: 2px;
}

/* HUD overlays do not eat pointer events by default; only interactive
   sub-panels opt back in via pointer-events:auto. */
#hud,
#minimap-wrap,
#selection-area,
#game-menu,
#command-card,
#toast {
  position: absolute;
  z-index: var(--hud-z);
}

/* Shared frosted-panel look for HUD chrome. */
.hud-panel,
#hud,
#minimap-wrap,
#selected-panel,
#command-card {
  background: rgba(39, 37, 31, 0.94);
  border: 1px solid var(--panel-edge);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* --- Above-card settings menu --- */
#game-menu {
  right: 12px;
  bottom: 273px;
  z-index: 20;
  pointer-events: auto;
}
#settings-button {
  appearance: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  background: rgba(39, 37, 31, 0.94);
  color: var(--ink);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
#settings-button:hover {
  border-color: var(--accent);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.4), inset 0 0 0 1px var(--panel-glow);
}
#settings-menu {
  position: absolute;
  right: 0;
  bottom: 44px;
  min-width: 240px;
  padding: 8px;
}
.audio-settings {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 245, 234, 0.12);
}
.audio-slider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  font-size: 12px;
  color: var(--ink);
}
.audio-slider-label {
  flex: 0 0 64px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.audio-slider input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: #d28a70;
  cursor: pointer;
}
#settings-menu button {
  appearance: none;
  width: 100%;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0;
  text-align: left;
  padding: 8px 10px;
}
#settings-menu button:hover {
  border-color: #d28a70;
  background: rgba(182, 74, 63, 0.18);
  color: #fff5ea;
}
#settings-menu button[aria-checked="true"] {
  border-color: #d28a70;
  background: rgba(210, 138, 112, 0.22);
  color: #fff5ea;
}
#settings-menu button:disabled {
  cursor: default;
  opacity: 0.5;
}

/* --- Give-up confirmation --- */
#give-up-confirm {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(17, 17, 15, 0.55);
  pointer-events: auto;
}
.give-up-box {
  width: min(380px, calc(100vw - 32px));
  padding: 22px;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  background: rgba(39, 37, 31, 0.98);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.give-up-box h2 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 24px;
  letter-spacing: 0;
}
.give-up-box p {
  margin: 0 0 18px;
  color: var(--ink-dim);
  line-height: 1.45;
}
.give-up-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --- Top resource bar --- */
#hud {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 24px;
  padding: 9px 20px;
  border-radius: var(--radius);
  pointer-events: none; /* read-only readout */
  font-variant-numeric: tabular-nums;
}
#hud .res {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0;
}
#hud .res-icon {
  font-size: 14px;
  line-height: 1;
}
#hud .res-icon.steel {
  color: var(--steel);
  text-shadow: 1px 1px 0 #191710;
}
#hud .res-icon.oil {
  color: var(--oil);
  text-shadow: 1px 1px 0 #191710;
}
#hud .res-icon.supply {
  color: var(--supply);
}
/* hud.js marks supply as capped when supplyUsed >= supplyCap. */
#hud .res.over #res-supply,
#res-supply.supply-capped {
  color: var(--bad);
}

/* Replay mode: one row per player, color dot on the left. */
#hud:has(.replay-player-res) {
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  left: 12px;
  transform: none;
  padding: 8px 14px;
}
.replay-player-res {
  gap: 8px;
  font-size: 14px;
}
.replay-player-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
}
.replay-res-val {
  min-width: 28px;
  display: inline-block;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.replay-res-val.supply-capped {
  color: var(--bad);
}

/* --- Bottom-left minimap frame --- */
#minimap-wrap {
  left: 12px;
  bottom: 12px;
  padding: 8px;
  border-radius: var(--radius);
  pointer-events: auto; /* clickable: pan / move commands */
  line-height: 0;
}
#minimap {
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: var(--void);
  cursor: pointer;
  image-rendering: pixelated;
}

/* --- Bottom-center selected panel --- */
#selection-area {
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: clamp(280px, 36vw, 520px);
  max-width: calc(100vw - 24px);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
#control-group-tabs {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 4px;
  min-height: 24px;
  margin: 0 4px -1px;
  pointer-events: none;
}
#control-group-tabs.empty {
  min-height: 0;
  margin-top: 0;
  margin-bottom: 0;
}
.control-group-slot {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: end;
}
.control-group-tab {
  position: relative;
  width: 100%;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 4px 3px 12px;
  border: 1px solid var(--panel-edge);
  border-bottom-color: rgba(39, 37, 31, 0.94);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: rgba(52, 48, 36, 0.96);
  color: var(--ink);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.control-group-tab.selected {
  background: rgba(26, 25, 21, 0.98);
  border-color: #4b4435;
  border-bottom-color: rgba(26, 25, 21, 0.98);
  color: #fff5ea;
}
.control-group-key {
  position: absolute;
  top: 3px;
  left: 4px;
  color: var(--ink-faint);
  font-size: 9px;
  font-weight: 700;
}
.control-group-kind {
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}
.control-group-count {
  color: var(--ink-dim);
  flex: 0 0 auto;
  font-weight: 700;
  text-align: right;
}
#selected-panel {
  min-width: 280px;
  width: 100%;
  min-height: 92px;
  padding: 10px 14px;
  border-radius: var(--radius);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#selected-panel .sel-name,
#selected-panel .sel-title {
  font-weight: 700;
  font-size: 14px;
}
#selected-panel .sel-hptext,
#selected-panel .sel-sub {
  font-size: 12px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
#selected-panel .sel-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
#selected-panel .sel-stat strong {
  color: var(--supply);
  font-weight: 700;
}
/* HP read-out / bar inside the selected panel. */
#selected-panel .sel-hp {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}
#selected-panel .sel-single {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#selected-panel .sel-hpbar {
  height: 6px;
  border-radius: 0;
  background: #101010;
  overflow: hidden;
}
#selected-panel .sel-hpfill {
  height: 100%;
  background: var(--good);
}
#selected-panel .sel-hpfill.mid {
  background: var(--warn);
}
#selected-panel .sel-hpfill.low {
  background: var(--bad);
}
#selected-panel .bar {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 0;
  background: #101010; /* COLORS.hpBack */
  overflow: hidden;
}
#selected-panel .bar > span {
  display: block;
  height: 100%;
  background: var(--good);
}
#selected-panel .bar.mid > span {
  background: var(--warn);
}
#selected-panel .bar.low > span {
  background: var(--bad);
}
/* Multi-select roster: little icon chips. */
#selected-panel .sel-grid,
#selected-panel .sel-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
#selected-panel .sel-chip {
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 4px;
  place-items: center;
  font-size: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: var(--void);
}

/* Production progress inside #selected-panel (buildings training units). */
#selected-panel .sel-prod-label {
  font-size: 11px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
#selected-panel .sel-prod-bar {
  height: 5px;
  background: #101010;
  border-radius: 0;
  overflow: hidden;
}
#selected-panel .sel-prod-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s linear;
}

/* --- Bottom-right command card (3x3 fixed grid of buttons) --- */
#command-card {
  right: 12px;
  bottom: 12px;
  padding: 13px;
  border-radius: var(--radius);
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(3, 75px);
  grid-auto-rows: 75px;
  gap: 11px;
}
.cmd-empty {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  opacity: 0.25;
  pointer-events: none;
}
.cmd-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius-sm);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  padding: 0;
  transition: border-color 0.1s ease, box-shadow 0.1s ease, transform 0.04s ease;
}
.cmd-btn:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--panel-glow);
}
.cmd-btn.active:not(:disabled) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent), 0 0 10px var(--panel-glow);
}
.cmd-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.cmd-btn:disabled {
  cursor: not-allowed;
}
.cmd-btn:disabled .cmd-icon,
.cmd-btn:disabled .cmd-label,
.cmd-btn:disabled .cmd-hotkey,
.cmd-btn:disabled .cmd-cost {
  opacity: 0.38;
}
.cmd-btn .cmd-icon {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}
.cmd-btn .cmd-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--ink-dim);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Hotkey badge, top-left. */
.cmd-btn .cmd-hotkey {
  position: absolute;
  top: 0;
  left: 0;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--void);
  background: var(--accent);
  border-right: 1px solid var(--panel-edge);
  border-bottom: 1px solid var(--panel-edge);
}
.cmd-btn .cmd-ready-count {
  position: absolute;
  top: 3px;
  right: 4px;
  min-width: 14px;
  padding: 0 3px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  background: rgba(17, 17, 15, 0.82);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
}
.cmd-btn .cmd-cooldowns {
  position: absolute;
  top: 5px;
  right: 23px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.cmd-btn .cmd-cd-clock {
  position: relative;
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  background: rgba(17, 17, 15, 0.92);
}
.cmd-btn .cmd-cd-arm {
  position: absolute;
  left: 50%;
  top: 1px;
  width: 1px;
  height: 4px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(17, 17, 15, 0.18);
  transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(var(--cooldown-rotation, 0deg));
}
/* Cost badge, bottom edge. Steel / oil costs colored to match the world. */
.cmd-btn .cmd-cost {
  position: absolute;
  bottom: 4px;
  right: 5px;
  display: flex;
  gap: 1px;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cmd-btn .cmd-cost .c-steel {
  color: var(--steel);
}
.cmd-btn .cmd-cost .c-sep {
  color: inherit;
  font-weight: 400;
}
.cmd-btn .cmd-cost .c-oil {
  color: #8aaf6a;
}
/* Unaffordable cost shown in red even though the whole button may be disabled. */
.cmd-btn.unaffordable .cmd-cost {
  color: var(--bad);
}

/* --- Replay speed controls --- */
#replay-speed {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  gap: 4px;
}
.spd-btn {
  appearance: none;
  border: 1px solid var(--panel-edge);
  background: rgba(17, 17, 15, 0.88);
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.1s, color 0.1s;
}
.spd-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}
.spd-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(17, 17, 15, 0.95);
}
.spd-sep {
  display: inline-block;
  width: 1px;
  align-self: stretch;
  background: var(--panel-edge);
  margin: 2px 4px;
}
.seek-btn {
  color: var(--ink);
}

/* --- Transient toast --- */
#toast {
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 60vw;
  padding: 11px 20px;
  border-radius: var(--radius);
  background: rgba(39, 37, 31, 0.96);
  border: 1px solid var(--bad);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  box-shadow: var(--shadow);
  pointer-events: none;
  animation: toast-in 0.16s ease-out;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* --- Game-over overlay --- */
#game-over {
  position: absolute;
  inset: 0;
  z-index: var(--overlay-z);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 13, 0.18);
  backdrop-filter: none;
}
.game-over-box {
  text-align: center;
  background: rgba(39, 37, 31, 0.98);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: min(960px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 32px 40px;
}
#game-over-text {
  margin: 0 0 22px;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
/* Verdict tint set via data-verdict in main.js (won/lost/draw). */
#game-over-text[data-verdict="won"] {
  color: var(--good);
  text-shadow: 2px 2px 0 #191710;
}
#game-over-text[data-verdict="lost"] {
  color: var(--bad);
  text-shadow: 2px 2px 0 #191710;
}
#game-over-text[data-verdict="draw"] {
  color: var(--supply);
}
.scoreboard {
  margin: 0 0 24px;
  overflow-x: auto;
}
.score-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0;
}
.score-table th,
.score-table td {
  border-bottom: 1px solid rgba(91, 83, 65, 0.72);
  padding: 9px 10px;
  vertical-align: middle;
}
.score-table th {
  color: var(--ink-dim);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
  text-transform: uppercase;
  white-space: normal;
}
.score-table th:first-child,
.score-table td:first-child {
  width: 28%;
  text-align: left;
}
.score-table tbody tr.you {
  background: rgba(199, 208, 122, 0.08);
}
.score-table tbody tr.winner .score-name {
  color: var(--good);
}
.score-player {
  white-space: nowrap;
}
.score-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 1px solid rgba(231, 223, 197, 0.45);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
  margin-right: 8px;
  vertical-align: middle;
}
.score-name {
  display: inline-block;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}
.score-number {
  color: var(--ink);
  font-family: var(--mono);
  text-align: right;
  white-space: nowrap;
}

/* ============================ Responsive ============================ */
/* Keep everything usable down to ~1280x720: shrink the command card grid and
   tighten gaps so the bottom row of HUD panels does not overlap. */
@media (max-width: 1366px), (max-height: 768px) {
  #command-card {
    grid-template-columns: repeat(3, 64px);
    grid-auto-rows: 64px;
    gap: 8px;
    padding: 11px;
  }
  #game-menu {
    bottom: 250px;
  }
  .cmd-btn .cmd-icon {
    font-size: 20px;
  }
  #selected-panel {
    min-width: 240px;
    max-width: 40vw;
  }
  #minimap {
    width: 198px;
    height: 198px;
  }
  #game-over-text {
    font-size: 36px;
  }
  .game-over-box {
    padding: 26px 28px;
  }
  .score-table {
    font-size: 12px;
  }
}
