:root {
  --bg: #0a0a0a;
  --fg: #ffffff;
  --muted: rgba(255, 255, 255, 0.6);
  --accent: #ffffff;
  --panel: rgba(18, 18, 22, 0.72);
  --panel-strong: rgba(18, 18, 22, 0.92);
  --border: rgba(255, 255, 255, 0.1);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
a-scene,
a-scene canvas {
  touch-action: manipulation;
}

#loader {
  position: fixed;
  inset: 0;
  background: #0a0a0a;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
#loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loader-inner { display: flex; align-items: center; justify-content: center; }
.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-top-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#hud {
  display: none;
  position: fixed;
  top: 20px;
  left: 24px;
  z-index: 50;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
  opacity: 0;
  animation: hudFade 0.6s ease forwards;
}
#room-title {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
}
@keyframes hudFade {
  to { opacity: 1; }
}

#tooltip {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translate(-50%, 6px);
  z-index: 55;
  padding: 6px 12px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--fg);
  font-size: 12px;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: nowrap;
  max-width: 60vw;
  text-align: center;
}
#tooltip.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

#menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  width: 40px;
  height: 40px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: background 0.2s ease, transform 0.15s ease;
}
#menu-toggle:hover {
  background: var(--panel-strong);
  transform: translateY(-1px);
}
#menu-toggle:active { transform: translateY(0); }

#rooms-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: var(--panel-strong);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border-left: 1px solid var(--border);
  z-index: 65;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -20px 0 40px -12px rgba(0, 0, 0, 0.6);
}
#rooms-panel.closed {
  transform: translateX(100%);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
#panel-close {
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
#panel-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  border-color: var(--border);
}
#rooms-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.room-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  text-align: left;
  width: 100%;
}
.room-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}
.room-btn.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}
.room-btn img {
  width: 72px;
  height: 42px;
  object-fit: cover;
  border-radius: 5px;
  background: #1a1a1e;
  flex: 0 0 auto;
}
.room-btn span { letter-spacing: 0.02em; }

#panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 62;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
#panel-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

#controls {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  gap: 4px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.5);
}
#controls button {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
#controls button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
}
#controls button.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--fg);
}

#controls button[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  #hud { top: 14px; left: 16px; }
  #room-title { font-size: 13px; }
  #menu-toggle { top: 12px; right: 12px; width: 36px; height: 36px; }
  #controls { bottom: 14px; padding: 4px; }
  #controls button { width: 32px; height: 32px; }
  #tooltip { bottom: 72px; font-size: 11px; padding: 5px 10px; }

  #ctrl-fullscreen { display: none !important; }
}

@media (pointer: coarse) {
  #ctrl-fullscreen { display: none !important; }
}

a-scene canvas { cursor: grab; }
a-scene canvas:active { cursor: grabbing; }

#editor-panel {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 300px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  z-index: 90;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.7);
  color: var(--fg);
  font-size: 13px;
}
#editor-panel[hidden] { display: none !important; }

.ed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.ed-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}
.ed-close {
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.ed-close:hover { background: rgba(255, 255, 255, 0.06); color: var(--fg); }

.ed-section {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.ed-section:last-child { border-bottom: none; }

.ed-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.ed-sub {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

#editor-panel select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
}
#editor-panel select:focus { outline: 1px solid rgba(255, 255, 255, 0.3); }

#ed-hotspot-list {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  max-height: 160px;
  overflow-y: auto;
}
#ed-hotspot-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 12px;
}
#ed-hotspot-list li .ed-actions {
  display: flex;
  gap: 4px;
}
#ed-hotspot-list li .mv,
#ed-hotspot-list li .rm {
  width: 22px;
  height: 22px;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#ed-hotspot-list li .mv {
  border: 1px solid rgba(255, 210, 122, 0.3);
  color: #ffd27a;
}
#ed-hotspot-list li .mv:hover { background: rgba(255, 210, 122, 0.15); }
#ed-hotspot-list li .rm {
  border: 1px solid rgba(255, 100, 100, 0.3);
  color: #ff9b9b;
}
#ed-hotspot-list li .rm:hover { background: rgba(255, 100, 100, 0.15); }
#ed-hotspot-list li.moving {
  background: rgba(255, 210, 122, 0.12);
  border-color: rgba(255, 210, 122, 0.4);
}
#ed-hotspot-list li.empty {
  color: var(--muted);
  font-style: italic;
  justify-content: center;
  background: transparent;
}

.ed-btn {
  width: 100%;
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-top: 4px;
}
.ed-btn:hover { background: rgba(255, 255, 255, 0.1); }
.ed-btn-primary {
  background: rgba(255, 255, 255, 0.9);
  color: #0a0a0a;
  border-color: rgba(255, 255, 255, 0.9);
}
.ed-btn-primary:hover { background: #ffffff; }
.ed-btn-danger { color: #ff9b9b; border-color: rgba(255, 100, 100, 0.25); }
.ed-btn-danger:hover { background: rgba(255, 100, 100, 0.12); }

.ed-hint {
  font-size: 11px;
  color: rgba(255, 210, 122, 0.9);
  padding: 8px 10px;
  background: rgba(255, 210, 122, 0.08);
  border: 1px solid rgba(255, 210, 122, 0.2);
  border-radius: 6px;
  margin: 8px 0;
  text-align: center;
}

body.ed-awaiting-click a-scene canvas {
  cursor: crosshair !important;
}


#vr-info-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 20px;
  animation: vrInfoFade 0.25s ease;
}
#vr-info-modal.hidden { display: none; }
.vr-info-inner {
  max-width: 380px;
  width: 100%;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px 22px;
  color: var(--fg);
  text-align: center;
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(26px) saturate(1.3);
  -webkit-backdrop-filter: blur(26px) saturate(1.3);
}
.vr-info-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  color: var(--fg);
}
.vr-info-inner h3 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.vr-info-inner p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
}
.vr-info-hint {
  font-size: 12px !important;
  color: rgba(255, 255, 255, 0.5) !important;
  margin-top: 14px !important;
}
.vr-info-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.vr-info-actions button {
  flex: 1;
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 11px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.vr-info-actions .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
}
.vr-info-actions .btn-primary {
  background: rgba(255, 255, 255, 0.9);
  color: #0a0a0a;
  border-color: rgba(255, 255, 255, 0.9);
}
.vr-info-actions .btn-primary:hover {
  background: #ffffff;
}
.vr-info-actions button:active { transform: scale(0.97); }

@keyframes vrInfoFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.a-enter-vr,
.a-enter-ar,
.a-enter-vr-button,
.a-enter-ar-button,
.a-orientation-modal { display: none !important; }

.a-enter-vr,
.a-enter-ar,
.a-enter-vr-button,
.a-enter-ar-button,
.a-orientation-modal { display: none !important; }
