:root {
  --bg: #05080d;
  --surface: rgba(10, 15, 24, 0.76);
  --surface-strong: rgba(10, 16, 28, 0.92);
  --border: rgba(255, 255, 255, 0.11);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --live: #ef4444;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

.app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 40%, #0c1524 0%, #05080d 75%);
}

/* --- Floating Glass Top HUD Bar --- */
.hud-bar {
  position: fixed;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--border);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

body.user-idle:not(.drawer-open) .hud-bar {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}

body.user-idle:not(.drawer-open) {
  cursor: none;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid rgba(239, 68, 68, 0.42);
  color: #fecaca;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.live-pill.standby {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.42);
  color: #fde68a;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 10px var(--live);
  animation: pulseDot 2s ease-in-out infinite;
}

.live-pill.standby .live-dot {
  background: #f59e0b;
  box-shadow: none;
  animation: none;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.brand-titles {
  display: flex;
  align-items: baseline;
  gap: 9px;
  white-space: nowrap;
  overflow: hidden;
}

.brand-name {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #f8fafc;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Telemetry Strip --- */
.telemetry-strip {
  display: flex;
  align-items: center;
  gap: 6px;
}

.telemetry-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
  white-space: nowrap;
}

.chip-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}

.chip-val {
  color: #e2e8f0;
  font-weight: 500;
}

/* --- Controls --- */
.controls-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-strong);
  color: #ffffff;
}

.hud-btn[aria-pressed="true"],
.hud-btn[aria-expanded="true"] {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.5);
  color: #bae6fd;
}

.hud-btn-primary {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* --- Main 16:9 Stage --- */
.stage-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.stage-box {
  position: relative;
  /* Exact 16:9 letterbox fit so YouTube timeline & skyline calibration stay 1:1 */
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  background: #000;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.8);
  transition: width 0.3s ease, height 0.3s ease;
}

/* Edge-to-edge Cinema Cover Mode (toggled with Fill button or Z key) */
body.fill-mode .stage-box {
  width: max(100vw, calc(100dvh * 16 / 9));
  height: max(100dvh, calc(100vw * 9 / 16));
}

#ytPlayer,
.stage-box iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* --- Photogrammetric Skyline Landmark Pins --- */
.landmarks-layer {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

.landmark-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pin-card {
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(6, 11, 19, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
  font-size: 11px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.pin-card strong {
  color: #ffffff;
  font-weight: 600;
}

.pin-stem {
  width: 1px;
  background: linear-gradient(to bottom, rgba(56, 189, 248, 0.75), rgba(56, 189, 248, 0.2));
}

.pin-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.landmarks-note {
  position: absolute;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(6, 11, 19, 0.78);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.landmarks-note kbd,
.shortcut-list kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #f8fafc;
}

/* --- Fallback / Local File Notice --- */
.fallback-overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(rgba(5, 8, 13, 0.82), rgba(5, 8, 13, 0.92)), url("/og.jpg") center / cover no-repeat;
}

.fallback-card {
  max-width: 460px;
  padding: 26px;
  border-radius: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  text-align: center;
}

.fallback-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.fallback-card p {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.fallback-card pre {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: #bae6fd;
  overflow-x: auto;
  user-select: all;
}

.cta-link {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 9px;
  background: var(--accent);
  color: #041019;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}

/* --- Slide-over About Drawer --- */
.info-drawer {
  position: fixed;
  top: 72px;
  right: 16px;
  bottom: 16px;
  width: min(370px, calc(100vw - 32px));
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-radius: 16px;
  background: var(--surface-strong);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--border-strong);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
  overflow-y: auto;
  user-select: text;
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.drawer-eyebrow {
  margin: 0 0 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.drawer-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.drawer-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  cursor: pointer;
}

.drawer-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.drawer-lead {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: #cbd5e1;
}

.drawer-section h3 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.landmark-list,
.shortcut-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
}

.landmark-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.landmark-list li span:last-child {
  color: var(--text-muted);
  font-size: 12px;
}

.shortcut-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #cbd5e1;
}

.drawer-hint {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  font-size: 12.5px;
  line-height: 1.5;
  color: #bae6fd;
}

.drawer-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

.drawer-footer a {
  color: #e2e8f0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mobile-footer {
  display: none;
}

/* --- Responsive Breakpoints --- */
@media (max-width: 1120px) {
  .brand-sub,
  .hide-sm {
    display: none;
  }
}

@media (max-width: 760px) {
  .hud-bar {
    position: static;
    margin: 10px 10px 0;
    flex-wrap: wrap;
    padding: 10px;
  }

  body.user-idle:not(.drawer-open) .hud-bar {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  .telemetry-strip {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  .telemetry-chip {
    flex: 1;
    justify-content: space-between;
  }

  .btn-label,
  .hide-mobile {
    display: none;
  }

  .stage-box {
    width: 100vw;
    height: calc(100vw * 9 / 16);
  }

  .mobile-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px 20px;
  }

  .mobile-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
    font-size: 12.5px;
  }

  .info-drawer {
    top: 12px;
  }
}
