:root {
  --ink: #140d33;
  --glass: rgba(20, 13, 51, 0.74);
  --glass-strong: rgba(20, 13, 51, 0.88);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f6f4ff;
  --muted: #c1b9e6;
  --purple: #7900e0;
  --violet: #9b4dff;
  --orange: #ff8a1f;
  --blue: #3d4ed8;
  --radius: 16px;
  --font: "Readex Pro", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene.dragging { cursor: grabbing; }

button { font-family: inherit; }

/* ---------- 3D labels ---------- */
.labels { position: fixed; inset: 0; pointer-events: none; }

.zlabel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 14px 8px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
  transition: opacity 0.2s;
}
.zlabel b { font-weight: 600; font-size: 14px; letter-spacing: 0.01em; }
.zlabel span { font-size: 11px; color: var(--muted); }
.zlabel i {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; margin-right: 6px; vertical-align: 1px;
}

.plabel {
  position: relative;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(20, 13, 51, 0.62);
  font-size: 11px;
  white-space: nowrap;
  color: #fff;
}
.plabel.me { background: var(--purple); font-weight: 600; }
.plabel.npc { background: linear-gradient(90deg, var(--purple), var(--blue)); font-weight: 500; }
.plabel .emote {
  position: absolute;
  left: 50%;
  bottom: 120%;
  transform: translate(-50%, 6px) scale(0.6);
  font-size: 22px;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
}
.plabel .emote.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* ---------- brand ---------- */
.brand {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 5;
}
.brand .logo { width: 34px; height: 22px; }
.brand strong { display: block; font-weight: 600; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; }
.brand span { display: block; font-size: 11px; color: var(--muted); }

/* ---------- right HUD ---------- */
.hud-right {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  z-index: 5;
}
.minimap-card {
  padding: 8px;
  border-radius: var(--radius);
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
#minimap { width: 150px; height: 150px; display: block; cursor: pointer; }
.mm-zone { margin-top: 6px; font-size: 12px; text-align: center; color: var(--muted); }

.hud-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.15s, transform 0.15s;
}
.chip:hover { background: var(--glass-strong); }
.chip:active { transform: scale(0.97); }
.chip.accent { background: linear-gradient(90deg, var(--purple), var(--blue)); border-color: transparent; font-weight: 500; }
.chip.ghost { background: transparent; }
.chip:focus-visible, .enter:focus-visible, .btn:focus-visible, .prompt:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.places {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: var(--radius);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  min-width: 220px;
}
.places[hidden] { display: none; }
.places button {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}
.places button:hover, .places button:focus-visible { background: rgba(255, 255, 255, 0.08); outline: none; }
.places i { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* ---------- hint / prompt / toast ---------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  transition: opacity 0.6s;
  pointer-events: none;
  z-index: 4;
}
.hint kbd {
  font-family: inherit;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--text);
}
.hint.gone { opacity: 0; }

.prompt {
  position: absolute;
  left: 50%;
  bottom: 74px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  border: 0;
  background: linear-gradient(90deg, var(--purple), var(--blue));
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(121, 0, 224, 0.45);
  z-index: 6;
  animation: pop 0.25s ease-out;
}

.toast {
  position: absolute;
  top: 78px;
  left: 50%;
  transform: translate(-50%, -10px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 8;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- panel ---------- */
.panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 370px;
  max-height: calc(100% - 290px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 20px 18px;
  border-radius: 20px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  z-index: 7;
  animation: slide 0.3s ease-out;
}
.panel[hidden] { display: none; }
.panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.kicker {
  margin: 0 0 4px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orange);
}
.panel h2 { margin: 0 36px 10px 0; font-size: 22px; font-weight: 600; line-height: 1.2; }
.pbody { font-size: 14px; line-height: 1.55; color: #e6e1fb; overflow-y: auto; min-height: 0; flex: 1 1 auto; overscroll-behavior: contain; }
.pbody::-webkit-scrollbar { width: 6px; }
.pbody::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 3px; }
.pbody p { margin: 0 0 10px; }
.pbody ul { margin: 0 0 10px; padding-left: 18px; }
.pbody li { margin-bottom: 3px; }
.pbody .muted { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.chips span {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; flex: none; }
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn.primary { background: linear-gradient(90deg, var(--purple), var(--blue)); border-color: transparent; font-weight: 500; }
.btn.primary:hover { filter: brightness(1.1); }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg {
  max-width: 88%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  animation: pop 0.2s ease-out;
}
.msg.bot { align-self: flex-start; background: rgba(155, 77, 255, 0.22); border-bottom-left-radius: 4px; }
.msg.user { align-self: flex-end; background: rgba(255, 138, 31, 0.22); border-bottom-right-radius: 4px; }
.msg.typing { display: flex; gap: 4px; padding: 12px 14px; }
.msg.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.msg.typing i:nth-child(2) { animation-delay: 0.15s; }
.msg.typing i:nth-child(3) { animation-delay: 0.3s; }

/* ---------- tour bar ---------- */
.tourbar {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  font-size: 13px;
  z-index: 6;
  white-space: nowrap;
}
.tourbar[hidden] { display: none; }

/* ---------- joystick ---------- */
.joy {
  position: absolute;
  left: 22px;
  bottom: max(26px, env(safe-area-inset-bottom));
  width: 116px;
  height: 116px;
  border-radius: 50%;
  background: rgba(20, 13, 51, 0.45);
  border: 1px solid var(--line);
  touch-action: none;
  z-index: 6;
}
.joy[hidden] { display: none; }
.joy .knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.fade { position: absolute; inset: 0; background: #0b0720; opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 9; }
.fade.on { opacity: 1; }

/* ---------- intro ---------- */
.intro {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(1200px 700px at 30% 20%, rgba(121, 0, 224, 0.35), transparent 60%),
    linear-gradient(180deg, rgba(11, 7, 32, 0.55), rgba(11, 7, 32, 0.82));
  z-index: 10;
  transition: opacity 0.7s;
}
.intro.out { opacity: 0; pointer-events: none; }
.intro-card { max-width: 560px; width: 100%; }
.eyebrow { margin: 0 0 10px; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--orange); }
.intro h1 { margin: 0 0 14px; font-size: clamp(32px, 6vw, 54px); line-height: 1.05; font-weight: 600; }
.intro h1 em {
  font-style: normal;
  background: linear-gradient(90deg, #ffb066, var(--violet) 55%, #7f8cff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { margin: 0 0 18px; font-size: 16px; line-height: 1.6; color: #ddd6fb; }
.controls {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.controls li {
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.controls b { display: block; color: var(--text); font-weight: 500; }
.enter {
  appearance: none;
  border: 0;
  padding: 15px 28px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, var(--orange), var(--purple) 60%, var(--blue));
  box-shadow: 0 14px 40px rgba(121, 0, 224, 0.45);
  cursor: pointer;
  transition: transform 0.15s, filter 0.15s;
}
.enter:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.08); }
.enter:disabled { opacity: 0.6; cursor: progress; }
.fine { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

@keyframes pop { from { opacity: 0; transform: translateX(-50%) scale(0.92); } }
.msg { animation-name: msgin; }
@keyframes msgin { from { opacity: 0; transform: translateY(4px); } }
@keyframes slide { from { opacity: 0; transform: translateY(12px); } }
@keyframes blink { 50% { opacity: 0.3; } }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .brand { padding: 6px 12px 6px 8px; }
  .brand span { display: none; }
  #minimap { width: 96px; height: 96px; }
  .mm-zone { display: none; }
  .hud-actions { flex-direction: column; align-items: flex-end; }
  .chip { padding: 7px 12px; font-size: 12px; }
  .panel {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-height: 52%;
    padding: 16px;
  }
  .panel h2 { font-size: 19px; }
  .hint { display: none; }
  .tourbar { bottom: auto; top: 64px; }
  .prompt { bottom: 160px; }
  .toast { top: 64px; left: 16px; right: 136px; transform: translateY(-10px); text-align: left; max-width: none; }
  .toast.show { transform: translateY(0); }
  body.panel-open .joy { bottom: calc(var(--panel-h, 0px) + 22px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* showroom stand labels + back-to-site link (VolareVerse) */
.plabel.stand {
  display: grid;
  gap: 1px;
  text-align: center;
  padding: 5px 12px;
  border-radius: 12px;
  background: rgba(20, 13, 51, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 138, 31, 0.6);
}
.plabel.stand b { font-size: 12px; font-weight: 600; }
.plabel.stand span { font-size: 10px; color: #d6ccff; }
.brand .back {
  display: inline-block;
  margin-top: 2px;
  font-size: 11px;
  color: #ffb066;
  text-decoration: none;
  pointer-events: auto;
}
.brand .back:hover { text-decoration: underline; }
.intro .fine a { color: #ffb066; }
