:root {
  color-scheme: light;
  --bg: #14181c;
  --panel: #1e252b;
  --text: #eef1f3;
  --muted: #9aa7b0;
  --accent: #4fb0e8;
  --error: #ff5c5c;
  --border: #2c353c;
}

* {
  box-sizing: border-box;
}

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

#statusBar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 10;
}

#statusText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Flashes once per successful poll so a live feed is visible at a glance,
   independent of whether any dot moved far enough to notice. */
.live-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background-color 120ms linear, box-shadow 120ms linear;
}

.live-dot.pulse {
  background: #3ddc84;
  box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.25);
}

.live-dot.stale {
  background: var(--error);
}

#errorBanner {
  color: var(--error);
  font-weight: 600;
}

.hidden {
  display: none !important;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  gap: 1rem;
}

/* The map and its SVG overlay share this box. Both children are stretched
   to 100% of this element using the SAME aspect ratio (1080:1312) as the
   source assets, so the SVG viewBox coordinate space and the rendered map
   pixels stay in lockstep at any window size without any JS resize math. */
/* The map.svg extracted from the PDF has no page rect, so it is transparent
   and its near-black text/linework needs a light surface behind it. */
.map-wrap {
  position: relative;
  width: 100%;
  max-width: min(92vw, calc((100vh - 8.5rem) * (1080 / 1312)));
  aspect-ratio: 1080 / 1312;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  touch-action: none; /* we handle pinch/drag ourselves via pointer events */
}

.map-wrap.dragging {
  cursor: grabbing;
}

/* Zoom/pan target. Both map layers ride inside it, so they can never drift
   apart — one transform moves the image and the train overlay together. */
/* No `will-change: transform` here on purpose: promoting this to a permanent
   composited layer lets the compositor bitmap-scale it, which reintroduces
   the exact blur that inlining the SVG was meant to fix. */
.map-canvas {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.map-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.zoom-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}

.zoom-controls button {
  width: 30px;
  height: 30px;
  font-size: 1rem;
  line-height: 1;
  color: var(--text);
  background: rgba(30, 37, 43, 0.92);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

.zoom-controls button:hover {
  background: rgba(46, 56, 64, 0.95);
}

.zoom-controls button:disabled {
  opacity: 0.4;
  cursor: default;
}

.zoom-level {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: rgba(30, 37, 43, 0.92);
  border: 1px solid var(--border);
  border-radius: 4px;
  z-index: 5;
}

.map-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.map-hint kbd {
  padding: 0 4px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--panel);
}

#mapImage {
  object-fit: contain;
}

#trainOverlay {
  pointer-events: none;
}

.map-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.95rem;
  background: rgba(12, 15, 18, 0.85);
}

.fallback-panel {
  width: 100%;
  max-width: 900px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.85rem;
}

.fallback-panel p {
  margin-top: 0;
  color: var(--muted);
}

#fallbackTable {
  width: 100%;
  border-collapse: collapse;
}

#fallbackTable th,
#fallbackTable td {
  text-align: left;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

#fallbackTable th {
  color: var(--muted);
  font-weight: 600;
}
