:root {
  --panel: rgba(12, 16, 22, 0.86);
  --panel-edge: rgba(160, 200, 220, 0.18);
  --text: #d8dee6;
  --muted: #8a96a3;
  --accent: #7fd6e8;
  --hp: #c43c3c;
  --armor: #c08a3a;
  --shield: #3f8fd6;
  --energy: #c9b44a;
  --fatigue: #7d5aa8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05070c;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  user-select: none;
}

#game { position: fixed; inset: 0; }
#game canvas { display: block; }

#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 55%, rgba(5, 10, 20, 0.45) 100%);
}

#overlay { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }

kbd {
  display: inline-block; padding: 0 5px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.22);
  font-family: inherit; font-size: 11px;
}

/* ---- Top bar ---------------------------------------------------------- */
#top-bar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px;
  background: linear-gradient(to bottom, rgba(6, 10, 16, 0.7), rgba(6, 10, 16, 0));
  font-size: 12px; letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  flex-wrap: wrap;
}
#top-bar .title { font-weight: 600; font-size: 15px; letter-spacing: 0.22em; }
#top-bar .title span { font-weight: normal; font-size: 10px; color: var(--muted); letter-spacing: 0.15em; margin-left: 8px; text-transform: uppercase; }
#top-bar .info { display: flex; gap: 18px; color: var(--muted); text-transform: uppercase; }
#top-bar .controls { color: var(--muted); }

/* ---- Battle bar / banner ---------------------------------------------- */
#battle-bar {
  position: fixed; left: 50%; top: 54px; transform: translate(-50%, -8px);
  padding: 6px 18px;
  background: rgba(70, 14, 14, 0.82);
  border: 1px solid rgba(255, 120, 100, 0.35);
  border-left: 3px solid #e0533e;
  font-size: 12px; letter-spacing: 0.05em; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.4s, transform 0.4s;
}
#battle-bar b { letter-spacing: 0.2em; color: #ffb3a3; margin-right: 4px; }
#battle-bar.show { opacity: 1; transform: translate(-50%, 0); }

#banner {
  position: fixed; left: 50%; top: 26%; transform: translate(-50%, -50%);
  padding: 20px 40px;
  background: var(--panel);
  border-top: 1px solid var(--panel-edge); border-bottom: 1px solid var(--panel-edge);
  text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.6s;
}
#banner.show { opacity: 1; }
#banner h1 { margin: 0 0 8px; font-size: 24px; font-weight: 500; letter-spacing: 0.25em; text-transform: uppercase; }
#banner p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---- Unit stat boxes (under each character, battle only) --------------- */
#units {
  position: fixed; inset: 0; pointer-events: none;
  opacity: 0; transition: opacity 0.5s;
}
#units.show { opacity: 1; }
#units.show .unit.party { pointer-events: auto; }

.unit {
  position: absolute; left: 0; top: 0;
  width: 150px;
  display: flex; flex-direction: column; gap: 4px;
  will-change: transform;
}
.unit.enemy { width: 124px; }
.unit.party { cursor: grab; touch-action: none; }
.unit.dragging { cursor: grabbing; z-index: 10; opacity: 0.9; }
.unit.dragging .box { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); border-color: var(--accent); }
.unit.drop-target .box { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 14px rgba(127, 214, 232, 0.35); }
.unit.down { filter: grayscale(1) brightness(0.6); }

.box {
  padding: 6px 7px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 3px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  transition: border-color 0.15s;
}
.unit.enemy .box { border-color: rgba(220, 120, 90, 0.3); }
.unit.firing .skillbox { border-color: rgba(255, 210, 140, 0.7); }

.unit-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.unit-head .name { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.unit.enemy .unit-head .name { color: #e6b3a0; font-size: 10px; }
.unit-head .meta { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

.bar {
  position: relative; height: 11px; margin: 2px 0;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 1px; overflow: hidden;
  font-size: 9px; line-height: 11px;
}
.bar .fill { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width 0.15s linear; }
.bar .label { position: relative; padding-left: 4px; font-weight: 600; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.8); }
.bar .val { position: absolute; right: 4px; top: 0; color: rgba(255, 255, 255, 0.85); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.8); }
.bar.health .fill { background: linear-gradient(90deg, #8e2626, var(--hp)); }
.bar.armor .fill { background: linear-gradient(90deg, #7c5520, var(--armor)); }
.bar.shield .fill { background: linear-gradient(90deg, #22528a, var(--shield)); }
.bar.energy .fill { background: linear-gradient(90deg, #7d6e22, var(--energy)); }
.bar.fatigue .fill { background: linear-gradient(90deg, #4a3266, var(--fatigue)); }
.bar.morale .fill { background: linear-gradient(90deg, #7a4320, #d27a3c); }
.bar.cooldown { height: 4px; margin: 3px 0 4px; }
.bar.cooldown .fill { background: var(--accent); transition: none; }

.skill-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 10px; }
.skill-name { font-weight: 600; letter-spacing: 0.05em; color: #e9edf2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.skill-status { font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }
.s-ready { color: #8fe0a0; }
.s-idle, .s-drawing { color: var(--muted); }
.s-cooldown { color: #c6ced8; }
.s-energy { color: var(--energy); }
.s-fatigue { color: #b493dd; }
.s-down { color: #e06060; }

/* ---- Floating text & speech ------------------------------------------- */
.float {
  position: absolute; left: 0; top: 0;
  font-weight: 700; font-size: 17px; white-space: nowrap;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.9);
}
.float small { font-size: 10px; font-weight: 500; opacity: 0.85; }

.bubble {
  position: absolute; left: 0; top: 0;
  max-width: 260px; padding: 6px 10px 7px;
  background: rgba(10, 14, 20, 0.82);
  border-left: 2px solid var(--accent);
  color: #e6ebf0; font-size: 12px; line-height: 1.35;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  margin-top: -10px;
}
.bubble b {
  display: block; font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1px;
}

@media (max-width: 820px) {
  #top-bar .controls { display: none; }
  #battle-bar { white-space: normal; width: calc(100% - 32px); text-align: center; }
  .unit { width: 128px; }
  .unit.enemy { width: 108px; }
}

/* ---- Stat box: multi-skill rows ---------------------------------------- */
.skill-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.skill-head .buff { font-size: 9px; letter-spacing: 0.08em; color: #ffd36a; }
.sk-row { margin-bottom: 1px; }
.sk-row .skill-name { font-size: 10px; color: var(--muted); transition: color 0.2s; }
.sk-row .skill-name i { font-style: normal; font-size: 8px; color: #e8d27a; margin-left: 2px; }
.sk-row.ready .skill-name { color: #e9edf2; }
.sk-row.fired .skill-name { color: #ffd59a; }
.sk-row .bar.cooldown { margin: 1px 0 3px; height: 3px; }
.sk-row.ready .bar.cooldown .fill { background: #8fe0a0; }
.sk-empty { font-size: 10px; color: var(--muted); font-style: italic; padding: 2px 0 4px; }
.unit-head .slowed { font-size: 9px; color: #a9c8ff; letter-spacing: 0.06em; text-transform: uppercase; }
.s-noskills { color: #e0a060; }

#top-bar #level-label { color: #e8d27a; }
#top-bar #level-label b { color: #ffe38a; }

/* ---- Toast + setup hint ------------------------------------------------- */
#toast {
  position: fixed; left: 50%; top: 92px; transform: translate(-50%, -8px);
  padding: 9px 20px 10px; min-width: 280px; text-align: center;
  background: rgba(30, 26, 10, 0.88);
  border: 1px solid rgba(232, 210, 122, 0.35); border-left: 3px solid #e8d27a;
  font-size: 12px; color: #e9e2c4;
  opacity: 0; pointer-events: none; transition: opacity 0.35s, transform 0.35s;
}
#toast b { display: block; font-size: 13px; letter-spacing: 0.2em; text-transform: uppercase; color: #ffe38a; margin-bottom: 3px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#setup-hint {
  position: fixed; left: 50%; top: 54px; transform: translateX(-50%);
  padding: 7px 18px;
  background: rgba(40, 32, 10, 0.88);
  border: 1px solid rgba(232, 210, 122, 0.35); border-left: 3px solid #e8d27a;
  font-size: 12px; letter-spacing: 0.05em; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.3s, box-shadow 0.2s;
}
#setup-hint.show { opacity: 1; }
#setup-hint.flash { box-shadow: 0 0 0 2px #e8d27a, 0 0 22px rgba(232, 210, 122, 0.5); }

/* ---- Character screen --------------------------------------------------- */
#charscreen, #intro {
  position: fixed; inset: 0; z-index: 50;
  display: none; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(4, 8, 14, 0.55), rgba(2, 4, 8, 0.82));
  backdrop-filter: blur(2px);
  padding: 16px;
}
#charscreen.show, #intro.show { display: flex; }

.cs-panel {
  width: min(900px, 100%); max-height: calc(100vh - 32px);
  display: grid; grid-template-columns: 170px 1fr; grid-template-rows: auto auto 1fr auto;
  background: rgba(10, 14, 20, 0.96);
  border: 1px solid var(--panel-edge); border-top: 2px solid var(--accent);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.cs-panel button { font: inherit; color: inherit; cursor: pointer; }
.cs-panel button:disabled { cursor: default; }

.cs-header {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 20px;
  padding: 12px 16px; border-bottom: 1px solid var(--panel-edge);
}
.cs-title { font-size: 15px; font-weight: 600; letter-spacing: 0.25em; text-transform: uppercase; }
.cs-title span { font-size: 10px; color: #e8d27a; letter-spacing: 0.15em; margin-left: 8px; font-weight: 500; }
.cs-xp { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.cs-xp small { font-size: 10px; color: var(--muted); letter-spacing: 0.05em; }
.cs-xpbar { height: 5px; background: rgba(255, 255, 255, 0.07); }
.cs-xpbar span { display: block; height: 100%; background: linear-gradient(90deg, #8a7430, #e8d27a); }
.cs-close { background: none; border: 0; font-size: 11px; color: var(--muted); }
.cs-close:hover { color: var(--text); }

.cs-chars {
  grid-row: 2 / 4; display: flex; flex-direction: column; gap: 2px;
  padding: 10px 0; border-right: 1px solid var(--panel-edge);
}
.cs-char {
  position: relative; text-align: left; padding: 10px 16px;
  background: none; border: 0; border-left: 2px solid transparent;
  display: flex; flex-direction: column;
}
.cs-char:hover { background: rgba(255, 255, 255, 0.03); }
.cs-char.active { background: rgba(127, 214, 232, 0.08); border-left-color: var(--accent); }
.cc-name { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.cc-role { font-size: 10px; color: var(--muted); letter-spacing: 0.08em; }
.badge {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #e8d27a; color: #1a1608; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.cs-tabs { display: flex; align-items: center; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--panel-edge); }
.cs-tab {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 8px 14px; font-size: 12px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted);
}
.cs-tab:hover { color: var(--text); }
.cs-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.cs-keys { margin-left: auto; font-size: 10px; color: var(--muted); }

.cs-body { padding: 14px 16px; overflow-y: auto; min-height: 360px; }
.cs-foot { grid-column: 1 / -1; padding: 9px 16px; border-top: 1px solid var(--panel-edge); font-size: 11px; color: var(--muted); }
.cs-foot .warn { color: #e8d27a; }

.cs-body h3 { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.cs-body h3 span { font-weight: 400; letter-spacing: 0.04em; text-transform: none; margin-left: 6px; }

/* Inventory */
.inv { display: grid; grid-template-columns: 1fr 1.25fr; gap: 18px; }
.slots, .stash { display: flex; flex-direction: column; gap: 6px; }
.slot, .stash-item {
  text-align: left; padding: 9px 11px;
  background: rgba(255, 255, 255, 0.025); border: 1px solid var(--panel-edge);
  display: flex; flex-direction: column; gap: 2px;
  transition: border-color 0.15s, background 0.15s;
}
.slot { border-style: dashed; }
.slot.filled { border-style: solid; border-color: rgba(127, 214, 232, 0.35); }
.slot.filled:not(:disabled):hover, .stash-item:not(:disabled):hover { border-color: var(--accent); background: rgba(127, 214, 232, 0.06); }
.slot-label { font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.slot-item { font-size: 13px; font-weight: 600; }
.slot:not(.filled) .slot-item { color: var(--muted); font-weight: 400; font-style: italic; }
.slot-mods, .si-mods { font-size: 11px; color: #9fd8a8; }
.slot:not(.filled) .slot-mods { color: var(--muted); }
.slot-hint, .si-note { font-size: 10px; color: var(--muted); }
.si-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.si-name { font-size: 12px; font-weight: 600; }
.stash-item.unusable { opacity: 0.45; }
.tag { font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; padding: 1px 6px; border: 1px solid; }
.tag-armor { color: var(--armor); }
.tag-weapon { color: #e07a5a; }
.tag-gadget { color: #7fd6e8; }
.empty { font-size: 12px; color: var(--muted); font-style: italic; }

/* Skills */
.skills { display: flex; flex-direction: column; gap: 8px; }
.points { padding: 9px 12px; background: rgba(255, 255, 255, 0.03); border-left: 3px solid var(--panel-edge); font-size: 12px; }
.points.has { border-left-color: #e8d27a; background: rgba(232, 210, 122, 0.07); }
.points b { font-size: 16px; color: #ffe38a; margin-right: 3px; }
.points span { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }
.skill-card { padding: 10px 12px; background: rgba(255, 255, 255, 0.025); border: 1px solid var(--panel-edge); }
.skill-card.inactive { opacity: 0.62; }
.skill-card p { margin: 6px 0; font-size: 12px; line-height: 1.45; color: #c2cad3; }
.sc-head { display: flex; align-items: center; gap: 10px; }
.sc-order { width: 18px; height: 18px; border: 1px solid var(--panel-edge); font-size: 10px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.sc-name { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; }
.pips { display: flex; gap: 3px; margin-left: auto; }
.pips i { width: 10px; height: 10px; border: 1px solid rgba(232, 210, 122, 0.5); transform: rotate(45deg) scale(0.75); }
.pips i.on { background: #e8d27a; border-color: #e8d27a; box-shadow: 0 0 6px rgba(232, 210, 122, 0.6); }
.sc-buttons { display: flex; gap: 4px; }
.sc-buttons button {
  width: 26px; height: 26px; font-size: 16px; line-height: 1;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-edge);
}
.sc-buttons button.plus:not(:disabled) { border-color: #e8d27a; color: #ffe38a; }
.sc-buttons button:not(:disabled):hover { background: rgba(255, 255, 255, 0.12); }
.sc-buttons button:disabled { opacity: 0.3; }
.sc-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 10px; color: var(--muted); letter-spacing: 0.04em; }
.sc-rank { color: #d8c88a; }

/* Stats */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-cards div { padding: 9px 11px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--panel-edge); display: flex; flex-direction: column; }
.stat-cards span { font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); }
.stat-cards b { font-size: 20px; font-weight: 600; margin-top: 2px; }
.stat-cards small { font-size: 10px; color: var(--muted); }
.stats table { width: 100%; border-collapse: collapse; font-size: 12px; }
.stats th { text-align: right; font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--panel-edge); }
.stats th:first-child { text-align: left; color: var(--text); }
.stats td { text-align: right; padding: 6px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); font-variant-numeric: tabular-nums; }
.stats td:first-child { text-align: left; color: #c2cad3; }
.stats td.pos { color: #9fd8a8; }
.stats td.zero { color: rgba(255, 255, 255, 0.2); }
.stats .note { font-size: 10px; color: var(--muted); margin: 10px 0 0; }

/* ---- Intro briefing ------------------------------------------------------ */
.intro-panel {
  width: min(860px, 100%); max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 28px 34px 24px;
  background: rgba(10, 14, 20, 0.96);
  border: 1px solid var(--panel-edge); border-top: 2px solid var(--accent);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.intro-kicker { font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--accent); }
.intro-panel h1 { margin: 6px 0 10px; font-size: 28px; font-weight: 500; letter-spacing: 0.22em; text-transform: uppercase; }
.intro-panel .lore { margin: 0 0 20px; font-size: 13px; line-height: 1.6; color: #b8c2cc; max-width: 680px; }
.intro-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.intro-grid div { padding: 12px 14px; background: rgba(255, 255, 255, 0.03); border-top: 1px solid var(--panel-edge); }
.intro-grid h2 { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: #e8d27a; }
.intro-grid p { margin: 0; font-size: 12px; line-height: 1.55; color: #c2cad3; }
.intro-cta { margin: 18px 0 12px; font-size: 13px; }
.intro-go {
  font: inherit; font-size: 13px; letter-spacing: 0.15em; text-transform: uppercase; cursor: pointer;
  padding: 10px 22px; color: #1a1608; background: #e8d27a; border: 0;
}
.intro-go:hover { background: #ffe38a; }
.intro-go kbd { background: rgba(0, 0, 0, 0.12); border-color: rgba(0, 0, 0, 0.25); color: #1a1608; margin-left: 6px; }
.intro-keys { margin: 14px 0 0; font-size: 11px; color: var(--muted); }

@media (max-width: 820px) {
  .cs-panel { grid-template-columns: 1fr; }
  .cs-chars { grid-row: auto; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--panel-edge); padding: 0; }
  .cs-char { flex: 1; border-left: 0; border-bottom: 2px solid transparent; }
  .cs-char.active { border-bottom-color: var(--accent); }
  .cs-keys { display: none; }
  .inv, .intro-grid { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  #setup-hint { white-space: normal; width: calc(100% - 32px); text-align: center; }
}

/* ---- Skill chain ----------------------------------------------------------- */
.chain { padding: 10px 12px; background: rgba(127, 214, 232, 0.05); border: 1px solid rgba(127, 214, 232, 0.25); }
.chain h3 { margin-bottom: 8px; }
.chain-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chain-slot { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 150px; }
.cs-num {
  width: 20px; height: 20px; flex: none; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; border: 1px solid var(--panel-edge); color: var(--muted);
}
.chain-slot.filled .cs-num { border-color: var(--accent); color: var(--accent); }
.chain-slot select {
  flex: 1; min-width: 0; padding: 6px 8px; font: inherit; font-size: 12px; color: var(--text);
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-edge); cursor: pointer;
}
.chain-slot.filled select { border-color: rgba(127, 214, 232, 0.45); }
.chain-slot select:disabled { opacity: 0.5; cursor: default; }
.chain-slot select option { background: #10151c; color: var(--text); }
.chain-arrow { color: var(--muted); font-size: 14px; }
.chain-arrow.loop { color: var(--accent); font-size: 16px; }
.chain-note { margin: 8px 0 0; font-size: 11px; line-height: 1.45; color: var(--muted); }
.sc-chain { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); border: 1px solid rgba(127, 214, 232, 0.4); padding: 1px 6px; }

.sk-row .skill-name em {
  font-style: normal; font-size: 8px; color: var(--muted);
  display: inline-block; width: 11px; margin-right: 3px; text-align: center; border: 1px solid rgba(255, 255, 255, 0.15);
}
.sk-row.next .skill-name em { color: #1a1608; background: var(--accent); border-color: var(--accent); }
.sk-row.next .skill-name { color: #e9edf2; }

/* ---- Dialogue box ----------------------------------------------------------- */
#dialogue {
  position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 10px);
  width: min(680px, calc(100% - 32px));
  padding: 14px 20px 10px;
  background: rgba(8, 12, 18, 0.92);
  border: 1px solid var(--panel-edge); border-left: 3px solid var(--accent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  z-index: 40; cursor: pointer;
  opacity: 0; pointer-events: none; transition: opacity 0.3s, transform 0.3s;
}
#dialogue.show { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.dlg-name { font-size: 11px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; margin-bottom: 5px; }
.dlg-text { font-size: 15px; line-height: 1.5; color: #e6ebf0; min-height: 45px; }
.dlg-foot { display: flex; justify-content: space-between; margin-top: 8px; font-size: 10px; color: var(--muted); letter-spacing: 0.06em; }

/* Dialogue portraits */
#dialogue { display: flex; gap: 16px; align-items: stretch; }
.dlg-portrait {
  flex: none; width: 96px; height: 96px; align-self: center;
  border: 2px solid; border-radius: 3px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, rgba(60, 74, 92, 0.9), rgba(10, 14, 20, 1) 75%);
  display: flex; align-items: center; justify-content: center;
}
.dlg-portrait img { width: 100%; height: 100%; display: block; object-fit: cover; }
.dlg-portrait span { font-size: 40px; font-weight: 700; }
.dlg-body { flex: 1; min-width: 0; }
@media (max-width: 600px) { .dlg-portrait { width: 64px; height: 64px; } }

/* Level transition fade */
#fade {
  position: fixed; inset: 0; background: #000; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity 1s ease;
}
#fade.show { opacity: 1; pointer-events: auto; }

/* NPC ally stat box (Hollis): same layout as the party, but muted and not draggable */
#units.show .unit.ally { pointer-events: none; }
.unit.ally .box { border-style: dashed; opacity: 0.9; }
.unit.ally .unit-head .meta { color: #ffd45a; }

/* Enemy weakness tag under the bars */
.unit .weak { margin-top: 4px; font-size: 10px; letter-spacing: 0.04em; color: #8fe3ff; }

/* Level select: the button stays hidden until the unlock code is typed */
#level-btn { display: none; }
#level-btn.unlocked {
  display: inline-block; cursor: pointer;
  position: fixed; top: 44px; right: 18px; z-index: 56; /* above the briefing, character screen and level menu */
  font: inherit; text-transform: uppercase; letter-spacing: 0.12em; font-size: 11px;
  padding: 3px 10px; color: #fff4c8;
  background: rgba(255, 200, 80, 0.16); border: 1px solid #ffd45a; border-radius: 3px;
  box-shadow: 0 0 10px rgba(255, 210, 90, 0.55);
  animation: lvl-glow 1.8s ease-in-out infinite;
}
#level-btn.unlocked:hover { background: rgba(255, 200, 80, 0.3); }
@keyframes lvl-glow { 50% { box-shadow: 0 0 18px rgba(255, 210, 90, 0.9); } }

#level-menu {
  position: fixed; inset: 0; z-index: 55;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 4, 8, 0.7);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
#level-menu.show { opacity: 1; pointer-events: auto; }
.lm-panel {
  width: min(460px, calc(100% - 32px)); padding: 20px 22px;
  background: rgba(8, 12, 18, 0.96); border: 1px solid var(--panel-edge);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}
.lm-panel h2 { margin: 0 0 14px; font-size: 14px; font-weight: 600; letter-spacing: 0.25em; text-transform: uppercase; }
.lm-level {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 8px;
  padding: 10px 12px; cursor: pointer; text-align: left;
  font: inherit; color: #e6ebf0; background: rgba(40, 52, 66, 0.5);
  border: 1px solid var(--panel-edge); border-radius: 3px;
}
.lm-level:hover { background: rgba(70, 90, 112, 0.6); border-color: #ffd45a; }
.lm-num { font-size: 18px; font-weight: 700; color: #ffd45a; width: 18px; }
.lm-name { flex: 1; font-size: 13px; }
.lm-xp { font-size: 11px; color: #e8d27a; }
.lm-note { font-size: 11px; color: var(--muted); margin: 10px 0 12px; }
.lm-close { font: inherit; font-size: 11px; color: var(--muted); background: none; border: 1px solid var(--panel-edge); padding: 4px 10px; cursor: pointer; }

/* ---- World map (between levels) ------------------------------------------ */
#worldmap {
  position: fixed; inset: 0; z-index: 54;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 4, 8, 0.82); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 0.35s;
}
#worldmap.show { opacity: 1; pointer-events: auto; }
.wm-panel {
  width: min(1000px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto;
  padding: 16px 20px 18px; background: rgba(8, 12, 18, 0.96);
  border: 1px solid var(--panel-edge); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}
.wm-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.wm-head h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.25em; text-transform: uppercase; }
.wm-head span { font-size: 11px; color: var(--muted); }
.wm-map { width: 100%; height: auto; display: block; border: 1px solid rgba(120, 200, 255, 0.12); }
.wm-deco circle { fill: rgba(0, 0, 0, 0.18); stroke: rgba(255, 255, 255, 0.04); }
.road { fill: none; stroke: rgba(160, 180, 200, 0.25); stroke-width: 4; stroke-dasharray: 2 10; stroke-linecap: round; }
.road.walked { stroke: rgba(160, 220, 255, 0.55); stroke-dasharray: none; }
.road.live { stroke: #ffd45a; stroke-dasharray: 10 8; animation: wm-march 1s linear infinite; }
@keyframes wm-march { to { stroke-dashoffset: -18; } }
.node .dot { fill: #2a3440; stroke: #6a7a8a; stroke-width: 2; }
.node .label { fill: #c8d2dc; font-size: 17px; letter-spacing: 0.06em; }
.node .tag { fill: #ffd45a; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; }
.node.done .dot { fill: #3a6a8a; stroke: #8fd8ff; }
.node.here .dot { fill: #8fd8ff; stroke: #fff; }
.node.open { cursor: pointer; }
.node.open .dot { fill: #6a5420; stroke: #ffd45a; stroke-width: 3; }
.node.open .label { fill: #fff4c8; }
.node.open:hover .dot, .node.selected .dot { fill: #ffd45a; }
.node.selected .label { fill: #ffd45a; }
.node.locked { opacity: 0.55; }
.node.dest .dot { fill: #3a2a2a; stroke: #ff8a5a; }
.node .dest-icon { fill: #ff8a5a; }
.node .pulse { fill: none; stroke: #ffd45a; stroke-width: 2; animation: wm-pulse 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes wm-pulse { from { opacity: 0.9; transform: scale(0.6); } to { opacity: 0; transform: scale(1.5); } }
.wm-info { margin-top: 12px; min-height: 52px; font-size: 13px; line-height: 1.5; text-align: center; }
.wm-foot { display: flex; justify-content: flex-end; margin-top: 4px; }
.wm-go:disabled { cursor: default; opacity: 0.35; background: #8a7a4a; }
.wm-info p { margin: 6px 0; color: #d6dde4; }
.wm-title { font-size: 15px; font-weight: 600; letter-spacing: 0.08em; }
.wm-title em { font-style: normal; color: #ffd45a; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; margin-right: 10px; }
.wm-sub { font-size: 11px; color: var(--muted); }
.wm-threat { font-size: 11px; color: #e8b88a !important; }
.wm-note, .wm-hint { color: var(--muted) !important; font-size: 12px; }
.wm-go {
  margin-top: 6px; font: inherit; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  padding: 8px 16px; color: #1a1408; background: #ffd45a; border: none; border-radius: 3px;
}
.wm-go:hover:not(:disabled) { background: #ffe38a; }

/* ---- Credits + shop ---------------------------------------------------------- */
#level-label .cr { color: #7fe0c8; }
#interact-hint {
  position: fixed; left: 50%; bottom: 250px; transform: translateX(-50%);
  padding: 7px 16px; font-size: 12px; letter-spacing: 0.06em;
  background: rgba(8, 12, 18, 0.88); border: 1px solid #7fe0c8; border-radius: 3px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
#interact-hint.show { opacity: 1; }
#shop {
  position: fixed; inset: 0; z-index: 53;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 4, 8, 0.78); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
#shop.show { opacity: 1; pointer-events: auto; }
.sh-panel {
  width: min(760px, calc(100% - 32px)); max-height: calc(100% - 40px); display: flex; flex-direction: column;
  padding: 16px 20px; background: rgba(8, 12, 18, 0.96);
  border: 1px solid var(--panel-edge); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}
.sh-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 10px; }
.sh-head h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.25em; text-transform: uppercase; }
.sh-head span { font-size: 11px; color: var(--muted); }
.sh-credits { text-align: right; }
.sh-credits span { display: block; font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.sh-credits b { font-size: 22px; color: #7fe0c8; }
.sh-tutorial {
  margin-bottom: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.55; color: #d6dde4;
  background: rgba(127, 224, 200, 0.08); border-left: 3px solid #7fe0c8;
}
.sh-tutorial b:first-child { display: block; color: #7fe0c8; letter-spacing: 0.1em; text-transform: uppercase; font-size: 11px; margin-bottom: 3px; }
.sh-tutorial em { display: block; margin-top: 4px; font-style: normal; color: #ffd45a; }
.sh-filters { display: flex; gap: 6px; margin-bottom: 8px; }
.sh-filters button {
  font: inherit; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  padding: 4px 10px; color: var(--muted); background: none; border: 1px solid var(--panel-edge); border-radius: 3px;
}
.sh-filters button.on { color: #fff; border-color: #7fe0c8; }
.sh-list { overflow-y: auto; flex: 1; min-height: 0; }
.sh-item { display: flex; gap: 12px; align-items: center; padding: 8px 10px; margin-bottom: 6px; background: rgba(40, 52, 66, 0.4); border: 1px solid var(--panel-edge); border-radius: 3px; }
.sh-item.sold { opacity: 0.45; }
.sh-main { flex: 1; min-width: 0; }
.sh-name { font-size: 13px; font-weight: 600; }
.sh-slot { font-weight: normal; font-size: 10px; letter-spacing: 0.08em; color: var(--muted); text-transform: uppercase; margin-left: 6px; }
.sh-mods { font-size: 12px; color: #9dffc0; }
.sh-note { font-size: 11px; color: var(--muted); }
.sh-buy { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.sh-price { font-size: 13px; color: #7fe0c8; font-weight: 600; }
.sh-item.poor .sh-price { color: #a07070; }
.sh-buy button {
  font: inherit; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  padding: 4px 12px; color: #08201a; background: #7fe0c8; border: none; border-radius: 3px;
}
.sh-buy button:disabled { cursor: default; color: var(--muted); background: rgba(255, 255, 255, 0.06); }
.sh-sold { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.sh-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; }
.sh-msg { font-size: 12px; color: #9dffc0; }
.sh-close {
  font: inherit; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  padding: 6px 14px; color: #fff; background: none; border: 1px solid var(--panel-edge); border-radius: 3px;
}
.sh-close:disabled { cursor: default; color: #a07070; border-color: rgba(160, 112, 112, 0.5); }

/* ---- Act 1 finale ----------------------------------------------------- */
.dlg-portrait .dlg-radio { font-size: 13px; letter-spacing: 0.25em; font-weight: 600; }

/* Orbital strike countdown */
#countdown {
  position: fixed; right: 18px; top: 46px;
  padding: 8px 16px 9px; text-align: right;
  background: rgba(60, 10, 8, 0.82);
  border: 1px solid rgba(255, 110, 80, 0.35); border-right: 3px solid #ff5a3a;
  opacity: 0; pointer-events: none; transition: opacity 0.4s;
}
#countdown.show { opacity: 1; }
#countdown .cd-label { font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase; color: #ffb3a3; }
#countdown .cd-time { font-size: 28px; font-weight: 600; letter-spacing: 0.08em; color: #ffe0d6; font-variant-numeric: tabular-nums; }
#countdown.low .cd-time { color: #ff6a4a; animation: cd-pulse 1s infinite; }
#countdown.held .cd-time { color: #c8c0bc; }
@keyframes cd-pulse { 50% { opacity: 0.45; } }

/* Boss stat box */
.unit.enemy.boss .box { border-color: rgba(180, 106, 255, 0.55); box-shadow: 0 0 14px rgba(180, 106, 255, 0.25); }
.unit.enemy.boss .unit-head .name { color: #d9b0ff; }
.unit-head .meta.threshold { color: #b46aff; font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase; }

/* ---- Sector map (lunar survey chart) ------------------------------------ */
.wm-grid { stroke: rgba(230, 235, 240, 0.12); stroke-width: 1; stroke-dasharray: 3 5; }
.wm-deg { fill: rgba(230, 235, 240, 0.45); font-size: 10px; letter-spacing: 0.05em; font-family: ui-monospace, Consolas, monospace; }
.wm-region { fill: rgba(240, 238, 228, 0.42); font-size: 26px; letter-spacing: 0.4em; font-style: italic; font-family: Georgia, "Times New Roman", serif; }
.wm-region.small { font-size: 14px; letter-spacing: 0.3em; }
.wm-feat { fill: rgba(240, 238, 228, 0.6); font-size: 11px; font-style: italic; font-family: Georgia, "Times New Roman", serif; }
.wm-ridge { fill: none; stroke: rgba(220, 220, 210, 0.22); stroke-width: 1.4; }
.wm-mtn { fill: none; stroke: rgba(30, 30, 30, 0.45); stroke-width: 1.4; stroke-linejoin: round; }
.wm-trees circle { fill: rgba(20, 45, 25, 0.55); }
.wm-mutation path { fill: rgba(150, 90, 190, 0.28); stroke: rgba(200, 140, 255, 0.35); stroke-width: 1; stroke-dasharray: 4 3; }
.wm-ribs line { stroke: rgba(159, 220, 255, 0.55); stroke-width: 1.2; }
.wm-domelabel { fill: #bfe8ff; font-size: 11px; letter-spacing: 0.3em; }
.wm-compass circle { fill: rgba(10, 14, 20, 0.6); stroke: rgba(232, 230, 220, 0.6); }
.wm-compass path { fill: rgba(232, 230, 220, 0.5); }
.wm-compass path.n { fill: #ffd45a; }
.wm-compass text { fill: #e8e6dc; font-size: 12px; font-weight: 600; }
.wm-title-block > rect, .wm-legend > rect:first-child { fill: rgba(10, 14, 20, 0.78); stroke: rgba(232, 230, 220, 0.4); }
.wm-title-block .t1 { fill: #e8e6dc; font-size: 12px; font-weight: 600; letter-spacing: 0.15em; }
.wm-title-block .t2 { fill: rgba(232, 230, 220, 0.65); font-size: 10px; font-family: ui-monospace, Consolas, monospace; }
.wm-title-block .t3 { fill: rgba(232, 230, 220, 0.7); font-size: 9px; }
.wm-legend text { fill: #d6dde4; font-size: 11px; }
.wm-legend .l-here { fill: #8fd8ff; stroke: #fff; }
.wm-legend .l-open { fill: #6a5420; stroke: #ffd45a; stroke-width: 2; }
.wm-legend .l-done { fill: #3a6a8a; stroke: #8fd8ff; }
.wm-legend .l-mut { fill: rgba(150, 90, 190, 0.45); stroke: rgba(200, 140, 255, 0.6); }
.wm-map .road:not(.walked):not(.live) { stroke: rgba(230, 230, 220, 0.4); }
.wm-map .node .label { paint-order: stroke; stroke: rgba(5, 8, 12, 0.85); stroke-width: 4px; }
.wm-map .node .tag { paint-order: stroke; stroke: rgba(5, 8, 12, 0.85); stroke-width: 3px; }
.node.final .dot { fill: #2a2a3a; stroke: #b9c8ff; }
.node.final .dest-icon { fill: #dfe6ff; }
.node.final.open .dot { fill: #3a3a5a; stroke: #ffd45a; }

/* ---- Act 1 epilogue ---------------------------------------------------- */
#epilogue {
  position: fixed; inset: 0; z-index: 58; overflow: auto;
  display: flex; align-items: flex-start; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(30, 24, 40, 0.97), rgba(3, 4, 8, 0.99) 70%);
  opacity: 0; pointer-events: none; transition: opacity 1.2s;
}
#epilogue.show { opacity: 1; pointer-events: auto; }
.ep-panel { width: min(900px, calc(100% - 32px)); padding: 24px 0 40px; text-align: center; }
.ep-sky { position: relative; height: 170px; margin-bottom: 8px; overflow: hidden; }
.ep-moon {
  position: absolute; left: 50%; top: 10px; width: 150px; height: 150px; margin-left: -75px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c9c7c0, #8d8b85 45%, #4a4945 80%, #2a2a28);
  box-shadow: inset -18px -12px 30px rgba(0, 0, 0, 0.55), 0 0 40px rgba(255, 140, 90, 0.15); overflow: hidden;
}
.ep-moon::before { /* maria */
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 60% 40%, rgba(60, 60, 64, 0.55) 0 18%, transparent 19%),
              radial-gradient(circle at 40% 62%, rgba(60, 60, 64, 0.45) 0 14%, transparent 15%),
              radial-gradient(circle at 70% 70%, rgba(60, 60, 64, 0.35) 0 9%, transparent 10%);
}
.ep-dome {
  position: absolute; left: 42%; top: 40%; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid rgba(160, 220, 255, 0.6); background: rgba(80, 140, 90, 0.35);
  animation: ep-dome-burn 5s ease-in 3s forwards; /* glows hot under the strike, then it's gone */
}
@keyframes ep-dome-burn {
  0% { opacity: 1; }
  35% { opacity: 1; background: rgba(255, 150, 70, 0.7); border-color: rgba(255, 200, 140, 0.9); box-shadow: 0 0 14px rgba(255, 120, 60, 0.8); }
  100% { opacity: 0; background: rgba(40, 20, 10, 0.6); border-color: transparent; box-shadow: none; }
}
/* What's left afterwards: a black crater with a scorched ring, for good. */
.ep-crater {
  position: absolute; left: 42%; top: 40%; width: 26px; height: 26px; margin: -5px; padding: 5px; box-sizing: content-box; border-radius: 50%;
  background: radial-gradient(circle, #020202 0 45%, #120c08 58%, rgba(40, 30, 24, 0.85) 70%, rgba(60, 50, 44, 0) 100%);
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.9);
  opacity: 0; animation: ep-crater 4s ease-out 5.5s forwards;
}
@keyframes ep-crater { to { opacity: 1; } }
.ep-flash {
  position: absolute; width: 14px; height: 14px; margin: -7px; border-radius: 50%;
  background: radial-gradient(circle, #fff6e0, #ffb060 40%, rgba(255, 90, 40, 0) 70%);
  opacity: 0; animation: ep-flash 2.6s ease-out 3 both; /* three rounds of strikes, then quiet */
}
@keyframes ep-flash { 0% { opacity: 0; transform: scale(0.3); } 6% { opacity: 1; transform: scale(1.6); } 30% { opacity: 0; transform: scale(2.4); } 100% { opacity: 0; } }
.ep-ship { position: absolute; left: 60%; top: 118px; width: 4px; height: 4px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px 2px rgba(150, 200, 255, 0.8); animation: ep-ship 14s ease-in forwards; }
/* Accelerates away toward Earth and leaves the frame for good. */
@keyframes ep-ship { from { transform: translate(0, 0) scale(1); } to { transform: translate(560px, 60px) scale(0.5); } }
.ep-kicker { font-size: 11px; letter-spacing: 0.4em; text-transform: uppercase; color: #ffb3a3; }
.ep-panel h1 { margin: 6px 0 16px; font-size: 30px; font-weight: 500; letter-spacing: 0.3em; text-transform: uppercase; }
.ep-story { text-align: left; font-size: 14px; line-height: 1.65; color: #d6dde4; }
.ep-story p { margin: 0 0 12px; }
.ep-scene { margin: 18px 0 10px; text-align: left; }
.ep-line { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.ep-line p { margin: 0; font-size: 14px; color: #e4e8ec; }
.ep-line b { display: block; font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; margin-bottom: 2px; }
.ep-face { flex: none; width: 46px; height: 46px; border: 2px solid; border-radius: 4px; overflow: hidden; background: rgba(255, 255, 255, 0.04); }
.ep-face.big { width: 58px; height: 58px; }
.ep-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ep-after { font-style: italic; color: var(--muted); font-size: 13px; margin: 14px 0 22px; }
.ep-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: left; }
@media (max-width: 700px) { .ep-cards { grid-template-columns: 1fr; } }
.ep-card { padding: 14px 16px; background: rgba(12, 16, 22, 0.85); border: 1px solid var(--panel-edge); border-top: 3px solid; }
.ep-card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.ep-name { font-size: 16px; font-weight: 600; letter-spacing: 0.1em; }
.ep-role { font-size: 11px; color: var(--muted); }
.ep-stat { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); font-size: 12px; }
.ep-stat span { color: var(--muted); }
.ep-stat b { font-weight: 600; text-align: right; }
.ep-stat small { color: var(--muted); font-weight: normal; }
.ep-foot { margin-top: 24px; font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }

/* ---- Field manual (H) ------------------------------------------------------ */
:root { --morale: #d27a3c; --grav: #5fbf8a; --entropic: #9a7cf0; }
#manual {
  position: fixed; inset: 0; z-index: 55;
  display: none; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(4, 8, 14, 0.6), rgba(2, 4, 8, 0.86));
  backdrop-filter: blur(2px);
  padding: 16px;
}
#manual.show { display: flex; }
.mn-panel {
  width: min(940px, 100%); max-height: calc(100vh - 32px);
  display: flex; flex-direction: column;
  background: rgba(10, 14, 20, 0.96);
  border: 1px solid var(--panel-edge); border-top: 2px solid var(--accent);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}
.mn-panel button { font: inherit; color: inherit; cursor: pointer; }
.mn-panel button:disabled { cursor: default; opacity: 0.35; }
.mn-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--panel-edge); }
.mn-title { font-size: 15px; font-weight: 600; letter-spacing: 0.25em; text-transform: uppercase; }
.mn-title span { font-size: 10px; color: #e8d27a; letter-spacing: 0.15em; margin-left: 8px; font-weight: 500; }
.mn-close { background: none; border: 0; font-size: 11px; color: var(--muted); }
.mn-close:hover { color: var(--text); }
.mn-tabs { display: flex; border-bottom: 1px solid var(--panel-edge); }
.mn-tab {
  flex: 1; padding: 10px 12px; background: none; border: 0; border-bottom: 2px solid transparent;
  font-size: 11px !important; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted) !important;
}
.mn-tab kbd { margin-right: 8px; }
.mn-tab:hover { color: var(--text) !important; }
.mn-tab.active { color: var(--text) !important; border-bottom-color: var(--accent); background: rgba(127, 214, 232, 0.05); }
.mn-body { padding: 18px 20px 20px; overflow-y: auto; }
.mn-body h2 { margin: 0 0 4px; font-size: 20px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; }
.mn-lead { margin: 0 0 16px; font-size: 13px; line-height: 1.6; color: #b8c2cc; }
.mn-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.mn-cards-3 { grid-template-columns: repeat(3, 1fr); }
.mn-card { padding: 12px 14px; background: rgba(255, 255, 255, 0.03); border-top: 2px solid var(--panel-edge); }
.mn-card h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: #e8d27a; }
.mn-card p, .mn-card li { margin: 0 0 6px; font-size: 12px; line-height: 1.55; color: #c2cad3; }
.mn-card ul { margin: 0 0 6px; padding-left: 16px; }
.mn-card b { color: var(--text); }

.mn-card.dmg-physical { border-top-color: var(--armor); } .mn-card.dmg-physical h3, th.dmg-physical { color: var(--armor); }
.mn-card.dmg-energy { border-top-color: var(--shield); } .mn-card.dmg-energy h3, th.dmg-energy { color: var(--shield); }
.mn-card.dmg-grav { border-top-color: var(--grav); } .mn-card.dmg-grav h3, th.dmg-grav { color: var(--grav); }
.mn-card.dmg-entropic { border-top-color: var(--entropic); } .mn-card.dmg-entropic h3, th.dmg-entropic { color: var(--entropic); }
.mn-card.def-shield { border-top-color: var(--shield); } .mn-card.def-shield h3 { color: var(--shield); }
.mn-card.def-armor { border-top-color: var(--armor); } .mn-card.def-armor h3 { color: var(--armor); }
.mn-card.def-health { border-top-color: var(--hp); } .mn-card.def-health h3 { color: #e05a5a; }
.mn-card.res-energy { border-top-color: var(--energy); } .mn-card.res-energy h3 { color: var(--energy); }
.mn-card.res-fatigue { border-top-color: var(--fatigue); } .mn-card.res-fatigue h3 { color: #a585d0; }
.mn-card.res-morale { border-top-color: var(--morale); } .mn-card.res-morale h3 { color: var(--morale); }

.mn-table { width: 100%; margin-top: 16px; border-collapse: collapse; font-size: 12px; }
.mn-table th, .mn-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid rgba(160, 200, 220, 0.1); }
.mn-table thead th { font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.mn-table tbody th { font-weight: 600; letter-spacing: 0.08em; }
.mn-table td.yes { color: #e07a7a; }
.mn-table td.part { color: var(--armor); }
.mn-table td.block { color: #6fb0ec; }
.mn-table td.no { color: var(--muted); }

.mn-diagram { display: flex; gap: 10px; margin-top: 8px; font-size: 16px; color: rgba(160, 200, 220, 0.3); }
.mn-diagram .hit { color: #e05a5a; text-shadow: 0 0 8px rgba(224, 90, 90, 0.6); }

.mn-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 18px; border-top: 1px solid var(--panel-edge);
}
.mn-keys { font-size: 11px; color: var(--muted); }
.mn-nav { display: flex; gap: 8px; }
.mn-nav button { padding: 8px 16px; font-size: 12px !important; letter-spacing: 0.15em; text-transform: uppercase; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--panel-edge); }
.mn-nav button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.mn-nav .mn-next { color: #1a1608 !important; background: #e8d27a; border-color: #e8d27a; }
.mn-nav .mn-next:hover { background: #ffe38a; }
.mn-nav .mn-next kbd { background: rgba(0, 0, 0, 0.12); border-color: rgba(0, 0, 0, 0.25); color: #1a1608; margin-left: 6px; }

@media (max-width: 820px) {
  .mn-cards, .mn-cards-3 { grid-template-columns: 1fr 1fr; }
  .mn-keys { display: none; }
}
.mn-mods { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mn-mod { padding: 3px 8px; font-size: 11px; letter-spacing: 0.04em; border: 1px solid; }
.mn-mod.weak { color: #7fd69a; border-color: rgba(127, 214, 154, 0.4); background: rgba(127, 214, 154, 0.08); }
.mn-mod.resist { color: #e07a7a; border-color: rgba(224, 122, 122, 0.4); background: rgba(224, 122, 122, 0.08); }
.mn-mod.morale { color: var(--morale); border-color: rgba(210, 122, 60, 0.45); background: rgba(210, 122, 60, 0.08); }

/* Enemy traits under the stat bars */
.unit .traits { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.unit .trait { padding: 1px 5px; font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: #c2cad3; border: 1px solid rgba(160, 200, 220, 0.25); }
.unit .trait.t-conductive { color: #8fc8ff; border-color: rgba(143, 200, 255, 0.4); }
.unit .trait.t-large, .unit .trait.t-small { color: #e0a860; border-color: rgba(224, 168, 96, 0.4); }
.unit .trait.t-phasing { color: #c3a2ff; border-color: rgba(195, 162, 255, 0.4); }
.unit .trait.t-robot { color: #b8c2cc; }
.unit .trait.t-human { color: #d27a3c; border-color: rgba(210, 122, 60, 0.4); }

/* Skill card tags (character screen) */
.sc-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.sc-tags .tag { padding: 1px 6px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: 1px solid rgba(160, 200, 220, 0.2); }
.sc-tags .tag.t-physical { color: var(--armor); border-color: rgba(192, 138, 58, 0.5); }
.sc-tags .tag.t-energy { color: var(--shield); border-color: rgba(63, 143, 214, 0.5); }
.sc-tags .tag.t-gravitational { color: var(--grav); border-color: rgba(95, 191, 138, 0.5); }
.sc-tags .tag.t-entropic { color: var(--entropic); border-color: rgba(154, 124, 240, 0.5); }
.sc-tags .tag.t-support { color: #7fd6a0; border-color: rgba(127, 214, 160, 0.4); }

/* Battle-script markers in the stat boxes */
.sk-row .bar.cooldown .fill { background: rgba(127, 214, 232, 0.35); }
.sk-row.cooling .bar.cooldown .fill { background: var(--accent); }
.sk-script { font-size: 8px; letter-spacing: 0.06em; color: #c3a2ff; border: 1px solid rgba(195, 162, 255, 0.35); padding: 0 3px; }
.sk-row.scripted .skill-name em { border-style: dashed; }
.sk-row.armed .sk-script { color: #1a1030; background: #c3a2ff; border-color: #c3a2ff; }

/* Battle-script editor (character screen) */
.script-slots { display: flex; flex-direction: column; gap: 8px; }
.script-slot { padding: 8px 10px; background: rgba(255, 255, 255, 0.025); border: 1px solid var(--panel-edge); }
.script-slot.scripted { border-color: rgba(195, 162, 255, 0.45); }
.script-slot .chain-slot { min-width: 0; }
.ss-mode { flex: none; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.script-slot.scripted .ss-mode { color: #c3a2ff; }
.ss-body { margin: 6px 0 0 26px; display: flex; flex-direction: column; gap: 5px; }
.ss-cond { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.ss-word { width: 52px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.ss-cond select {
  padding: 4px 6px; font: inherit; font-size: 12px; color: var(--text);
  background: rgba(195, 162, 255, 0.07); border: 1px solid rgba(195, 162, 255, 0.3); cursor: pointer;
}
.ss-cond select option { background: #10151c; color: var(--text); }
.ss-cond select:disabled { opacity: 0.5; cursor: default; }
.ss-then select { background: rgba(127, 214, 232, 0.07); border-color: rgba(127, 214, 232, 0.35); }
.ss-del { padding: 2px 8px; background: none; border: 1px solid var(--panel-edge); color: var(--muted); }
.ss-del:hover:not(:disabled) { color: #e07a7a; border-color: rgba(224, 122, 122, 0.5); }
.ss-add {
  align-self: flex-start; padding: 4px 10px; font-size: 11px !important; letter-spacing: 0.08em;
  background: none; border: 1px dashed rgba(195, 162, 255, 0.4); color: #c3a2ff !important;
}
.ss-add:hover:not(:disabled) { background: rgba(195, 162, 255, 0.08); }
.ss-add:disabled { opacity: 0.4; }

.ss-cond select.ss-join { width: 52px; padding: 4px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: rgba(255, 255, 255, 0.04); border-color: var(--panel-edge); }
.ss-fixed { padding: 4px 6px; font-size: 12px; color: var(--text); }

/* ---- Main menu (title screen + Esc menu) ---------------------------------- */
#main-menu {
  position: fixed; inset: 0; z-index: 70;
  display: none; align-items: center; justify-content: flex-start;
  padding: 0 9vw;
  background: none; /* title screen: the solar system shows through undimmed */
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8); /* keeps the menu readable over space */
}
#main-menu.show { display: flex; }
body:not(.title-open) #main-menu { background: rgba(2, 4, 8, 0.78); backdrop-filter: blur(2px); }
body.title-open #top-bar,
body.title-open #units,
body.title-open #battle-bar,
body.title-open #toast,
body.title-open #banner { visibility: hidden; }

.mm-wrap { width: min(440px, 90vw); }
.mm-title h1 {
  margin: 6px 0 0; font-weight: 300; font-size: clamp(26px, 3.4vw, 44px);
  letter-spacing: 0.22em; color: #e6eef5; line-height: 1.15;
  text-shadow: 0 0 24px rgba(127, 214, 232, 0.25);
}
.mm-kicker { font-size: 11px; letter-spacing: 0.4em; text-transform: uppercase; color: var(--accent); opacity: 0.8; }
.mm-rule { height: 1px; margin: 18px 0 30px; background: linear-gradient(90deg, var(--accent), transparent); opacity: 0.5; }
.mm-sub { font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--muted); margin: -12px 0 14px; }

.mm-list { display: flex; flex-direction: column; gap: 2px; }
.mm-item {
  display: flex; align-items: center; gap: 12px;
  font: inherit; font-size: 15px; letter-spacing: 0.16em; text-transform: uppercase; text-align: left;
  padding: 11px 16px; color: #aeb9c4; cursor: pointer;
  background: transparent; border: 0; border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s, padding 0.12s;
}
.mm-item .mm-label { flex: 1; }
.mm-item.sel {
  color: #f2f7fb; padding-left: 22px;
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(127, 214, 232, 0.14), rgba(127, 214, 232, 0));
}
.mm-item.warn.sel { border-left-color: #d9734a; background: linear-gradient(90deg, rgba(217, 115, 74, 0.16), transparent); color: #ffd9c8; }
.mm-item.disabled { color: #56616c; cursor: default; }
.mm-value { font-size: 12px; color: var(--accent); letter-spacing: 0.2em; }
.mm-value.off { color: #7a838d; }
.mm-foot { margin-top: 30px; font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.mm-foot kbd {
  font: inherit; font-size: 10px; padding: 1px 5px; border: 1px solid #3a434c; border-radius: 2px; color: #c4ced8;
}
.mm-item .mm-label small {
  display: block; margin-top: 3px; font-size: 10px; letter-spacing: 0.12em; text-transform: none;
  color: #6f7a85;
}
.mm-item.sel .mm-label small { color: #8fa3b3; }
.mm-item.warn .mm-label small { color: #e0906c; }

/* Load page: long save lists scroll; ✕ deletes */
.mm-list.scroll { max-height: 48vh; overflow-y: auto; padding-right: 4px; }
.mm-list.scroll::-webkit-scrollbar { width: 4px; }
.mm-list.scroll::-webkit-scrollbar-thumb { background: rgba(127, 214, 232, 0.3); }
.mm-del {
  font-size: 12px; color: #5d6873; padding: 2px 6px; border-radius: 2px; opacity: 0;
  transition: opacity 0.12s, color 0.12s;
}
.mm-item.sel .mm-del { opacity: 1; }
.mm-del:hover { color: #ff9a76; background: rgba(217, 115, 74, 0.15); }

/* Confirm box (Exit / Main Menu): sits over the menu, game-styled, not a browser alert */
.mm-dlg-back {
  position: fixed; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2, 4, 8, 0.6); backdrop-filter: blur(2px);
  animation: mm-dlg-fade 0.15s ease-out;
}
.mm-dlg {
  width: min(400px, 88vw); padding: 22px 24px 18px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-top: 2px solid #d9734a;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.mm-dlg-title { font-size: 13px; letter-spacing: 0.3em; text-transform: uppercase; color: #ffd9c8; margin-bottom: 14px; }
.mm-dlg p { margin: 0 0 6px; font-size: 14px; color: var(--text); line-height: 1.45; }
.mm-dlg p.mm-dlg-warn { font-size: 12px; color: #e0906c; }
.mm-dlg-warn kbd { font: inherit; font-size: 11px; padding: 0 5px; border: 1px solid #6a4a3c; border-radius: 2px; color: #ffd9c8; }
.mm-dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.mm-dlg-btn {
  font: inherit; font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase;
  min-width: 96px; padding: 8px 14px; cursor: pointer;
  color: #aeb9c4; background: transparent; border: 1px solid #3a434c;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.mm-dlg-btn.sel { color: #f2f7fb; border-color: var(--accent); background: rgba(127, 214, 232, 0.12); }
.mm-dlg-btn.danger.sel { color: #ffd9c8; border-color: #d9734a; background: rgba(217, 115, 74, 0.18); }
@keyframes mm-dlg-fade { from { opacity: 0; } to { opacity: 1; } }

/* Save terminal panel */
#save-panel {
  position: fixed; inset: 0; z-index: 57;
  display: none; align-items: center; justify-content: center;
  background: rgba(2, 4, 8, 0.55);
}
#save-panel.show { display: flex; }
.sp-box {
  width: min(420px, 92vw); padding: 22px 26px 18px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-left: 2px solid var(--accent);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.sp-kicker { font-size: 10px; letter-spacing: 0.35em; text-transform: uppercase; color: var(--accent); }
.sp-box h2 { margin: 6px 0 10px; font-weight: 400; font-size: 20px; letter-spacing: 0.08em; color: #eef4f8; }
.sp-box p { margin: 0 0 14px; font-size: 13px; line-height: 1.5; color: #aab5c0; }
.sp-cost { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.sp-cost b { color: #ffd27a; font-weight: 600; }
.sp-cost .short { color: #ff8a6a; }
.sp-msg { font-size: 13px; color: #9fe6b0; margin-bottom: 12px; }
.sp-actions { display: flex; gap: 8px; }
.sp-btn {
  font: inherit; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 8px 14px; cursor: pointer; color: #c9d3dc;
  background: rgba(255, 255, 255, 0.04); border: 1px solid #3a434c; border-radius: 2px;
}
.sp-btn:hover:not([disabled]) { border-color: var(--accent); color: #fff; }
.sp-btn.primary { border-color: rgba(127, 214, 232, 0.6); color: #e8f8fc; background: rgba(127, 214, 232, 0.12); }
.sp-btn[disabled] { opacity: 0.4; cursor: default; }
.sp-foot { margin-top: 12px; font-size: 11px; color: var(--muted); }
.sp-foot kbd { font: inherit; font-size: 10px; padding: 1px 5px; border: 1px solid #3a434c; border-radius: 2px; color: #c4ced8; }
