:root {
  color-scheme: dark;
  --bg: #080c12;
  --bg-elev: #0e141c;
  --glass: rgba(16, 22, 30, 0.82);
  --border: rgba(76, 104, 136, 0.28);
  --text: #e9f0f8;
  --muted: #8fa3b8;
  --faint: #5a6d82;
  --accent: #4cc9f0;
  --accent-dim: rgba(76, 201, 240, 0.18);
  --accent-glow: rgba(76, 201, 240, 0.35);
  --enemy: #ff6b6b;
  --friend: #5ae68c;
  --npc: #ffbe46;
  --danger: #ff8a65;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(120% 80% at 50% -20%, #152033 0%, var(--bg) 55%);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* —— Splash (loader-style boot) —— */
.splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse 90% 60% at 50% 35%, rgba(76, 201, 240, 0.07), transparent 60%),
    var(--bg);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.splash.out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-card {
  text-align: center;
  padding: 28px 36px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.splash-mark {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
}

.splash-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: rgba(76, 201, 240, 0.25);
  animation: spin 0.9s linear infinite;
}

.splash-core {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent), #1e6b88 80%);
  box-shadow: 0 0 28px var(--accent-glow);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.splash-title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.splash-msg {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

/* —— App chrome —— */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.72);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.status-pill {
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--bg-elev);
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.status-pill.live {
  color: var(--friend);
  border-color: rgba(90, 230, 140, 0.35);
  box-shadow: 0 0 20px rgba(90, 230, 140, 0.12);
}

.status-pill.wait {
  color: #f0c070;
  border-color: rgba(240, 192, 112, 0.35);
}

.status-pill.dead {
  color: var(--danger);
  border-color: rgba(255, 138, 101, 0.35);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* —— Gate —— */
.gate {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  max-width: 420px;
  padding: 28px 26px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-card h1 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.gate-card p {
  margin: 0 0 10px;
  line-height: 1.55;
  color: var(--muted);
}

.gate-hint {
  font-size: 0.82rem;
  color: var(--faint) !important;
}

/* —— Live layout —— */
.live {
  display: flex;
  flex: 1;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

.map-shell {
  position: relative;
  flex: 1 1 300px;
  min-height: min(72vh, 760px);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(165deg, #121a24 0%, #0c1118 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-loading {
  text-align: center;
  padding: 24px;
}

.map-loading p {
  margin: 14px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.loader-dial {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(76, 201, 240, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}

#map {
  width: 100%;
  height: 100%;
  max-width: min(96vw, 860px);
  max-height: min(72vh, 860px);
  touch-action: none;
  display: block;
}

.panel {
  flex: 0 1 300px;
  padding: 16px 18px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  align-self: flex-start;
}

.panel-head h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-sub {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--faint);
}

/* —— Custom toggles —— */
.toggles {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(52vh, 480px);
  overflow: auto;
  padding-right: 4px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}

.toggle-row:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.04);
}

.toggle-row span {
  font-size: 0.88rem;
  color: var(--text);
}

.toggle {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 999px;
  background: #1a2430;
  border: 1px solid var(--border);
  transition: background 0.2s, box-shadow 0.2s;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #6a7d94;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
}

.toggle-row.on .toggle {
  background: var(--accent-dim);
  border-color: rgba(76, 201, 240, 0.45);
  box-shadow: 0 0 16px rgba(76, 201, 240, 0.15);
}

.toggle-row.on .toggle::after {
  transform: translateX(18px);
  background: var(--accent);
}

.range-block {
  display: block;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.range-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.range-head output {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  appearance: none;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-dim), #1a2430);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
  border: 2px solid #0a1018;
}

@media (max-width: 720px) {
  .live {
    flex-direction: column-reverse;
  }
  .panel {
    flex: none;
    width: 100%;
  }
  .map-shell {
    min-height: 58vh;
  }
}
