:root {
  --bg: #080c18;
  --panel: #0e1424;
  --panel-border: #28324e;
  --text: #dce1eb;
  --dim: #8c96aa;
  --title: #f0f5ff;
  --station-dot: #465072;
  --map-water: #0b1022;
  --map-land: #141b30;
  --map-park: #163024;
  --map-boundary: rgba(150,162,190,0.10);
  --map-shore: rgba(120,150,190,0.35);
}

body.light {
  --bg: #eef1f6;
  --panel: #ffffff;
  --panel-border: #ccd3e0;
  --text: #1a2030;
  --dim: #59637a;
  --title: #0f1626;
  --station-dot: #9aa6c2;
  --map-water: #d9e4f2;
  --map-land: #eef1f6;
  --map-park: #d5e8d4;
  --map-boundary: rgba(60,72,96,0.12);
  --map-shore: rgba(70,110,150,0.40);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Consolas, "Cascadia Mono", Menlo, monospace;
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: 52px 1fr 150px;
  height: 100vh;
}

/* Start overlay */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 16, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay-card {
  text-align: center;
  max-width: 460px;
  padding: 32px;
}
.overlay-card h1 { color: var(--title); font-size: 28px; margin: 0 0 12px; letter-spacing: 1px; }
.overlay-card p { color: var(--dim); line-height: 1.5; }
.overlay-card .hint { font-size: 12px; margin-top: 18px; }
#start-btn {
  margin-top: 12px;
  padding: 12px 34px;
  font: inherit;
  font-size: 18px;
  color: #06111f;
  background: #35c1ff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#start-btn:hover { background: #5cd0ff; }

/* Top bar */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--panel-border);
}
#topbar .title { color: var(--title); font-weight: bold; letter-spacing: 2px; }
#topbar .stats { display: flex; align-items: center; gap: 18px; color: var(--dim); font-size: 13px; }
#topbar .stats b { color: var(--text); }
.pill {
  padding: 2px 10px;
  border-radius: 10px;
  background: #16324a;
  color: #6fd0ff;
  font-size: 12px;
  letter-spacing: 1px;
}
.pill.demo { background: #3a2a12; color: #ffbf5c; }
.vol { display: flex; align-items: center; gap: 6px; }
.vol input { width: 90px; }

.mode-toggle { display: inline-flex; border: 1px solid var(--panel-border); border-radius: 8px; overflow: hidden; }
.mode-btn { font: inherit; font-size: 12px; padding: 4px 10px; background: transparent; color: var(--dim); border: none; cursor: pointer; }
.mode-btn.active { background: #16324a; color: #6fd0ff; }
.mode-btn:hover { color: var(--text); }
.hdr-link { color: var(--dim); font-size: 12px; text-decoration: none; white-space: nowrap; }
.hdr-link:hover { color: var(--text); text-decoration: underline; }

/* Main area */
main {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}
#map-wrap, #legend-wrap {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  min-height: 0;
}
#map-wrap { position: relative; overflow: hidden;}
#map { width: 100%; height: 100%; display: block; }

#legend-wrap { padding: 10px 12px; display: flex; flex-direction: column; min-height: 0; }
.panel-title { color: var(--dim); font-size: 12px; letter-spacing: 1px; margin-bottom: 8px; }
#legend { overflow: hidden; display: flex; flex-direction: column; flex: 1; padding: 0 12px; margin: 0 -12px;}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-height: 0;
}
.bullet {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  flex: 0 0 auto;
}
.bullet.pulse { animation: pulse 0.9s ease-out; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 currentColor; transform: scale(1.25); }
  100% { box-shadow: 0 0 0 10px transparent; transform: scale(1); }
}
.lname { color: var(--dim); font-size: 12px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcount { color: var(--text); font-size: 12px; min-width: 28px; text-align: right; }

/* Ticker */
#ticker-wrap {
  margin: 0 12px 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
}
#ticker { display: flex; flex-direction: column; gap: 3px; }
.tick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); }
.tick:first-child { color: var(--text); }
.tick .bullet { width: 18px; height: 18px; font-size: 11px; }

/* About modal */
.about-btn { font: inherit; font-size: 12px; padding: 4px 10px; background: transparent; color: var(--dim); border: 1px solid var(--panel-border); border-radius: 8px; cursor: pointer; }
.about-btn:hover { color: var(--text); }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-card { position: relative; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; max-width: 620px; width: calc(100% - 40px); max-height: 82vh; overflow-y: auto; padding: 26px 30px; }
.modal-card h2 { color: var(--title); margin: 0 0 10px; }
.modal-card h3 { color: var(--title); margin: 18px 0 6px; font-size: 15px; }
.modal-card p, .modal-card li { color: var(--dim); line-height: 1.55; font-size: 14px; }
.modal-card ul { margin: 6px 0; padding-left: 20px; }
.modal-card b { color: var(--text); }
.modal-card a { color: #3f9fe0; }
.modal-card .about-foot { margin-top: 18px; font-size: 12px; opacity: 0.85; }
.modal-close { position: absolute; top: 8px; right: 14px; background: transparent; border: none; color: var(--dim); font-size: 26px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--text); }
