:root {
  --bg: #000000;
  --bg-elevated: #0a0a0a;
  --card: rgba(12, 4, 4, 0.92);
  --text: #f2f2f2;
  --muted: #9a8a8a;
  --accent: #ff2b2b;
  --accent-bright: #ff5555;
  --accent-dim: rgba(255, 43, 43, 0.35);
  --glow: rgba(255, 30, 30, 0.55);
  --glow-soft: rgba(255, 40, 40, 0.18);
  --ok: #3dff8a;
  --err: #ff4444;
  --border: rgba(255, 50, 50, 0.45);
  --font-display: "Orbitron", "Segoe UI", system-ui, sans-serif;
  --font-body: "Rajdhani", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-weight: 500;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(180, 0, 0, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 50%, rgba(120, 0, 0, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 35% at 0% 80%, rgba(100, 0, 0, 0.1), transparent 45%),
    #000;
  pointer-events: none;
}

.bg-watermark {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("/static/logo-icon.png") center 40% / min(520px, 70vw) no-repeat;
  opacity: 0.04;
  pointer-events: none;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(20, 0, 0, 0.95), rgba(0, 0, 0, 0.98));
  box-shadow: 0 0 24px var(--glow-soft);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  width: 42px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px var(--glow));
}

.brand-text {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-bright);
  text-shadow: 0 0 12px var(--glow), 0 0 28px var(--glow-soft);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.topbar nav a {
  color: var(--muted);
  padding: 0.4rem 0.75rem;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: 2px;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.topbar nav a:hover {
  color: var(--accent-bright);
  border-color: var(--accent-dim);
  box-shadow: 0 0 12px var(--glow-soft);
}

.topbar nav a.active {
  color: #fff;
  border-color: var(--accent);
  background: rgba(255, 30, 30, 0.12);
  box-shadow: 0 0 16px var(--glow-soft), inset 0 0 20px rgba(255, 0, 0, 0.08);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-bright);
  text-shadow: 0 0 14px var(--glow);
  margin: 0 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.page-hero {
  text-align: center;
  margin-bottom: 1.75rem;
  padding: 1rem 0 0.5rem;
}

.page-hero img {
  max-width: min(640px, 100%);
  height: auto;
  filter: drop-shadow(0 0 20px var(--glow)) drop-shadow(0 0 40px var(--glow-soft));
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  padding: 2rem 1rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
  text-shadow: none;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow:
    0 0 20px var(--glow-soft),
    inset 0 0 40px rgba(255, 0, 0, 0.03);
}

.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border-color: var(--accent);
  border-style: solid;
  opacity: 0.7;
}

.card::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
}

.card::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 2px 2px 0;
}

.card.narrow { max-width: 420px; margin: 2rem auto; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.grid.two-col { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.card.stat {
  text-align: center;
  padding: 1.35rem 1rem;
}

.stat-num {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--accent-bright);
  display: block;
  text-shadow: 0 0 16px var(--glow), 0 0 32px var(--glow-soft);
  line-height: 1.1;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.35rem;
}

.card.stat a {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.muted { color: var(--muted); }
.ok { color: var(--ok); text-shadow: 0 0 8px rgba(61, 255, 138, 0.35); }
.error { color: var(--err); text-shadow: 0 0 8px var(--glow-soft); }

label {
  display: block;
  margin: 0.75rem 0 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #050505;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--glow-soft);
}

label.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: none;
  color: var(--text);
}

label.check input { width: auto; }

button,
.btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.55rem 1.25rem;
  background: linear-gradient(180deg, rgba(80, 0, 0, 0.9), rgba(30, 0, 0, 0.95));
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: 2px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 0 14px var(--glow-soft);
  transition: box-shadow 0.2s, background 0.2s;
}

button:hover,
.btn:hover {
  box-shadow: 0 0 22px var(--glow);
  background: linear-gradient(180deg, rgba(120, 0, 0, 0.95), rgba(50, 0, 0, 0.98));
  color: #fff;
}

button.link {
  background: none;
  border: none;
  color: var(--muted);
  margin: 0;
  padding: 0;
  font-weight: normal;
  font-family: inherit;
  text-transform: none;
  letter-spacing: normal;
  box-shadow: none;
}

button.link.danger { color: var(--err); }

.inline { display: inline; margin-left: 0.5rem; }

.actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

table { width: 100%; border-collapse: collapse; }

th {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-bright);
  border-bottom: 1px solid var(--border);
}

th, td {
  text-align: left;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid rgba(255, 50, 50, 0.15);
}

code {
  background: rgba(255, 30, 30, 0.08);
  border: 1px solid rgba(255, 50, 50, 0.2);
  padding: 0.1rem 0.35rem;
  border-radius: 2px;
  font-size: 0.9em;
  color: var(--accent-bright);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.5rem 1rem;
}

.field .hint {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.card h2 {
  margin-top: 0;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-bright);
  text-shadow: 0 0 10px var(--glow-soft);
}

.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.search-row input { flex: 1; min-width: 200px; }
.card.narrow-search { max-width: 520px; }

a {
  color: var(--accent-bright);
  text-decoration: none;
  transition: text-shadow 0.2s;
}

a:hover {
  text-shadow: 0 0 10px var(--glow);
}

table a { color: var(--accent-bright); }

.card.stat a { color: var(--muted); font-size: 0.8rem; }
.card.stat a:hover { color: var(--accent-bright); }

/* Login */
body.page-login .container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
}

body.page-login .page-hero-login {
  text-align: center;
  margin-bottom: 1.5rem;
}

body.page-login .page-hero-login img {
  max-width: min(480px, 92vw);
  filter: drop-shadow(0 0 24px var(--glow));
}

body.page-login h1.page-title {
  text-align: center;
  border: none;
  margin-bottom: 1rem;
}

/* Live map */
body.page-map .container { max-width: 1280px; }

.map-hint { margin: -0.75rem 0 1rem; font-size: 0.9rem; }

.map-layout {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px);
  gap: 1rem;
  align-items: start;
}

.map-panel { padding: 0.75rem; }

.leaflet-map {
  width: 100%;
  height: min(78vh, 720px);
  min-height: 420px;
  border: 1px solid var(--border);
  background: #0a0a0a;
}

.leaflet-container {
  font-family: var(--font-body);
  background: #0a0a0a;
}

.leaflet-map .leaflet-tile-pane {
  filter: saturate(1.05) brightness(0.95);
}

.leaflet-player-icon {
  background: none;
  border: none;
}

.leaflet-player-dot {
  display: block;
  width: 14px;
  height: 14px;
  margin: 2px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #ff2b2b;
  box-shadow: 0 0 10px rgba(255, 40, 40, 0.9);
}

.leaflet-player-icon.stale .leaflet-player-dot {
  background: #666;
  box-shadow: none;
}

.leaflet-popup-content-wrapper {
  background: #1a0a0a;
  color: #f2f2f2;
  border: 1px solid rgba(255, 60, 60, 0.5);
  border-radius: 4px;
}

.leaflet-popup-tip {
  background: #1a0a0a;
}

.leaflet-popup-content a {
  color: var(--accent-bright);
}

.map-meta {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.map-sidebar h2 { margin-bottom: 0.75rem; }

.map-player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 520px;
  overflow-y: auto;
}

.map-player-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid rgba(255, 50, 50, 0.12);
  font-size: 0.95rem;
}

.map-list-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.map-sidebar-note { margin-top: 1rem; font-size: 0.8rem; }

.lead {
  margin: -0.5rem 0 1.5rem;
  color: var(--muted);
  font-size: 1.1rem;
}

.stats-row {
  margin-bottom: 2rem;
}

.feature-section {
  margin-bottom: 2.25rem;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 0.25rem;
  color: var(--accent-bright);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.section-head .muted {
  margin: 0 0 1rem;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.feature-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 8.5rem;
}

.feature-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.feature-card h3 {
  margin: 0;
  font-size: 1.05rem;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

.badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.45rem;
  border-radius: 3px;
  flex-shrink: 0;
}

.badge-on {
  background: rgba(61, 255, 138, 0.15);
  color: var(--ok);
  border: 1px solid rgba(61, 255, 138, 0.35);
}

.badge-off {
  background: rgba(120, 120, 120, 0.15);
  color: var(--muted);
  border: 1px solid rgba(120, 120, 120, 0.3);
}

.feature-detail {
  margin: 0;
  font-size: 0.92rem;
  flex: 1;
}

.feature-cmd {
  margin: 0;
  font-size: 0.8rem;
}

.feature-edit {
  margin-top: 0.35rem;
  font-weight: 600;
  color: var(--accent-bright);
  text-decoration: none;
}

.feature-edit:hover {
  text-decoration: underline;
}

.group-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin: 1.5rem 0 0.75rem;
  color: var(--accent-bright);
  letter-spacing: 0.05em;
}

.link-list {
  margin: 0;
  padding-left: 1.2rem;
}

.link-list li { margin: 0.35rem 0; }

.link-list a {
  color: var(--accent-bright);
  text-decoration: none;
}

.link-list a:hover { text-decoration: underline; }

.quick-links { margin-top: 1rem; }

.guide-toc {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
}

.guide-toc ol {
  margin: 0.5rem 0 0;
  padding-left: 1.35rem;
}

.guide-toc a {
  color: var(--accent-bright);
  text-decoration: none;
}

.guide-toc a:hover { text-decoration: underline; }

.guide-doc {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.guide-section h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 0.75rem;
  color: var(--accent-bright);
  letter-spacing: 0.04em;
}

.guide-section ul,
.guide-section ol {
  margin: 0.5rem 0;
  padding-left: 1.35rem;
}

.guide-section li { margin: 0.35rem 0; }

.guide-section p { margin: 0.5rem 0; }

.steps {
  counter-reset: step;
  list-style: none;
  padding-left: 0;
}

.steps li {
  position: relative;
  padding-left: 2rem;
  margin: 0.65rem 0;
}

.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  width: 1.45rem;
  height: 1.45rem;
  line-height: 1.45rem;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: 3px;
}

.tip-box {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(61, 255, 138, 0.06);
  border-left: 3px solid var(--ok);
  border-radius: 0 4px 4px 0;
  font-size: 0.95rem;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.92rem;
}

.guide-table th,
.guide-table td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 50, 50, 0.2);
}

.guide-table th {
  color: var(--accent-bright);
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.checklist {
  list-style: none;
  padding-left: 0;
}

.checklist li {
  padding-left: 1.5rem;
  position: relative;
}

.checklist li::before {
  content: "☐";
  position: absolute;
  left: 0;
  color: var(--muted);
}

.badge.inline {
  display: inline-block;
  vertical-align: middle;
  font-size: 0.6rem;
}

.guide-footer {
  margin-top: 1.5rem;
  text-align: center;
}

.edit-back {
  margin: 0 0 0.5rem;
}

.edit-back a {
  color: var(--muted);
  text-decoration: none;
}

.edit-back a:hover { color: var(--accent-bright); }

.edit-focus-card {
  max-width: 520px;
}

.edit-focus-grid {
  grid-template-columns: 1fr;
}

.edit-view-all {
  margin-top: 1rem;
  font-size: 0.9rem;
}

.edit-view-all a {
  color: var(--accent-bright);
  text-decoration: none;
}

.btn-secondary {
  display: inline-block;
  margin-left: 0.75rem;
  padding: 0.55rem 1rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

.warn-box {
  border-color: rgba(255, 180, 60, 0.55);
  background: rgba(40, 24, 0, 0.5);
}

.warn-box strong { color: #ffc857; }

.setup-help { margin-bottom: 1.25rem; }

.setup-help .steps.compact { margin: 0.5rem 0 0; }

.setup-form .card + .card { margin-top: 1rem; }

.setup-advanced summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--accent-bright);
}

.ok-hint { color: var(--ok); }

.sticky-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
}

.btn-ghost {
  display: inline-block;
  padding: 0.55rem 1rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--accent-dim);
}

@media (max-width: 900px) {
  .map-layout { grid-template-columns: 1fr; }
  .map-player-list { max-height: 200px; }
}

@media (max-width: 640px) {
  .topbar nav a {
    font-size: 0.65rem;
    padding: 0.35rem 0.5rem;
  }
  .brand-text { display: none; }
  .brand-icon { width: 36px; height: 36px; }
}
