:root {
  --panel-w: 318px;
  --date-line: #ff8a93;
  --soft-ink: #afc3d9;
}
[hidden] { display: none !important; }
#stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background:
    radial-gradient(ellipse at 50% 48%, #102034 0%, #080e19 48%, transparent 76%),
    #05070d;
}
.stage-top, .stage-bottom {
  position: relative;
  z-index: 2;
}
.stage-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 17px 20px 0;
}
.stage-heading h2 {
  margin: 0;
  color: var(--accent);
  font-size: 18px;
}
.stage-heading p {
  margin: 2px 0 0;
  color: var(--soft-ink);
  font-size: 12px;
}
.seg button, button.small, #panelToggle {
  min-height: 34px;
  color: var(--accent);
  white-space: nowrap;
}
.seg button { padding: 4px 12px; }
.seg button:hover, #panelToggle:hover { border-color: var(--accent); }
.seg button.on { color: #111; }
#globe {
  position: relative;
  min-height: 0;
  isolation: isolate;
}
#globe canvas {
  position: absolute;
  inset: 0;
  cursor: grab;
  touch-action: none;
}
#globe canvas.can-select { cursor: crosshair; }
#globe canvas:active { cursor: grabbing; }
#globe.fallback {
  background: radial-gradient(circle closest-side, #132f45, #090d18 98%, transparent);
}
.map-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: max-content;
  padding: 2px 7px;
  border: 1px solid #526d87;
  border-radius: 6px;
  color: #e1edf9;
  background: #0b1627ee;
  font-size: 12px;
  pointer-events: none;
}
.map-marker.place {
  transform: translate(-50%, calc(-100% - 8px));
  border-color: #af8e47;
  color: #ffe2a0;
}
.map-marker.place::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  box-shadow: 0 0 0 2px #111b23;
}
.map-marker.line { color: #ffd4d8; border-color: #bf6877; }
#plane {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  transform: translate(-50%, -50%);
  color: #fff4cf;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
}
#plane:hover, #plane:focus-visible, #plane.dragging {
  border-color: #ffc94ab3;
  background: #12182475;
}
#plane.dragging { cursor: grabbing; }
#plane svg { width: 34px; fill: currentColor; filter: drop-shadow(0 1px 3px #04111f); }
#plane.westbound svg { transform: rotate(180deg); }
.stage-tools {
  position: absolute;
  right: 18px;
  top: 64px;
  z-index: 3;
  display: flex;
  gap: 7px;
}
.stage-bottom {
  width: min(100% - 36px, 620px);
  margin: auto auto 10px;
}
.clocks {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
  align-items: center;
  margin: 0 0 9px;
}
.clock {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: baseline;
  min-width: 0;
  padding: 7px 12px;
  border: 1px solid #31455d;
  border-radius: 10px;
  background: #0c1524ec;
}
.clock > div { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0 8px; }
.clock-name { font-weight: 650; color: #dce9f6; font-size: 13px; }
.clock-zone { color: #a4bcda; font: 11px/1.75 var(--mono); }
.clock-hour { color: #f3f7fd; font: 600 23px/1.12 var(--mono); letter-spacing: -.04em; }
.clock-day { color: #cbdef1; font-size: 12px; white-space: nowrap; }
#clockB { border-color: #77663b; }
#clockB .clock-hour { color: #ffe2a0; }
#clockBridge { text-align: center; color: var(--soft-ink); font-size: 12px; white-space: nowrap; }
[data-scene="crossing"] #clockB { border-color: #31455d; }
[data-scene="crossing"] #clockB .clock-hour { color: #f3f7fd; }
[data-scene="crossing"] .active-side:is(#clockA, #clockB) { border-color: #e4b74e; }
[data-scene="crossing"] .active-side .clock-day { color: var(--accent); }
#routeControls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1px 14px;
  padding: 0 0 7px;
}
.route-info {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  color: var(--soft-ink);
  font-size: 12px;
}
.route-info strong { color: var(--accent); font-weight: 650; }
.route-range {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  color: var(--soft-ink);
  font-size: 11px;
  position: relative;
}
.route-range::before {
  content: '';
  position: absolute;
  width: 2px;
  height: 8px;
  left: calc(50% - 1px);
  bottom: 0;
  background: var(--date-line);
  pointer-events: none;
}
.route-actions { display: flex; gap: 7px; align-items: center; }
.time-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 4px 8px;
  background: #0d1523;
  border: 1px solid #27384d;
  border-radius: 10px;
}
.time-control label { color: #dceaff; font-size: 12px; white-space: nowrap; }
.time-control output { margin-left: 4px; color: #c4d7ee; }
input[type=range] { margin: 0; min-width: 0; height: 35px; touch-action: pan-y; }
.learn-fab {
  position: relative;
  justify-self: center;
  left: auto;
  bottom: auto;
  transform: none;
  margin-bottom: 8px;
}
#panel h1 { color: #f0f4f9; }
#panel h2 { font-size: 14px; }
#panel p { margin: 0 0 8px; }
#panel p.note { margin: 8px 0 0; }
#panel .switch { margin-top: 11px; }
#panel label[for="places"] { display: block; margin-bottom: 5px; }
.place-data {
  margin-top: 10px;
  padding: 9px 10px;
  background: #172335;
  border: 1px solid #303f56;
  border-radius: 9px;
}
#placeCoord { color: var(--accent); font-weight: 640; }
.place-data dd { font-variant-numeric: tabular-nums; }
.cross-rules { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; font-size: 12px; }
.cross-rules b { color: var(--accent); }
.panel-buttons { display: flex; flex-wrap: wrap; gap: 6px; }

@media (max-width: 760px) {
  .stage-top { padding: 8px 12px 0; flex-wrap: wrap; gap: 4px 8px; }
  .stage-heading { width: 100%; }
  .stage-heading h2 { font-size: 16px; }
  .stage-heading p { font-size: 11px; }
  .stage-tools { top: 52px; right: 11px; gap: 5px; }
  #panelToggle { position: static; padding: 4px 7px; border-radius: 8px; font-size: 11px; }
  #panel.collapsed { visibility: hidden; }
  .stage-tools button.small { padding: 4px 7px; font-size: 11px; }
  .seg button { padding: 4px 7px; font-size: 11px; }
  .seg button, button.small, #panelToggle { min-height: 40px; }
  .stage-bottom { width: calc(100% - 22px); margin-bottom: 7px; }
  .clocks { grid-template-columns: minmax(0, 1fr) 59px minmax(0, 1fr); margin-bottom: 6px; }
  .clock { gap: 2px 5px; padding: 6px 7px; }
  .clock > div { column-gap: 5px; }
  .clock-name, #clockBridge, .clock-day { font-size: 11px; }
  .clock-zone { font-size: 10px; }
  .clock-hour { font-size: 18px; }
  .time-control { gap: 7px; padding: 0 5px; }
  .time-control label, .time-control output { font-size: 11px; }
  .time-control output { margin-left: 2px; }
  .time-control button.small { min-width: 49px; padding-inline: 5px; }
  .time-control button.small, .route-actions button { min-height: 40px; }
  #routeControls { column-gap: 7px; }
  .route-actions { gap: 4px; }
  .route-actions button.small { padding-inline: 6px; }
  .map-marker { font-size: 11px; }
  input[type=range] { height: 40px; }
}
@media (max-width: 360px) {
  .stage-top { padding-inline: 9px; }
  .stage-tools { right: 8px; }
  .clocks { grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  #panel { transition: none; }
}
