:root {
  --md-bg: #10140f;
  --md-panel: rgba(12, 18, 12, 0.9);
  --md-line: rgba(201, 232, 106, 0.22);
  --md-canary: #f5d76e;
  --md-green: #2d8a4e;
  --md-lime: #c9e86a;
  --md-alert: #ff5a36;
  --md-ok: #7dcea0;
  --md-thin: #e8a838;
  --md-muted: #b7c2ae;
  --md-away: #8aa4c8;
  --md-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--md-bg);
  color: #eef3e8;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

body.md-play #mh-navbar,
body.md-play #mh-version-footer-only {
  display: none !important;
}

#view {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: linear-gradient(180deg, rgba(10, 14, 10, 0.92), rgba(10, 14, 10, 0.35) 80%, transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.topbar a.leave {
  color: var(--md-canary);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 0.85rem;
}
.brand {
  font-family: Barlow, sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--md-lime);
  font-size: 0.95rem;
}
.hud-clock {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-variant-numeric: tabular-nums;
}
.scoreboard {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--md-line);
  border-radius: 10px;
  padding: 6px 12px;
  font-family: Barlow, sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}
.weather-chip {
  color: var(--md-muted);
  font-size: 0.85rem;
}
.speeds {
  display: flex;
  gap: 6px;
}
.speeds button, .btn, .role-btn, .kit-btn {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--md-line);
  background: rgba(20, 28, 18, 0.9);
  color: #eef3e8;
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 600;
}
.speeds button.on, .btn.primary {
  background: var(--md-green);
  border-color: var(--md-lime);
  color: #08120a;
}
.btn.danger { background: #6b1d12; border-color: var(--md-alert); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.panel {
  position: fixed;
  z-index: 18;
  width: min(360px, 34vw);
  max-height: calc(100vh - 86px);
  overflow: auto;
  background: var(--md-panel);
  border: 1px solid var(--md-line);
  border-radius: 14px;
  box-shadow: var(--md-shadow);
  padding: 12px 14px 16px;
  backdrop-filter: blur(10px);
}
.panel h2, .sheet h2 {
  font-family: Barlow, sans-serif;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--md-canary);
  margin: 0 0 10px;
}
.panel.left { top: 58px; left: 12px; }
.panel.right { top: 58px; right: 12px; }
.panel.hidden, .sheet.hidden { display: none; }

.sheet {
  position: fixed;
  z-index: 30;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  width: min(920px, 94vw);
  max-height: calc(100vh - 72px);
  overflow: auto;
  background: var(--md-panel);
  border: 1px solid var(--md-line);
  border-radius: 16px;
  padding: 22px 24px 28px;
  box-shadow: var(--md-shadow);
}
.sheet header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.meta { color: var(--md-muted); font-size: 0.92rem; line-height: 1.45; }
.flash { margin: 8px 0; padding: 8px 10px; border-left: 3px solid var(--md-alert); background: rgba(255, 90, 54, 0.08); }

.budget {
  font-family: Barlow, sans-serif;
  font-size: 1.4rem;
  color: var(--md-lime);
  margin: 4px 0 10px;
}
.roles, .kits {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}
.role-btn.on, .kit-btn.on { outline: 2px solid var(--md-lime); }
.role-btn small, .kit-btn small { display: block; color: var(--md-muted); font-weight: 500; }

.catalog {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  gap: 6px 18px;
}
.catalog li {
  break-inside: avoid;
  font-size: 0.82rem;
  padding: 3px 0;
  color: var(--md-muted);
}
.catalog li .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: #555;
}
.catalog li.covered { color: var(--md-ok); }
.catalog li.covered .dot { background: var(--md-ok); }
.catalog li.thin { color: var(--md-thin); }
.catalog li.thin .dot { background: var(--md-thin); }
.catalog li.none { color: #d98880; }
.catalog li.none .dot { background: var(--md-alert); }

.incident {
  border: 1px solid rgba(255, 90, 54, 0.45);
  background: rgba(80, 18, 10, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 6px 0;
  cursor: pointer;
}
.incident.sel { border-color: var(--md-canary); }
.incident b { display: block; color: var(--md-canary); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1a1208;
  color: var(--md-canary);
  border: 1px solid var(--md-canary);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.show { opacity: 1; }

.alert-banner {
  position: fixed;
  z-index: 22;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--md-alert);
  color: #1a0806;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 8px;
  letter-spacing: 0.08em;
  display: none;
}
.alert-banner.on { display: block; }

.compass {
  position: fixed;
  z-index: 16;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 8px 12px;
  background: rgba(10, 16, 10, 0.72);
  border: 1px solid var(--md-line);
  border-radius: 10px;
  font-size: 0.78rem;
  color: var(--md-muted);
  pointer-events: none;
  max-width: min(520px, 46vw);
}
.compass b { color: var(--md-lime); margin-right: 4px; }

.fx-strip {
  position: fixed;
  z-index: 21;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.fx-chip, .inc-chip {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: Barlow, sans-serif;
  font-weight: 800;
  letter-spacing: 0.06em;
  background: var(--c, var(--md-alert));
  color: #120806;
  font-size: 0.78rem;
}
.inc-chip {
  font-size: 0.7rem;
  margin-right: 6px;
  vertical-align: middle;
}

.grade {
  font-family: Barlow, sans-serif;
  font-size: 5rem;
  line-height: 1;
  color: var(--md-lime);
  margin: 8px 0;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.stat {
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  padding: 8px;
}
.stat b { display: block; font-size: 1.2rem; color: var(--md-canary); }
.history { font-size: 0.85rem; color: var(--md-muted); }
.history li { margin: 4px 0; }

.fillbar {
  height: 8px;
  background: #222;
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0;
}
.fillbar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--md-green), var(--md-lime));
  width: 0;
}

.hint { font-size: 0.8rem; color: var(--md-muted); margin-top: 8px; }

body.md-play .panel,
body.md-play .sheet,
body.md-play .panel.mh-force-surface,
body.md-play .sheet.mh-force-surface {
  background: rgba(12, 18, 12, 0.92) !important;
  color: #eef3e8 !important;
  border: 1px solid var(--md-line) !important;
}
body.md-play .panel button,
body.md-play .sheet button,
body.md-play .topbar button {
  background: rgba(20, 28, 18, 0.95) !important;
  color: #eef3e8 !important;
  border-color: var(--md-line) !important;
}
body.md-play .speeds button.on,
body.md-play .btn.primary,
body.md-play button.primary {
  background: var(--md-green) !important;
  color: #08120a !important;
  border-color: var(--md-lime) !important;
}
body.md-play .role-btn.on,
body.md-play .kit-btn.on {
  outline: 2px solid var(--md-lime);
}
body.md-play .budget { color: var(--md-lime) !important; }
body.md-play h2 { color: var(--md-canary) !important; }

@media (max-width: 900px) {
  .panel { width: min(100vw - 16px, 420px); max-height: 38vh; }
  .panel.left { top: auto; bottom: 8px; }
  .panel.right { top: 58px; }
  .catalog { columns: 1; }
}
