:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: rgba(13, 18, 27, 0.88);
  --line: rgba(126, 223, 255, 0.18);
  --text: #edf8ff;
  --muted: #7e96a6;
  --cyan: #73e7ff;
  --red: #ff4d64;
  --amber: #ffc857;
  --green: #66f2a4;
  --blue: #72a7ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: #030407; }
body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 0, #111a27 0, #07090d 45%, #030407 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
}
button { font: inherit; }

.scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  background: linear-gradient(rgba(255,255,255,0) 50%, rgba(0,0,0,.08) 50%);
  background-size: 100% 4px;
  mix-blend-mode: soft-light;
  opacity: .55;
}

.shell { width: min(1540px, 100%); margin: auto; padding: 22px; }
.topbar, .panel-heading, .progress-copy, footer, .map-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar { padding: 8px 4px 20px; }
.eyebrow, .panel-label, .detail-label {
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--cyan);
  font-weight: 800;
}
.topbar h1 { margin: 4px 0 0; font-size: clamp(25px, 4vw, 42px); letter-spacing: -.04em; }
.topbar h1 span { font-weight: 300; color: #9fd8e8; }
.connection {
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 9px;
}
.connection i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 15px currentColor;
  animation: pulse 1.8s infinite;
}
.connection.online i { background: var(--green); }
.connection.error i { background: var(--red); }

.panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(17,24,36,.94), rgba(8,12,18,.94));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 70px rgba(0,0,0,.32), inset 0 1px rgba(255,255,255,.025);
  padding: 20px;
}
.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 20%, rgba(115,231,255,.035) 45%, transparent 70%);
  transform: translateX(-100%);
  animation: sweep 8s linear infinite;
}

.hero-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.threat-panel { text-align: center; display: flex; flex-direction: column; align-items: center; }
.pressure-orb {
  width: 156px;
  height: 156px;
  border-radius: 50%;
  margin: 17px auto 8px;
  display: grid;
  place-items: center;
  position: relative;
  background: conic-gradient(var(--red) calc(var(--pressure, 0) * 1%), rgba(255,255,255,.05) 0);
  box-shadow: 0 0 55px color-mix(in srgb, var(--mode-color, var(--cyan)) 24%, transparent);
}
.pressure-orb::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #121b28 0, #080c12 65%, #020305 100%);
  border: 1px solid rgba(255,255,255,.05);
}
.pressure-core { position: relative; z-index: 2; }
.pressure-core strong { font-size: 48px; line-height: 1; letter-spacing: -.06em; }
.pressure-core small { color: var(--muted); }
.mode { font-weight: 900; letter-spacing: .15em; color: var(--mode-color, var(--cyan)); font-size: 12px; }
.canon { font-size: 12px; color: var(--muted); margin-top: 8px; }
.flashpoint-panel h2, .mission-panel h3, .panel-heading h3 { margin: 7px 0 10px; font-size: 24px; }
.flashpoint-panel p, .mission-panel p { color: #b3c4d0; line-height: 1.55; max-width: 900px; }
.metrics { display: grid; grid-template-columns: 130px minmax(160px,1fr) minmax(160px,1fr); gap: 10px; margin-top: 24px; }
.metrics div { padding: 13px; border: 1px solid rgba(255,255,255,.06); border-radius: 12px; background: rgba(0,0,0,.16); }
.metrics span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.metrics strong { display: block; margin-top: 5px; font-size: 14px; }

.grid.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, .65fr);
  gap: 16px;
  margin-top: 16px;
}
.map-panel { grid-row: span 3; }
.map-heading { align-items: flex-start; }
.map-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.map-stats span {
  color: #9ab4c3;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.025);
  border-radius: 999px;
  padding: 7px 9px;
  font-size: 9px;
  letter-spacing: .09em;
}
.map-legend {
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
  color: #718897;
  font-size: 9px;
  letter-spacing: .06em;
  margin: 3px 0 10px;
}
.map-legend span { display: inline-flex; gap: 5px; align-items: center; }
.map-legend i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: #647987; }
.map-legend .legend-location { border: 1px solid var(--cyan); background: transparent; }
.map-legend .legend-hero { background: var(--cyan); box-shadow: 0 0 7px rgba(115,231,255,.7); }
.map-legend .legend-hostile { background: var(--red); box-shadow: 0 0 7px rgba(255,77,100,.7); }
.map-legend .legend-hotspot { background: var(--amber); box-shadow: 0 0 8px rgba(255,200,87,.7); }
.map-legend .legend-travel { width: 18px; height: 1px; border-radius: 0; background: var(--cyan); }

.map {
  height: 620px;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at 49% 50%, rgba(40,111,130,.16), transparent 25%),
    radial-gradient(circle at 50% 15%, rgba(114,167,255,.08), transparent 24%),
    radial-gradient(circle at 85% 35%, rgba(188,126,255,.06), transparent 25%),
    linear-gradient(135deg, #080d14, #04070b);
  border: 1px solid rgba(115,231,255,.14);
}
.grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(115,231,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(115,231,255,.045) 1px, transparent 1px);
  background-size: 42px 42px;
}
.map-vignette { position: absolute; inset: 0; box-shadow: inset 0 0 100px rgba(0,0,0,.72); pointer-events: none; z-index: 8; }
.map-center {
  position: absolute;
  left: 49%;
  top: 49%;
  translate: -50% -50%;
  font-size: 9px;
  letter-spacing: .24em;
  color: rgba(154,222,238,.15);
  text-align: center;
  pointer-events: none;
}
.sector {
  position: absolute;
  border: 1px solid rgba(115,231,255,.06);
  border-radius: 50%;
  pointer-events: none;
}
.sector span { position: absolute; font-size: 8px; letter-spacing: .2em; color: rgba(126,150,166,.28); }
.sector-earth { left: 16%; top: 24%; width: 59%; height: 58%; }
.sector-earth span { right: 11%; bottom: 7%; }
.sector-realm { left: 2%; top: 2%; width: 60%; height: 94%; border-style: dashed; }
.sector-realm span { left: 7%; bottom: 8%; }
.sector-cosmic { right: 1%; top: 3%; width: 35%; height: 72%; border-color: rgba(114,167,255,.08); }
.sector-cosmic span { right: 8%; top: 9%; }
.sector-multiverse { right: 3%; bottom: 1%; width: 51%; height: 36%; border-color: rgba(202,137,255,.08); }
.sector-multiverse span { right: 8%; bottom: 8%; }

.travel-layer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.travel-line {
  stroke: rgba(115,231,255,.17);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 8 8;
  animation: dash 5s linear infinite;
}
.travel-line.latest { stroke: rgba(115,231,255,.42); stroke-width: 2; filter: drop-shadow(0 0 4px rgba(115,231,255,.5)); }

.location-node {
  position: absolute;
  z-index: 5;
  translate: -50% -50%;
  width: 92px;
  height: 92px;
  border: 0;
  padding: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.location-node:focus-visible { outline: 2px solid var(--cyan); outline-offset: 6px; border-radius: 50%; }
.location-ring, .location-core { position: absolute; left: 50%; top: 50%; border-radius: 50%; translate: -50% -50%; }
.location-ring {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(115,231,255,.2);
  background: radial-gradient(circle, rgba(115,231,255,.08), transparent 65%);
  transition: width .25s ease, height .25s ease, border-color .25s ease;
}
.location-core {
  width: 11px;
  height: 11px;
  background: #07131a;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 16px rgba(115,231,255,.45);
}
.location-node.selected .location-ring { width: 62px; height: 62px; border-color: rgba(115,231,255,.7); box-shadow: 0 0 28px rgba(115,231,255,.13); }
.location-node.hotspot .location-ring { animation: hotspot 1.8s ease-out infinite; }
.location-node.severity-3 .location-core { border-color: var(--amber); box-shadow: 0 0 18px rgba(255,200,87,.7); }
.location-node.severity-4 .location-core,
.location-node.severity-5 .location-core { border-color: var(--red); box-shadow: 0 0 23px rgba(255,77,100,.85); }
.location-node.severity-4 .location-ring,
.location-node.severity-5 .location-ring { border-color: rgba(255,77,100,.55); }
.location-node.sector-cosmic .location-core { border-color: var(--blue); }
.location-node.sector-multiverse .location-core { border-color: #c889ff; }
.location-node.sector-realm .location-core { border-color: #9fd8e8; }
.location-label {
  position: absolute;
  left: 50%;
  top: 72px;
  translate: -50% 0;
  min-width: 108px;
  max-width: 150px;
  padding: 5px 7px;
  border-radius: 8px;
  background: rgba(3,6,9,.84);
  border: 1px solid rgba(255,255,255,.07);
  text-align: center;
  pointer-events: none;
}
.location-label b { display: block; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.location-label small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.character-cluster { position: absolute; inset: 0; pointer-events: none; }
.character-signal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 7px;
  letter-spacing: -.04em;
  color: #dffaff;
  background: #0b2029;
  border: 1px solid rgba(115,231,255,.75);
  box-shadow: 0 0 10px rgba(115,231,255,.3);
  transform: translate(var(--dx), var(--dy)) translate(-50%, -50%);
}
.character-signal.hostile { background: #2a0b12; border-color: rgba(255,77,100,.8); box-shadow: 0 0 11px rgba(255,77,100,.35); }
.character-signal.incapacitated { border-color: var(--amber); opacity: .65; }
.character-more {
  position: absolute;
  left: 72%;
  top: 65%;
  min-width: 24px;
  height: 19px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--muted);
  background: #0b1017;
  border: 1px solid rgba(255,255,255,.1);
  font-size: 8px;
}

.travel-ghost {
  position: absolute;
  z-index: 10;
  translate: -50% -50%;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #dffaff;
  color: #061015;
  font-weight: 950;
  font-size: 9px;
  border: 2px solid white;
  box-shadow: 0 0 9px #fff, 0 0 24px rgba(115,231,255,.9), 0 0 42px rgba(115,231,255,.55);
}
.travel-ghost::after { content: ""; position: absolute; right: 22px; width: 55px; height: 2px; background: linear-gradient(90deg, transparent, rgba(115,231,255,.85)); }
.travel-burst {
  position: absolute;
  z-index: 9;
  translate: -50% -50%;
  width: 20px;
  height: 20px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  animation: burst 1.2s ease-out forwards;
}

.event-ticker { display: flex; gap: 7px; overflow-x: auto; padding: 10px 1px 4px; scrollbar-width: thin; }
.ticker-item {
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.025);
  color: #91a9b7;
  border-radius: 999px;
  padding: 7px 9px;
  font-size: 9px;
  letter-spacing: .05em;
  cursor: pointer;
}
.ticker-item:hover, .ticker-item:focus-visible { color: var(--text); border-color: rgba(115,231,255,.35); outline: none; }

.map-detail { margin-top: 10px; padding: 14px; border: 1px solid rgba(255,255,255,.06); border-radius: 13px; background: rgba(0,0,0,.16); }
.map-detail-head h4 { margin: 5px 0 0; font-size: 19px; }
#selectedLocationState { font-size: 9px; letter-spacing: .12em; color: var(--amber); }
#selectedLocationSummary { margin: 10px 0 13px; color: #a9bbc7; line-height: 1.45; font-size: 12px; }
.map-detail-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-label { display: block; margin-bottom: 6px; font-size: 8px; }
.detail-list { display: grid; gap: 5px; }
.detail-row { display: grid; gap: 2px; padding: 7px 8px; border-radius: 8px; background: rgba(255,255,255,.025); }
.detail-row b { font-size: 10px; }
.detail-row span { color: var(--muted); font-size: 9px; line-height: 1.35; }
.detail-row.event b { text-transform: capitalize; }
.muted { color: var(--muted); font-size: 10px; }

.mission-panel { min-height: 280px; }
.empty { color: var(--muted); display: grid; place-items: center; min-height: 200px; text-align: center; }
.empty.compact { min-height: 90px; }
.progress { height: 10px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.06); margin: 20px 0 8px; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--green)); box-shadow: 0 0 18px rgba(115,231,255,.35); transition: width .8s ease; }
.progress-copy { font-size: 12px; color: var(--muted); }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.action-chip { padding: 10px 11px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.025); border-radius: 10px; font-size: 11px; color: #b9ccd8; }
.factions { display: grid; gap: 8px; margin-top: 12px; }
.faction-row { display: grid; grid-template-columns: minmax(110px,1fr) 90px 70px; align-items: center; gap: 10px; padding: 9px 10px; background: rgba(255,255,255,.025); border-radius: 10px; }
.faction-row b { font-size: 12px; }
.faction-row span, .faction-row small { font-size: 11px; color: var(--muted); text-align: right; }
.defense-total { display: flex; align-items: baseline; gap: 8px; margin: 18px 0; }
.defense-total strong { font-size: 42px; }
.defense-total span { font-size: 10px; color: var(--muted); letter-spacing: .16em; }
.defense-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.defense-stats div { display: grid; grid-template-columns: auto auto 1fr; gap: 6px; align-items: center; padding: 8px; border-radius: 9px; background: rgba(255,255,255,.025); font-size: 11px; }
.defense-stats span { color: var(--muted); }
.mitigation { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.06); font-size: 10px; color: var(--muted); letter-spacing: .1em; }
.mitigation strong { float: right; color: var(--green); font-size: 13px; }
footer { padding: 16px 4px 0; font-size: 9px; letter-spacing: .12em; color: #526877; }

@keyframes pulse { 0%,100% { opacity: .5; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.15); } }
@keyframes sweep { 0% { transform: translateX(-110%); } 55%,100% { transform: translateX(110%); } }
@keyframes dash { to { stroke-dashoffset: -32; } }
@keyframes hotspot { 0% { scale: .75; opacity: .85; } 100% { scale: 1.65; opacity: 0; } }
@keyframes burst { 0% { scale: .4; opacity: 1; } 100% { scale: 4; opacity: 0; } }

@media (max-width: 980px) {
  .shell { padding: 12px; }
  .hero-grid, .grid.lower-grid { grid-template-columns: 1fr; }
  .map-panel { grid-row: auto; }
  .threat-panel { min-height: 220px; }
  .pressure-orb { width: 130px; height: 130px; }
  .pressure-core strong { font-size: 40px; }
  .map { height: 540px; }
}

@media (max-width: 640px) {
  .topbar { align-items: flex-start; }
  .connection span { display: none; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics div:last-child { grid-column: span 2; }
  .map { height: 480px; }
  .map-stats { justify-content: flex-start; }
  .map-heading { display: grid; }
  .location-node { width: 72px; height: 72px; }
  .location-label { top: 59px; min-width: 88px; max-width: 110px; }
  .location-label b { font-size: 8px; }
  .character-signal { width: 18px; height: 18px; font-size: 6px; }
  .map-detail-columns { grid-template-columns: 1fr; }
  .faction-row { grid-template-columns: minmax(100px,1fr) 75px; }
  .faction-row small { display: none; }
  footer { display: grid; justify-content: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .travel-line { stroke-dasharray: none; }
}
