:root {
  --quinchamali: rgba(20, 16, 14, 0.88);
  --quinchamali-solid: #161210;
  --greda: #a84b31;
  --greda-dark: #78301c;
  --mimbre: #ddb065;
  --mimbre-soft: rgba(221, 176, 101, 0.36);
  --crin: #f6ebd8;
  --bosque: #63c786;
  --peligro: #ff6b4a;
  --text: #f9f2e6;
  --muted: #cbbba4;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #080b07;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}

#gl-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

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

#holo-frame {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  box-shadow: inset 0 0 0 2px rgba(221, 176, 101, 0.24), inset 0 0 54px rgba(8, 10, 6, 0.58);
  transition: box-shadow 0.25s ease;
}

#holo-frame.meteor-alert {
  box-shadow: inset 0 0 0 4px rgba(255, 95, 45, 0.75), inset 0 0 75px rgba(255, 68, 20, 0.42);
  animation: alertFlash 0.55s infinite alternate;
}

@keyframes alertFlash {
  from {
    box-shadow: inset 0 0 0 3px rgba(255, 95, 45, 0.45), inset 0 0 55px rgba(255, 68, 20, 0.2);
  }
  to {
    box-shadow: inset 0 0 0 5px rgba(255, 140, 60, 0.85), inset 0 0 90px rgba(255, 68, 20, 0.55);
  }
}

.world-bubble {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-50%, -118%);
  z-index: 16;
  pointer-events: none;
  max-width: min(80vw, 320px);
  background: var(--quinchamali);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid var(--crin);
  border-radius: 20px;
  padding: 10px 15px;
  font-size: 13px;
  line-height: 1.38;
  color: var(--crin);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.56), inset 0 0 0 2px rgba(221, 176, 101, 0.22);
  opacity: 0;
  transition: opacity 0.25s ease;
  text-align: center;
}

.world-bubble.show {
  opacity: 1;
}

.world-bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: var(--quinchamali-solid);
  border-right: 1.5px solid var(--crin);
  border-bottom: 1.5px solid var(--crin);
}

#animal-bubble {
  border-color: var(--bosque);
  max-width: min(68vw, 265px);
  font-size: 12.5px;
}

#animal-bubble::after {
  border-color: var(--bosque);
}

.telar-ribbon {
  height: 8px;
  width: 100%;
  background-color: #1a1411;
  background-image:
    linear-gradient(135deg, var(--greda) 25%, transparent 25%),
    linear-gradient(225deg, var(--greda) 25%, transparent 25%),
    linear-gradient(45deg, var(--mimbre) 25%, transparent 25%),
    linear-gradient(315deg, var(--crin) 25%, #1a1411 25%);
  background-position: 8px 0, 8px 0, 0 0, 0 0;
  background-size: 16px 8px;
  background-repeat: repeat-x;
}

/* TOP HUD CONTAINER */
.hud-top {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: clamp(8px, 2vw, 16px);
  z-index: 20;
  pointer-events: none;
}

/* LEFT HUD DOCK (TOP LEFT: BAND CARD + POSTAL RETO) */
.left-hud {
  pointer-events: none;
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: min(44vw, 300px);
  max-width: min(44vw, 300px);
}

#pudu-postal-slot {
  width: 100%;
  max-width: 100%;
}

/* BAND CARD */
.band-card {
  pointer-events: auto;
  width: 100%;
  max-width: 100%;
  background: var(--quinchamali);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid var(--mimbre-soft);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.52);
  position: relative;
  contain: layout style;
}

.band-title,
.band-sub {
  overflow-wrap: anywhere;
}

.band-body {
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.band-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.band-logo-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--mimbre);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
  background: #221a15;
}

.band-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--crin);
  line-height: 1.15;
}

.band-sub {
  font-size: 10.5px;
  color: var(--mimbre);
  margin-top: 2px;
}

.band-links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.pill-link {
  appearance: none;
  border: 1px solid rgba(246, 235, 216, 0.22);
  background: rgba(255, 255, 255, 0.07);
  color: var(--crin);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.pill-link:hover {
  background: rgba(255, 255, 255, 0.16);
}

.pill-link:active {
  transform: scale(0.95);
}

.pill-link.spotify {
  border-color: rgba(30, 215, 96, 0.55);
  color: #a7f3d0;
}

.pill-link.spotify:hover,
.pill-link.spotify.active,
#btn-spotify.active {
  background: rgba(30, 215, 96, 0.28);
  border-color: #4ade80;
  box-shadow: 0 0 12px rgba(74, 222, 128, 0.45);
}

#btn-spotify {
  background: rgba(30, 215, 96, 0.14);
  font-weight: 700;
}

.pill-link.youtube {
  border-color: rgba(248, 113, 113, 0.6);
  color: #fecaca;
}

.quest-bar {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px dashed rgba(221, 176, 101, 0.3);
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--crin);
}

.quest-badge {
  background: linear-gradient(135deg, rgba(168, 75, 49, 0.55), rgba(120, 48, 28, 0.65));
  border: 1px solid var(--mimbre);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 800;
  color: var(--crin);
}

.lives-pill {
  font-size: 11px;
  letter-spacing: 1px;
}

/* RIGHT HUD DOCK (TOP RIGHT: AI PILL + ACTIONS + ADVENTURE + EVENTS) */
.right-hud {
  pointer-events: none;
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  width: min(50vw, 320px);
  max-width: min(50vw, 320px);
}

.brain-pill {
  pointer-events: auto;
  background: var(--quinchamali);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid var(--mimbre-soft);
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--crin);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 170px;
  max-width: 100%;
  box-sizing: border-box;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.48);
  transition: all 0.35s ease;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brain-pill.ready {
  border-color: var(--bosque);
  background: rgba(18, 36, 24, 0.92);
  color: #dcfce7;
  box-shadow: 0 0 20px rgba(99, 199, 134, 0.32);
}

.brain-pill.error {
  border-color: var(--peligro);
  background: rgba(45, 18, 16, 0.92);
}

.brain-pill.listening {
  border-color: #4ade80;
  background: rgba(16, 42, 26, 0.88);
  color: #dcfce7;
  box-shadow: 0 0 18px rgba(74, 222, 128, 0.28);
}

.brain-pill.thinking {
  border-color: #60a5fa;
  background: rgba(16, 28, 48, 0.88);
  color: #dbeafe;
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.25);
}

.brain-pill.speaking {
  border-color: #f59e0b;
  background: rgba(45, 28, 12, 0.88);
  color: #fef3c7;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.28);
}

.brain-pill.needs-gesture {
  border-color: #fbbf24;
  background: rgba(48, 28, 12, 0.90);
  color: #fef08a;
  cursor: pointer;
}

.brain-info-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.brain-sub-row {
  font-size: 10px;
  font-weight: 500;
  color: var(--mimbre);
  opacity: 0.92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brain-progress-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.brain-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mimbre), var(--bosque));
  border-radius: 999px;
  transition: width 0.25s ease-out;
}

.brain-pill.ready .brain-progress-track {
  display: none;
}

.brain-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mimbre);
  animation: pulse 1.4s infinite;
  flex-shrink: 0;
}

.brain-pill.ready .brain-dot {
  background: var(--bosque);
  box-shadow: 0 0 8px var(--bosque);
  animation: none;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 100%;
}

.artisan-btn {
  appearance: none;
  border: 1px solid var(--mimbre-soft);
  background: var(--quinchamali);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--crin);
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.42);
  transition: transform 0.12s ease;
}

.artisan-btn:active {
  transform: scale(0.95);
}

/* SECONDARY DOCKED HUDS (FLOW INSIDE LEFT / RIGHT CORNER DOCKS) */

/* Postal Challenge Card (inside left-hud below band card) */
.pudu-postal-card {
  position: relative;
  background: rgba(12, 18, 14, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 7px 11px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  pointer-events: auto;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  z-index: 21;
  font: 600 11px/1.35 system-ui, sans-serif;
  color: #f4efe6;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.pudu-postal-card button {
  cursor: pointer;
  border: 0;
  border-radius: 6px;
  padding: 4px 8px;
  background: #2f4f3a;
  color: #f4efe6;
  font: inherit;
  font-size: 11px;
  transition: background 0.15s ease;
}

.pudu-postal-card button:hover {
  background: #3d684c;
}

/* Adventure HUD (points, streak, photos - inside right-hud) */
.adventure-hud {
  position: relative;
  z-index: 21;
  display: flex;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid rgba(167, 243, 208, 0.45);
  border-radius: 999px;
  background: rgba(15, 35, 25, 0.88);
  color: #ecfdf5;
  font-size: 11px;
  font-weight: 800;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  max-width: 100%;
  box-sizing: border-box;
}

/* Emergent Events HUD (inside right-hud below adventure-hud) */
.emergent-events-hud {
  position: relative;
  z-index: 21;
  pointer-events: auto;
  font: 600 11px/1.35 system-ui, sans-serif;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255, 209, 102, 0.45);
  border-radius: 12px;
  padding: 6px 11px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* BOTTOM CONTROLS */

/* Bottom Left: Joystick dock */
.game-pad-left {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  max-width: 44vw;
}

#joystick-base {
  width: 114px;
  height: 114px;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(22, 18, 16, 0.88) 46%, rgba(221, 176, 101, 0.28) 100%),
    repeating-conic-gradient(rgba(221, 176, 101, 0.26) 0deg 12deg, rgba(120, 48, 28, 0.28) 12deg 24deg);
  border: 2.5px solid var(--mimbre);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.62), inset 0 0 18px rgba(0, 0, 0, 0.62);
  position: relative;
  touch-action: none;
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
}

#joystick-knob {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #e6a07b, var(--greda) 62%, var(--greda-dark) 100%);
  border: 2px solid var(--crin);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}

.joy-hint {
  font-size: 10.5px;
  color: var(--crin);
  background: rgba(20, 16, 14, 0.72);
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(221, 176, 101, 0.28);
  pointer-events: auto;
}

/* Pudú Bond: inside game-pad-left directly above Joystick */
.pudu-bond-hud {
  position: relative;
  z-index: 22;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 5px 10px;
  border-radius: 12px;
  background: rgba(16, 28, 22, 0.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #e9f5ec;
  font: 11px/1.2 system-ui, sans-serif;
  border: 1px solid rgba(170, 230, 190, 0.28);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  user-select: none;
  max-width: 100%;
  box-sizing: border-box;
}

.pudu-bond-hud button {
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 4px 8px;
  background: #3a6b4c;
  color: #fff;
  font: inherit;
  font-size: 11px;
  transition: transform 0.12s ease;
}

.pudu-bond-hud button:active {
  transform: scale(0.95);
}

/* Bottom Right: Action Buttons */
.game-pad-right {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  right: max(16px, env(safe-area-inset-right));
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: 54vw;
  pointer-events: none;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  align-items: center;
  max-width: 100%;
}

.clay-btn {
  appearance: none;
  border: 2px solid var(--crin);
  border-radius: 999px;
  background: radial-gradient(circle at 30% 25%, #c76244, var(--greda) 65%, var(--greda-dark) 100%);
  color: var(--crin);
  font-weight: 800;
  font-size: 12.5px;
  padding: 10px 14px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.56);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  line-height: 1.15;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.12s ease;
}

.clay-btn:active {
  transform: scale(0.93);
}

.clay-btn.sprint-btn.active {
  background: radial-gradient(circle at 30% 25%, #fde047, #d97706 70%, #92400e 100%);
  border-color: #fef08a;
  box-shadow: 0 0 18px rgba(250, 204, 21, 0.55);
}

.clay-btn.ichipi-btn {
  background: radial-gradient(circle at 30% 25%, #f5be78, #c47a2c 70%, #8a4f16 100%);
}

.clay-btn.talk-main {
  background: radial-gradient(circle at 30% 25%, #7ce3a0, #3a965b 68%, #22633a 100%);
  border-color: #ecfdf5;
  font-size: 13.5px;
  padding: 11px 18px;
}

.clay-btn.talk-main.listening-active {
  background: radial-gradient(circle at 30% 25%, #f87171, #dc2626 68%, #991b1b 100%) !important;
  border-color: #fecaca !important;
  color: #fff !important;
  animation: listenPulse 1.2s infinite ease-in-out !important;
}

.clay-btn.talk-main.speaking-active {
  background: radial-gradient(circle at 30% 25%, #f5be78, #d97706 70%, #78350f 100%);
  border-color: #fde68a;
}

.clay-btn.talk-main.thinking-active {
  background: radial-gradient(circle at 30% 25%, #93c5fd, #2563eb 70%, #1e3a8a 100%);
  border-color: #dbeafe;
}

@keyframes listenPulse {
  0%, 100% {
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.6);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 26px rgba(239, 68, 68, 0.95);
    transform: scale(1.03);
  }
}

.quick-chat-wrap {
  display: flex;
  gap: 6px;
  margin-top: 2px;
  background: rgba(28, 20, 16, 0.94);
  border: 1.5px solid rgba(220, 155, 90, 0.6);
  border-radius: 999px;
  padding: 4px 6px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

.quick-chat-wrap.hidden {
  display: none !important;
}

.quick-chat-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  min-width: 145px;
  user-select: text;
  -webkit-user-select: text;
}

.quick-chat-wrap button {
  background: radial-gradient(circle at 30% 25%, #7ce3a0, #3a965b 68%, #22633a 100%);
  border: 1px solid #ecfdf5;
  border-radius: 999px;
  color: #fff;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* Pudú Bestiary: inside game-pad-right directly above Action buttons */
.pudu-bestiary-hud {
  position: relative;
  z-index: 23;
  max-width: 100%;
  box-sizing: border-box;
  padding: 5px 9px;
  border-radius: 12px;
  background: rgba(13, 26, 20, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #eff9ed;
  font: 11px/1.35 system-ui, sans-serif;
  border: 1px solid rgba(183, 235, 170, 0.28);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

.pudu-bestiary-hud button {
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 4px 8px;
  background: #476e4d;
  color: #fff;
  font: inherit;
  font-size: 11px;
}

/* Live speech transcription pill: inside game-pad-right above Bestiary */
.voice-live-pill {
  position: relative;
  display: none;
  z-index: 24;
  max-width: 100%;
  box-sizing: border-box;
  background: rgba(16, 26, 20, 0.92);
  border: 1px solid rgba(99, 199, 134, 0.55);
  border-radius: 12px;
  padding: 5px 10px;
  font-size: 11px;
  color: #d1fae5;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.voice-live-pill.show {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Tutorial HUD (Diegetic onboarding): bottom center, never covering bottom controls */
.pudu-tutorial-hud {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 28;
  pointer-events: none;
  font: 500 12.5px/1.35 system-ui, sans-serif;
  max-width: min(88vw, 420px);
  width: 100%;
  color: #f4f7f2;
  box-sizing: border-box;
}

.pudu-tutorial-hud button {
  pointer-events: auto;
}

/* CENTER ALERTS & NOTIFICATIONS (FLOATING SAFELY IN UPPER CENTER) */
#toast {
  position: fixed;
  top: min(180px, 22vh);
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  z-index: 50;
  background: var(--quinchamali-solid);
  border: 1.5px solid var(--mimbre);
  color: var(--crin);
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s ease;
  text-align: center;
  max-width: min(88vw, 420px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.62);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#meteor-banner {
  position: fixed;
  top: min(180px, 22vh);
  left: 50%;
  transform: translateX(-50%) scale(0.92);
  z-index: 48;
  background: linear-gradient(135deg, rgba(165, 36, 15, 0.94), rgba(88, 18, 8, 0.95));
  border: 2px solid #fbbf24;
  color: #fff7ed;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  box-shadow: 0 12px 34px rgba(220, 38, 38, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  text-align: center;
  max-width: min(92vw, 480px);
}

#meteor-banner.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* MODALS & DRAWERS */
.spotify-drawer {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  z-index: 80;
  width: min(92vw, 380px);
  max-height: min(90vh, 480px);
  background: rgba(14, 22, 17, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid rgba(30, 215, 96, 0.6);
  border-radius: 18px;
  padding: 12px 14px 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85), 0 0 35px rgba(30, 215, 96, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 1;
  pointer-events: auto;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
  box-sizing: border-box;
}

.spotify-drawer.collapsed {
  transform: translate(-50%, -46%) scale(0.92);
  opacity: 0;
  pointer-events: none;
}

.spotify-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.spotify-drawer-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.spotify-icon {
  font-size: 14px;
}

.spotify-title-main {
  font-size: 12.5px;
  font-weight: 800;
  color: #a7f3d0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

.spotify-title-sub {
  font-size: 10px;
  color: var(--mimbre);
}

.spotify-drawer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.spotify-iframe-container {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #121212;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.spotify-drawer-footer {
  font-size: 10px;
  color: #d1fae5;
  text-align: center;
  opacity: 0.85;
  padding: 2px 4px 0;
}

.advanced-modal {
  position: fixed;
  top: max(64px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 45;
  width: min(92vw, 375px);
  max-height: 80vh;
  overflow-y: auto;
  background: var(--quinchamali-solid);
  border: 1.5px solid var(--mimbre);
  border-radius: 18px;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.78);
  transition: transform 0.28s ease, opacity 0.25s ease;
}

.advanced-modal.hidden {
  transform: translateY(-16px) scale(0.96);
  opacity: 0;
  pointer-events: none;
}

.adv-inner {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.adv-title {
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--mimbre);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.adv-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.adv-group select,
.adv-group input[type="text"],
.adv-row-btns button {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(221, 176, 101, 0.32);
  color: var(--crin);
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.adv-group input[type="text"] {
  user-select: text;
  -webkit-user-select: text;
}

.adv-group select option {
  background: #161210;
}

.adv-row-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.adv-row-btns button {
  cursor: pointer;
  font-weight: 600;
}

.adv-row-btns button.active {
  background: rgba(99, 199, 134, 0.25);
  border-color: var(--bosque);
}

.hw-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(221, 176, 101, 0.22);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--crin);
}

.bestiary-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 11px;
}

.bestiary-item {
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.bestiary-item.found {
  border-color: var(--bosque);
  color: var(--crin);
  background: rgba(99, 199, 134, 0.14);
}

/* LOADER */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at center, rgba(22, 34, 24, 0.94) 0%, rgba(10, 13, 9, 0.98) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  text-align: center;
  padding: 24px;
  transition: opacity 0.55s ease;
}

#loader.done {
  opacity: 0;
  pointer-events: none;
}

.loader-logo {
  max-width: min(84vw, 390px);
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 20px rgba(221, 176, 101, 0.28));
}

.loader-title-fallback {
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--crin);
  letter-spacing: 0.05em;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.7);
  display: none;
}

.loader-progress-track {
  width: min(82vw, 310px);
  height: 7px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.loader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ddb065, #63c786);
  border-radius: 999px;
  transition: width 0.2s ease-out;
}

#loader-pudu-stage {
  height: 88px;
  display: grid;
  place-items: center;
  touch-action: none;
  user-select: none;
}

#loader-pudu-toy {
  position: relative;
  width: 78px;
  height: 56px;
  cursor: grab;
  touch-action: none;
  animation: pudu-bob 1.4s ease-in-out infinite;
  will-change: transform;
}

#loader-pudu-toy.dragging {
  cursor: grabbing;
  animation: none;
}

#loader-pudu-toy span {
  position: absolute;
  display: block;
  pointer-events: none;
}

.pudu-body {
  left: 12px;
  top: 22px;
  width: 46px;
  height: 24px;
  border-radius: 16px;
  background: #7c5338;
}

.pudu-head {
  right: 6px;
  top: 10px;
  width: 28px;
  height: 24px;
  border-radius: 14px 12px 11px 12px;
  background: #9c6b49;
}

.pudu-ear {
  top: 2px;
  width: 9px;
  height: 12px;
  border-radius: 8px 8px 2px 2px;
  background: #7c5338;
}

.pudu-ear.l {
  right: 22px;
  transform: rotate(-14deg);
}

.pudu-ear.r {
  right: 11px;
  transform: rotate(10deg);
}

.pudu-eye {
  top: 8px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #1d1614;
}

.pudu-eye.l {
  left: 8px;
}

.pudu-eye.r {
  left: 17px;
}

.pudu-nose {
  right: 2px;
  bottom: 5px;
  width: 6px;
  height: 5px;
  border-radius: 50%;
  background: #1d1614;
}

.pudu-leg {
  bottom: 2px;
  width: 7px;
  height: 14px;
  border-radius: 4px;
  background: #5a3a26;
}

.pudu-leg.l1 {
  left: 18px;
}

.pudu-leg.l2 {
  left: 42px;
}

.loader-touch-hint {
  color: #cbbba4;
  font-size: 11px;
}

@keyframes pudu-bob {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -6px, 0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.75);
    opacity: 0.45;
  }
}

:is(.game-pad-right button, #btn-talk):focus-visible {
  outline: 3px solid #ffe082;
  outline-offset: 2px;
}

/* RESPONSIVE: TABLET & MOBILE BREAKPOINT (max-width: 768px) */
@media (max-width: 768px) {
  .hud-top {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    gap: 6px;
  }

  .left-hud {
    max-width: 46%;
    gap: 4px;
  }

  .band-card {
    border-radius: 10px;
    font-size: 10px;
  }
  .band-card .telar-ribbon {
    height: 3px;
  }
  .band-body {
    padding: 4px 7px;
    gap: 3px;
  }
  .band-header {
    gap: 6px;
  }
  .band-logo-img {
    width: 24px;
    height: 24px;
    border-width: 1px;
  }
  .band-title {
    font-size: 10px;
    line-height: 1.15;
  }
  .band-sub,
  .joy-hint {
    display: none;
  }
  .band-links {
    gap: 3px;
    flex-wrap: wrap;
  }
  #btn-spotify {
    width: 100%;
    justify-content: center;
    padding: 3px 6px;
    font-size: 9.5px;
  }
  .pill-link {
    padding: 3px 6px;
    font-size: 9px;
    letter-spacing: -0.2px;
  }
  .quest-bar {
    margin-top: 0;
    padding-top: 2px;
    gap: 3px;
    font-size: 9px;
  }
  .quest-badge {
    padding: 1px 4px;
    font-size: 9px;
  }
  .lives-pill {
    font-size: 9.5px;
    letter-spacing: 0.5px;
  }

  .pudu-postal-card {
    padding: 4px 8px;
    font-size: 9.5px;
    border-radius: 9px;
  }
  .pudu-postal-card button {
    padding: 3px 6px;
    font-size: 9px;
  }

  .right-hud {
    max-width: 52%;
    gap: 3px;
  }
  .brain-pill {
    padding: 4px 8px;
    font-size: 9.5px;
    min-width: 0;
    border-radius: 9px;
    gap: 2px;
  }
  .brain-info-row {
    gap: 4px;
    font-size: 9.5px;
  }
  .brain-sub-row {
    font-size: 8.5px;
  }
  .brain-dot {
    width: 6px;
    height: 6px;
  }

  .top-actions {
    gap: 3px;
    flex-wrap: nowrap;
    justify-content: flex-end;
  }
  .artisan-btn {
    padding: 4px 6px;
    font-size: 9px;
    border-radius: 8px;
    white-space: nowrap;
    letter-spacing: -0.2px;
  }

  .adventure-hud {
    padding: 3px 8px;
    font-size: 9.5px;
  }

  .emergent-events-hud {
    padding: 4px 8px;
    font-size: 9px;
    min-width: 0;
    max-width: 200px;
    border-radius: 9px;
  }

  /* Bottom Left */
  .game-pad-left {
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    gap: 4px;
    max-width: 44vw;
  }
  #joystick-base {
    width: 86px;
    height: 86px;
    border-width: 2px;
  }
  #joystick-knob {
    width: 36px;
    height: 36px;
  }

  .pudu-bond-hud {
    padding: 4px 8px;
    font-size: 9.5px;
    border-radius: 9px;
    gap: 4px;
  }
  .pudu-bond-hud button {
    padding: 3px 6px;
    font-size: 9px;
  }

  /* Bottom Right */
  .game-pad-right {
    bottom: max(8px, env(safe-area-inset-bottom));
    right: max(8px, env(safe-area-inset-right));
    gap: 4px;
    max-width: calc(100vw - 100px);
  }
  .action-row {
    gap: 3px;
    flex-wrap: nowrap;
  }
  .clay-btn {
    padding: 7px 9px;
    font-size: 10px;
    min-width: 32px;
    min-height: 32px;
    white-space: nowrap;
    letter-spacing: -0.2px;
  }
  .clay-btn.talk-main {
    padding: 7px 11px;
    font-size: 10.5px;
    min-height: 32px;
  }
  #btn-quick-chat {
    padding: 7px 9px !important;
    font-size: 12px !important;
    min-width: 32px !important;
    min-height: 32px !important;
  }
  .quick-chat-wrap {
    padding: 3px 6px;
  }
  .quick-chat-wrap input {
    font-size: 10.5px;
    padding: 4px 6px;
    min-width: 100px;
  }
  .quick-chat-wrap button {
    font-size: 10px;
    padding: 4px 8px;
  }

  .pudu-bestiary-hud {
    padding: 4px 8px;
    font-size: 9.5px;
    border-radius: 9px;
  }
  .pudu-bestiary-hud button {
    padding: 3px 6px;
    font-size: 9px;
  }

  .voice-live-pill {
    padding: 3px 8px;
    font-size: 9.5px;
  }

  .pudu-tutorial-hud {
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 140px);
    max-width: min(88vw, 340px);
    font-size: 11px;
  }
  .pudu-tutorial-hud > div {
    padding: 8px 10px !important;
  }

  #toast {
    top: calc(max(8px, env(safe-area-inset-top)) + 155px);
    padding: 5px 12px;
    font-size: 10.5px;
    max-width: 86vw;
  }
  #meteor-banner {
    top: calc(max(8px, env(safe-area-inset-top)) + 155px);
    padding: 5px 12px;
    font-size: 10.5px;
    max-width: 88vw;
  }
}

/* RESPONSIVE: NARROW MOBILE (max-width: 360px) */
@media (max-width: 360px) {
  .band-logo-img {
    width: 20px;
    height: 20px;
  }
  .band-title {
    font-size: 9px;
  }
  .pill-link {
    padding: 2px 4px;
    font-size: 8px;
  }
  .quest-bar {
    font-size: 8px;
  }
  .pudu-postal-card {
    padding: 3px 5px;
    font-size: 8.5px;
  }
  .brain-pill {
    padding: 3px 5px;
    font-size: 8.5px;
  }
  .artisan-btn {
    padding: 3px 5px;
    font-size: 8px;
  }
  #joystick-base {
    width: 76px;
    height: 76px;
  }
  #joystick-knob {
    width: 32px;
    height: 32px;
  }
  .clay-btn {
    padding: 6px 7px;
    font-size: 9px;
    min-height: 30px;
  }
  .clay-btn.talk-main {
    padding: 6px 9px;
    font-size: 9.5px;
    min-height: 30px;
  }
  .pudu-tutorial-hud {
    bottom: calc(max(6px, env(safe-area-inset-bottom)) + 140px);
    font-size: 10px;
  }
}

/* RESPONSIVE: SHORT LANDSCAPE SCREENS (max-height: 520px) */
@media (max-height: 520px) {
  .hud-top {
    top: max(4px, env(safe-area-inset-top));
  }
  .band-sub,
  .joy-hint {
    display: none;
  }
  .band-body {
    padding: 3px 6px;
    gap: 2px;
  }
  .pudu-postal-card {
    display: none;
  }
  .emergent-events-hud {
    display: none;
  }
  .game-pad-left {
    bottom: max(6px, env(safe-area-inset-bottom));
    left: max(6px, env(safe-area-inset-left));
    gap: 3px;
  }
  .pudu-bond-hud {
    padding: 2px 5px;
    font-size: 8.5px;
  }
  .game-pad-right {
    bottom: max(6px, env(safe-area-inset-bottom));
    right: max(6px, env(safe-area-inset-right));
    gap: 3px;
  }
  #joystick-base {
    width: 74px;
    height: 74px;
  }
  #joystick-knob {
    width: 30px;
    height: 30px;
  }
  .clay-btn {
    padding: 5px 8px;
    font-size: 9.5px;
    min-width: 30px;
    min-height: 30px;
  }
  .clay-btn.talk-main {
    padding: 5px 9px;
    font-size: 10px;
  }
  .pudu-bestiary-hud {
    padding: 2px 5px;
    font-size: 8.5px;
  }
  .voice-live-pill {
    padding: 2px 6px;
    font-size: 8.5px;
  }
  .pudu-tutorial-hud {
    display: none;
  }
  .spotify-drawer {
    width: min(92vw, 420px);
    max-height: min(92vh, 320px);
    padding: 8px 10px 8px;
    gap: 6px;
  }
  .spotify-drawer iframe {
    height: 180px;
  }
}

/* ACCESSIBILITY: REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  #loader-pudu-toy,
  #loader-progress-fill {
    animation: none !important;
    transition: none !important;
  }
}
