/* =========================================================
   ESTILOS DEL LOBBY · SOFT 3D
   Superficies claras, esquinas muy redondeadas, sombras suaves.
   ========================================================= */
:root {
  --cream: #fff8f1;
  --cream-2: #fdeee2;
  --ink: #5b3f33;
  --ink-soft: #9a7b6c;
  --peach: #ffb38a;
  --peach-dark: #f08a5d;
  --lilac: #9b8cff;
  --panel: rgba(255, 248, 241, 0.86);
  --shadow: 0 10px 30px rgba(140, 90, 70, 0.18), 0 2px 6px rgba(140, 90, 70, 0.1);
  --inset: inset 0 2px 0 rgba(255, 255, 255, 0.9), inset 0 -3px 0 rgba(200, 150, 120, 0.18);
  --radius: 22px;
  --font: "Nunito", "Trebuchet MS", system-ui, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(#cfe9ff, #fde7ef);
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#renderCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
  cursor: grab;
  touch-action: none;
}
#renderCanvas.grabbing { cursor: grabbing; }
#renderCanvas.pointer { cursor: pointer; }

/* Panel suave reutilizable */
.hud-top, .menu, #hint, #tip, #near {
  background: var(--panel);
  box-shadow: var(--shadow), var(--inset);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ---------- Carga ---------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #cfe9ff, #fde7ef 60%, #ffe3cf);
  transition: opacity 0.8s ease, visibility 0.8s;
}
#loader.done { opacity: 0; visibility: hidden; }
.loader-box { text-align: center; }
.loader-box p { font-weight: 800; font-size: 1.1rem; margin-top: 18px; color: var(--ink-soft); }
.blob { display: flex; gap: 10px; justify-content: center; }
.blob span {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--peach);
  box-shadow: var(--inset), 0 6px 12px rgba(240, 138, 93, 0.35);
  animation: bounce 0.9s ease-in-out infinite;
}
.blob span:nth-child(2) { background: var(--lilac); animation-delay: 0.15s; }
.blob span:nth-child(3) { background: #8fd19e; animation-delay: 0.3s; }
@keyframes bounce { 50% { transform: translateY(-14px) scale(1.08); } }

/* ---------- Cabecera ---------- */
.hud-top {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 22px;
  border-radius: 999px;
  pointer-events: none;
}
.hud-top h1 { font-size: 1.2rem; font-weight: 900; }
.tag {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px;
  background: var(--peach); color: #fff;
  box-shadow: inset 0 -2px 0 var(--peach-dark), inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

/* ---------- Menú ---------- */
.menu {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 10;
  width: 240px;
  border-radius: var(--radius);
  overflow: hidden;
}
.menu summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 18px;
  font-weight: 900;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after {
  content: "▾";
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; background: var(--cream-2); color: var(--peach-dark);
  transition: transform 0.2s;
}
.menu details:not([open]) summary::after { transform: rotate(-90deg); }
.menu ul { list-style: none; padding: 0 10px 12px; display: grid; gap: 4px; }
.menu li { display: flex; align-items: center; gap: 4px; }
.menu .go {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border: 0; border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font: 700 0.95rem var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.menu .go:hover, .menu .go:focus-visible {
  background: #fff;
  box-shadow: 0 4px 10px rgba(140, 90, 70, 0.12);
  transform: translateY(-1px);
  outline: none;
}
.menu .num {
  width: 24px; height: 24px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--cream-2);
  font-size: 0.75rem; font-weight: 900; color: var(--peach-dark);
}
.menu .ic { width: 22px; text-align: center; }
.menu a {
  width: 32px; height: 32px; flex: none; display: grid; place-items: center;
  border-radius: 12px; color: var(--peach-dark); text-decoration: none; font-weight: 900;
}
.menu a:hover, .menu a:focus-visible { background: #fff; outline: none; }

/* ---------- Ayuda ---------- */
#hint {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-soft);
  transition: opacity 0.6s, transform 0.6s;
  pointer-events: none;
  white-space: nowrap;
}
#hint b { color: var(--ink); font-weight: 900; }
#hint.hidden { opacity: 0; transform: translate(-50%, 12px); }
.hint-desktop { display: flex; gap: 18px; align-items: center; }
.hint-touch { display: none; }
kbd {
  display: inline-block;
  min-width: 24px;
  padding: 2px 7px;
  margin-right: 3px;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: 900 0.75rem var(--font);
  text-align: center;
  box-shadow: 0 3px 0 #ecd3c3, 0 4px 8px rgba(140, 90, 70, 0.12);
}

/* ---------- Tooltip y aviso ---------- */
#tip {
  position: fixed;
  top: var(--ty, 50%);
  left: var(--tx, 50%);
  transform: translate(18px, 26px) scale(0.92);
  z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 18px 10px 10px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
#tip.show { opacity: 1; transform: translate(18px, 26px) scale(1); }
.tip-icon {
  font-size: 1.5rem;
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 14px; background: #fff;
  box-shadow: 0 3px 8px rgba(140, 90, 70, 0.12);
}
#tip strong { display: block; font-weight: 900; font-size: 1.05rem; }
#tip small { color: var(--peach-dark); font-size: 0.78rem; font-weight: 800; }

#near {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translate(-50%, 10px);
  z-index: 10;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
}
#near strong { font-weight: 900; color: var(--peach-dark); }
#near.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Joystick ---------- */
#joystick {
  display: none;
  position: fixed;
  left: 28px;
  bottom: 36px;
  z-index: 12;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 4px 10px rgba(140, 90, 70, 0.15);
  touch-action: none;
}
#joystick .knob {
  position: absolute;
  left: 50%; top: 50%;
  width: 54px; height: 54px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #ffd2b8, var(--peach) 60%, var(--peach-dark));
  box-shadow: 0 6px 14px rgba(240, 138, 93, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.6);
}

/* ---------- Transición ---------- */
#fade {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(160deg, #cfe9ff, #fde7ef 60%, #ffe3cf);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s;
}
#fade.show { opacity: 1; visibility: visible; }
.fade-icon {
  font-size: 3.4rem;
  width: 110px; height: 110px; display: grid; place-items: center;
  border-radius: 36px; background: #fff;
  box-shadow: var(--shadow), var(--inset);
  animation: bounce 1.2s ease-in-out infinite;
}
.fade-title { font-size: 2.2rem; font-weight: 900; margin-top: 8px; }
.fade-sub { color: var(--peach-dark); font-weight: 800; letter-spacing: 0.15em; text-transform: uppercase; font-size: 0.8rem; }

/* ---------- Táctil / móvil ---------- */
@media (hover: none) and (pointer: coarse) {
  #joystick { display: block; }
  .hint-desktop { display: none; }
  .hint-touch { display: block; }
  #hint { bottom: 176px; white-space: normal; text-align: center; max-width: 86vw; border-radius: var(--radius); }
  #near { bottom: 176px; }
}

@media (max-width: 640px) {
  .hud-top { top: auto; bottom: 18px; left: auto; right: 16px; transform: none; padding: 8px 10px 8px 16px; }
  .hud-top h1 { font-size: 1rem; }
  .menu { top: 12px; left: 12px; width: min(240px, calc(100vw - 24px)); }
  #near { font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- Tour por el mapa ---------- */
.menu { max-height: calc(100vh - 36px); overflow-y: auto; }
.menu details + details { border-top: 1px solid rgba(200, 150, 120, 0.2); }
.menu .tour summary::after { background: #e9f6ec; color: #4f9a62; }
.menu .tour .go:first-child { color: var(--peach-dark); }

#outsideChip {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translate(-50%, -8px);
  z-index: 10;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow), var(--inset);
  font-weight: 800;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}
body.outside #outsideChip { opacity: 1; transform: translate(-50%, 0); }

#blink {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: #fff8f1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
#blink.show { opacity: 1; }

@media (max-width: 640px) {
  #outsideChip { top: auto; bottom: 70px; font-size: 0.78rem; }
  .menu details:not([open]) summary { padding: 12px 16px; }
}
