:root {
  --glass: rgba(16, 18, 24, 0.72);
  --glass-strong: rgba(14, 16, 22, 0.90);
  --glass-border: rgba(255, 255, 255, 0.10);
  --hover: rgba(255, 255, 255, 0.09);
  --text: #f5f6f8;
  --text-2: rgba(245, 246, 248, 0.70);
  --text-3: rgba(245, 246, 248, 0.45);
  --accent: #0050e8;
  --accent-ink: #ffffff;
  --accent-text: #6ea2ff; /* HV blue lightened, for accent text on the dark panels */
  --ok: #5ee08f;
  --warn: #8fb8ff;
  --bad: #ff7a6b;
  --edge: 16px;
  --r-panel: 14px;
  --r-ctl: 9px;
  --shadow: 0 16px 36px -14px rgba(0, 0, 0, 0.72), 0 2px 8px rgba(0, 0, 0, 0.28);
  --font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0c10;
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 5px;
  font-family: var(--font);
  font-size: 10.5px;
  font-weight: 650;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
}

#canvas-container:active {
  cursor: grabbing;
}

.panel {
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow);
}

/* Loading Screen */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: radial-gradient(110% 85% at 50% 40%, #171b24 0%, #0b0d12 60%, #06070a 100%);
}

.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px;
}

.loader-badge, .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent-ink);
  font-weight: 800;
}

.hv-mark {
  width: 70%;
  height: auto;
  display: block;
}

.loader-badge {
  width: 52px;
  height: 52px;
  font-size: 18px;
  margin-bottom: 18px;
}

.badge {
  width: 28px;
  height: 28px;
  font-size: 11px;
  flex: none;
}

.loader-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.loader-world-name {
  margin-top: 5px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--accent-text);
  letter-spacing: 0.01em;
  min-height: 20px;
}

.loader-track {
  position: relative;
  width: 240px;
  height: 4px;
  margin: 22px 0 12px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.loader-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0.05);
}

#loading-status {
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

/* HUD Positions */
.hud {
  position: fixed;
  z-index: 10;
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.hud-top-left {
  top: max(var(--edge), env(safe-area-inset-top));
  left: max(var(--edge), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.hud-top-right {
  top: max(var(--edge), env(safe-area-inset-top));
  right: max(var(--edge), env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.hud-bottom-left {
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  left: max(var(--edge), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.hud-bottom-center {
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hud-top-center {
  top: max(var(--edge), env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
}

/* Brand & Stats */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
}

.brand-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-titles h1 {
  font-size: 14px;
  font-weight: 700;
}

.brand-world-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  white-space: nowrap;
}

.stream-badge {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(0, 80, 232, 0.24);
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}

.brand-subtitle {
  font-size: 11.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

#hud-fps.fps-ok { color: var(--ok); font-weight: 650; }
#hud-fps.fps-warn { color: var(--warn); font-weight: 650; }
#hud-fps.fps-bad { color: var(--bad); font-weight: 650; }

.stats-panel {
  padding: 10px 13px;
  min-width: 235px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--text-2);
}

.stats-row strong {
  color: var(--text);
  font-weight: 600;
}

/* Toolbar & Floor Buttons */
.toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  flex-wrap: wrap;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  margin: 0 3px;
  background: rgba(255, 255, 255, 0.12);
}

.floor-switch {
  display: flex;
  gap: 3px;
}

.tool-btn, .floor-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r-ctl);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
}

.tool-btn:hover, .floor-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.floor-btn.active, .tool-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.floor-btn.active kbd, .tool-btn.active kbd {
  background: rgba(0, 0, 0, 0.18);
  color: var(--accent-ink);
  box-shadow: none;
}

/* Places & Settings Panels */
.places-panel {
  width: min(324px, calc(100vw - 16px));
  padding: 12px;
  background: var(--glass-strong);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.places-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: min(66vh, 440px);
  overflow-y: auto;
  padding-right: 2px;
}

.places-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 3px;
  font-size: 10.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.places-group-header:first-child {
  padding-top: 2px;
}

.places-group-count {
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-2);
}

.place-thumb {
  width: 52px;
  height: 34px;
  border-radius: 6px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  flex: none;
}

.place-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--r-ctl);
  text-align: left;
  transition: background 0.15s ease;
}

.place-item:hover {
  background: var(--hover);
}

.place-kind {
  font-size: 9.5px;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--accent);
  color: var(--accent-ink);
  flex: none;
}

.place-kind.kind-photo360 { background: #38e2ff; color: #091d26; }
.place-kind.kind-video { background: #ff5a4f; color: #240908; }

.place-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.place-info strong {
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.place-info small {
  font-size: 11px;
  color: var(--text-3);
}

.interact-prompt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 650;
  color: var(--accent-text);
  border-color: rgba(0, 80, 232, 0.55);
}

.photo360-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--glass-strong);
}

.photo360-hint {
  font-size: 11.5px;
  color: var(--text-2);
}

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  background: rgba(6, 8, 12, 0.86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 20px;
}

.video-card {
  width: min(860px, 94vw);
  padding: 14px;
  background: var(--glass-strong);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.video-player {
  width: 100%;
  aspect-ratio: 16 / 9;   /* its full size before the clip's first bytes arrive */
  max-height: 75vh;
  border-radius: 10px;
  background: #000;
}

/* Settings Panel */
.settings-panel {
  width: 268px;
  padding: 14px;
  background: var(--glass-strong);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-header h2 {
  font-size: 14px;
  font-weight: 700;
}

.icon-close {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  color: var(--text-2);
}

.icon-close:hover {
  background: var(--hover);
  color: var(--text);
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-2);
}

.setting-item > span {
  display: flex;
  justify-content: space-between;
}

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

.setting-item input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

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

.setting-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.setting-select {
  background: rgba(255, 255, 255, 0.10);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 3px 8px;
  font: inherit;
  font-size: 11.5px;
}

.action-btn {
  width: 100%;
  height: 34px;
  border-radius: var(--r-ctl);
  background: rgba(255, 255, 255, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Minimap */
.minimap-label-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 650;
}

.minimap-card {
  width: 176px;
  height: 176px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

#minimap-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Controls Card */
.controls-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.controls-card.faded {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Touch Controls */
.touch-controls {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.touch-left {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(22px, env(safe-area-inset-bottom));
  pointer-events: auto;
}

.touch-stick {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(16, 18, 24, 0.55);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  touch-action: none;
}

.touch-stick-ring {
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.16);
}

.touch-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 50%;
  background: rgba(0, 80, 232, 0.9);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transform: translate(var(--stick-x, 0px), var(--stick-y, 0px));
}

.touch-look-zone {
  position: absolute;
  right: 0;
  top: 64px;
  bottom: 0;
  width: 56%;
  pointer-events: auto;
  touch-action: none;
}

.touch-right {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(26px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
  z-index: 2;
}

.touch-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: rgba(18, 20, 28, 0.72);
  border: 1.5px solid rgba(255, 255, 255, 0.20);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  touch-action: none;
}

.touch-btn.is-pressed, .touch-btn[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* Full Map Modal */
.fullmap-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 10, 14, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.fullmap-wrap {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

#fullmap-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.fullmap-top {
  position: absolute;
  top: max(var(--edge), env(safe-area-inset-top));
  left: max(var(--edge), env(safe-area-inset-left));
  right: max(var(--edge), env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  pointer-events: none;
}

.fullmap-top > * {
  pointer-events: auto;
}

.fullmap-header-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
}

.fullmap-header-bar h2 {
  font-size: 14.5px;
  font-weight: 700;
}

.fullmap-sub {
  font-size: 11.5px;
  color: var(--text-2);
}

.fullmap-floors, .fullmap-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
}

/* Mobile / 390pt viewport layout */
@media (max-width: 640px) {
  :root {
    --edge: 8px;
  }

  .brand,
  .controls-card,
  .toolbar-divider,
  kbd {
    display: none;
  }

  .hud-top-right {
    left: max(var(--edge), env(safe-area-inset-left));
    right: max(var(--edge), env(safe-area-inset-right));
    align-items: stretch;
  }

  .toolbar {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 2px;
    padding: 4px;
  }

  .toolbar::-webkit-scrollbar {
    display: none;
  }

  /* The floor buttons' group must not shrink inside the scrolling toolbar, or Floor 3 is drawn over Places. */
  .floor-switch {
    flex: none;
  }

  .tool-btn, .floor-btn {
    height: 27px;
    padding: 0 6px;
    font-size: 11px;
    flex: none;
  }

  .hud-top-left {
    top: 48px;
  }

  .hud-bottom-left {
    top: 48px;
    bottom: auto;
  }

  .minimap-card {
    width: 96px;
    height: 96px;
  }

  .minimap-label-bar {
    padding: 3px 7px;
    font-size: 10px;
  }

  .touch-stick {
    width: 104px;
    height: 104px;
  }

  .touch-btn {
    width: 60px;
    height: 60px;
    font-size: 12px;
  }
}
