:root {
  --green: #1f3d2b;
  --green-dark: #142a1d;
  --terracotta: #c1592b;
  --gold: #e8a33d;
  --white: #ffffff;
  --ink: #10140f;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, Calibri, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}

#viewer {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: grab;
  background: var(--ink);
}
#viewer.dragging { cursor: grabbing; }
#viewer canvas { display: block; }

/* ---------------- Hotspots ---------------- */

#hotspot-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 20;
}

.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.hotspot-dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(193, 89, 43, 0.85);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 rgba(232, 163, 61, 0.6);
  animation: pulse 2.2s infinite;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 15px;
}
.hotspot[data-type="info"] .hotspot-dot { background: rgba(31, 61, 43, 0.9); }
.hotspot[data-type="locked"] .hotspot-dot { background: rgba(232, 163, 61, 0.92); }
.hotspot.focused .hotspot-dot { outline: 3px solid var(--gold); }

.hotspot-label {
  margin-top: 6px;
  background: rgba(16, 20, 15, 0.75);
  color: var(--white);
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(232, 163, 61, 0.55); }
  70%  { box-shadow: 0 0 0 16px rgba(232, 163, 61, 0); }
  100% { box-shadow: 0 0 0 0 rgba(232, 163, 61, 0); }
}

/* Center reticle — only visible in TV remote-navigation mode */
#reticle {
  position: fixed; top: 50%; left: 50%;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  z-index: 25;
  display: none;
  pointer-events: none;
}
body.tv-mode #reticle { display: block; }

/* ---------------- Top bar / captions ---------------- */

#topbar {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 18px 22px;
  z-index: 15;
  background: linear-gradient(to bottom, rgba(10,14,9,0.65), transparent);
  pointer-events: none;
}
#tour-title { color: var(--gold); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; font-weight: 700; }
#scene-name { color: var(--white); font-size: 22px; font-weight: 700; margin-top: 2px; text-shadow: 0 2px 6px rgba(0,0,0,0.5); }

#caption {
  position: fixed; bottom: 90px; left: 50%;
  transform: translateX(-50%);
  max-width: 640px;
  text-align: center;
  color: var(--white);
  background: rgba(16, 20, 15, 0.7);
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 15px;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
#caption.visible { opacity: 1; }

/* ---------------- Bottom controls ---------------- */

#controls {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  gap: 14px;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(10,14,9,0.75), transparent);
  z-index: 15;
}

#controls button {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  color: var(--white);
  width: 46px; height: 46px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease, transform 0.15s ease;
}
#controls button:hover { background: rgba(255,255,255,0.22); }
#controls button:active { transform: scale(0.92); }
#btn-vr { width: auto; padding: 0 16px; border-radius: 24px; background: var(--terracotta); border-color: var(--terracotta); font-size: 14px; font-weight: 700; }

#scene-dots { display: flex; gap: 8px; margin: 0 6px; }
.scene-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,0.35);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.scene-dot.active { background: var(--gold); transform: scale(1.3); }

.hidden { display: none !important; }

/* ---------------- Loading screen ---------------- */

#loading-screen {
  position: fixed; inset: 0;
  background: radial-gradient(circle at center, var(--green) 0%, var(--green-dark) 100%);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s ease;
}
#loading-screen.fade-out { opacity: 0; pointer-events: none; }
.loading-inner { text-align: center; color: var(--white); }
.spinner {
  width: 46px; height: 46px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { font-size: 14px; letter-spacing: 1px; color: rgba(255,255,255,0.85); }

/* ---------------- Motion permission gate (iOS) ---------------- */

#motion-gate {
  position: fixed; inset: 0;
  background: rgba(10, 14, 9, 0.92);
  z-index: 90;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.motion-gate-card {
  background: var(--green);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 360px;
  text-align: center;
  color: var(--white);
  box-shadow: var(--shadow);
}
.motion-gate-card p { font-size: 15px; line-height: 1.5; margin: 0 0 18px; }
#enable-motion-btn {
  background: var(--terracotta);
  color: var(--white);
  border: none;
  padding: 12px 22px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* Smart-TV screens are wide and viewed from a distance — scale the whole UI up */
@media (min-width: 1900px) {
  #scene-name { font-size: 30px; }
  #tour-title { font-size: 15px; }
  .hotspot-dot { width: 44px; height: 44px; font-size: 19px; }
  .hotspot-label { font-size: 16px; padding: 6px 14px; }
  #caption { font-size: 19px; max-width: 900px; }
  #controls button { width: 58px; height: 58px; font-size: 22px; }
}
