:root {
  --bg: #0b1220;
  --panel: rgba(13, 21, 38, 0.92);
  --panel-border: #24344f;
  --text: #dbe6f5;
  --text-dim: #8fa3c0;
  --accent: #4fc3f7;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
  cursor: crosshair;
}
#map.dragging { cursor: grabbing; }

#masthead {
  position: fixed;
  top: 14px;
  left: 18px;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}
#masthead h1 {
  margin: 0;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
}
#masthead .tagline {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.92rem;
}

#panel {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 295px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px 14px;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
#panel .row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
#panel .row:last-child { margin-bottom: 0; }
#panel label {
  width: 48px;
  flex: none;
  color: var(--text-dim);
  font-size: 0.85rem;
}
#panel select, #panel button {
  background: #16233c;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 0.85rem;
  cursor: pointer;
}
#panel select { flex: 1; min-width: 0; }
.warp-row { flex-wrap: wrap; }
.rangecap {
  flex: none;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#panel input[type="range"] { min-width: 90px; }
#panel button:hover { border-color: var(--accent); }
#panel input[type="range"] { flex: 1; accent-color: var(--accent); }
#panel .hint {
  color: var(--text-dim);
  font-size: 0.8rem;
  line-height: 1.35;
}
#panel .small { justify-content: flex-end; }

#stats { margin: 4px 0 10px; }
.stats-title {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.statbar { margin-bottom: 5px; font-size: 0.78rem; }
.statbar .bar-bg {
  background: #16233c;
  border-radius: 4px;
  height: 14px;
  position: relative;
  overflow: hidden;
}
.statbar .bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.statbar .bar-label {
  position: absolute;
  left: 6px;
  top: 0;
  line-height: 14px;
  font-size: 0.72rem;
  color: #fff;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

#legend {
  position: fixed;
  bottom: 38px;
  left: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 9px 12px;
  width: 240px;
}
.legend-title { font-size: 0.78rem; color: var(--text-dim); margin-bottom: 6px; }
.legend-ramp { height: 12px; border-radius: 3px; }
.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 3px;
}

#tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.82rem;
  max-width: 240px;
  z-index: 5;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}
#tooltip .tt-name { font-weight: 600; }
#tooltip .tt-line { color: var(--text-dim); font-size: 0.76rem; }
#tooltip .tt-time { color: var(--accent); font-weight: 600; }

#about {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 40px));
  max-height: 80vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 20px 26px;
  z-index: 10;
  font-size: 0.92rem;
  line-height: 1.55;
}
#about h2 { font-size: 1.02rem; margin: 14px 0 6px; color: var(--accent); }
#about h2:first-child { margin-top: 0; }
#about a { color: var(--accent); }
#about button {
  background: #16233c;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  margin-top: 8px;
}

#loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 20;
  color: var(--text-dim);
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #24344f;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#credits {
  position: fixed;
  bottom: 10px;
  right: 14px;
  font-size: 0.72rem;
  color: var(--text-dim);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
#credits a { color: var(--text-dim); }

@media (max-width: 700px) {
  #masthead h1 { font-size: 1.15rem; }
  #panel { width: calc(100vw - 28px); top: auto; bottom: 12px; right: 14px; }
  #legend { bottom: auto; top: 70px; left: 14px; width: 180px; }
  #credits { display: none; }
}
