:root {
  --bg: #0c1117;
  --bg-soft: #131a23;
  --ink: #e8ecf2;
  --ink-dim: #9aa7b5;
  --accent: #6ea8ff;
  --accent-warm: #ffc46b;
  --line: rgba(255, 255, 255, 0.12);
  --serif: Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  overflow: hidden;
}

#app, .screen {
  position: absolute;
  inset: 0;
}

.screen {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

.btn {
  font-family: var(--sans);
  font-size: 15px;
  padding: 11px 22px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: #2c5db8;
  color: #fff;
}

.btn-primary:hover { background: #3771d4; }

.btn-ghost {
  background: rgba(10, 14, 20, 0.55);
  color: var(--ink);
  border-color: var(--line);
  backdrop-filter: blur(6px);
}

.btn-ghost:hover { border-color: rgba(255, 255, 255, 0.35); }

.btn-lg { font-size: 17px; padding: 14px 34px; }
.btn-block { width: 100%; }
.btn-back { align-self: flex-start; }

#screen-intro { background: #000; }

.intro-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 1s linear;
}

#intro-tone {
  position: absolute;
  inset: 0;
  background: var(--tone, #16233a);
  mix-blend-mode: multiply;
  opacity: var(--tone-op, 0.55);
  pointer-events: none;
}

#intro-grain {
  position: absolute;
  inset: -120px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: var(--grain, 0.05);
  pointer-events: none;
  animation: grain-shift 0.9s steps(3) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-32px, 22px); }
  66% { transform: translate(26px, -34px); }
  100% { transform: translate(0, 0); }
}

.intro-shade {
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    radial-gradient(ellipse at center, transparent 22%, rgba(0, 0, 0, 0.72) 100%),
    linear-gradient(to top, rgba(0, 0, 0, 0.82), transparent 45%);
}

.intro-logo-wrap {
  position: absolute;
  z-index: 4;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 32px 60px;
  border-radius: 50%;
  background: radial-gradient(
    ellipse closest-side at 50% 50%,
    rgba(255, 255, 255, 0.92) 0%,
    rgba(255, 255, 255, 0.55) 42%,
    rgba(255, 255, 255, 0) 78%
  );
}

.intro-logo {
  display: block;
  height: 96px;
  width: auto;
}

.intro-footer {
  position: absolute;
  z-index: 4;
  bottom: 18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(210, 220, 232, 0.45);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
  padding: 0 24px;
}

.intro-content {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 24px;
}

.intro-kicker {
  font-size: 13px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent-warm);
}

#intro-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(44px, 8vw, 92px);
  line-height: 1.05;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.6);
}

#intro-subtitle {
  max-width: 560px;
  color: var(--ink-dim);
  font-size: 17px;
  line-height: 1.55;
  margin-bottom: 18px;
}

#map-canvas-wrap, #map-canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#map-fallback-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hud {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 26px;
  pointer-events: none;
  z-index: 5;
}

.hud > * { pointer-events: auto; }

.hud-top {
  top: 0;
  background: linear-gradient(to bottom, rgba(5, 8, 12, 0.75), transparent);
}

.hud-bottom {
  bottom: 0;
  justify-content: center;
  background: linear-gradient(to top, rgba(5, 8, 12, 0.7), transparent);
  color: var(--ink-dim);
  font-size: 14px;
  letter-spacing: 0.08em;
  padding-bottom: 22px;
}

.hud-title {
  font-family: var(--serif);
  font-size: 20px;
}

.hud-title span { color: var(--ink-dim); font-size: 15px; }

.hud-actions { display: flex; align-items: center; gap: 16px; }

.counter {
  font-size: 13px;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 6px 14px;
  background: rgba(10, 14, 20, 0.5);
}

#map-tooltip {
  position: absolute;
  transform: translate(-50%, -140%);
  background: rgba(10, 14, 20, 0.85);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  white-space: nowrap;
  z-index: 6;
}

#map-tooltip.show { opacity: 1; }

#map-tuner {
  position: absolute;
  top: 76px;
  left: 26px;
  display: none;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #cfe3ff;
  white-space: pre;
  z-index: 20;
  pointer-events: none;
}

.map-fallback-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: rgba(110, 168, 255, 0.25);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
}

.map-fallback-marker.active { border-color: var(--accent-warm); background: rgba(255, 196, 107, 0.3); }

#toast {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(10, 14, 20, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 15px;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 20;
}

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

.facade-stage {
  position: absolute;
  inset: 0;
  background: #05080c;
}

.facade-media {
  position: absolute;
  inset: 0;
  transform: translateX(-12%);
}

#facade-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#facade-dim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

#panel-glow {
  position: absolute;
  z-index: 2;
  border: 2px solid rgba(255, 226, 172, 0.95);
  border-radius: 4px;
  box-shadow:
    0 0 26px 3px rgba(255, 212, 140, 0.55),
    0 0 110px 28px rgba(255, 198, 110, 0.42),
    0 0 260px 80px rgba(255, 186, 96, 0.2),
    inset 0 0 70px rgba(255, 220, 160, 0.18);
}

.info-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 30px;
  background: rgba(9, 13, 19, 0.82);
  backdrop-filter: blur(14px);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  z-index: 3;
}

.crumbs { color: var(--ink-dim); font-size: 13px; letter-spacing: 0.06em; }

#tuner {
  display: none;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #cfe3ff;
  white-space: pre;
}
.crumbs span { margin: 0 6px; }

#facade-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  line-height: 1.25;
}

.meta { list-style: none; display: grid; gap: 9px; }

.meta li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding-bottom: 9px;
}

.meta .k { color: var(--ink-dim); }
.meta .v { text-align: right; }

#facade-desc { color: var(--ink-dim); line-height: 1.65; font-size: 15px; }

#btn-details { margin-top: auto; }

#osd { position: absolute; inset: 0; background: #05080c; }

#osd .annotation-dot {
  position: relative;
  width: 26px;
  height: 26px;
  cursor: pointer;
  pointer-events: auto;
}

#osd .annotation-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-warm);
  background: rgba(255, 196, 107, 0.25);
  box-shadow: 0 0 18px rgba(255, 196, 107, 0.5);
  animation: dot-pulse 2.2s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

.viewer-hud { z-index: 10; }

#osd .zoom-dim-overlay {
  pointer-events: none;
  border-radius: 4px;
  box-shadow:
    0 0 0 40px rgba(4, 7, 11, 0.3),
    0 0 0 120px rgba(4, 7, 11, 0.5),
    0 0 0 300px rgba(4, 7, 11, 0.65),
    0 0 0 640px rgba(4, 7, 11, 0.78),
    0 0 0 3000px rgba(4, 7, 11, 0.85);
}

#osd .zoom-glow-overlay {
  pointer-events: none;
  border: 2px solid rgba(210, 216, 222, 0.85);
  border-radius: 4px;
  box-shadow:
    0 0 26px 3px rgba(190, 198, 206, 0.4),
    0 0 110px 28px rgba(180, 188, 196, 0.25),
    0 0 240px 70px rgba(170, 178, 186, 0.12);
}

#vtuner {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #cfe3ff;
  white-space: pre;
  z-index: 20;
  pointer-events: none;
}

#annotation-card {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%) translateY(10px);
  width: min(520px, 90vw);
  background: rgba(9, 13, 19, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10;
}

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

.annotation-title {
  font-family: var(--serif);
  font-size: 19px;
  margin-bottom: 8px;
  color: var(--accent-warm);
}

.annotation-text { color: var(--ink-dim); font-size: 14px; line-height: 1.6; }

#osd-minimap {
  position: absolute;
  right: 26px;
  bottom: 26px;
  width: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #05080c;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  overflow: hidden;
  z-index: 10;
}

#minimap-rect {
  position: absolute;
  border: 1.5px solid var(--accent-warm);
  box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0.45);
}

#minimap-label {
  position: absolute;
  left: 8px;
  bottom: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.65);
  letter-spacing: 0.08em;
  z-index: 2;
}

@media (max-width: 720px) {
  .facade-media { transform: none; }
  .info-panel {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 62vh;
    border-left: none;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
  }
  #osd-minimap { display: none; }
  .viewer-tools { display: none; }
}

#mobile-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: radial-gradient(ellipse at center, #101926 0%, #060a10 100%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 32px;
}

.mobile-gate-icon {
  font-size: 44px;
  opacity: 0.85;
}

.mobile-gate-title {
  font-family: var(--serif);
  font-size: 22px;
  color: #e8edf4;
}

.mobile-gate-text {
  max-width: 420px;
  font-size: 14px;
  line-height: 1.6;
  color: rgba(210, 220, 232, 0.7);
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  #mobile-gate { display: flex; }
}
