:root {
  --bg: #0c0c0e;
  --panel: #121218;
  --panel-2: #18181f;
  --ink: #f2f2f0;
  --muted: #9a9aa3;
  --line: #2a2a32;
  --accent: #c4a35a;
  --blue: #3b82f6;
  --red: #ef4444;
  --ok: #22c55e;
  --warn: #eab308;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --rail-w: 280px;
  --bottom-h: 148px;
  --top-h: auto;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

body {
  min-height: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ——— Login ——— */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 30% 20%, #1a2030, #0c0c0e 60%);
}
.login-gate[hidden],
#app[hidden] {
  display: none !important;
}
.login-card {
  width: min(380px, 92vw);
  background: #141417;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
}
.login-card h1 { margin: 0 0 8px; font-size: 22px; }
.login-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0;
}
.login-label input, .login-label select {
  background: #0e0e12;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 10px;
  font: inherit;
}

/* ——— Theater shell ——— */
.theater {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.chrome-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px 16px;
  align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #14141a, #0f0f14);
  z-index: 5;
}
.chrome-brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}
.chrome-brand h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.brand { color: var(--muted); font-weight: 600; font-size: 12px; }
.sep { color: #555; }
.mode-btns { margin-left: 6px; }
.chrome-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.role-pill {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.role-pill[data-role="blue"] { border-color: var(--blue); color: #93c5fd; }
.role-pill[data-role="red"] { border-color: var(--red); color: #fca5a5; }
.role-pill[data-role="editor"] { border-color: var(--accent); color: #e7d3a1; }

.nav-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}

/* Asset meters — top */
.asset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.meter {
  display: grid;
  grid-template-columns: auto 88px auto;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  min-width: 0;
}
.meter b { color: var(--ink); font-variant-numeric: tabular-nums; min-width: 2.2em; }
.meter-label { text-transform: uppercase; letter-spacing: 0.04em; font-size: 10px; }
.asset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.asset-chip {
  font-size: 10px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #16161c;
  color: var(--muted);
  font-family: var(--mono);
}
.asset-chip strong { color: var(--accent); font-weight: 600; }
.casualty-pills {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
.casualty-pills b { color: #fca5a5; }

.bar {
  height: 7px;
  background: #1c1c24;
  border-radius: 99px;
  overflow: hidden;
}
.bar i { display: block; height: 100%; border-radius: 99px; }
.fill-man { background: linear-gradient(90deg, #1d4ed8, #60a5fa); }
.fill-fuel { background: linear-gradient(90deg, #a16207, #facc15); }
.fill-ammo { background: linear-gradient(90deg, #9a3412, #fb923c); }
.fill-op { background: linear-gradient(90deg, #991b1b, #f87171); }

/* Body: left | map | right */
.theater-body {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr var(--rail-w);
  min-height: 0;
  overflow: hidden;
}

.rail {
  padding: 12px;
  overflow: auto;
  background: var(--panel);
  min-height: 0;
}
.rail-left { border-right: 1px solid var(--line); }
.rail-right { border-left: 1px solid var(--line); }

h2 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.group { margin-bottom: 14px; }

.dossier {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
}
.dossier .title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
}
.dossier .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 3px 0;
  color: var(--muted);
}
.dossier .row b { color: var(--ink); font-weight: 500; }
.dossier .mods {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}
.mod-pill {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 6px;
  border-radius: 4px;
  background: #22222a;
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
}
.mod-pill.good { border-color: #166534; color: #86efac; }
.mod-pill.bad { border-color: #7f1d1d; color: #fca5a5; }

.chrono-card {
  background: radial-gradient(ellipse at 30% 0%, #1e2433, var(--panel-2) 70%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.chrono-card .day {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.chrono-card .phase {
  margin-top: 4px;
  font-size: 13px;
  color: var(--accent);
}
.chrono-card .meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}
.phase-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 10px;
}
.phase-pip {
  height: 4px;
  border-radius: 99px;
  background: #2a2a32;
}
.phase-pip.on { background: var(--accent); }
.phase-pip.past { background: #4a4538; }

.atmosphere {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
}
.atmosphere .wx-main {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.atmosphere .wx-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 11px;
}
.atmosphere .wx-grid b { color: var(--ink); display: block; font-size: 13px; font-weight: 500; }

.ready-pips {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.ready-pip {
  flex: 1;
  text-align: center;
  font-size: 11px;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ready-pip[data-side="blue"].on { border-color: var(--blue); color: #93c5fd; background: #152238; }
.ready-pip[data-side="red"].on { border-color: var(--red); color: #fca5a5; background: #2a1515; }

.ops-list { font-size: 12px; }
.op-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
}
.aar {
  font-size: 11px;
  line-height: 1.4;
  max-height: 140px;
  overflow: auto;
  background: #0e0e12;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}
.aar div { margin-bottom: 4px; }

.stage-wrap {
  position: relative;
  min-height: 0;
  min-width: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(40, 48, 60, 0.35), transparent 50%),
    #1a1814;
  display: flex;
  flex-direction: column;
}
#stage {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}
.legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(20, 20, 24, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}
.legend strong { color: var(--ink); }

/* Bottom command deck */
.chrome-bottom {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: linear-gradient(0deg, #101016, #14141a);
  min-height: var(--bottom-h);
  max-height: 180px;
  z-index: 5;
}
.chrome-bottom[hidden] { display: none !important; }
.bottom-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.bottom-units, .bottom-orders { min-width: 0; }
.unit-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
}
.unit-card {
  flex: 0 0 auto;
  width: 168px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 8px 10px;
  background: #1c1c24;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}
.unit-card:hover { border-color: #555; }
.unit-card.active {
  border-color: var(--accent);
  background: #2a2418;
  color: #fff8e7;
}
.unit-card .muted { font-size: 10px; color: var(--muted); }
.unit-card .ord {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
}
.stack-tag {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.order-hint { margin: 8px 0 0; max-width: 48ch; }

.btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
button, .chip {
  appearance: none;
  border: 1px solid var(--line);
  background: #1c1c22;
  color: var(--ink);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
button:hover { border-color: #555; }
button.active, .chip.active {
  border-color: var(--accent);
  color: #fff8e7;
  background: #2a2418;
}
button.primary {
  border-color: var(--accent);
  background: #2a2418;
  color: #fff8e7;
  font-weight: 600;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0;
}
input[type="range"] { width: 100%; }

.note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 8px;
}
.muted { color: var(--muted); font-size: 12px; }
.c-blue { color: #60a5fa; }
.c-red { color: #f87171; }

@media (max-width: 1100px) {
  :root { --rail-w: 240px; }
  .chrome-top { grid-template-columns: 1fr; }
  .asset-strip { justify-content: flex-start; }
}
@media (max-width: 860px) {
  .theater-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto auto;
  }
  .rail-left, .rail-right {
    border: 0;
    border-top: 1px solid var(--line);
    max-height: 28vh;
  }
  .chrome-bottom {
    grid-template-columns: 1fr;
    max-height: none;
  }
}
