:root {
  --ink: #443538;
  --ink-soft: #756266;
  --glass: rgba(255, 252, 248, 0.86);
  --border: rgba(255, 255, 255, 0.94);
  --shadow: 0 10px 30px rgba(55, 42, 54, 0.16);
  --pink: #ff80ab;
  --sky: #55b6f5;
  --gold: #ffbe3b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Zen Maru Gothic', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  color: var(--ink);
  background: #a5e0ff;
}

.hidden {
  display: none !important;
}

#fly-canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

/* ===== Top Left ===== */
.fly-top-left {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}

.city-card {
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 2.5px solid var(--border);
  border-radius: 22px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.city-header-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.city-flag {
  font-size: 1.7rem;
  line-height: 1.1;
}

.city-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.city-title-row h1 {
  font-size: 1.12rem;
  font-weight: 900;
}

.city-en {
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #3a92d4;
  background: #e6f5ff;
  padding: 2px 7px;
  border-radius: 999px;
}

.city-selector-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.city-chip {
  border: 1.5px solid rgba(68, 53, 56, 0.14);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  padding: 2px 9px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}

.city-chip.active {
  background: linear-gradient(135deg, #e8f7ff, #d1eeff);
  border-color: var(--sky);
  color: #1f74b8;
}

.city-chip.soon {
  opacity: 0.55;
  cursor: not-allowed;
}

.stamp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  font-size: 0.75rem;
  font-weight: 800;
}

.stamp-track {
  flex: 1;
  height: 9px;
  background: rgba(85, 182, 245, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.stamp-fill {
  height: 100%;
  background: linear-gradient(90deg, #55b6f5, #ff80ab);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.star-score {
  color: #d98216;
  white-space: nowrap;
}

/* Tour Postcard */
.tour-postcard {
  display: flex;
  gap: 11px;
  background: rgba(255, 253, 249, 0.93);
  backdrop-filter: blur(14px);
  border: 3px solid #ffbe3b;
  border-radius: 20px;
  padding: 12px 14px;
  box-shadow: 0 12px 28px rgba(70, 50, 40, 0.2);
  animation: slideInCard 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInCard {
  from { transform: translateY(-10px) scale(0.92); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.postcard-badge {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff5d6, #ffe094);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55rem;
  flex-shrink: 0;
}

.postcard-tag {
  font-size: 0.68rem;
  font-weight: 900;
  color: #d97706;
}

.postcard-body h2 {
  font-size: 1.02rem;
  font-weight: 900;
  margin-top: 1px;
}

.postcard-body p {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 3px;
  line-height: 1.4;
}

.postcard-tip {
  margin-top: 5px;
  font-size: 0.72rem;
  font-weight: 800;
  color: #c2416c;
  background: #fff0f5;
  padding: 3px 8px;
  border-radius: 8px;
}

/* ===== Top Center ===== */
.fly-top-center {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mode-pill-group {
  display: flex;
  gap: 6px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 2.5px solid var(--border);
  border-radius: 999px;
  padding: 5px;
  box-shadow: var(--shadow);
}

.mode-btn {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 7px 16px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 900;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mode-btn.active {
  background: linear-gradient(135deg, #55b6f5, #7d96ff);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(85, 182, 245, 0.4);
}

.osm-btn {
  border: 2px solid var(--border);
  background: rgba(255, 252, 248, 0.88);
  backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 5px 14px;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(55, 42, 54, 0.12);
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}

.osm-btn:hover {
  transform: translateY(-2px);
  background: #ffffff;
  border-color: var(--sky);
}

.osm-btn.loaded {
  background: #e6fff3;
  border-color: #34d399;
  color: #067a50;
}

/* ===== Top Right ===== */
.fly-top-right {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.fly-right-drawer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.fly-mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.nav-links-row {
  display: flex;
  gap: 7px;
}

.nav-pill {
  text-decoration: none;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 2.5px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 900;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.nav-pill:hover {
  transform: translateY(-2px) scale(1.04);
}

.nav-race {
  background: linear-gradient(135deg, #ff7098, #ffaa4c);
  color: #ffffff;
}

.tool-pill-group {
  display: flex;
  gap: 6px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 2.5px solid var(--border);
  border-radius: 999px;
  padding: 5px 7px;
  box-shadow: var(--shadow);
}

.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  font-size: 1.08rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, border-color 0.2s;
}

.tool-btn:hover {
  transform: scale(1.12);
}

.tool-btn.active {
  background: #ffffff;
  border-color: var(--pink);
}

.music-jukebox-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  border: 2.5px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  box-shadow: var(--shadow);
}

.jukebox-icon {
  font-size: 1rem;
}

.jukebox-select {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  outline: none;
}

/* ===== Center Toast ===== */
.fly-toast {
  position: fixed;
  top: 112px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(56, 44, 52, 0.88);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 8px 20px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
}

/* ===== Bottom Left Radar ===== */
.radar-card {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 25;
  background: rgba(255, 252, 248, 0.82);
  backdrop-filter: blur(12px);
  border: 2.5px solid var(--border);
  border-radius: 20px;
  padding: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.radar-caption {
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink);
}

/* ===== Bottom Center Aircraft Dock ===== */
.aircraft-dock {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 2.5px solid var(--border);
  border-radius: 24px;
  padding: 6px 9px;
  box-shadow: var(--shadow);
  max-width: min(680px, calc(100vw - 440px));
}

.aircraft-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 6px;
  border-radius: 999px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.aircraft-btn:hover {
  transform: translateY(-2px);
  background: #ffffff;
  border-color: var(--accent);
}

.aircraft-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-2px) scale(1.04);
}

/* ===== Bottom Right Flight Gauge ===== */
.flight-gauge-card {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 25;
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 2.5px solid var(--border);
  border-radius: 20px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  min-width: 215px;
}

.aircraft-name-badge {
  font-size: 0.78rem;
  font-weight: 900;
  color: #d64e7c;
  margin-bottom: 6px;
  text-align: center;
}

.gauge-grid {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  padding: 6px 10px;
}

.gauge-item {
  display: flex;
  flex-direction: column;
}

.gauge-label {
  font-size: 0.62rem;
  font-weight: 900;
  color: var(--ink-soft);
}

.gauge-val strong {
  font-size: 1.25rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.flight-keys {
  margin-top: 7px;
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink-soft);
}

kbd {
  background: #ffffff;
  border: 1.5px solid rgba(68, 53, 56, 0.22);
  border-radius: 5px;
  padding: 1px 4px;
  font-family: inherit;
  font-size: 0.64rem;
  font-weight: 800;
}

.photo-flash {
  position: fixed;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.35s ease;
}

.photo-flash.flash {
  opacity: 0.85;
  transition: opacity 0.05s ease;
}

.fly-touch-controls {
  display: none;
  position: fixed;
  bottom: 84px;
  left: 14px;
  right: 14px;
  z-index: 30;
  justify-content: space-between;
  pointer-events: none;
}

.ft-pad {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.ft-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.92);
  background: rgba(255, 252, 248, 0.8);
  backdrop-filter: blur(8px);
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
  touch-action: none;
}

.ft-btn:active,
.ft-btn.pressed {
  transform: scale(0.92);
  background: #dff3ff;
}

.ft-boost {
  background: linear-gradient(135deg, #ff7098, #ffaa4c);
  color: #ffffff;
}

/* Ultra-clean Mobile Mode (works on BOTH portrait & landscape iPhone!) */
body.is-mobile .radar-card,
body.is-mobile .flight-gauge-card,
body.is-mobile .osm-btn,
body.is-mobile .city-en,
body.is-mobile .city-selector-row,
body.is-mobile .stamp-track { display: none; }

body.is-mobile .fly-top-left {
  top: max(8px, env(safe-area-inset-top));
  left: 8px;
  max-width: 145px;
}
body.is-mobile .city-card {
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.8);
}
body.is-mobile .city-header-row { gap: 5px; align-items: center; }
body.is-mobile .city-flag { font-size: 0.95rem; }
body.is-mobile .city-title-row h1 { font-size: 0.74rem; white-space: nowrap; }
body.is-mobile .stamp-row { margin-top: 1px; font-size: 0.62rem; gap: 5px; }

body.is-mobile .tour-postcard {
  position: fixed;
  top: calc(52px + env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  max-width: none;
  padding: 6px 10px;
  border-radius: 14px;
  border-width: 2px;
  background: rgba(255, 253, 249, 0.88);
}
body.is-mobile .postcard-badge { width: 28px; height: 28px; font-size: 1rem; border-radius: 10px; }
body.is-mobile .postcard-tag { font-size: 0.6rem; }
body.is-mobile .postcard-body h2 { font-size: 0.8rem; }
body.is-mobile .postcard-body p { font-size: 0.68rem; line-height: 1.25; }
body.is-mobile .postcard-tip { display: none; }

body.is-mobile .fly-top-center {
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}
body.is-mobile .mode-pill-group { padding: 3px; gap: 3px; background: rgba(255, 252, 248, 0.82); }
body.is-mobile .mode-btn { padding: 5px 9px; font-size: 0.72rem; }

body.is-mobile .fly-top-right { top: max(8px, env(safe-area-inset-top)); right: 8px; }
body.is-mobile .fly-mobile-menu-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; font-size: 1rem;
}
body.is-mobile .fly-right-drawer {
  display: none;
  background: rgba(255, 252, 248, 0.96);
  backdrop-filter: blur(16px);
  border: 2px solid #ffffff;
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 12px 28px rgba(45, 35, 50, 0.25);
}
body.is-mobile .fly-right-drawer.open { display: flex; }

/* Ultra-slim bottom swipeable aircraft dock */
body.is-mobile .aircraft-dock {
  bottom: max(8px, env(safe-area-inset-bottom));
  width: calc(100vw - 14px);
  max-width: calc(100vw - 14px);
  flex-wrap: nowrap;
  justify-content: flex-start;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.78);
}
body.is-mobile .aircraft-dock::-webkit-scrollbar { display: none; }
body.is-mobile .aircraft-btn { flex-shrink: 0; padding: 3px 8px 3px 5px; font-size: 0.72rem; }

body.is-mobile .fly-touch-controls {
  display: flex;
  bottom: calc(52px + env(safe-area-inset-bottom));
  left: 10px;
  right: 10px;
}
body.is-mobile .ft-btn { width: 52px; height: 52px; font-size: 1.2rem; opacity: 0.82; }
