/* ============================================================
   PTV Live Maps - Dark Theme Stylesheet
   ============================================================ */

:root {
  --bg:        #0d0d0d;
  --bg2:       #141414;
  --panel-bg:  rgba(12, 12, 12, 0.96);
  --border:    rgba(255, 255, 255, 0.07);
  --text:      #e0e0e0;
  --text-dim:  #666;
  --accent:    #00d4ff;
  --green:     #00d48a;
  --red:       #ff4a4a;
  --amber:     #ffb300;
  --panel-w:   288px;
  --header-h:  52px;
  --radius:    10px;
  --font:      -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
}

/* ---- Light theme overrides ---- */
[data-theme="light"] {
  --bg:       #f0f2f5;
  --bg2:      #e4e7ec;
  --panel-bg: rgba(248, 249, 251, 0.97);
  --border:   rgba(0, 0, 0, 0.09);
  --text:     #1a1a2e;
  --text-dim: #7a7a90;
}

[data-theme="light"] #map                    { background: #e8ecf0; }
[data-theme="light"] .leaflet-container      { background: #e8ecf0 !important; }
[data-theme="light"] .logo-text              { color: var(--text); }
[data-theme="light"] .tm                     { border-color: #fff; }
[data-theme="light"] #search-input           { background: rgba(0,0,0,0.05); }
[data-theme="light"] #search-input::placeholder { color: #bbb; }
[data-theme="light"] .action-btn             { background: rgba(0,0,0,0.05); }
[data-theme="light"] .slider                 { background: rgba(0,0,0,0.12); }
[data-theme="light"] kbd                     { background: rgba(0,0,0,0.07); color: var(--text); }
[data-theme="light"] .leaflet-control-zoom a { background: var(--panel-bg) !important; color: var(--text) !important; border-color: var(--border) !important; }
[data-theme="light"] .leaflet-control-attribution { background: var(--panel-bg) !important; color: var(--text-dim) !important; }
[data-theme="light"] .leaflet-popup-content-wrapper { background: var(--panel-bg) !important; color: var(--text) !important; border-color: var(--border) !important; }
[data-theme="light"] .sp-dep:hover { background: rgba(0,0,0,0.05); }
[data-theme="light"] .dis-item { border-color: var(--border); }

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; width: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

/* ---- Map ---- */
#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #0a0a0a;
}

/* ---- Header ---- */
#header {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  min-width: 680px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

#header-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  flex-shrink: 0;
}

#header-status {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

#train-count    { color: #fff; font-weight: 600; font-size: 13px; }
#last-update    { color: var(--text-dim); font-size: 12px; }
#next-update    { color: var(--text-dim); font-size: 11px; opacity: 0.6; }
#stale-warning  { font-size: 11px; color: var(--amber); font-weight: 600; letter-spacing: 0.3px; }
#stale-warning.hidden { display: none; }

#delay-filter {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #FFC400;
  background: rgba(255, 196, 0, 0.14);
  border: 1px solid rgba(255, 196, 0, 0.45);
  border-radius: 999px;
  padding: 1px 9px;
  margin-left: -6px;                 /* sit snug after the count (gap is 14px) */
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#delay-filter:hover  { background: rgba(255, 196, 0, 0.24); }
#delay-filter.active { background: #FFC400; color: #10131a; }
#delay-filter.hidden { display: none; }

#api-dot { font-size: 10px; line-height: 1; }
.dot-ok      { color: var(--green); }
.dot-error   { color: var(--red); }
.dot-loading { color: var(--amber); animation: blink 1s step-start infinite; }

@keyframes blink { 50% { opacity: 0; } }

#logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-pulse {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: sonar 2.4s ease-out infinite;
  flex-shrink: 0;
}

@keyframes sonar {
  0%   { box-shadow: 0 0 0 0   rgba(0, 212, 255, 0.6); }
  70%  { box-shadow: 0 0 0 12px rgba(0, 212, 255, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(0, 212, 255, 0);   }
}

.logo-text {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #fff;
  line-height: 1.1;
}

.logo-words {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.logo-sub {
  font-size: 13px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
  font-weight: 400;
}

.logo-dedication {
  font-size: 11px;
  color: rgba(0, 212, 255, 0.6);
  letter-spacing: 1px;
  font-style: italic;
  margin-top: 1px;
}

#cinema-btn,
#theme-toggle,
#panel-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  padding-left: 10px;
  margin-left: 2px;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s;
}
#cinema-btn:hover,
#theme-toggle:hover,
#panel-toggle:hover { color: var(--text); }

/* ---- Side panel ---- */
#panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  z-index: 400;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  padding-top: 56px;
}

.panel-hidden { transform: translateX(100%); }

#panel:not(.panel-hidden) { transform: translateX(0); }

.panel-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.section-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
  margin-bottom: 10px;
  user-select: none;
}

/* ---- Search ---- */
.search-wrap {
  position: relative;
}

#search-input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}
#search-input::placeholder { color: #444; }
#search-input:focus { border-color: var(--accent); }

#search-results {
  margin-top: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.sr-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 7px;
}
.sr-item:hover { background: rgba(255,255,255,0.07); }

.sr-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #fff;
  opacity: 0.4;
}

/* ---- Layer toggles ---- */
.toggle-row-fun {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 10px;
  color: var(--text-dim);
}
.toggle-row-fun span:first-child { font-size: 12px; letter-spacing: 0.2px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text);
}

.toggle-row input[type="checkbox"] { display: none; }

.slider {
  position: relative;
  display: block;
  width: 38px;
  height: 21px;
  background: rgba(255,255,255,0.1);
  border-radius: 21px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

input[type="checkbox"]:checked ~ .slider             { background: var(--accent); }
input[type="checkbox"]:checked ~ .slider::after      { transform: translateX(17px); }

/* ---- Route filter chips ---- */
#route-filters {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.filter-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.filter-all-btn {
  flex: 1;
  padding: 4px 0;
  font-size: 11px;
  font-family: var(--font);
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.filter-all-btn:hover { background: rgba(255,255,255,0.12); color: var(--text); }

.rf-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: background 0.15s, opacity 0.2s;
  user-select: none;
}
.rf-item:hover { background: rgba(255,255,255,0.05); }
.rf-item.off   { opacity: 0.35; }

.rf-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.rf-name { flex: 1; }

.rf-count {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 16px;
  text-align: right;
}

/* ---- Action buttons ---- */
.action-row {
  display: flex;
  gap: 8px;
}
.action-btn {
  flex: 1;
  padding: 8px 0;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.action-btn:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.15);
}

/* ---- Panel footer ---- */
.panel-footer {
  margin-top: auto;
  padding: 16px 18px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.9;
}
.panel-footer a {
  color: var(--accent);
  text-decoration: none;
}
.panel-footer a:hover { text-decoration: underline; }

kbd {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  font-size: 10px;
  font-family: monospace;
}

/* ---- Train info popup ---- */
#train-info {
  position: absolute;
  bottom: 70px;
  left: 14px;
  z-index: 600;
  min-width: 240px;
  max-width: 300px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
#train-info.hidden { display: none; }

#train-info-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.2s;
}
#train-info-close:hover { color: var(--text); }

.ti-route {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 3px;
}
.ti-dest {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.ti-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.ti-row:last-of-type { border-bottom: none; }
.ti-label { color: var(--text-dim); }
.ti-value { font-weight: 500; }
.ti-late   { color: var(--red); }
.ti-ontime { color: var(--green); }
.ti-eta    { color: var(--text-dim); font-size: 12px; font-weight: 400; margin-left: 4px; }

#train-follow-row { margin-top: 12px; }

/* ---- Panel toggle disruption badge ---- */
#panel-toggle { position: relative; }
#dis-badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  padding: 0 3px;
  pointer-events: none;
}
#dis-badge.hidden { display: none; }

/* ---- Disruptions panel section ---- */
.dis-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.dis-item:last-child { border-bottom: none; }
.dis-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--amber);
  margin-bottom: 3px;
}
.dis-title {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}
.dis-link {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}
.dis-link:hover { text-decoration: underline; }

/* ---- Station popup ---- */
.station-popup .leaflet-popup-content-wrapper {
  background: var(--panel-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0;
}
.station-popup .leaflet-popup-content {
  margin: 12px 14px;
  min-width: 220px;
}
.station-popup .leaflet-popup-tip-container { display: none; }
.station-popup .leaflet-popup-close-button {
  color: var(--text-dim) !important;
  font-size: 16px !important;
  top: 6px !important;
  right: 8px !important;
}
.sp-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  padding-right: 16px;
}
.sp-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.sp-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.sp-deps { display: flex; flex-direction: column; gap: 2px; }
.sp-dep {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.12s;
}
.sp-dep:hover { background: rgba(255,255,255,0.07); }
.sp-dep-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sp-dep-dest {
  flex: 1;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-eta {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.sp-min { font-size: 10px; font-weight: 400; }
.sp-arr { font-size: 12px; font-weight: 700; color: var(--green); flex-shrink: 0; }
.sp-late {
  font-size: 10px;
  color: var(--red);
  flex-shrink: 0;
}
.sp-no-trains {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 0;
}
#follow-btn {
  width: 100%;
  padding: 7px;
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 7px;
  color: var(--accent);
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s;
}
#follow-btn:hover { background: rgba(0, 212, 255, 0.2); }
#follow-btn.active {
  background: rgba(0, 212, 255, 0.25);
  border-color: var(--accent);
}

/* ---- Legend ---- */
#legend {
  position: absolute;
  bottom: 18px;
  right: 14px;
  z-index: 500;
  padding: 12px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 11px;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.legend-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
}

#legend-toggle {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 10px;
  cursor: pointer;
  padding: 0 0 0 8px;
  line-height: 1;
}
#legend-toggle:hover { color: var(--text); }

.legend-section {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 4px;
  margin-top: 2px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  padding: 2px 0;
}

.ldot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- Train marker (DivIcon: rotating wrapper + dot + heading nub) ---- */
.tm-wrap {
  width: 28px;
  height: 28px;
  position: relative;
  transform-origin: 50% 50%;   /* rotate() (set inline from heading) pivots on the dot centre */
}
.tm {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;                          /* centre the dot in the wrapper */
  border-radius: 50%;
  border: 2.5px solid #fff;                       /* opaque white ring - pops on any line colour */
  cursor: pointer;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.85);    /* crisp dark edge, no blur: high-contrast + cheap */
  transition: transform 0.08s;
}
.tm:hover { transform: scale(1.4); }

.tm-nub {                                         /* white arrowhead, points "forward" (up at heading 0) */
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 6px solid #fff;
}
.tm-wrap.no-dir .tm-nub { display: none; }        /* at a terminus: no meaningful heading */

/* Delay state */
.tm.delay-minor { border-color: #FFC400; }                        /* amber = running late */
.tm.delay-major { border-color: #FF4A4A; animation: tm-pulse 1.6s ease-out infinite; }

@keyframes tm-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(255, 74, 74, 0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(255, 74, 74, 0);   }
  100% { box-shadow: 0 0 0 0   rgba(255, 74, 74, 0);   }
}

/* ---- Route line casing + glow ----
   A tight dark casing for legibility + a soft currentColor glow (colour set on the
   path via JS). Kept deliberately restrained so trains read on top of the lines. */
.route-line {
  filter:
    drop-shadow(0 0 0.6px rgba(0,0,0,0.9))
    drop-shadow(0 0 1.5px currentColor);
}
[data-theme="light"] .route-line {
  filter:
    drop-shadow(0 0 0.6px rgba(255,255,255,0.95))
    drop-shadow(0 0 1px currentColor);
}

/* ---- Network fade-in on first load ---- */
.net-fade .leaflet-overlay-pane,
.net-fade .leaflet-marker-pane { animation: netFade 0.9s ease-out both; }
@keyframes netFade { from { opacity: 0; } to { opacity: 1; } }

/* ---- Major interchange labels (revealed at high zoom) ---- */
.stn-label {
  background: none;
  border: none;
  width: auto !important;
  height: auto !important;
  color: var(--text);
  font: 600 11px/1 var(--font);
  letter-spacing: 0.2px;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 3px var(--bg), 0 0 3px var(--bg), 0 0 4px var(--bg), 0 1px 2px rgba(0,0,0,0.85);
}

/* ---- Leaflet overrides ---- */
.leaflet-container       { background: #0a0a0a; font-family: var(--font); }
.leaflet-control-zoom a  { background: var(--panel-bg) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-control-zoom a:hover { background: var(--bg2) !important; }
.leaflet-bar            { border: none !important; box-shadow: none !important; }
.leaflet-control-zoom   { border: 1px solid var(--border) !important; border-radius: 8px !important; overflow: hidden; backdrop-filter: blur(16px); }
.leaflet-control-attribution { background: var(--panel-bg) !important; color: var(--text-dim) !important; font-size: 9px !important; border-top-left-radius: 6px !important; }
.leaflet-control-attribution a { color: #555 !important; }
.leaflet-popup-content-wrapper { background: var(--panel-bg) !important; color: var(--text) !important; border: 1px solid var(--border) !important; border-radius: 8px !important; box-shadow: 0 4px 24px rgba(0,0,0,0.6) !important; }
.leaflet-popup-tip-container .leaflet-popup-tip { background: var(--panel-bg) !important; }

/* ---- Scrollbar ---- */
#panel::-webkit-scrollbar       { width: 4px; }
#panel::-webkit-scrollbar-track { background: transparent; }
#panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ---- Setup overlay ---- */
#setup-overlay {
  position: absolute;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#setup-overlay.hidden { display: none; }

#setup-card {
  max-width: 420px;
  width: calc(100% - 40px);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 30px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.setup-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}

.setup-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 20px;
  line-height: 1.6;
}

.setup-steps {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.setup-steps li {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.setup-steps code {
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: monospace;
}

.setup-note {
  font-size: 11px;
  color: rgba(0, 212, 255, 0.6);
  font-style: italic;
}

/* ---- Cinema mode - map only, all UI hidden ---- */
#cinema-exit {
  display: none;
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.3);
  font-size: 15px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.2s, background 0.2s;
}
#cinema-exit:hover {
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
}

body.cinema #header       { display: none; }
body.cinema #panel        { display: none !important; }
body.cinema #legend       { display: none; }
body.cinema #train-info   { display: none; }
body.cinema #setup-overlay { display: none; }
body.cinema #cinema-exit  { display: flex; }

/* ---- Responsive - Tablet (641px to 1024px) ---- */
@media (min-width: 641px) and (max-width: 1024px) {
  #header  { min-width: unset; left: 10px; right: 10px; top: 10px; }
  #panel   { width: 300px; }
  #legend  { right: 10px; bottom: 10px; font-size: 10px; }
}

/* ---- Responsive - Mobile (up to 640px) ---- */
@media (max-width: 640px) {
  #panel     { width: 100vw; }
  #legend    { display: none; }
  #train-info { left: 10px; right: 10px; max-width: unset; bottom: 16px; }

  /* Header: stretch edge to edge, single compact row */
  #header {
    min-width: unset;
    top: 8px;
    left: 8px;
    right: 8px;
    padding: 9px 12px;
    gap: 8px;
  }

  /* Logo: shrink text, keep "For Alexander", hide subtitle */
  .logo-text       { font-size: 17px; }
  .logo-sub        { display: none; }
  .logo-dedication { font-size: 9.5px; letter-spacing: 0.6px; margin-top: 0; }

  /* Status: hide timestamp, keep train count small */
  #header-divider  { display: none; }
  #last-update     { display: none; }
  #next-update     { display: none; }
  #train-count     { font-size: 11px; }

  /* Setup overlay: full-width card with less padding */
  #setup-card { padding: 22px 20px; }
  .setup-title { font-size: 17px; }

  /* Panel: safe area padding for iOS home indicator */
  #panel { padding-bottom: env(safe-area-inset-bottom, 16px); }
}
