/* ============================================================
   ClivTrans — sim-game HUD theme
   Dark glassmorphism · cyan/teal accent · amber money/warnings
   Vanilla CSS, system fonts only (offline-safe).
   ============================================================ */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #0a0f18;
  --bg-deep: #070b12;
  --glass: rgba(17, 24, 38, 0.78);
  --glass-strong: rgba(13, 19, 31, 0.9);
  --glass-soft: rgba(148, 163, 184, 0.07);
  --well: rgba(7, 11, 18, 0.55);

  /* Lines */
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.26);

  /* Text */
  --text: #e7edf7;
  --muted: #a3b2ca;
  --faint: #6b7a94;

  /* Accents */
  --accent: #22d3ee;            /* primary cyan */
  --accent-2: #67e8f9;          /* light cyan (main.js inline styles use this) */
  --accent-deep: #0e93b4;
  --accent-soft: rgba(34, 211, 238, 0.12);
  --accent-line: rgba(34, 211, 238, 0.45);
  --warn: #fbbf24;              /* amber — money & warnings */
  --warn-soft: rgba(251, 191, 36, 0.12);
  --good: #34d399;
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.12);

  /* Effects */
  --blur: blur(16px) saturate(1.35);
  --shadow: 0 10px 30px rgba(2, 6, 14, 0.5), 0 2px 8px rgba(2, 6, 14, 0.35);
  --inner-hl: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --ring: 0 0 0 2px rgba(34, 211, 238, 0.55);
  --ease: 0.15s ease;

  /* Metrics */
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;
  --ibar-h: 52px;

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1100px 560px at 18% -12%, #131f36, transparent 62%),
    radial-gradient(900px 480px at 105% 115%, #0c1a26, transparent 60%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* —— Scrollbars (thin, subtle) —— */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.24);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* —— kbd chips —— */
kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: rgba(148, 163, 184, 0.1);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  vertical-align: baseline;
}

/* ============================================================
   Forms & buttons
   ============================================================ */

label {
  display: grid;
  gap: 6px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

input,
select {
  background: var(--well);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  min-height: 40px;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

input::placeholder {
  color: var(--faint);
}

input:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus-visible,
select:focus-visible,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: var(--ring);
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

button {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.1), rgba(148, 163, 184, 0.04));
  color: var(--text);
  border-radius: var(--r-sm);
  min-height: 34px;
  padding: 7px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  line-height: 1.3;
  box-shadow: var(--inner-hl);
  transition: border-color var(--ease), background var(--ease), color var(--ease),
    box-shadow var(--ease), transform var(--ease), opacity var(--ease), filter var(--ease);
}

button:hover {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.14), rgba(148, 163, 184, 0.06));
}

button:active {
  transform: translateY(1px);
  filter: brightness(0.94);
}

button:focus-visible {
  outline: none;
  box-shadow: var(--ring), var(--inner-hl);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(180deg, #38d9f2, var(--accent-deep));
  border-color: rgba(103, 232, 249, 0.55);
  color: #05222d;
  font-weight: 700;
  width: 100%;
  padding: 10px 14px;
  text-shadow: none;
}

button.primary:hover {
  filter: brightness(1.08);
  border-color: rgba(165, 243, 252, 0.75);
}

button.ghost {
  background: transparent;
  box-shadow: none;
}

button.ghost:hover {
  background: var(--glass-soft);
}

button.full {
  width: 100%;
  margin-top: 6px;
}

button.danger,
.ibar-btn.danger {
  color: #fecaca;
}

.ibar-btn.danger:hover {
  border-color: rgba(248, 113, 113, 0.45);
  background: var(--bad-soft);
}

button.active,
.ibar-btn.active,
.station-type.active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-2);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.35), var(--inner-hl);
}

.danger-text {
  color: #fca5a5 !important;
}

/* ============================================================
   Boot screen
   ============================================================ */

/* Full-screen living map behind the boot card (real renderer, no input) */
#bootHero {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.7s ease;
  background: #050d18;
}

#bootHero.is-on {
  opacity: 1;
}

#boot {
  position: relative;
  z-index: 2;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Fall back to top-align so a tall card is fully scrollable; `safe center`
     keeps it vertically centred only when it fits the viewport. */
  justify-content: flex-start;
  justify-content: safe center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background: transparent;
}

/* Readability vignette over the living map (not selectable) */
#boot::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(5, 10, 18, 0.15) 0%, rgba(5, 10, 18, 0.55) 70%, rgba(5, 10, 18, 0.78) 100%),
    linear-gradient(
      180deg,
      rgba(10, 15, 24, 0.25) 0%,
      rgba(10, 15, 24, 0.35) 40%,
      rgba(10, 15, 24, 0.65) 78%,
      rgba(10, 15, 24, 0.88) 100%
    );
}

/* Fallback still hero if canvas fails to load (no .is-on on #bootHero) */
body:not(:has(#bootHero.is-on)) #boot::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: min(88vh, 920px);
  pointer-events: none;
  z-index: 0;
  background: url('/assets/hero.png') center top / cover no-repeat;
}

.boot-card {
  position: relative;
  z-index: 2;
  width: min(440px, 100%);
  flex-shrink: 0;
  background: rgba(12, 18, 30, 0.78);
  backdrop-filter: blur(16px) saturate(1.15);
  -webkit-backdrop-filter: blur(16px) saturate(1.15);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow), var(--inner-hl), 0 12px 48px rgba(0, 0, 0, 0.45);
}

.boot-card-wide {
  width: min(780px, 100%);
}

.boot-card-glow {
  border-color: rgba(34, 211, 238, 0.22);
  box-shadow:
    var(--shadow),
    var(--inner-hl),
    0 0 0 1px rgba(34, 211, 238, 0.06),
    0 0 48px rgba(34, 211, 238, 0.08);
}

.boot-brand {
  margin-bottom: 4px;
}

/* —— Auth tabs & forms —— */
.auth-tabs {
  display: flex;
  gap: 4px;
  margin: 16px 0 14px;
  padding: 4px;
  background: var(--well);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  min-height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.auth-tab:hover {
  color: var(--text);
}

.auth-tab.active {
  background: rgba(34, 211, 238, 0.14);
  color: #7dd3fc;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.25);
}

.auth-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.auth-label input,
.auth-label select {
  font-size: 0.95rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}

.auth-pass-wrap {
  position: relative;
  display: block;
}

.auth-pass-wrap input {
  width: 100%;
  padding-right: 42px;
}

.auth-show-pass {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 28px;
  min-width: 32px;
  padding: 0 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  opacity: 0.7;
  font-size: 0.9rem;
}

.auth-show-pass:hover {
  opacity: 1;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
  min-height: 42px;
  font-size: 0.95rem;
}

.auth-hint {
  margin: 10px 0 0;
  text-align: center;
}

.auth-status {
  margin: 12px 0 0;
  min-height: 1.2em;
  font-size: 0.84rem;
  color: #fbbf24;
}

.auth-status.is-error {
  color: #f87171;
}

.auth-status.is-ok {
  color: #4ade80;
}

.auth-inline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.auth-inline-row input {
  flex: 1;
  min-width: 120px;
}

/* —— Mode hub —— */
.hub-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin: 8px 0 16px;
}

.hub-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.hub-title {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 720px) {
  .mode-grid {
    grid-template-columns: 1fr;
  }
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-align: left;
  padding: 16px 14px;
  min-height: 148px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(165deg, rgba(30, 41, 59, 0.75), rgba(15, 23, 42, 0.9));
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

.mode-card:hover {
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.12);
  transform: translateY(-1px);
}

.mode-card:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.mode-card-soon {
  opacity: 0.88;
}

.mode-card-soon:hover {
  border-color: rgba(251, 191, 36, 0.4);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.08);
}

.mode-ico {
  font-size: 1.5rem;
  line-height: 1;
}

.mode-name {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.mode-desc {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--muted);
  font-weight: 500;
}

.mode-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.mode-badge-inline {
  display: inline-block;
  margin: 8px 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.hub-account {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.hub-account.collapsed .hub-account-body {
  display: none;
}

.boot-section-title {
  margin: 14px 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

.phase-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.single-actions {
  margin: 12px 0 8px;
}

.single-continue {
  width: 100%;
  min-height: 44px;
  font-size: 0.95rem;
}

.single-continue:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.single-new-block {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.advanced-details {
  margin: 10px 0 12px;
  font-size: 0.82rem;
  color: var(--muted);
}

.advanced-details summary {
  cursor: pointer;
  color: #a3b2ca;
  font-weight: 600;
  user-select: none;
}

.advanced-body {
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--r-md);
  background: var(--well);
  border: 1px solid var(--border);
}

.advanced-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 520px) {
  .advanced-row {
    grid-template-columns: 1fr;
  }
}

/* Short viewports (phones in landscape, small laptops): never clip the card top */
@media (max-height: 720px) {
  #boot {
    justify-content: flex-start;
  }
}

.multi-create-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.multi-create-row input {
  flex: 1;
}

.online-soon-card {
  text-align: center;
  padding: 12px 8px 8px;
}

.online-soon-card .blurb {
  max-width: 36em;
  margin: 10px auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.boot-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  margin-top: 8px;
}

@media (max-width: 700px) {
  .boot-grid {
    grid-template-columns: 1fr;
  }
}

.boot-col h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

.boot-hint {
  margin: 0 0 12px;
  font-size: 0.76rem;
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, #7dd3fc, #22d3ee, #2dd4bf);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 4px 0 12px;
  color: var(--accent-2);
  font-weight: 600;
  font-size: 0.9rem;
}

.blurb {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.money-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
}

.money-prefix {
  color: var(--warn);
  font-weight: 700;
  padding-left: 4px;
}

.money-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 10px;
}

.money-presets .chip,
.boot-card .chip {
  min-height: 28px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--well);
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.money-presets .chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.money-presets .chip.active {
  background: var(--warn-soft);
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.5);
}

.boot-saves {
  background: var(--well);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
}

.save-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  max-height: min(240px, 32vh);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.save-list li {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  background: var(--glass-soft);
  transition: border-color var(--ease), background var(--ease);
}

.save-list li.world-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.save-list li.world-row .world-row-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.save-list li.world-row .world-row-main strong {
  font-size: 0.92rem;
}

.save-list li.world-row .save-btns {
  flex-shrink: 0;
}

.save-list li:hover {
  border-color: var(--border-strong);
  background: rgba(148, 163, 184, 0.1);
}

.save-list .save-title {
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text);
}

.save-list .save-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.save-list .save-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.save-list .save-btns button {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 0.75rem;
}

.boot-save-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.boot-save-actions .ghost {
  border-color: var(--border);
}

.resume-block {
  margin: 10px 0 14px;
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid rgba(34, 211, 238, 0.28);
  background: rgba(34, 211, 238, 0.06);
}

.resume-block h3 {
  margin-top: 0;
}

.resume-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.resume-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--glass-soft);
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color var(--ease), background var(--ease);
}

.resume-list li:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.resume-list .meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.status {
  color: var(--muted);
  font-size: 0.82rem;
  min-height: 1.2em;
}

/* ============================================================
   App shell
   ============================================================ */

#app {
  height: 100%;
  display: grid;
  grid-template-rows: var(--ibar-h) 1fr auto;
}

/* —— Icon top bar —— */
#iconbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  height: var(--ibar-h);
  background: linear-gradient(180deg, rgba(17, 24, 38, 0.92), rgba(10, 15, 24, 0.88));
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  z-index: 40;
  position: relative;
}

.ibar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

.logo-sm {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 0.95rem;
  background: linear-gradient(90deg, #7dd3fc, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: var(--accent-2);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge:empty {
  display: none;
}

/* Segmented button groups */
.ibar-tools,
.ibar-toggles {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding: 3px;
  background: var(--well);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.ibar-sep {
  width: 1px;
  height: 22px;
  background: var(--border-strong);
  margin: 0 4px;
}

.ibar-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  position: relative;
}

.ibar-btn:hover {
  background: var(--glass-soft);
  border-color: var(--border);
}

.ibar-btn:active {
  transform: none;
  filter: brightness(0.9);
}

.ibar-btn .ibar-mini {
  position: absolute;
  bottom: 1px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
}

.ibar-btn.active .ibar-mini,
.ibar-btn[aria-pressed="true"] .ibar-mini {
  color: var(--accent-2);
}

.ibar-btn[aria-pressed="true"],
.ibar-btn.panel-open {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.ibar-ico {
  font-size: 1.1rem;
  line-height: 1;
}

/* CSS tooltips from data-tip */
.stat[data-tip]::after,
.ibar-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%) translateY(-2px);
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ease), transform var(--ease);
  z-index: 60;
  box-shadow: var(--shadow);
}

.stat[data-tip]:hover::after,
.ibar-btn[data-tip]:hover::after,
.ibar-btn[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.ibar-toggles .ibar-btn[data-tip]::after {
  left: auto;
  right: 0;
  transform: translateY(-2px);
}

.ibar-toggles .ibar-btn[data-tip]:hover::after,
.ibar-toggles .ibar-btn[data-tip]:focus-visible::after {
  transform: translateY(0);
}

/* —— Demand chip: passenger-demand pill docked beside the canvas clock —— */
.demand-chip {
  position: absolute;
  top: 10px;
  left: 50%;
  height: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-radius: 12px;
  background: rgba(10, 16, 28, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #e7edf7;
  font: 600 11px system-ui, sans-serif;
  white-space: nowrap;
  z-index: 24;
  cursor: default;
  user-select: none;
}

.demand-chip .demand-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}

.demand-chip .demand-bars i {
  display: block;
  width: 4px;
  border-radius: 1px;
  background: rgba(148, 163, 184, 0.28);
}

.demand-chip .demand-bars i:nth-child(1) { height: 5px; }
.demand-chip .demand-bars i:nth-child(2) { height: 8px; }
.demand-chip .demand-bars i:nth-child(3) { height: 12px; }

.demand-chip .demand-bars i.lit { background: var(--demand-col, #7dd3fc); }

.demand-chip[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%) translateY(-2px);
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  white-space: normal;
  width: 280px;
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ease), transform var(--ease);
  z-index: 60;
  box-shadow: var(--shadow);
}

.demand-chip[data-tip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* invisible hover target over the canvas clock chip — carries the calendar
   data-tip (the chip itself is drawn on canvas and can't host a tooltip) */
.clock-tip {
  transform: translateX(-50%);
  background: transparent;
  border-color: transparent;
  z-index: 23;
}

/* —— ⚙️ menu option groups: display (local) + world settings (host) —— */
.settings-group {
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  margin-top: 4px;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7f8fa8;
  padding: 0 8px 4px;
  margin: 0;
}

.settings-group-title span {
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
}

.settings-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 7px 8px;
  min-height: 32px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
}

.settings-opt:hover {
  background: var(--glass-soft);
}

.settings-opt > span {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  line-height: 1.3;
}

.settings-opt input[type='checkbox'] {
  accent-color: #38bdf8;
  order: 2;
  width: 15px;
  height: 15px;
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

.settings-opt select {
  order: 2;
  flex-shrink: 0;
  width: auto;
  min-width: 118px;
  min-height: 0;
  margin: 0;
  padding: 3px 8px;
  background: rgba(10, 16, 28, 0.8);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
}

.settings-opt kbd {
  font-size: 10px;
  color: var(--faint);
}

.settings-group.readonly .settings-opt {
  opacity: 0.55;
  pointer-events: none;
}

/* —— ⚙️ Settings dropdown (pause / save / minimap / sound / help / quit) —— */
#settingsWrap {
  margin-left: auto;
  position: relative;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  max-height: min(80vh, calc(100dvh - var(--ibar-h) - 20px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 80;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-size: 12.5px;
  text-align: left;
}

.settings-item:hover {
  background: var(--glass-soft);
  border-color: var(--border);
}

.settings-item .ibar-ico {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.settings-item .settings-label {
  flex: 1;
}

.settings-item kbd {
  font-size: 10px;
  color: var(--faint);
}

.settings-item[aria-pressed="true"] {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.settings-item.danger-text {
  margin-top: 4px;
}

/* —— Stats strip —— */
.ibar-stats {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
  /* when stats overflow, plain `center` clips the left edge beyond scroll
     reach — `safe center` falls back to start-aligned only on overflow
     (browsers without `safe` support keep the plain center above) */
  justify-content: safe center;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.ibar-stats::-webkit-scrollbar {
  display: none;
}

.ibar-stats .stat {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  transition: border-color var(--ease), background var(--ease);
}

.ibar-stats .stat:hover {
  border-color: var(--border);
  background: var(--glass-soft);
}

.ibar-stats .stat span {
  opacity: 0.8;
  font-size: 12px;
}

.ibar-stats .stat strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

#moneyStat {
  color: var(--warn);
}

#transferRevStat {
  color: #fde68a;
}

.ibar-stats .stat.muted {
  opacity: 0.6;
}

/* ============================================================
   Main viewport — canvas fills its parent, do not pad
   ============================================================ */

#main {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
}

#viewport-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--bg-deep);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

#hoverInfo {
  position: absolute;
  left: 12px;
  top: 12px;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  pointer-events: none;
  max-width: 280px;
  z-index: 3;
  box-shadow: var(--shadow);
}

#hoverInfo:empty {
  display: none;
}

/* —— Performance HUD (toggle ` / F3) —— */
#perfHud {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 5;
  min-width: 248px;
  max-width: 320px;
  padding: 8px 10px 7px;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow), var(--inner-hl);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
  user-select: text;
  pointer-events: auto;
}

#perfHud header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  margin-bottom: 6px;
}

#perfHud header .hint {
  font-weight: 500;
  letter-spacing: 0;
  color: var(--faint);
  font-size: 10px;
}

#perfHud .grid {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 1px 8px;
}

#perfHud .grid span {
  color: var(--faint);
}

#perfHud .grid strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

#perfHud .ok { color: var(--good); }
#perfHud .warn { color: var(--warn); }
#perfHud .bad { color: var(--bad); }
#perfHud .dim { color: var(--faint); font-weight: 500; }

#perfHud footer {
  margin-top: 6px;
  color: var(--faint);
  font-size: 10px;
  line-height: 1.3;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(4px);
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--accent-line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity var(--ease), transform var(--ease);
  pointer-events: none;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 6;
  box-shadow: var(--shadow), 0 0 18px rgba(34, 211, 238, 0.12);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* —— Minimap —— */
#minimapWrap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 168px;
  height: 168px;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-strong);
  background: var(--bg-deep);
  cursor: crosshair;
  z-index: 5;
  transition: opacity 0.2s ease, transform 0.2s ease, border-color var(--ease);
}

#minimapWrap:hover {
  border-color: var(--accent-line);
}

#minimapWrap.hidden-map {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.96);
}

#minimap {
  display: block;
  width: 168px;
  height: 168px;
}

.minimap-label {
  position: absolute;
  left: 8px;
  top: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(203, 213, 225, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  font-weight: 700;
}

/* ============================================================
   Flyout panels
   ============================================================ */

#flyouts {
  position: absolute;
  left: 12px;
  top: 12px;
  bottom: 20px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.flyout {
  pointer-events: auto;
  width: min(320px, calc(100vw - 24px));
  max-height: 100%;
  overflow: auto;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), var(--inner-hl);
  padding: 14px;
  animation: flyIn 0.15s ease;
}

.flyout-wide {
  width: min(420px, calc(100vw - 24px));
}

@keyframes flyIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.flyout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -14px -14px 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, 0.35);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  position: sticky;
  top: -14px;
  z-index: 2;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.flyout-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent-2);
}

.flyout-close {
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 7px;
  border-color: transparent;
  font-size: 1.05rem;
  line-height: 1;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.flyout-close:hover {
  color: var(--text);
  background: var(--glass-soft);
  border-color: var(--border);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 8px;
}

.hint strong {
  color: var(--text);
  font-weight: 600;
}

/* —— Track piece grid —— */
.piece-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.piece-btn {
  aspect-ratio: 1;
  min-height: 36px;
  padding: 4px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: var(--r-sm);
  background: var(--well);
  box-shadow: none;
}

.piece-btn small {
  display: block;
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 600;
}

.piece-btn:hover {
  background: var(--glass-soft);
}

.piece-btn.active {
  border-color: var(--accent-line);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.35);
  background: var(--accent-soft);
}

.piece-btn.active small {
  color: var(--accent-2);
}

/* —— Stations & depots —— */
.station-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.station-type {
  text-align: center;
  padding: 9px 6px;
  font-size: 0.82rem;
  line-height: 1.35;
  background: var(--well);
  box-shadow: none;
}

.station-type small {
  color: var(--warn);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.depot-select-label {
  margin: 0 0 10px;
  font-size: 12px;
}

.depot-select-label select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  min-height: 36px;
  font-size: 0.85rem;
}

/* —— Buy vehicles —— */
.buy-grid {
  display: grid;
  gap: 6px;
}

.buy {
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
  font-weight: 600;
  font-size: 0.86rem;
}

.buy small {
  color: var(--warn);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--warn-soft);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
}

/* —— Quick fleet —— */
.fleet-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  max-height: 220px;
  overflow: auto;
}

.fleet-list li {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.84rem;
  transition: background var(--ease), border-color var(--ease);
}

.fleet-list li:hover {
  background: var(--glass-soft);
}

.fleet-list li.selected {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.fleet-list .meta {
  color: var(--muted);
  font-size: 0.72rem;
}

/* —— World panel —— */
.world-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.town-directory {
  gap: 8px;
  max-height: min(46vh, 420px);
  margin: 4px 0 12px;
}

.town-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.town-head {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 4px;
  align-items: stretch;
}

.town-twist {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  line-height: 1;
  border-radius: 4px;
}

.town-twist:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.town-twist-spacer {
  visibility: hidden;
  pointer-events: none;
}

.town-subs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 24px;
}

.town-subs.hidden {
  display: none;
}

.fleet-item.stats-item {
  grid-template-rows: auto auto auto;
  min-height: 66px;
  align-items: start;
  padding-top: 7px;
  padding-bottom: 7px;
}

.fleet-item.stats-item .fleet-item-ico {
  grid-row: 1 / span 3;
  align-self: center;
}

.fleet-item-meta2 {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
  opacity: 0.92;
}

.suburb-item {
  min-height: 58px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.suburb-item .fleet-item-ico {
  width: 34px;
  height: 34px;
  font-size: 1.05rem;
}

.flyout h4 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

#leaderboard,
#eventList {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  max-height: 140px;
  overflow: auto;
  font-size: 12.5px;
}

#leaderboard li,
#eventList li {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  transition: background var(--ease);
}

.events li {
  color: var(--muted);
}

.transfer-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.transfer-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.transfer-stats > div {
  background: var(--well);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px;
  text-align: center;
}

.transfer-stats span {
  display: block;
  font-size: 10px;
  color: var(--faint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.transfer-stats strong {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Selection inspector
   ============================================================ */

.inspector {
  position: absolute;
  right: 12px;
  top: 12px;
  width: min(300px, calc(100vw - 24px));
  max-height: calc(100% - 32px);
  overflow: auto;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), var(--inner-hl);
  z-index: 18;
  padding: 14px;
  animation: flyIn 0.15s ease;
}

.inspector-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.inspector-kind {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-2);
}

.inspector-head h3 {
  margin: 3px 0 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.inspector-body {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.45;
}

.inspector-body .insp-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.inspector-body .insp-row strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.inspector-body .insp-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 140px;
  overflow: auto;
}

.inspector-body .insp-list li {
  padding: 6px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  margin-bottom: 4px;
  background: var(--well);
  border: 1px solid transparent;
  font-size: 12.5px;
  color: var(--text);
  transition: border-color var(--ease), background var(--ease);
}

.inspector-body .insp-list li:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.inspector-body .insp-list .meta {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.inspector-body .xfer-list {
  max-height: 220px;
}
.inspector-body .xfer-list li {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inspector-body .xfer-row-main {
  flex: 1;
  min-width: 0;
}
.inspector-body .xfer-walk-btn {
  flex-shrink: 0;
  padding: 2px 8px;
  font-size: 10.5px;
}
.inspector-body .xfer-list li.xfer-off {
  opacity: 0.72;
}

.inspector.inspector-wide {
  width: min(340px, calc(100vw - 24px));
}

.queue-advice {
  margin: 8px 0 6px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.4;
}

.queue-group {
  margin: 6px 0 2px;
  padding-top: 4px;
}

.queue-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  padding: 3px 0;
  cursor: default;
}

.queue-head[data-queuevid],
.queue-head[data-queuesid] {
  cursor: pointer;
}

.queue-head[data-queuevid]:hover,
.queue-head[data-queuesid]:hover {
  color: var(--accent-2);
}

.queue-sub {
  font-weight: 500;
  font-size: 11px;
  color: var(--muted);
}

.queue-dest {
  padding-left: 12px !important;
  cursor: pointer;
}

.queue-group.queue-bad .queue-head {
  color: #f87171;
}

.queue-group.queue-warn .queue-head {
  color: #fbbf24;
}

.fleet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.fleet-tabs .ops-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
}

.fleet-tab-n {
  display: inline-block;
  min-width: 1.25em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.fleet-sort-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.fleet-sort-label select {
  flex: 1;
  min-width: 0;
}

.fleet-btn-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: min(52vh, 440px);
  overflow: auto;
  margin-top: 6px;
}

.fleet-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 1px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  box-sizing: border-box;
  text-align: left;
  padding: 6px 10px 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--well);
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.fleet-item:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.fleet-item.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.fleet-item-ico {
  grid-row: 1 / span 2;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.fleet-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.fleet-item-title {
  font-weight: 650;
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.fleet-item-kind {
  flex-shrink: 0;
  font-size: 0.64rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.fleet-item-meta {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.station-group-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 2px 4px;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.station-group-h:first-child {
  margin-top: 2px;
}
.station-group-h span {
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

#stationList {
  max-height: min(64vh, 560px);
}

.inspector-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.inspector-actions button {
  width: 100%;
  text-align: left;
}

.inspector-actions .insp-rename-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.inspector-actions .insp-rename-row input {
  padding: 7px 10px;
  min-height: 34px;
  font-size: 0.84rem;
}

/* ============================================================
   Status bar
   ============================================================ */

#statusBar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  padding: 5px 14px;
  border-top: 1px solid var(--border);
  background: rgba(13, 19, 31, 0.92);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#connStatus {
  color: var(--good);
  font-weight: 600;
}

/* Stats strip lives in the footer now — right-aligned, slimmer pills */
#statusBar .ibar-stats {
  flex: 0 1 auto;
  margin-left: auto;
  justify-content: flex-end;
}

#statusBar .stat {
  padding: 2px 8px;
}

/* footer tooltips open UPWARD so they never fall off-screen */
#statusBar .stat[data-tip]::after {
  top: auto;
  bottom: calc(100% + 9px);
  transform: translateX(-50%) translateY(2px);
}

#statusBar .stat[data-tip]:hover::after {
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Modals
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  align-content: safe center;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  z-index: 50;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
}

.help-card {
  width: min(660px, 96vw) !important;
  max-height: 88vh;
  overflow-y: auto;
}

.guide-card {
  width: min(980px, 96vw) !important;
  max-height: min(90vh, 860px);
  display: flex;
  flex-direction: column;
  padding: 16px 16px 12px !important;
  overflow: hidden;
}

.guide-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.guide-head h2 {
  margin: 0;
}

.guide-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.guide-layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.guide-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

#guideSearch {
  width: 100%;
  box-sizing: border-box;
  background: rgba(8, 14, 26, 0.65);
  border: 1px solid var(--border-strong);
  color: inherit;
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.82rem;
}

.guide-nav {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: 4px;
}

.guide-sec {
  margin: 10px 0 4px;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.guide-sec:first-child {
  margin-top: 0;
}

.guide-nav-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  gap: 1px;
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font: inherit;
}

.guide-nav-item:hover {
  background: rgba(148, 163, 184, 0.1);
}

.guide-nav-item.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
}

.guide-nav-title {
  font-size: 0.84rem;
  font-weight: 600;
}

.guide-nav-blurb {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.guide-body {
  overflow-y: auto;
  min-height: 0;
  padding: 2px 6px 16px 4px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text, #e7eef8);
}

.guide-body h1 {
  margin: 0 0 10px;
  font-size: 1.25rem;
}

.guide-body h2 {
  margin: 18px 0 6px;
  font-size: 1.02rem;
}

.guide-body h3 {
  margin: 14px 0 4px;
  font-size: 0.92rem;
}

.guide-body p,
.guide-body li {
  color: var(--muted);
}

.guide-body p {
  margin: 0 0 8px;
}

.guide-body ul,
.guide-body ol {
  margin: 0 0 10px;
  padding-left: 1.2rem;
}

.guide-body li {
  margin-bottom: 3px;
}

.guide-body a {
  color: #7dd3fc;
  text-decoration: none;
}

.guide-body a:hover {
  text-decoration: underline;
}

.guide-body hr {
  border: 0;
  border-top: 1px solid var(--border-strong);
  margin: 14px 0;
}

.guide-table-wrap {
  overflow-x: auto;
  margin: 8px 0 12px;
}

.guide-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.guide-body th,
.guide-body td {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  vertical-align: top;
}

.guide-body th {
  color: #cbd5e1;
  font-weight: 600;
}

.boot-guide-btn {
  margin-top: 10px;
}

@media (max-width: 720px) {
  .guide-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .guide-side {
    max-height: 34vh;
  }
  .guide-card {
    max-height: 94dvh;
  }
}

.modal-card {
  width: min(520px, 100%);
  max-height: min(92dvh, 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow), var(--inner-hl);
}

.modal-card h2 {
  margin-top: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-card ol {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.9rem;
  padding-left: 20px;
}

.modal-card ol li {
  margin-bottom: 4px;
}

.modal-card strong {
  color: var(--text);
}

.keys-row {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 2;
}

.save-modal-card {
  width: min(420px, 100%);
}

.save-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.save-modal-actions .primary {
  width: auto;
  min-width: 120px;
}

.save-modal-list-title {
  margin: 18px 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================================
   Operations drawer (route manager)
   ============================================================ */

#routeModal.modal {
  place-items: stretch end;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
  padding: 12px;
}

#routeModal .route-card {
  pointer-events: auto;
  width: min(440px, 100%);
  height: calc(100vh - 24px);
  max-height: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px rgba(34, 211, 238, 0.15);
}

#routeModal .ops-card {
  width: min(480px, 100%);
}

.route-card {
  width: min(860px, 100%);
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.route-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, 0.35);
}

.route-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.route-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

#closeRoutes {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--muted);
}

#closeRoutes:hover {
  color: var(--text);
}

/* —— Ops tabs —— */
.ops-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, 0.35);
}

.ops-tab {
  flex: 1;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  padding: 10px;
  font-weight: 600;
  font-size: 0.84rem;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.ops-tab:hover {
  color: var(--text);
  background: var(--glass-soft);
  transform: none;
  border-color: transparent;
  border-bottom-color: var(--border-strong);
}

.ops-tab.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: none;
}

.route-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(120px, 28%) 1fr;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

/* —— Fleet list section —— */
.route-fleet {
  border-bottom: 1px solid var(--border);
  padding: 12px;
  overflow: auto;
  background: rgba(7, 11, 18, 0.3);
}

.route-fleet h3,
.route-detail h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

#routeFleetList {
  list-style: none;
  margin: 0;
  padding: 0;
}

#routeFleetList li {
  padding: 9px 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  cursor: pointer;
  margin-bottom: 6px;
  background: var(--glass-soft);
  font-size: 0.86rem;
  transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
}

#routeFleetList li:hover {
  border-color: var(--border-strong);
  background: rgba(148, 163, 184, 0.1);
}

#routeFleetList li.active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.15);
}

#routeFleetList .meta {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 3px;
}

.route-detail {
  padding: 14px 16px 18px;
  overflow: auto;
}

.route-empty {
  color: var(--muted);
  padding: 40px 12px;
  text-align: center;
  line-height: 1.5;
  font-size: 0.9rem;
}

.route-empty p {
  margin: 0 0 8px;
}

.route-empty strong {
  color: var(--text);
}

/* —— Vehicle meta / legacy —— */
.route-vehicle-meta,
.ops-vehicle-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  align-items: end;
  margin-bottom: 12px;
}

.route-name-label {
  margin: 0;
  grid-column: 1;
}

.route-stats {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.route-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* —— Ops status pills —— */
.ops-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.ops-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--well);
  border: 1px solid var(--border);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ops-pill strong {
  color: var(--text);
  font-weight: 600;
}

.ops-pill.warn {
  border-color: rgba(251, 191, 36, 0.45);
  background: var(--warn-soft);
  color: #fde68a;
}

.ops-pill.good {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.1);
  color: #a7f3d0;
}

.ops-pill.accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-2);
}

/* —— Ops sections —— */
.ops-section {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: rgba(7, 11, 18, 0.28);
}

.ops-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.ops-section-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

.ops-section-head .hint {
  margin: 0;
  font-size: 11px;
  text-align: right;
}

.ops-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.ops-chip {
  min-height: 26px;
  padding: 3px 11px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--well);
  color: var(--muted);
  box-shadow: none;
}

.ops-chip:hover {
  color: var(--text);
}

.ops-chip.active {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: var(--accent-line);
  box-shadow: none;
}

/* —— Route stops —— */
.route-stops {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  counter-reset: stop;
}

.route-stops li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  background: var(--glass-soft);
  counter-increment: stop;
  transition: border-color var(--ease), background var(--ease);
}

.route-stops li:hover {
  border-color: var(--border-strong);
}

.route-stops li::before {
  content: counter(stop);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: var(--accent-2);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.route-stops li.active-stop {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.25);
}

.route-stops .stop-name {
  font-size: 0.86rem;
  font-weight: 500;
}

.route-stops .stop-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.route-stops .stop-btns {
  display: flex;
  gap: 4px;
}

.route-stops .stop-btns button {
  min-height: 28px;
  padding: 4px 8px;
  min-width: 30px;
  font-size: 0.78rem;
}

.route-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.route-add-row select {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.ops-stop-tools {
  display: flex;
  gap: 6px;
}

.ops-stop-tools .ghost {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 0.78rem;
}

.ops-quick-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-bottom: 6px;
}

.ops-quick-row select {
  padding: 7px 10px;
  min-height: 36px;
  font-size: 0.84rem;
}

.ops-save-tpl {
  margin-top: 4px;
}

.ops-save-tpl:disabled,
#opsApplySavedBtn:disabled,
#opsCopyFromBtn:disabled,
#routeApplyBtn:disabled,
#routeDispatchBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* —— Route actions —— */
.route-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.route-actions .primary {
  width: auto;
  min-width: 140px;
}

.ops-actions {
  flex-wrap: wrap;
}

.ops-actions button {
  flex: 0 0 auto;
}

.ops-actions-sticky {
  position: sticky;
  bottom: 0;
  margin-top: 8px;
  padding: 12px 0 4px;
  background: linear-gradient(180deg, transparent, rgba(13, 19, 31, 0.94) 30%);
  z-index: 2;
}

/* —— Route library —— */
.ops-saved-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 50vh;
  overflow: auto;
}

.ops-saved-list li {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  background: var(--glass-soft);
  transition: border-color var(--ease), background var(--ease);
}

.ops-saved-list li:hover {
  border-color: var(--border-strong);
  background: rgba(148, 163, 184, 0.1);
}

.ops-saved-list .ops-saved-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 4px;
}

.ops-saved-list .ops-saved-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.ops-saved-list .ops-saved-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.ops-saved-list .tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(34, 211, 238, 0.25);
  color: var(--accent-2);
}

.ops-saved-list .ops-saved-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ops-saved-list .ops-saved-btns button {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 0.75rem;
}

.ops-lib-empty {
  padding: 20px 8px;
  text-align: center;
}

#opsLibraryTab.hidden,
#opsVehicleTab.hidden {
  display: none !important;
}

/* ============================================================
   Responsive
   ============================================================ */

/* Mid-size screens: slim the stats strip so the tool/toggle groups never get
   pushed off the right edge. The bar stays a single row (the app grid row is
   fixed at var(--ibar-h)); the stats strip shrinks and scrolls instead. */
@media (max-width: 1500px) {
  .ibar-stats {
    gap: 3px;
  }
  .ibar-stats .stat.muted {
    display: none;
  }
  .ibar-stats .stat {
    padding: 3px 7px;
    gap: 4px;
    font-size: 11px;
  }
  .ibar-stats .stat span {
    font-size: 11px;
  }
  .ibar-stats .stat strong {
    font-size: 11.5px;
  }
}

@media (max-width: 1200px) {
  #iconbar {
    gap: 6px;
  }
  .badge {
    max-width: 90px;
  }
}

@media (max-width: 900px) {
  .logo-sm {
    display: none;
  }
}

@media (max-width: 640px) {
  .ibar-stats {
    display: none;
  }
  .flyout-wide {
    width: min(100vw - 24px, 360px);
  }
  .world-cols {
    grid-template-columns: 1fr;
  }

  /* —— Boot / world-create / all menu cards —— */
  #boot {
    padding: max(10px, env(safe-area-inset-top)) 10px max(20px, env(safe-area-inset-bottom));
  }
  .boot-card,
  .boot-card-wide {
    width: 100%;
    padding: 16px 14px 18px;
    border-radius: 14px;
  }
  .logo {
    font-size: 1.55rem;
  }
  .tagline {
    font-size: 0.82rem;
  }
  .blurb {
    font-size: 0.84rem;
    margin-bottom: 8px;
  }
  .hub-header {
    flex-wrap: wrap;
  }
  .hub-header-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .mode-card {
    min-height: 0;
    padding: 12px;
  }
  .multi-create-row {
    flex-direction: column;
  }
  .multi-create-row .primary,
  .auth-inline-row .ghost,
  .auth-inline-row .primary {
    width: 100%;
  }
  .phase-nav {
    flex-wrap: wrap;
  }
  .save-list {
    max-height: min(200px, 28vh);
  }
  .single-new-block .primary,
  .auth-submit {
    width: 100%;
  }

  .settings-menu {
    position: fixed;
    top: calc(var(--ibar-h) + 6px);
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100dvh - var(--ibar-h) - 14px);
  }

  #iconbar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
  }

  .flyout {
    width: min(100vw - 16px, 360px);
    max-height: calc(100dvh - var(--ibar-h) - 32px);
  }

  #routeModal.modal {
    padding: 0;
    place-items: stretch stretch;
  }
  #routeModal .route-card,
  #routeModal .ops-card {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .modal-card {
    padding: 16px 14px;
    max-height: min(94dvh, 100%);
  }

  .help-card {
    width: 100% !important;
    max-height: 94dvh;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.stat[data-tip] { position: relative; }
.stat[data-tip]::after { white-space: normal; width: max-content; max-width: 260px; text-align: left; line-height: 1.35; z-index: 60; }
