:root {
  --bg: #dfe6e4;
  --panel: rgba(255, 255, 255, 0.86);
  --ink: #1d2a2f;
  --muted: #5d6c72;
  --line: rgba(20, 40, 50, 0.12);
  --accent: #c8553a;
  --shadow: 0 6px 24px rgba(20, 40, 50, 0.18);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1416;
    --panel: rgba(24, 31, 34, 0.86);
    --ink: #e9f0ee;
    --muted: #9aaab0;
    --line: rgba(255, 255, 255, 0.12);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.35 var(--font); overflow: hidden; }
#map { position: fixed; inset: 0; background: var(--bg); outline: none; }
.leaflet-container { background: var(--bg); font: inherit; }
.pixelated .leaflet-tile { image-rendering: pixelated; }
.leaflet-control-attribution { display: none; }

.panel {
  background: var(--panel);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* search */
.search {
  position: fixed; z-index: 1000; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(420px, calc(100vw - 96px)); display: flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 999px;
}
.search svg { color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; height: 44px; border: 0; outline: 0; background: none; color: inherit; font: inherit; font-size: 15px; }
.search input::placeholder { color: var(--muted); }
#results {
  position: absolute; top: 52px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); max-height: 50vh; overflow: auto;
}
#results li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 10px; cursor: pointer; }
#results li[aria-selected="true"], #results li:hover { background: var(--line); }
#results small { color: var(--muted); text-transform: capitalize; }

/* tools */
.tools {
  position: fixed; z-index: 1000; right: max(14px, env(safe-area-inset-right)); top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; padding: 4px; border-radius: 14px;
}
.tools button { width: 38px; height: 38px; border-radius: 10px; font-size: 20px; display: grid; place-items: center; }
.tools button:hover { background: var(--line); }

/* minimap */
.minimap {
  position: fixed; z-index: 1000; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom));
  width: 168px; padding: 0; overflow: hidden; border-radius: 12px; cursor: crosshair; line-height: 0;
}
.minimap img { width: 100%; display: block; }
#mini-view { position: absolute; border: 2px solid var(--accent); border-radius: 3px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7); pointer-events: none; }

/* landmark carousel */
.carousel {
  position: fixed; z-index: 1000; bottom: max(14px, env(safe-area-inset-bottom)); left: 200px; right: 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px; pointer-events: none;
}
.carousel > * { pointer-events: auto; }
.strip { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none; padding: 4px; max-width: 760px; }
.strip::-webkit-scrollbar { display: none; }
.card {
  flex: none; width: 112px; height: 84px; position: relative; border-radius: 12px; overflow: hidden; scroll-snap-align: start;
  border: 2px solid var(--panel); box-shadow: var(--shadow); background: var(--bg) center/cover; transition: transform 0.15s;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); outline: none; border-color: var(--accent); }
.card span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 5px; font-size: 11.5px; font-weight: 650; color: #fff; text-align: left;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nudge { width: 30px; height: 44px; flex: none; font-size: 20px; border-radius: 12px; }

/* map labels */
.label { pointer-events: auto; }
.label b {
  position: absolute; transform: translate(-50%, -130%); white-space: nowrap; font-weight: 650; font-size: 12px;
  padding: 3px 9px; border-radius: 999px; background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(20, 40, 50, 0.22); cursor: pointer;
}
.label b::after { content: ""; position: absolute; left: 50%; top: 100%; width: 2px; height: 9px; margin-left: -1px; background: var(--panel); }
.label.active b { background: var(--accent); color: #fff; }
.label.active b::after { background: var(--accent); }
.labels-off .label { display: none; }

.credit { position: fixed; z-index: 999; right: 12px; bottom: 4px; font-size: 10.5px; color: var(--muted); opacity: 0.9; }
.credit a { color: inherit; }
#toast {
  position: fixed; z-index: 1100; left: 50%; bottom: 120px; transform: translateX(-50%); padding: 9px 16px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow);
}

@media (max-width: 720px) {
  .minimap { display: none; }
  .carousel { left: 8px; right: 8px; bottom: max(20px, env(safe-area-inset-bottom)); }
  .nudge { display: none; }
  .search { width: calc(100vw - 28px); }
  .tools { top: auto; bottom: 130px; transform: none; }
  .credit { left: 12px; right: auto; }
}
@media (prefers-reduced-motion: reduce) { .card { transition: none; } }

/* boat / plane mode buttons */
.modes { position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 104px); display: flex; gap: 8px; }
.modes[hidden] { display: none; }
.modes button { padding: 9px 16px; border-radius: 999px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.modes button.on { background: var(--accent); color: #fff; border-color: transparent; }
.modes kbd { font: inherit; font-size: 11px; font-weight: 600; opacity: 0.7; border: 1px solid currentColor; border-radius: 5px; padding: 0 5px; }
body[data-craft] .carousel, body[data-craft] .search { display: none; }
body[data-craft] .modes { bottom: max(18px, env(safe-area-inset-bottom)); }
@media (max-width: 720px) { .modes { bottom: calc(max(20px, env(safe-area-inset-bottom)) + 104px); } }
body:not(:has(.carousel)) .modes { bottom: max(18px, env(safe-area-inset-bottom)); }

/* the plane's game: score pill and place card */
.fly-hud { position: fixed; z-index: 1000; top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); display: flex; gap: 12px; align-items: center; padding: 9px 16px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.fly-hud[hidden], .fly-card[hidden], .fly-menu[hidden] { display: none; }
.fly-pick { display: flex; align-items: center; gap: 8px; margin: -5px 0 -5px -10px; padding: 3px 12px 3px 6px; border: 1px solid var(--line); border-radius: 999px; }
.fly-pick:hover { border-color: var(--accent); }
.fly-pick img { width: 30px; height: 30px; image-rendering: pixelated; }
.fly-pick i { font-style: normal; color: var(--muted); font-size: 11px; }
.fly-speed { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.fly-speed input { width: 110px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.fly-speed span { min-width: 2.6em; font-variant-numeric: tabular-nums; }
/* what is on: a pin per venue, coloured by its state, and its card */
.tools button.on { color: var(--accent); }
.venue-pin { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #8a9099; color: #fff; font-size: 13px; font-weight: 700; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); cursor: pointer; }
.venue-pin.open { background: #1f9e58; }
.venue-pin.soon { background: #e08a1e; }
.venue-pin.unknown { background: #5b7fb8; }
body[data-craft] .leaflet-venues-pane { display: none; }
.venue-popup .leaflet-popup-content-wrapper { border-radius: 14px; }
.venue-popup .leaflet-popup-content { margin: 12px 14px; }
.venue-card { display: flex; flex-direction: column; gap: 3px; min-width: 180px; font: 13px/1.35 ui-sans-serif, system-ui, sans-serif; }
.venue-card b { font-size: 15px; }
.venue-card span { font-weight: 650; }
.venue-card span.open { color: #1f9e58; } .venue-card span.soon { color: #c8741a; } .venue-card span.unknown { color: #5b7fb8; }
.venue-card small { color: #6b7280; }
.venue-card a { color: #b4532a; font-weight: 600; text-decoration: none; margin-top: 2px; }
/* the ride: pick-your-ride dialog, countdown, sprint bar */
.ride-dialog { position: fixed; z-index: 1100; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(520px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow-y: auto; padding: 18px 20px; }
.ride-dialog[hidden], .ride-count[hidden] { display: none; }
.ride-dialog header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ride-dialog h2 { margin: 0; font-size: 20px; }
.ride-dialog header span, .ride-best { color: var(--muted); font-size: 13px; }
.ride-result { margin: -6px 0 14px; font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ride-modes { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; margin-bottom: 12px; }
.ride-modes button { padding: 6px 16px; border-radius: 999px; font-weight: 600; color: var(--muted); }
.ride-modes button.on { color: inherit; box-shadow: inset 0 0 0 2px var(--accent); }
.ride-dialog .fly-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ride-dialog .fly-grid img { width: 80px; height: 80px; }
.ride-best { margin: 10px 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.ride-dialog footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.ride-dialog footer button { padding: 9px 20px; border-radius: 999px; font-weight: 650; border: 1px solid var(--line); }
.ride-dialog footer button.primary { background: var(--accent); color: #fff; border-color: transparent; }
.ride-count { position: fixed; z-index: 1090; left: 50%; top: 34%; transform: translate(-50%, -50%); font-size: 84px; font-weight: 800; color: #fff; text-shadow: 0 3px 0 #1b1f2a, 0 0 18px rgba(0, 0, 0, 0.45); pointer-events: none; font-variant-numeric: tabular-nums; }
.ride-legs { display: inline-block; width: 64px; height: 8px; border-radius: 4px; border: 1px solid var(--line); overflow: hidden; }
.ride-legs i { display: block; height: 100%; background: var(--accent); }
/* the hangar: every aircraft with its picture, and the keys */
.fly-menu { position: fixed; z-index: 1050; top: calc(max(14px, env(safe-area-inset-top)) + 52px); left: max(14px, env(safe-area-inset-left)); width: min(452px, calc(100vw - 28px)); max-height: calc(100vh - 150px); overflow-y: auto; padding: 14px 16px 16px; }
.fly-menu h3 { margin: 0 0 10px; font-size: 13px; font-weight: 700; }
.fly-menu h3:not(:first-child) { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.fly-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.fly-grid button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 9px; border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.fly-grid button:hover { border-color: var(--muted); }
.fly-grid button.on { border: 2px solid var(--accent); padding: 7px 5px 8px; }
.fly-grid img { width: 72px; height: 72px; image-rendering: pixelated; }
.fly-grid b { font-size: 13px; font-weight: 650; line-height: 1.2; text-wrap: balance; }
.fly-grid small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.fly-menu dl, .ride-dialog dl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 0; }
.fly-menu dl div, .ride-dialog dl div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fly-menu dt, .ride-dialog dt { flex: none; min-width: 46px; text-align: center; font-size: 11px; font-weight: 650; border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font-variant-numeric: tabular-nums; }
.fly-menu dd, .ride-dialog dd { margin: 0; color: var(--muted); font-size: 13px; }
.fly-hud b { font-weight: 700; }
.fly-hud span { color: var(--muted); }
.fly-card { position: fixed; z-index: 1100; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 32px)); display: flex; gap: 16px; padding: 16px; align-items: center; }
.fly-card img { width: 132px; height: 132px; border-radius: 12px; image-rendering: pixelated; flex: none; object-fit: cover; }
.fly-card small { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }
.fly-card h2 { margin: 4px 0 6px; font-size: 20px; line-height: 1.15; text-wrap: balance; }
.fly-card p { margin: 0 0 12px; color: var(--muted); }
.fly-card span { font-size: 12px; font-weight: 650; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; }

/* winter */
body.winter { --bg: #e9eef3; }
body.winter #season { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { body.winter { --bg: #141a20; } }

/* night: the page goes dark whatever the system theme, and what moves over the map is dimmed to match it */
body.night { --bg: #0b1020; --panel: rgba(20, 26, 40, 0.86); --ink: #e9eef6; --muted: #98a4b8; --line: rgba(255, 255, 255, 0.14); --shadow: 0 6px 24px rgba(0, 0, 0, 0.55); }
body.night #daynight { background: var(--accent); color: #fff; }
body.night .leaflet-traffic-pane, body.night .leaflet-ships-air-pane, body.night .leaflet-sail-air-pane, body.night .leaflet-fly-air-pane { filter: brightness(0.62) saturate(0.85); }
body.night .leaflet-ships-shadow-pane, body.night .leaflet-sail-shadow-pane, body.night .leaflet-fly-shadow-pane { opacity: 0.45; }

/* real-time transport */
#live { position: fixed; z-index: 999; left: 12px; top: 12px; display: flex; align-items: center; gap: 7px; padding: 5px 11px; font-size: 12px; font-variant-numeric: tabular-nums; }
#live[hidden] { display: none; }
#live i { width: 8px; height: 8px; border-radius: 50%; background: #e2001a; animation: live-pulse 1.6s infinite; }
@keyframes live-pulse { 50% { opacity: 0.25; } }
@media (max-width: 640px) { #live { top: 64px; } }
