@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600&display=swap');

:root {
  /* Calm, Modern & Elegant Palette */
  --bg-primary: #0d1117;
  --bg-surface: #141923;
  --bg-glass: rgba(18, 23, 33, 0.75);
  --bg-glass-card: rgba(24, 31, 45, 0.68);
  --bg-glass-hover: rgba(35, 45, 66, 0.85);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-active: rgba(255, 255, 255, 0.22);
  
  /* Refined, Calm Accents */
  --accent-primary: #e2e8f0;
  --accent-secondary: #94a3b8;
  --accent-highlight: #38bdf8;
  --accent-warm: #fbbf24;
  --accent-sage: #34d399;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --blur-amount: 20px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-panel: 0 16px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Plus Jakarta Sans', sans-serif;
  touch-action: none;
}

#canvas-container {
  width: 100vw;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* ==========================================================================
   Loading Screen (Calm & Minimal)
   ========================================================================== */
#loader-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, #161c28 0%, #0a0d13 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.7s;
}

#loader-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 420px;
  padding: 32px;
}

.loader-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  color: var(--accent-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 20px;
}

.loader-title {
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.loader-subtitle {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 32px;
  line-height: 1.5;
}

.loader-progress-container {
  width: 100%;
  margin-bottom: 16px;
}

.loader-bar-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.loader-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #94a3b8, #e2e8f0);
  border-radius: 999px;
  transition: width 0.25s ease-out;
}

.loader-stats {
  display: flex;
  justify-content: space-between;
  width: 100%;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-family: 'Space Grotesk', monospace;
  margin-top: 10px;
}

.loader-spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 1.2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  margin-top: 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   UI Layer Overlay
   ========================================================================== */
#ui-container {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
}

/* Header Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  pointer-events: auto;
}

.app-branding {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
}

.brand-info h1 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.brand-info span {
  font-size: 0.72rem;
  color: var(--accent-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-info span::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--accent-sage);
  border-radius: 50%;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Glass Buttons */
.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--bg-glass-card);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-soft);
}

.glass-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass-active);
  transform: translateY(-1px);
}

.glass-btn:active {
  transform: translateY(0);
}

.glass-btn.icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}

.glass-btn.active {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.35);
  color: #ffffff;
}

.glass-btn.primary {
  background: #f1f5f9;
  border: none;
  color: #0f172a;
  font-weight: 600;
}

.glass-btn.primary:hover {
  background: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   Control Mode Segment Switcher (Orbit / FPS / God Mode)
   ========================================================================== */
.mode-switcher-container {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
}

.segmented-control {
  display: flex;
  background: var(--bg-glass);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 4px;
  gap: 3px;
  box-shadow: var(--shadow-panel);
}

.segment-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.segment-btn:hover {
  color: var(--text-primary);
}

.segment-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  font-weight: 600;
}

.segment-btn svg {
  width: 16px;
  height: 16px;
}

/* God Mode Glow Badge */
.segment-btn.god-mode.active {
  background: rgba(251, 191, 36, 0.18);
  color: var(--accent-warm);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

/* ==========================================================================
   Center Crosshair / Pointer Lock Indicator
   ========================================================================== */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  pointer-events: none;
  z-index: 5;
  display: none;
  opacity: 0.75;
}

#crosshair::before, #crosshair::after {
  content: '';
  position: absolute;
  background: #ffffff;
  border-radius: 1px;
}

#crosshair::before {
  top: 4px;
  left: 0;
  width: 10px;
  height: 2px;
}

#crosshair::after {
  top: 0;
  left: 4px;
  width: 2px;
  height: 10px;
}

#crosshair.visible {
  display: block;
}

#crosshair.god {
  opacity: 0.9;
}

#crosshair.god::before, #crosshair.god::after {
  background: var(--accent-warm);
}

/* ==========================================================================
   Bottom Navigation / HUD Bar
   ========================================================================== */
.bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  pointer-events: none;
}

.hints-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  box-shadow: var(--shadow-panel);
  pointer-events: auto;
  max-width: 440px;
}

.hint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.hint-row:last-child {
  margin-bottom: 0;
}

.key-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: 'Space Grotesk', monospace;
  min-width: 22px;
}

.stats-card {
  background: var(--bg-glass);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  display: flex;
  gap: 14px;
  pointer-events: auto;
  font-family: 'Space Grotesk', monospace;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.stat-item strong {
  color: var(--text-primary);
}

/* ==========================================================================
   Mobile Virtual Controls (Joystick & Action Buttons)
   ========================================================================== */
#mobile-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  z-index: 15;
}

#joystick-zone {
  position: absolute;
  bottom: 35px;
  left: 25px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px dashed rgba(255, 255, 255, 0.12);
  pointer-events: auto;
  touch-action: none;
}

#joystick-stick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition: transform 0.05s ease-out;
}

#touch-look-zone {
  position: absolute;
  top: 90px;
  right: 0;
  bottom: 0;
  width: 50%;
  pointer-events: auto;
  touch-action: none;
}

.mobile-action-buttons {
  position: absolute;
  bottom: 35px;
  right: 25px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

.mobile-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg-glass-card);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
}

.mobile-btn:active {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(0.94);
}

/* ==========================================================================
   AR HUD & Guidance Overlay
   ========================================================================== */
#ar-hud {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px;
  z-index: 20;
  pointer-events: none;
}

#ar-hud.active {
  display: flex;
}

.ar-instructions {
  margin: 0 auto;
  padding: 10px 20px;
  background: rgba(15, 20, 30, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass-active);
  border-radius: 999px;
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.9rem;
  text-align: center;
  box-shadow: var(--shadow-panel);
  pointer-events: auto;
}

.ar-controls-bar {
  display: flex;
  justify-content: center;
  gap: 12px;
  width: 100%;
  pointer-events: auto;
}

/* ==========================================================================
   Settings Modal / Glass Drawer
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 90%;
  max-width: 440px;
  background: var(--bg-glass);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--border-glass-active);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: 24px 26px;
  transform: translateY(15px) scale(0.97);
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 10px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-label {
  font-size: 0.88rem;
  color: var(--text-primary);
  font-weight: 500;
}

.setting-sublabel {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Sliders & Toggles */
input[type="range"] {
  -webkit-appearance: none;
  width: 120px;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  cursor: pointer;
  transition: 0.25s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.25s;
}

input:checked + .toggle-slider {
  background: rgba(255, 255, 255, 0.35);
}

input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */
#toast {
  position: fixed;
  top: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: var(--bg-glass);
  backdrop-filter: blur(var(--blur-amount));
  -webkit-backdrop-filter: blur(var(--blur-amount));
  border: 1px solid var(--border-glass-active);
  padding: 10px 20px;
  border-radius: 999px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-panel);
  z-index: 9999;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

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

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 768px) {
  #ui-container {
    padding: 14px;
  }
  
  .mode-switcher-container {
    top: auto;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 380px;
  }
  
  .segmented-control {
    width: 100%;
    justify-content: space-around;
  }
  
  .segment-btn {
    padding: 6px 8px;
    font-size: 0.74rem;
    flex: 1;
    justify-content: center;
  }
  
  .hints-panel {
    display: none;
  }
  
  .stats-card {
    display: none;
  }
}
