/* ============================================
   PURE 3D GLOBE — No scroll, full viewport
   ============================================ */
:root {
  --bg: #000;
  --accent: #8b5cf6;
  --accent-2: #c084fc;
  --cyan: #06b6d4;
  --danger: #f43f5e;
  --amber: #f59e0b;
  --text: #e2e0f0;
  --text-muted: #7a789a;
  --text-dim: #4a4868;
  --surface: rgba(8, 8, 20, 0.88);
  --border: rgba(139, 92, 246, 0.12);
  --font-serif: 'Newsreader', Georgia, serif;
  --font-sans: 'Be Vietnam Pro', system-ui, sans-serif;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: var(--font-sans);
  color: var(--text);
  cursor: grab;
}

body:active {
  cursor: grabbing;
}

/* ============================================
   PRELOADER — Premium 8K Loading
   ============================================ */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0a0a1a 0%, #000005 70%);
  gap: 12px;
  transition: opacity 1s ease-out, visibility 1s;
}

#preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Cosmos animation */
.loader-cosmos {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 8px;
}

.loader-orbit {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(139, 92, 246, 0.15);
  border-radius: 50%;
  border-top-color: rgba(139, 92, 246, 0.6);
}

.loader-orbit-1 {
  animation: orbit-spin 2s linear infinite;
}

.loader-orbit-2 {
  inset: 12px;
  border-color: rgba(6, 182, 212, 0.1);
  border-top-color: rgba(6, 182, 212, 0.5);
  animation: orbit-spin 1.5s linear infinite reverse;
}

.loader-orbit-3 {
  inset: 24px;
  border-color: rgba(192, 132, 252, 0.08);
  border-top-color: rgba(192, 132, 252, 0.4);
  animation: orbit-spin 1s linear infinite;
}

.loader-planet {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #6dd5fa, #2980b9, #0a0a2e);
  box-shadow: 0 0 20px rgba(109, 213, 250, 0.4), 0 0 40px rgba(41, 128, 185, 0.2);
  animation: planet-pulse 2s ease-in-out infinite;
}

@keyframes orbit-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes planet-pulse {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(109, 213, 250, 0.4), 0 0 40px rgba(41, 128, 185, 0.2);
  }

  50% {
    box-shadow: 0 0 30px rgba(109, 213, 250, 0.6), 0 0 60px rgba(41, 128, 185, 0.4);
  }
}

.loader-title {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: rgba(139, 92, 246, 0.6);
}

.loader-percent {
  font-family: 'Courier New', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.05em;
  text-shadow: 0 0 30px rgba(139, 92, 246, 0.3);
}

.loader-bar {
  width: 220px;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
}

.loader-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: 3px;
  transition: width 0.4s ease-out;
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.5);
}

.loader-status {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  min-height: 1.2em;
  transition: opacity 0.3s;
}

.loader-textures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  margin-top: 8px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

.tex-group-label {
  grid-column: 1 / -1;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: rgba(139, 92, 246, 0.5);
  padding-bottom: 2px;
  padding-top: 4px;
}

.tex-group-label:first-child {
  padding-top: 0;
}

.tex-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.6rem;
  font-family: 'Courier New', monospace;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  transition: color 0.4s;
}

.tex-item.loading {
  color: var(--amber);
}

.tex-item.loaded {
  color: #34d399;
}

.tex-item.error {
  color: var(--danger);
}

.tex-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  transition: background 0.4s, box-shadow 0.4s;
  flex-shrink: 0;
}

.tex-item.loading .tex-dot {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
  animation: blink 1s ease infinite;
}

.tex-item.loaded .tex-dot {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

.tex-item.error .tex-dot {
  background: var(--danger);
}

.loader-tip {
  margin-top: 8px;
  font-size: 0.58rem;
  color: rgba(255, 255, 255, 0.15);
  font-style: italic;
}

/* ============================================
   CANVAS — full viewport
   ============================================ */
#globe {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

#flashOverlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: radial-gradient(ellipse at center, rgba(180, 220, 255, 0.9), rgba(0, 0, 20, 0.95));
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   HUD — heads-up display overlay
   ============================================ */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  padding: 20px;
}

.hud-topleft {
  position: absolute;
  top: 20px;
  left: 24px;
}

.hud-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--accent);
  opacity: 0.6;
}

.hud-topright {
  position: absolute;
  top: 20px;
  right: 24px;
}

.hud-coords {
  font-family: 'Courier New', monospace;
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.hud-bottom {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
}

.hud-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  animation: pulse-hint 2s ease infinite;
}

@keyframes pulse-hint {

  0%,
  100% {
    opacity: 0.8;
  }

  50% {
    opacity: 0.3;
  }
}

.hint-key {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--accent-2);
  margin-right: 4px;
}

.hud-phase {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 4vw, 3.5rem);
  font-weight: 700;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 40px rgba(139, 92, 246, 0.3);
}

.hud-phase em {
  font-style: italic;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================
   DOSSIER PANELS — floating over 3D
   ============================================ */
.dossier-panel {
  position: fixed;
  z-index: 20;
  width: 300px;
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  transition: opacity 0.5s, transform 0.5s;
  pointer-events: all;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.5), 0 0 20px rgba(139, 92, 246, 0.05);
}

.dossier-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent), transparent);
  border-radius: 16px 0 0 16px;
}

.dossier-panel.hidden {
  opacity: 0;
  transform: scale(0.9) translateY(20px);
  pointer-events: none;
}

#panelMonk {
  top: 50%;
  left: 5%;
  transform: translateY(-50%);
}

#panelTym {
  top: 50%;
  right: 5%;
  transform: translateY(-50%);
}

#panelMonk.hidden {
  transform: translateY(-50%) scale(0.9) translateX(-30px);
}

#panelTym.hidden {
  transform: translateY(-50%) scale(0.9) translateX(30px);
}

.panel-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: blink 1.5s ease infinite;
}

.dot-red {
  background: var(--danger);
}

.dot-cyan {
  background: var(--cyan);
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.2;
  }
}

.panel-portrait {
  width: 100px;
  height: 100px;
  margin: 0 auto 12px;
  border-radius: 50%;
  padding: 3px;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent));
  box-shadow: 0 0 25px rgba(139, 92, 246, 0.2);
}

#panelTym .panel-portrait {
  background: conic-gradient(from 0deg, var(--cyan), #38bdf8, var(--cyan));
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.2);
}

.panel-portrait img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(8, 8, 20, 0.95);
}

.dossier-panel h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.panel-id {
  font-family: 'Courier New', monospace;
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.panel-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 8px;
  text-align: left;
}

.panel-loc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.panel-loc strong {
  color: var(--accent-2);
}

.panel-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}

.tag {
  padding: 2px 10px;
  font-size: 0.55rem;
  font-weight: 700;
  border-radius: 100px;
  border: 1px solid;
}

.tag-red {
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.25);
  background: rgba(244, 63, 94, 0.08);
}

.tag-amber {
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.08);
}

.tag-purple {
  color: var(--accent);
  border-color: rgba(139, 92, 246, 0.25);
  background: rgba(139, 92, 246, 0.08);
}

.tag-cyan {
  color: var(--cyan);
  border-color: rgba(6, 182, 212, 0.25);
  background: rgba(6, 182, 212, 0.08);
}

/* ============================================
   TIMELINE OVERLAY
   ============================================ */
.timeline-overlay {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  width: min(600px, 90vw);
  background: var(--surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  pointer-events: all;
  transition: opacity 0.5s, transform 0.5s;
}

.timeline-overlay.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(20px);
  pointer-events: none;
}

.tl-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 14px;
}

.tl-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tl-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  align-items: baseline;
}

.tl-item time {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.tl-item.warn time {
  color: var(--amber);
}

.tl-item.danger time {
  color: var(--danger);
}

.tl-item.info time {
  color: var(--cyan);
}

.tl-item.accent time {
  color: var(--accent-2);
}

.tl-item p {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.tl-note {
  margin-top: 12px;
  font-size: 0.6rem;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
}

/* ============================================
   NAV BUTTONS
   ============================================ */
.nav-buttons {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: all;
  transition: opacity 0.4s;
}

.nav-buttons.hidden {
  opacity: 0;
  pointer-events: none;
}

.nav-btn {
  width: 40px;
  height: 40px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s, border-color 0.3s, color 0.3s;
}

.nav-btn:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
  color: var(--accent-2);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .dossier-panel {
    width: 240px;
    padding: 14px;
  }

  #panelMonk {
    left: 2%;
  }

  #panelTym {
    right: 2%;
  }

  .panel-portrait {
    width: 80px;
    height: 80px;
  }

  .dossier-panel h3 {
    font-size: 1.1rem;
  }

  .timeline-overlay {
    padding: 14px 16px;
  }
}

@media (max-width: 500px) {
  .dossier-panel {
    width: 200px;
    padding: 12px;
  }

  .panel-desc {
    font-size: 0.65rem;
  }
}