:root {
  --primary-color: #1a1a1a;
  --bg-color: #f7f7f7;
  --font-main: 'FKGrotesk', 'Inter', sans-serif;
  --room-w: 2000px;
  --room-h: 1000px;
  --room-d: 12000px;
  --panel-w: 600px;
  --panel-h: 700px;
  
  /* NEST Brand Colors */
  --nest-green: #d1fe01;
  --nest-dark: #27272c;
  --nest-glass-dark: rgba(39, 39, 44, 0.7);
}

@font-face {
  font-family: 'FKGrotesk';
  src: url('fonts/FKGrotesk-Regular.woff2') format('woff2');
  font-weight: normal;
}

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

body {
  width: 100vw; height: 100vh;
  overflow: hidden;
  background: #000;
  font-family: var(--font-main);
  /* cursor will be managed by pointer lock */
}

body.mobile-mode {
  touch-action: none;
}

/* WebGL Canvas */
#webgl-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 1; /* Behind UI overlay */
  touch-action: none;
}

/* UI Branding */
.overlay {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 1000;
}
.branding {
  position: absolute; top: 40px; left: 40px; width: 100px;
  background: rgba(255,255,255,0.32);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.65);
  padding: 15px; border-radius: 10px;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}

.branding img {
  width: 100%;
  height: auto;
  display: block;
}

/* Glassmorphism Utilities */
.glass-panel {
  background: var(--nest-glass-dark);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  color: #fff;
  pointer-events: auto;
}

/* Hamburger Menu */
.hamburger-menu {
  position: absolute;
  top: 40px;
  right: 40px;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  z-index: 1002;
  transition: background 0.3s;
}
.hamburger-menu:hover { background: rgba(255, 255, 255, 0.1); }
.hamburger-menu span {
  display: block; width: 24px; height: 2px;
  background: #fff; border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s, background 0.3s;
}
.hamburger-menu:hover span, .hamburger-menu.active span {
  background: var(--nest-green);
}
.hamburger-menu.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.hamburger-menu.active span:nth-child(2) { opacity: 0; }
.hamburger-menu.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* Bottom Action Bar */
.bottom-action-bar {
  position: absolute;
  bottom: 40px; left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 15px 30px;
  border-radius: 50px;
  min-width: 600px;
  justify-content: space-between;
}
.legend-hint {
  font-size: 0.75rem; letter-spacing: 1px;
  opacity: 0.8; font-weight: 700; white-space: nowrap;
}
.minimap-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 90px;
  height: 90px;
}
.minimap-radar {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background:
    radial-gradient(circle at center, rgba(209, 254, 1, 0.14) 0%, rgba(209, 254, 1, 0) 62%),
    conic-gradient(from 0deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02), rgba(255,255,255,0.1));
  box-shadow: inset 0 0 16px rgba(209, 254, 1, 0.15);
  position: relative;
  overflow: hidden;
}
.minimap-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  background: var(--nest-green); border-radius: 50%;
  box-shadow: 0 0 10px var(--nest-green);
  transition: transform 0.1s linear;
}
.action-controls {
  display: flex; gap: 15px;
}
.action-btn {
  background: transparent; border: none;
  color: #fff; cursor: pointer;
  opacity: 0.6; transition: opacity 0.3s, transform 0.3s, color 0.3s;
  display: flex; align-items: center; justify-content: center;
}
.action-btn:hover { opacity: 1; transform: scale(1.1); color: var(--nest-green); }
.action-btn.active { color: var(--nest-green); opacity: 1; }
.action-btn .icon-pause { display: none; }
.action-btn.is-paused .icon-play { display: none; }
.action-btn.is-paused .icon-pause { display: inline; }

.mobile-controls {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}

.mobile-move-zone {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(100px, calc(env(safe-area-inset-bottom) + 90px));
  width: 148px;
  height: 148px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.mobile-joystick-base {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.18);
  background: radial-gradient(circle at center, rgba(209,254,1,0.14), rgba(255,255,255,0.04));
  box-shadow: inset 0 0 20px rgba(209,254,1,0.12);
  position: relative;
}

.mobile-joystick-knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(209,254,1,0.9);
  box-shadow: 0 0 22px rgba(209,254,1,0.28);
}

.mobile-look-zone {
  position: absolute;
  right: 0;
  top: 120px;
  bottom: 120px;
  width: 48vw;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.mobile-look-indicator {
  margin-bottom: 140px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(39,39,44,0.4);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.72);
  font-size: 0.7rem;
  letter-spacing: 1.4px;
  pointer-events: none;
}

/* Cinematic Fade Layer */
.cinematic-fade {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.75s ease-in-out;
}
.cinematic-fade.active {
  opacity: 1;
  pointer-events: auto;
}

.crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,0.85);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(209, 254, 1, 0.45);
  z-index: 998;
  pointer-events: none;
}

.crosshair::before,
.crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.85);
}

.crosshair::before {
  width: 1px;
  height: 22px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.crosshair::after {
  width: 22px;
  height: 1px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Lightbox Styles */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  box-shadow: 0 20px 80px rgba(0,0,0,0.8);
  border: 5px solid #fff;
  border-radius: 4px;
}

.lightbox-close {
  position: absolute;
  top: 30px;
  right: 40px;
  color: #fff;
  font-size: 50px;
  font-weight: 300;
  cursor: pointer;
  z-index: 2001;
  line-height: 1;
  transition: color 0.2s;
}

.lightbox-close:hover {
  color: #ccc;
}

.pause-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.42);
  z-index: 2100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.pause-menu-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.pause-menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 28px));
  padding: 26px;
  border-radius: 18px;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.42);
  display: grid;
  gap: 12px;
}

.pause-menu h2 {
  color: #fff;
  font-size: 1.2rem;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.pause-menu-btn {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  background: rgba(39,39,44,0.72);
  color: #fff;
  padding: 12px;
  font-family: var(--font-main);
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, color 0.2s;
}

.pause-menu-btn:hover {
  transform: translateY(-1px);
  color: var(--nest-green);
  border-color: rgba(209,254,1,0.52);
}

.corner-meta {
  position: fixed;
  bottom: 10px;
  z-index: 1200;
  color: rgba(255,255,255,0.52);
  font-size: 11px;
  letter-spacing: 0.5px;
  pointer-events: none;
}

.corner-left {
  left: 14px;
}

.corner-right {
  right: 14px;
  text-align: right;
}

.local-protocol-warning {
  position: fixed;
  inset: 0;
  z-index: 2500;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  place-items: center;
  padding: 20px;
}

.local-protocol-warning.visible {
  display: grid;
}

.local-warning-card {
  max-width: 640px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 14px;
  color: #fff;
  padding: 22px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.local-warning-card h3 {
  color: var(--nest-green);
  margin-bottom: 10px;
}

.local-warning-card p {
  margin-top: 8px;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .bottom-action-bar {
    min-width: 0;
    width: calc(100vw - 24px);
    bottom: 12px;
    padding: 10px 14px;
    gap: 12px;
  }

  .legend-hint {
    display: none;
  }

  .minimap-container {
    width: 64px;
    height: 64px;
  }

  .minimap-radar {
    width: 58px;
    height: 58px;
  }

  .corner-meta {
    font-size: 10px;
    bottom: 8px;
  }
}

body.mobile-mode .mobile-controls {
  display: block;
}

body.mobile-mode .crosshair {
  display: none;
}

body.mobile-mode .legend-hint {
  display: none;
}

body.mobile-mode .pause-menu-btn#pause-exit-look {
  display: none;
}

body.mobile-mode .bottom-action-bar {
  width: min(480px, calc(100vw - 24px));
  bottom: max(12px, env(safe-area-inset-bottom));
}
