*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --g: #00C853;
  --g2: #008a3a;
  --dark: #111B21;
  --panel: #202C33;
  --p2: #2A3942;
  --tx: #E9EDEF;
  --tx2: #8696A0;
  --tx3: #667781;
  --bdr: #2A3942;
  --blue: #53BDEB;
  --yl: #FFD93D;
  --or: #FF6B35;
  --red: #FF4444;
  --controls-h: 250px;
  --map-bottom-safe: 250px;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d1a0d;
  display: flex;
  flex-direction: column;
  font-family: 'Nunito', sans-serif;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* TOP BAR */
#topBar {
  background: #0A1014;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  flex-shrink: 0;
  border-bottom: 1px solid #1a2a1a;
  z-index: 50;
  gap: 6px;
}

.tb-logo {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(13px, 3.5vw, 18px);
  color: var(--g);
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tb-stats {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

.tb-stat {
  background: rgba(255, 255, 255, .08);
  border-radius: 12px;
  padding: 3px 8px;
  font-size: clamp(10px, 2.2vw, 12px);
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 3px;
}

.tb-lvl {
  font-size: clamp(9px, 1.8vw, 11px);
  color: var(--g);
  font-weight: 700;
  background: rgba(0, 200, 83, .12);
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.tb-keys {
  font-size: 10px;
  color: var(--tx3);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex: 1;
  justify-content: center;
}

.tb-keys kbd {
  background: var(--p2);
  border: 1px solid var(--bdr);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
}

/* GAME AREA */
#gameArea {
  flex: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) var(--controls-h);
  overflow: hidden;
  position: relative;
  min-height: 0;
}

/* MAP VIEWPORT */
#mapVP {
  grid-row: 1;
  height: 100%;
  overflow: hidden;
  position: relative;
  cursor: grab;
  background: #5b8a38;
  min-width: 0;
  min-height: 0;
}

/* BOTTOM CONTROLS — slots + control area */
#bottomControls {
  grid-row: 2;
  position: relative;
  width: 100%;
  height: var(--controls-h);
  z-index: 900;
  background: linear-gradient(180deg, rgba(10,16,20,.98) 0%, rgba(8,12,16,1) 100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}

#bottomControls.hidden {
  transform: translateY(100%);
}

#chatBubble.hidden {
  transform: translateY(100px);
  opacity: 0;
  pointer-events: none;
}

#mapVP.drag {
  cursor: grabbing;
}

#mapWorld {
  width: 2800px;
  height: 2000px;
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0px, transparent 1px, transparent 47px, rgba(0, 0, 0, 0.06) 48px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.06) 0px, transparent 1px, transparent 47px, rgba(0, 0, 0, 0.06) 48px),
    repeating-conic-gradient(#5e9638 0% 25%, #5a9236 25% 50%, #62a03a 50% 75%, #5e9638 75% 100%) 0 0 / 96px 96px;
}

/* ZONES */
.zone {
  position: absolute;
  border-radius: 12px;
  z-index: 1;
}

.zlbl {
  display: none;
}

/* Plaza Central - stone tiles */
.z1 {
  left: 1050px;
  top: 700px;
  width: 700px;
  height: 500px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .1) 0, rgba(0, 0, 0, .1) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .1) 0, rgba(0, 0, 0, .1) 1px, transparent 1px, transparent 40px),
    repeating-conic-gradient(#8a9e7a 0% 25%, #84986e 25% 50%, #8ea475 50% 75%, #8a9e7a 75% 100%) 0 0 / 80px 80px;
}

/* Mercado Feliz - bright grass */
.z2 {
  left: 80px;
  top: 80px;
  width: 700px;
  height: 550px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .07) 0, rgba(0, 0, 0, .07) 1px, transparent 1px, transparent 48px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .07) 0, rgba(0, 0, 0, .07) 1px, transparent 1px, transparent 48px),
    repeating-conic-gradient(#72b840 0% 25%, #6db23c 25% 50%, #78bc42 50% 75%, #72b840 75% 100%) 0 0 / 96px 96px;
}

/* Zona Real - royal palace */
.zone-title { font-size: clamp(13px, 3vw, 18px); color: var(--g); letter-spacing: .5px; }
.z3 {
  left: 1950px;
  top: 80px;
  width: 700px;
  height: 600px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .25) 0, rgba(0, 0, 0, .25) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .25) 0, rgba(0, 0, 0, .25) 1px, transparent 1px, transparent 40px),
    repeating-conic-gradient(#3a2e38 0% 25%, #352834 25% 50%, #3f3040 50% 75%, #3a2e38 75% 100%) 0 0 / 80px 80px;
}

/* ═══════════════════════════════════════
   MURALLA DEL CASTILLO - Estilo piedra medieval
   ═══════════════════════════════════════ */

.castle-wall {
  position: absolute;
  background:
    /* líneas de mortero horizontales */
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 18px,
      #a8a49a 18px,
      #a8a49a 20px
    ),
    /* líneas de mortero verticales escalonadas */
    repeating-linear-gradient(
      90deg,
      #b5b0a6 0px,
      #b5b0a6 1px,
      transparent 1px,
      transparent 38px
    ),
    /* base cemento claro con variación */
    repeating-linear-gradient(
      0deg,
      #d4cfc7 0px,
      #d4cfc7 18px,
      #ccc7be 18px,
      #ccc7be 36px
    );
  border: 2px solid #9e9a90;
  box-shadow: 
    inset 0 0 12px rgba(0,0,0,0.15),
    2px 3px 8px rgba(0,0,0,0.35);
  z-index: 15;
}

/* almenas en la parte superior de muros horizontales */
.castle-wall::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
  background:
    repeating-linear-gradient(
      90deg,
      #c8c3b8 0px,
      #c8c3b8 14px,
      transparent 14px,
      transparent 28px
    );
  border: 1px solid #9e9a90;
  border-bottom: none;
}

.castle-gate {
  position: absolute;
  background: 
    repeating-linear-gradient(90deg, #4a3020 0px, #4a3020 20px, #3a2010 20px, #3a2010 40px),
    linear-gradient(to bottom, #5a4030, #3a2010);
  border: 4px solid #2a1a0a;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
  z-index: 16;
}

.castle-gate::after {
  content: '';
  position: absolute;
  top: 20%;
  left: 10%;
  right: 10%;
  bottom: 20%;
  background: repeating-linear-gradient(90deg, transparent 0px, transparent 8px, #2a2a2a 8px, #2a2a2a 12px);
}

.breakable-wall {
  position: absolute;
  background:
    /* mortero horizontal entre filas de ladrillos */
    repeating-linear-gradient(
      0deg,
      #8b7355 0px,
      #8b7355 2px,
      #b5651d 2px,
      #b5651d 10px,
      #a0522d 10px,
      #a0522d 18px,
      #8b7355 18px,
      #8b7355 20px
    ),
    /* mortero vertical entre ladrillos */
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 28px,
      #8b7355 28px,
      #8b7355 30px,
      transparent 30px,
      transparent 58px,
      #8b7355 58px,
      #8b7355 60px
    ),
    /* base ladrillo cálido */
    linear-gradient(135deg, #c4722f, #a0522d, #8b4513);
  border: 2px solid #5a2e11;
  z-index: 17;
  cursor: pointer;
  box-shadow:
    inset 0 0 10px rgba(0,0,0,0.35),
    2px 2px 6px rgba(0,0,0,0.4);
}

.breakable-wall::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /* filas alternadas desplazadas (patrón de ladrillo real) */
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 19px,
      rgba(60,30,10,0.7) 19px,
      rgba(60,30,10,0.7) 21px
    );
}

/* grietas visibles al acercarse con bomba */
.breakable-wall::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 4px;
  right: 4px;
  bottom: 2px;
  background:
    linear-gradient(45deg, transparent 40%, rgba(0,0,0,0.12) 42%, transparent 44%),
    linear-gradient(-30deg, transparent 60%, rgba(0,0,0,0.1) 62%, transparent 64%);
  pointer-events: none;
}

/* Tecnozona - metal tiles */
.z4 {
  left: 2000px;
  top: 800px;
  width: 700px;
  height: 550px;
  background:
    repeating-linear-gradient(0deg, rgba(100, 160, 255, .18) 0, rgba(100, 160, 255, .18) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(90deg, rgba(100, 160, 255, .18) 0, rgba(100, 160, 255, .18) 1px, transparent 1px, transparent 40px),
    repeating-conic-gradient(#283a50 0% 25%, #243448 25% 50%, #2c4058 50% 75%, #283a50 75% 100%) 0 0 / 80px 80px;
}

/* Reino de Fuego - lava tiles */
.z5 {
  left: 1600px;
  top: 1400px;
  width: 700px;
  height: 500px;
  background:
    repeating-linear-gradient(0deg, rgba(255, 80, 0, .18) 0, rgba(255, 80, 0, .18) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(90deg, rgba(255, 80, 0, .18) 0, rgba(255, 80, 0, .18) 1px, transparent 1px, transparent 40px),
    repeating-conic-gradient(#5a2010 0% 25%, #521c0c 25% 50%, #602212 50% 75%, #5a2010 75% 100%) 0 0 / 80px 80px;
}

/* Bosque Ancestral - dark forest */
.z6 {
  left: 100px;
  top: 1300px;
  width: 700px;
  height: 550px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .15) 0, rgba(0, 0, 0, .15) 1px, transparent 1px, transparent 48px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .15) 0, rgba(0, 0, 0, .15) 1px, transparent 1px, transparent 48px),
    repeating-conic-gradient(#2d5c1e 0% 25%, #285518 25% 50%, #326420 50% 75%, #2d5c1e 75% 100%) 0 0 / 96px 96px;
}

/* ROADS - stone/dirt paths */
.rh {
  position: absolute;
  height: 40px;
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .12) 0, rgba(0, 0, 0, .12) 1px, transparent 1px, transparent 40px),
    #a08856;
  border-top: 3px solid #7a6435;
  border-bottom: 3px solid #7a6435;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

.rv {
  position: absolute;
  width: 40px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .12) 0, rgba(0, 0, 0, .12) 1px, transparent 1px, transparent 40px),
    #a08856;
  border-left: 3px solid #7a6435;
  border-right: 3px solid #7a6435;
  pointer-events: none;
  box-shadow: 2px 0 8px rgba(0, 0, 0, .3);
}

/* LANDMARKS */
.lm {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  z-index: 4;
}

.lmi {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .7)) drop-shadow(0 2px 2px rgba(0, 0, 0, .5));
  transition: transform .2s;
}

.lm:hover .lmi {
  transform: scale(1.18) translateY(-3px);
}

.lml {
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 4px #000, 0 0 8px rgba(0, 0, 0, .8);
  white-space: nowrap;
  background: rgba(0, 0, 0, .65);
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .15);
  backdrop-filter: blur(3px);
}

/* NPCS */
.npc {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  z-index: 5;
}

.npe {
  font-size: 34px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .7));
  animation: nb 2s ease-in-out infinite;
}

.npc:nth-child(2n) .npe {
  animation-delay: .5s;
}

.npc:nth-child(3n) .npe {
  animation-delay: 1s;
}

.flying-coin {
  position: fixed;
  font-size: 24px;
  z-index: 9999;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  transition: all 0.8s cubic-bezier(0.6, -0.28, 0.735, 0.045);
}

@keyframes coinPop {
  0% { transform: scale(0) translateY(0); opacity: 0; }
  50% { transform: scale(1.2) translateY(-40px); opacity: 1; }
  100% { transform: scale(1) translateY(-20px); opacity: 1; }
}

.collect-float {
  /* ... existia? lo re-defino para seguridad ... */
  position: absolute; color: #FFD700; font-family: 'Fredoka One'; font-size: 20px;
  pointer-events: none; animation: collectFloat 1s forwards; z-index: 10000;
  text-align: center; text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

@keyframes collectFloat {
  0% { transform: translate(-50%, 0); opacity: 0; }
  20% { transform: translate(-50%, -20px); opacity: 1; }
  100% { transform: translate(-50%, -60px); opacity: 0; }
}

@keyframes nb {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.npn {
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 4px #000;
  background: rgba(0, 0, 0, .65);
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, .15);
  backdrop-filter: blur(3px);
}

.ping {
  position: absolute;
  top: -10px;
  right: -6px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: pp 1.5s ease-in-out infinite;
  z-index: 6;
}

@keyframes pp {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

.npc::before {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 8px;
  background: rgba(0, 0, 0, .3);
  border-radius: 50%;
  filter: blur(3px);
}

.npc-eddy {
  z-index: 10;
}

.npc-eddy .npe {
  animation-duration: 1.8s;
}

.npc-shot {
  position: absolute;
  left: 36px;
  top: 10px;
  font-size: 18px;
  line-height: 1;
  transform: rotate(-12deg);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
}

/* WATER - animated zelda style */
.water {
  position: absolute;
  z-index: 7;
  border-radius: 50%;
  background: repeating-linear-gradient(45deg, #3ab5e8 0px, #4dc5f0 8px, #38aede 8px, #4bbce8 16px);
  opacity: .88;
  pointer-events: none;
  overflow: visible;
  box-shadow: inset 0 0 40px rgba(0,0,0,.2),
              0 8px 30px rgba(0,100,200,.25),
              0 0 0 4px rgba(58,181,232,0.3);
  animation: waterShimmer 3s ease-in-out infinite;
}

.lake-duck {
  position: absolute;
  font-size: 26px;
  z-index: 17;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.25));
  animation: duckSwim 12s ease-in-out infinite;
}

@keyframes duckSwim {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(40px, -8px) rotate(8deg); }
  50% { transform: translate(20px, 4px) rotate(-4deg); }
  75% { transform: translate(-30px, -6px) rotate(4deg); }
}
  50% { transform: rotate(5deg) translateY(-6px); }
}


@keyframes waterShimmer {
  0%, 100% { filter: brightness(1) hue-rotate(0deg); }
  50% { filter: brightness(1.1) hue-rotate(8deg); }
}

.water::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: repeating-linear-gradient(135deg, #4ecff5 0px, #5ad8fc 6px, #3bbfea 6px, #4ecff5 12px);
  opacity: .55;
}

.water::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 3px solid rgba(58,181,232,.5);
  animation: waterRipple 2s ease-in-out infinite;
}

@keyframes waterRipple {
  0%,100%{ transform: scale(1);   opacity:.6; }
  50%    { transform: scale(1.04);opacity:.2; }
}

.lake-bubbles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.lake-bubble {
  position: absolute;
  width: var(--lb-size, 28px);
  height: var(--lb-size, 28px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--lb-size, 28px);
  line-height: 1;
  opacity: .78;
  filter: drop-shadow(0 0 8px rgba(147,197,253,.55));
  animation: lakeBubbleFloat 3.4s ease-in-out infinite;
  animation-delay: var(--lb-delay, 0s);
}

@keyframes lakeBubbleFloat {
  0%, 100% { transform: translateY(0) scale(.92); opacity: .45; }
  50% { transform: translateY(-14px) scale(1.06); opacity: .88; }
}

.dco {
  position: absolute;
  font-size: 22px;
  opacity: .8;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5));
}

.sgn {
  position: absolute;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, .2);
  backdrop-filter: blur(4px);
}

/* ZELDA TREES */
.tree {
  position: absolute;
  width: 52px;
  height: 52px;
  pointer-events: none;
  z-index: 3;
}

.tree::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  background: #5a3a10;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
}

.tree::after {
  content: '';
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #7ecb3a, #4a8c1c 50%, #2d6010 80%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .55), inset -4px -4px 10px rgba(0, 0, 0, .25), inset 4px 4px 8px rgba(255, 255, 255, .12);
}

.tree.dark::after {
  background: radial-gradient(circle at 38% 35%, #45a020, #2c7010 50%, #1a4808 80%);
}

.tree.big {
  width: 66px;
  height: 66px;
}

.tree.big::after {
  width: 62px;
  height: 62px;
}

.tree.big::before {
  width: 18px;
  height: 18px;
}

.tree-cluster {
  position: absolute;
  pointer-events: none;
  z-index: 3;
}

/* ── PLAYER 3D SPHERE ── */
#player {
  position: absolute;
  width: 42px;
  height: 42px;
  z-index: 10;
  pointer-events: none;
  transition: none;
  will-change: transform;
}

#mapFx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  overflow: hidden;
}

.ov-bubble,
.ov-water-shot,
.ov-gust,
.ov-explosion,
.ov-bomb,
.ov-bomb-shadow,
.ov-raindrop,
.ov-sprout {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

.ov-raindrop {
  font-size: 14px;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(59,130,246,.35));
  z-index: 9;
  animation: raindrop-fall 0.6s linear forwards;
}

@keyframes raindrop-fall {
  0% { opacity: 0.8; transform: translate(-50%, -50%) translateY(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) translateY(30px); }
}

.ov-sprout {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(34,197,94,.25));
  z-index: 6;
  animation: sprout-grow 0.5s ease-out forwards;
}

@keyframes sprout-grow {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.ov-bubble {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(191, 219, 254, .95);
  background:
    radial-gradient(circle at 30% 28%, rgba(255,255,255,.95), rgba(255,255,255,.05) 28%, rgba(147,197,253,.16) 64%, rgba(191,219,254,.05) 100%);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.25) inset,
    0 4px 12px rgba(59,130,246,.18);
  z-index: 9;
}

.ov-bubble::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,.82);
}

.ov-water-shot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #7dd3fc 45%, #0ea5e9 90%);
  box-shadow: 0 0 10px rgba(14,165,233,.45);
  z-index: 10;
}

.ov-gust {
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 2px 6px rgba(255,255,255,.22));
  z-index: 8;
}

.ov-explosion {
  font-size: 34px;
  line-height: 1;
  z-index: 11;
}

.ov-bomb-shadow {
  width: 18px;
  height: 8px;
  border-radius: 50%;
  background: rgba(0,0,0,.25);
  filter: blur(2px);
  z-index: 7;
}

.ov-bomb {
  font-size: 22px;
  line-height: 1;
  z-index: 10;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.2));
}

@keyframes explode {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.35); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.55); }
}

/* ── SPRITE 2D ── */
#playerSprite {
  font-size: 38px;
  line-height: 1;
  display: block;
  user-select: none;
  transform-origin: bottom center;
  will-change: transform;
  transition: transform 0.08s ease;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.45));
}

@keyframes playerBob {
  0%,100% { transform: translateY(0)   scaleX(1)    scaleY(1);    }
  25%      { transform: translateY(-5px) scaleX(0.94) scaleY(1.06); }
  75%      { transform: translateY(-2px) scaleX(0.97) scaleY(1.03); }
}

#player.dir-r  #playerSprite { transform: rotate(9deg)  scaleX(1); }
#player.dir-l  #playerSprite { transform: rotate(-9deg) scaleX(1); }
#player.dir-u  #playerSprite { transform: scaleY(0.88) translateY(4px); }
#player.dir-d  #playerSprite { transform: scaleY(1.08) translateY(-3px); }
#player.dir-ur #playerSprite { transform: rotate(7deg)  scaleY(0.92); }
#player.dir-ul #playerSprite { transform: rotate(-7deg) scaleY(0.92); }
#player.dir-dr #playerSprite { transform: rotate(7deg)  scaleY(1.05); }
#player.dir-dl #playerSprite { transform: rotate(-7deg) scaleY(1.05); }

#player.walk #playerSprite {
  animation: playerBob 0.28s ease-in-out infinite;
}
#player.walk.dir-r  #playerSprite,
#player.walk.dir-l  #playerSprite,
#player.walk.dir-ur #playerSprite,
#player.walk.dir-ul #playerSprite,
#player.walk.dir-dr #playerSprite,
#player.walk.dir-dl #playerSprite { animation-duration: 0.26s; }
#player.walk.dir-u  #playerSprite,
#player.walk.dir-d  #playerSprite { animation-duration: 0.22s; }

#playerShadow {
  position: absolute;
  bottom: -6px;
  left: 15%;
  width: 70%;
  height: 10px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 50%;
  filter: blur(3px);
  z-index: -1;
}

#player.jumping #playerSprite {
  animation: playerJump 0.52s cubic-bezier(0.33, 0, 0.2, 1) !important;
}

@keyframes playerJump {
  0%   { transform: translateY(0)    scaleX(1.12) scaleY(0.88); }
  15%  { transform: translateY(-6px) scaleX(0.94) scaleY(1.06); }
  42%  { transform: translateY(-36px) scaleX(0.92) scaleY(1.10); }
  58%  { transform: translateY(-36px) scaleX(0.92) scaleY(1.10); }
  88%  { transform: translateY(-3px) scaleX(1.06) scaleY(0.95); }
  100% { transform: translateY(0)    scaleX(1)    scaleY(1); }
}

#player.jumping #playerShadow {
  transform: translateX(-50%) scaleX(1.55) scaleY(.38);
  opacity: .12;
}

#player.riding-bubble #playerSprite {
  transform: translateY(-28px) scale(1.15) !important;
  animation: playerBob 1s ease-in-out infinite !important;
}

#player.riding-bubble #playerShadow {
  transform: translateX(-50%) scaleX(1.4) scaleY(0.3) !important;
  opacity: 0.15 !important;
}

.prox-bubble {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) scale(0);
  background: #fff;
  color: #222;
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .4);
  pointer-events: none;
  transition: transform .18s cubic-bezier(.175, .885, .32, 1.275);
  z-index: 20;
  border: 1.5px solid rgba(0, 0, 0, .1);
}

.prox-bubble.visible {
  transform: translateX(-50%) scale(1);
  pointer-events: auto;
  cursor: pointer;
}

.prox-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #fff;
}

/* ── ON-MAP SPEECH BUBBLE ── */
.map-speech-bubble {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) scale(0);
  background: linear-gradient(135deg, #ffffff 0%, #f8f8f8 100%);
  color: #222;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 20px;
  white-space: nowrap;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, .35),
    0 2px 8px rgba(0, 0, 0, .15),
    inset 0 1px 0 rgba(255, 255, 255, .8);
  pointer-events: none;
  transition: transform .3s cubic-bezier(.175, .885, .32, 1.275), opacity .3s ease;
  z-index: 999;
  border: 2px solid rgba(255, 215, 0, .4);
  max-width: 260px;
  line-height: 1.4;
}

.map-speech-bubble.visible {
  transform: translateX(-50%) scale(1);
}

.map-speech-bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #ffffff;
}

.map-speech-bubble strong {
  color: #FF8C00;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(255, 140, 0, .2);
}

/* ── JUMP BUTTON ── */
#jumpBtn {
  position: absolute;
  bottom: calc(60px + 74px);
  right: 14px;
  width: 52px;
  height: 52px;
  background: radial-gradient(circle at 38% 35%, rgba(255,230,60,.95), rgba(220,140,0,.92));
  border: 2.5px solid rgba(255, 225, 80, .9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: #7a3d00;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 4px 0 rgba(150,90,0,.6), 0 6px 16px rgba(200,140,0,.45);
  transition: transform .07s, box-shadow .07s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#jumpBtn:active, #jumpBtn.pressed {
  transform: translateY(3px) scale(.93);
  box-shadow: 0 1px 0 rgba(150,90,0,.6), 0 2px 8px rgba(200,140,0,.3);
}

/* HUD ZONE */
#hudZone {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .68);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 20px;
  padding: 5px 14px;
  font-family: 'Fredoka One', cursive;
  font-size: clamp(11px, 3vw, 14px);
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  z-index: 15;
  max-width: calc(100% - 180px);
  text-overflow: ellipsis;
  overflow: hidden;
}

/* MINIMAP */
#mm {
  position: absolute;
  top: 8px;
  right: 8px;
  width: clamp(70px, 12vw, 90px);
  height: clamp(50px, 9vw, 65px);
  border: 2px solid rgba(255, 255, 255, .22);
  border-radius: 10px;
  overflow: hidden;
  background: #0d1a0d;
  z-index: 15;
}

.mmz {
  position: absolute;
  border-radius: 3px;
  opacity: .7;
}

#mmd {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #00ff88;
  border-radius: 50%;
  border: 1.5px solid #fff;
  z-index: 2;
  box-shadow: 0 0 5px #00ff88;
}

/* JOYSTICK */
#joystick {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 110px;
  height: 110px;
  z-index: 20;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#joyBase {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .38);
  border: 2.5px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(4px);
}
#joyBase::before, #joyBase::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,.10);
  border-radius: 2px;
}
#joyBase::before { width: 1.5px; height: 60%; top: 20%; left: 50%; transform: translateX(-50%); }
#joyBase::after  { width: 60%;  height: 1.5px; left: 20%; top: 50%; transform: translateY(-50%); }

#joyKnob {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 34%, rgba(255,255,255,.55) 0%, rgba(180,220,255,.28) 50%, rgba(80,160,255,.22) 100%);
  border: 2.5px solid rgba(255, 255, 255, .55);
  box-shadow: 0 3px 14px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.4);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  transition: transform 0.08s ease;
  pointer-events: none;
}
#joyKnob.active { transition: none; }

/* ═══════════════════════════════════════
   SLOTS BAR — top of bottom controls
   ═══════════════════════════════════════ */

#slotsBar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: linear-gradient(180deg, rgba(10,16,20,.97) 0%, rgba(10,16,20,.99) 100%);
  border-top: none;
  z-index: 850;
}

.power-slot {
  position: relative;
  width: clamp(52px, 11vw, 68px);
  height: clamp(52px, 11vw, 68px);
  background: rgba(30, 20, 10, 0.9);
  border: 2px solid rgba(139, 94, 60, 0.7);
  border-radius: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(24px, 5vw, 32px);
  cursor: pointer;
  transition: all .2s cubic-bezier(.4, 0, .2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,.05);
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.power-slot.selected {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.2);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.4), inset 0 0 10px rgba(251, 191, 36, 0.2);
  transform: translateY(-4px) scale(1.05);
}

.power-slot.selected::after {
  content: '';
  position: absolute;
  inset: -6px;
  border: 2px solid #fbbf24;
  border-radius: 22px;
  opacity: .5;
  animation: slotPulseSelected 1.5s infinite;
  pointer-events: none;
}

@keyframes slotPulseSelected {
  0% { transform: scale(1); opacity: .5; }
  100% { transform: scale(1.2); opacity: 0; }
}

.power-slot.glow:active,
.power-slot.selected:active {
  transform: scale(.88);
}

.power-slot .plus {
  font-size: 28px;
  color: rgba(212, 165, 116, 0.45);
  line-height: 1;
  font-weight: 400;
}

.power-slot.glow {
  border-color: #fbbf24;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.5), 0 4px 12px rgba(0,0,0,.5);
  animation: slotPulse 1.5s ease-in-out infinite alternate;
}

@keyframes slotPulse {
  from { box-shadow: 0 0 8px rgba(251, 191, 36, 0.3), 0 4px 12px rgba(0,0,0,.5); }
  to   { box-shadow: 0 0 22px rgba(251, 191, 36, 0.6), 0 0 36px rgba(251, 191, 36, 0.2), 0 4px 12px rgba(0,0,0,.5); }
}

.power-slot .sclr {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #ff4444;
  color: #fff;
  font-size: 10px;
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(255,0,0,.4);
}

#slotsWrap.edit-mode .power-slot .sclr {
  display: flex;
}

#slotsWrap.edit-mode .power-slot {
  animation: jiggle .3s ease-in-out infinite alternate;
}

@keyframes jiggle {
  0% { transform: rotate(-2deg); }
  100% { transform: rotate(2deg); }
}

#editSlotsBtn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(30, 40, 50, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  user-select: none;
  -webkit-user-select: none;
  outline: none;
  flex-shrink: 0;
}

#editSlotsBtn:active {
  transform: scale(0.85);
}

#slotsWrap.edit-mode #editSlotsBtn {
  background: rgba(255, 68, 68, 0.85);
  border-color: rgba(255, 100, 100, 0.6);
  box-shadow: 0 0 15px rgba(255, 68, 68, 0.4);
}

/* ═══════════════════════════════════════
   CONTROL AREA — D-pad + Pause + A/B
   ═══════════════════════════════════════ */

#controlArea {
  position: absolute;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(10,16,20,.97) 0%, rgba(8,12,16,.99) 100%);
  border-top: none;
  z-index: 900;
}

/* ── PAUSE BUTTON (hamburger, circular) ── */
#pauseBtn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: 2px solid rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  z-index: 910;
  transition: all .15s;
  user-select: none;
  -webkit-user-select: none;
}

#pauseBtn:hover {
  background: rgba(255,255,255,.14);
  border-color: rgba(255,255,255,.25);
  color: #fff;
}

#pauseBtn:active {
  transform: translate(-50%, -50%) scale(.9);
}

/* ── BUTTON A (Jump) — ROJO Nintendo ── */
#btnA {
  position: absolute;
  right: 24px;
  bottom: 110px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #e60012 0%, #cc0000 60%, #a80000 100%);
  border: 2.5px solid rgba(255,80,80,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  color: rgba(255,255,255,.95);
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 910;
  box-shadow: 0 4px 0 #7a0000, 0 6px 16px rgba(230,0,18,.35);
  transition: transform .07s, box-shadow .07s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#btnA:active, #btnA.pressed {
  transform: translateY(3px) scale(.93);
  box-shadow: 0 1px 0 #7a0000, 0 2px 8px rgba(230,0,18,.25);
}

/* ── BUTTON B (Action) — VERDE Nintendo ── */
#btnB {
  position: absolute;
  right: 84px;
  bottom: 52px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #00c853 0%, #009624 60%, #006d18 100%);
  border: 2.5px solid rgba(80,220,120,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  color: rgba(255,255,255,.95);
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
  letter-spacing: 1px;
  cursor: pointer;
  z-index: 910;
  box-shadow: 0 4px 0 #004d12, 0 6px 16px rgba(0,200,83,.35);
  transition: transform .07s, box-shadow .07s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#btnB:active, #btnB.pressed {
  transform: translateY(3px) scale(.93);
  box-shadow: 0 1px 0 #004d12, 0 2px 8px rgba(0,200,83,.25);
}

#btnB.ready {
  background: radial-gradient(circle at 38% 35%, #69f0ae 0%, #00e676 60%, #00c853 100%);
  border-color: rgba(150,255,180,.6);
  box-shadow: 0 4px 0 #007e2e, 0 6px 18px rgba(0,230,118,.45), 0 0 20px rgba(0,200,83,.2);
}

#btnB .base-emoji,
#btnB .overlay-emoji {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#btnB .base-emoji {
  z-index: 1;
}

#btnB .overlay-emoji {
  z-index: 2;
  font-size: 28px;
  transform: scale(.95);
}

/* ── CHAT BUBBLE — right side, above slots ── */
#chatBubble {
  position: absolute;
  right: 12px;
  bottom: 255px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--g);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  z-index: 860;
  box-shadow: 0 4px 20px rgba(0, 200, 83, .4);
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s;
  user-select: none;
  -webkit-user-select: none;
}

#chatBubble:hover {
  transform: scale(1.08);
}

#chatBubble:active {
  transform: scale(.92);
}

#chatBadge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0A1014;
  animation: bp 2s ease-in-out infinite;
}

/* ── ITEM PICKER POPUP ── */
#pickerOverlay {
  position: fixed;
  bottom: 260px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 16, 20, .95);
  border: 1px solid rgba(255,215,0,.2);
  border-radius: 16px;
  padding: 12px;
  z-index: 870;
  display: none;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  min-width: 260px;
}

#pickerOverlay.show {
  display: block;
  animation: pickerSlideUp .2s ease-out;
}

@keyframes pickerSlideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#pickerOverlay .picker-title {
  font-family: 'Fredoka One', cursive;
  font-size: 13px;
  color: #FFD700;
  text-align: center;
  margin-bottom: 8px;
}

#pickerItems {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.picker-item {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255,255,255,.06);
  border: 1.5px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  transition: all .15s;
}

.picker-item:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,215,0,.4);
  transform: scale(1.08);
}

.picker-item:active {
  transform: scale(.9);
}

#pickerCancel {
  display: block;
  margin: 8px auto 0;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.6);
  padding: 6px 20px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}

#pickerCancel:hover {
  background: rgba(255,255,255,.14);
  color: #fff;
}

/* ── PAUSE OVERLAY ── */
#pauseOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .85);
  backdrop-filter: blur(8px);
  z-index: 950;
  display: none;
  align-items: center;
  justify-content: center;
}

#pauseOverlay.show {
  display: flex;
  animation: fadeIn .2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#pauseMenu {
  background: linear-gradient(135deg, #1a1a2e, #16213e, #0f3460);
  border: 2px solid rgba(255,215,0,.2);
  border-radius: 20px;
  padding: 0;
  width: 280px;
  max-width: 90%;
  box-shadow: 0 12px 48px rgba(0,0,0,.6);
  overflow: hidden;
}

.pause-header {
  text-align: center;
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.pause-header span {
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  color: #FFD700;
  letter-spacing: 2px;
}

.pause-items {
  padding: 8px 0;
}

.pause-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background .15s;
  color: rgba(255,255,255,.8);
  font-size: 14px;
  font-weight: 600;
}

.pause-item:hover {
  background: rgba(255,255,255,.08);
}

.pause-item:active {
  background: rgba(255,255,255,.14);
}

.pause-item .pi-em {
  font-size: 22px;
  width: 28px;
  text-align: center;
}

.pause-item .pi-nm {
  flex: 1;
}

.pause-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: 4px 16px;
}

.pause-continue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  cursor: pointer;
  transition: background .15s;
  color: #4CAF50;
  font-family: 'Fredoka One', cursive;
  font-size: 15px;
  letter-spacing: 1px;
}

.pause-continue:hover {
  background: rgba(76,175,80,.1);
}

.pause-continue:active {
  background: rgba(76,175,80,.2);
}

/* ── WORLD MAP OVERLAY ── */
#worldMapOverlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at top, rgba(59,130,246,.18), transparent 35%),
    radial-gradient(circle at bottom, rgba(34,197,94,.12), transparent 32%),
    rgba(3, 8, 18, .92);
  backdrop-filter: blur(10px);
  z-index: 980;
}

#worldMapOverlay.show {
  display: flex;
  animation: fadeIn .18s ease-out;
}

#worldMapPanel {
  width: min(1120px, 100%);
  height: min(760px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(10,18,34,.96), rgba(7,13,24,.98));
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
}

.worldmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
}

.worldmap-title {
  font-family: 'Fredoka One', cursive;
  font-size: 24px;
  color: #f8fbff;
  letter-spacing: .4px;
}

.worldmap-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: rgba(227, 238, 255, .72);
}

.worldmap-close {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  transition: transform .14s ease, background .14s ease;
}

.worldmap-close:hover {
  background: rgba(255,255,255,.14);
}

.worldmap-close:active {
  transform: scale(.92);
}

#worldMapViewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  margin: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,.08), transparent 44%),
    linear-gradient(180deg, #6fc0ff 0%, #89d36f 36%, #6bc76b 100%);
  cursor: grab;
  touch-action: none;
}

#worldMapViewport.dragging {
  cursor: grabbing;
}

#worldMapCanvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 2800px;
  height: 2000px;
  transform-origin: top left;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,.15), transparent 14%),
    radial-gradient(circle at 78% 18%, rgba(255,255,255,.12), transparent 12%),
    radial-gradient(circle at 18% 80%, rgba(255,255,255,.10), transparent 12%),
    linear-gradient(180deg, #8fd3ff 0%, #8fe08c 33%, #6fcb67 100%);
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.08), 0 22px 44px rgba(0,0,0,.22);
}

.wm-road {
  position: absolute;
  background: rgba(247, 231, 189, .92);
  box-shadow: inset 0 0 0 6px rgba(155, 116, 43, .12);
}

.wm-road-h {
  height: 62px;
}

.wm-road-v {
  width: 62px;
}

.wm-zone {
  position: absolute;
  border-radius: 36px;
  border: 3px solid rgba(255,255,255,.16);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}

.wm-zone span {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(4, 10, 20, .42);
  color: #fff;
  font-family: 'Fredoka One', cursive;
  font-size: 48px;
  letter-spacing: .4px;
  text-shadow: 0 3px 12px rgba(0,0,0,.35);
  white-space: nowrap;
}

.wm-zone-market { background: linear-gradient(180deg, rgba(106, 168, 79, .8), rgba(76, 140, 55, .86)); }
.wm-zone-plaza { background: linear-gradient(180deg, rgba(111, 178, 111, .72), rgba(77, 148, 90, .8)); }
.wm-zone-castle { background: linear-gradient(180deg, rgba(60, 30, 70, .82), rgba(35, 18, 46, .92)); }
.wm-zone-tech { background: linear-gradient(180deg, rgba(20, 56, 118, .84), rgba(16, 34, 88, .92)); }
.wm-zone-fire { background: linear-gradient(180deg, rgba(148, 63, 26, .82), rgba(118, 33, 11, .92)); }
.wm-zone-forest { background: linear-gradient(180deg, rgba(29, 92, 43, .84), rgba(16, 56, 24, .92)); }

.wm-place {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  color: #11223a;
  font-weight: 900;
  font-size: 34px;
  line-height: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  white-space: nowrap;
}

#worldMapPlayer {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.wm-player-pulse,
.wm-player-dot,
.wm-player-label {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
}

.wm-player-pulse {
  width: 94px;
  height: 94px;
  border-radius: 50%;
  background: rgba(56, 189, 248, .18);
  border: 4px solid rgba(56, 189, 248, .38);
  animation: worldMapPulse 1.8s ease-out infinite;
}

.wm-player-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fef08a, #f59e0b);
  border: 5px solid #fff;
  box-shadow: 0 8px 18px rgba(0,0,0,.28);
}

.wm-player-label {
  transform: translate(-50%, calc(-100% - 16px));
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(4, 12, 24, .82);
  color: #fff9c4;
  font-family: 'Fredoka One', cursive;
  font-size: 30px;
  white-space: nowrap;
}

@keyframes worldMapPulse {
  0% { transform: translate(-50%, -50%) scale(.55); opacity: .95; }
  100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
}

/* ═══════════════════════════════════════
   OLD ELEMENTS — REMOVED
   ═══════════════════════════════════════ */

/* ── RESPONSIVE STYLES ── */
@media(max-width:899px) {
  :root {
    --controls-h: 240px;
    --map-bottom-safe: 240px;
  }

  #bottomControls {
    height: 240px;
  }

  #controlArea {
    top: 70px;
  }

  #chatBubble {
    bottom: 265px;
  }

  #btnA {
    right: 20px;
    bottom: 100px;
  }

  #btnB {
    right: 76px;
    bottom: 46px;
  }

  #pauseBtn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  #worldMapOverlay {
    padding: 12px;
  }

  #worldMapPanel {
    height: min(720px, calc(100vh - 24px));
    border-radius: 18px;
  }

  .worldmap-header {
    padding: 14px 14px 12px;
  }

  .worldmap-title {
    font-size: 20px;
  }

  .worldmap-subtitle {
    font-size: 12px;
  }

  #worldMapViewport {
    margin: 10px;
  }
}

@media(max-width:420px) {
  .tb-keys {
    display: none !important;
  }

  .tb-stat {
    padding: 2px 6px;
  }

  .tb-logo span {
    display: none;
  }

  .power-slot {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }

  #btnA, #btnB {
    width: 54px;
    height: 54px;
    font-size: 20px;
  }
}

.bnb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  color: var(--tx3);
  font-size: 9px;
  font-weight: 800;
  transition: color .15s;
  letter-spacing: .5px;
  padding: 4px 14px;
}

.bnb:hover,
.bnb.on {
  color: var(--g);
}

.bni {
  font-size: clamp(18px, 5vw, 22px);
  line-height: 1;
}

/* ── FAB BUTTON (Inbox) ── */
#fab {
  position: absolute;
  bottom: calc(60px + 10px);
  right: 12px;
  width: 54px;
  height: 54px;
  background: var(--g);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  cursor: pointer;
  z-index: 20;
  box-shadow: 0 4px 24px rgba(0, 200, 83, .45);
  transition: transform .12s;
}

#fab:hover {
  transform: scale(1.08);
}

#fab:active {
  transform: scale(.92);
}

#fbadge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #0A1014;
  animation: bp 2s ease-in-out infinite;
}

@keyframes bp {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ── RESPONSIVE STYLES ── */
@media(max-width:899px) {
  #fab {
    width: 60px;
    height: 60px;
    font-size: 28px;
    right: 10px;
  }

  #bNav {
    height: 56px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #dpad {
    bottom: calc(56px + 10px);
  }

  #fab {
    bottom: calc(56px + 10px);
  }
}

@media(max-width:420px) {
  .tb-keys {
    display: none !important;
  }

  .tb-stat {
    padding: 2px 6px;
  }

  .tb-logo span {
    display: none;
  }

  .worldmap-title {
    font-size: 18px;
  }

  .worldmap-close {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }
}

@media(min-width:1400px) {
  #ibPanel.open {
    width: 420px;
  }
}

/* BACKGROUND CLASSES */
.bg0 {
  background: radial-gradient(circle, #2d4a2f, #1b3320);
}

.bg1 {
  background: radial-gradient(circle, #3a1a1a, #200a0a);
}

.bg2 {
  background: radial-gradient(circle, #1a1a3a, #0a0a20);
}

.bg3 {
  background: radial-gradient(circle, #3a2010, #200808);
}

.bg4 {
  background: radial-gradient(circle, #2a1a3a, #150a20);
}
.bg5 {
  background: radial-gradient(circle, #1B5E20, #2E7D32);
}

/* CAVE ENTRANCE */
.cave-entrance {
  position: absolute;
  z-index: 4;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.cave-entrance .cave-em { font-size: 52px; line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.8));
  animation: cavePulse 3s ease-in-out infinite; }
.cave-entrance .cave-lbl {
  font-size: 10px; font-weight: 900; color: #e8d5a0;
  text-shadow: 0 2px 6px #000; background: rgba(0,0,0,.7);
  padding: 2px 8px; border-radius: 8px; white-space: nowrap;
}
@keyframes cavePulse {
  0%,100%{ filter: drop-shadow(0 4px 12px rgba(0,0,0,.8)) brightness(1); }
  50%    { filter: drop-shadow(0 4px 18px rgba(180,120,50,.6)) brightness(1.12); }
}
.cave-blocked { cursor: not-allowed; }
.cave-blocked .cave-em { filter: grayscale(.5) drop-shadow(0 4px 12px rgba(0,0,0,.8)); }

#caveBlockMsg {
  position: fixed; bottom: 260px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.92); color: #FFD700;
  font-size: 13px; font-weight: 900;
  padding: 10px 20px; border-radius: 14px;
  border: 1.5px solid rgba(255,215,0,.5);
  z-index: 800; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  white-space: nowrap; text-align: center;
}
#caveBlockMsg.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* CAVE LOADER */
#caveLoader {
  position: absolute; inset: 0;
  background: #0a0510;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; z-index: 10;
}
.cave-load-em { font-size: 56px; animation: cavePulse 1.2s ease-in-out infinite; }
.cave-load-bar {
  width: min(260px, 80vw); height: 8px;
  background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden;
}
.cave-load-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #8B4513, #FFD700);
  border-radius: 4px;
  animation: caveLoadAnim 1.8s ease-in-out forwards;
}
@keyframes caveLoadAnim {
  0%  { width: 0%; }
  60% { width: 75%; }
  90% { width: 92%; }
  100%{ width: 100%; }
}
.cave-load-txt {
  font-family: 'Fredoka One', cursive;
  font-size: 14px; color: #e8d5a0;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}

/* GAME FRAME OVERLAY */
.game-frame-ov {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.96);
  z-index: 950;
  display: none; flex-direction: column;
}
.game-frame-ov.show { display: flex; }
.frame-hdr {
  background: rgba(0,0,0,.8); padding: 8px 16px;
  display: flex; align-items: center; gap: 10px;
}
.frame-hdr { border-bottom: 1px solid rgba(255,255,255,.1); flex-shrink: 0; }
.frame-close-btn {
  background: rgba(255,255,255,.1); border: none; border-radius: 50%;
  width: 30px; height: 30px; color: #fff; font-size: 16px;
  cursor: pointer; display:flex; align-items:center; justify-content:center;
}
.frame-body {
  flex: 1; position: relative; overflow: hidden;
}
.frame-body iframe {
  position: absolute; inset: 0;
  width: 100%; height: 100%; border: none;
}
.frame-body #caveLoader {
  position: absolute; inset: 0; z-index: 10;
}
.frame-body #mercadoLoader,
.frame-body #emojiGameLoader,
.frame-body #eddyLoader {
  position: absolute; inset: 0; z-index: 10;
  background: #0a1005;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
}

.frame-body #emojiGameLoader,
.frame-body #eddyLoader { background: #082033; }
.emoji-load-em { font-size: 56px; animation: cavePulse 1.2s ease-in-out infinite; }
.emoji-load-txt { font-family: 'Fredoka One', cursive; font-size: 14px; color: #f0a0ff; text-shadow: 0 2px 8px rgba(0,0,0,.8); }
.emoji-load-bar { width: min(260px, 80vw); height: 8px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
.emoji-load-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #aa00ff, #ff0055); border-radius: 4px; animation: caveLoadAnim 1.8s ease-in-out forwards; }


/* ALIEN SHIP */
.alien-ship {
  position: absolute; z-index: 8; cursor: pointer;
  animation: alienHover 2s ease-in-out infinite;
}
@keyframes alienHover {
  0%,100%{ transform: translateY(0) scale(1); filter: drop-shadow(0 0 20px rgba(150,50,255,.6)); }
  50%    { transform: translateY(-12px) scale(1.04); filter: drop-shadow(0 0 35px rgba(150,50,255,.9)); }
}
.alien-ship .ship-em { font-size: 72px; line-height: 1; }
.alien-ship .prox-bubble { bottom: calc(100% + 4px); }

#invasionOverlay {
  position: fixed; inset: 0;
  background: rgba(5,0,20,.92);
  z-index: 945; display: none;
  flex-direction: column; align-items: center; justify-content: center;
}
#invasionOverlay.show { display: flex; }

#elfaGateOv {
  position: fixed; inset: 0;
  background: rgba(0,20,10,.9);
  z-index: 940; display: none;
  align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
#elfaGateOv.show { display: flex; }
#elfaCard {
  background: linear-gradient(160deg,#0a2e18,#1a5c30);
  border: 3px solid #69F0AE; border-radius: 22px;
  padding: 26px 22px; width: min(360px,94vw);
  text-align: center;
  box-shadow: 0 0 60px rgba(105,240,174,.25), 0 20px 60px rgba(0,0,0,.6);
  animation: pop .35s cubic-bezier(.175,.885,.32,1.275);
}

#alienGateOv {
  position: fixed; inset: 0;
  background: rgba(20,10,30,.9);
  z-index: 940; display: none;
  align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
#alienGateOv.show { display: flex; }
#alienGateCard {
  background: linear-gradient(160deg,#2a0a1a,#4a1a30);
  border: 3px solid #FF6B6B; border-radius: 22px;
  padding: 26px 22px; width: min(360px,94vw);
  text-align: center;
  box-shadow: 0 0 60px rgba(255,107,107,.25), 0 20px 60px rgba(0,0,0,.6);
  animation: pop .35s cubic-bezier(.175,.885,.32,1.275);
}

/* PHASE BANNER */
#phaseBanner {
  position: fixed; top: 0; left: 0; right: 0;
  background: linear-gradient(135deg,#b71c1c,#880e4f);
  color: #fff; font-family:'Fredoka One',cursive;
  font-size: clamp(16px,4vw,26px);
  padding: 14px 20px; text-align: center; z-index: 999;
  transform: translateY(-100%);
  transition: transform .5s cubic-bezier(.175,.885,.32,1.275);
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
}
#phaseBanner.show { transform: translateY(0); }

/* JUMPABLE OBJECTS */
.jumpable-obj.on-top { filter: brightness(1.2) drop-shadow(0 6px 14px rgba(0,0,0,.7)) !important; }

/* BURIED SPOTS */
.buried-spot {
  position: absolute;
  width: 34px; height: 20px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(120,80,20,.7) 0%, rgba(80,50,10,.3) 60%, transparent 100%);
  z-index: 5;
  cursor: default;
  pointer-events: none;
}
.buried-spot .dig-prompt {
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%) scale(0);
  background: rgba(10,10,10,.9);
  color: #FFD700;
  font-size: 11px; font-weight: 900;
  padding: 4px 10px; border-radius: 10px;
  white-space: nowrap; pointer-events: none;
  transition: transform .18s cubic-bezier(.175,.885,.32,1.275);
  border: 1.5px solid rgba(255,215,0,.55);
}
.buried-spot.near .dig-prompt { transform: translateX(-50%) scale(1); }
.buried-spot.found { display: none; }

/* DIG BUTTON */
#digBtn {
  position: fixed; bottom: 78px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: linear-gradient(135deg,#8B4513,#5D2E0C);
  color: #FFD700; border: 2.5px solid #FFD700;
  border-radius: 24px; padding: 9px 24px;
  font-family: 'Fredoka One', cursive; font-size: 15px;
  cursor: pointer; z-index: 290; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 4px 18px rgba(0,0,0,.55);
}
#digBtn.show { opacity: 1; pointer-events: all; transform: translateX(-50%) translateY(0); }

/* dig anim */
.dig-fx {
  position: fixed; font-size: 34px; z-index: 9999;
  pointer-events: none; animation: digFx .45s ease-out forwards;
}
@keyframes digFx {
  0%  { opacity:1; transform: rotate(-20deg) translateY(0); }
  40% { opacity:1; transform: rotate(15deg)  translateY(-18px); }
  100%{ opacity:0; transform: rotate(0)      translateY(-30px); }
}
.collect-float {
  position: fixed; font-size: 20px; font-weight: 900;
  color: #FFD700; text-shadow: 0 2px 8px rgba(0,0,0,.8);
  pointer-events: none; z-index: 9999;
  animation: floatUp .95s ease-out forwards;
}
@keyframes floatUp {
  0%  { opacity:1; transform: translateY(0); }
  100%{ opacity:0; transform: translateY(-55px); }
}

/* POWER BAR */
#powerWrap {
  flex: 1; height: 12px; background: rgba(255,255,255,.1);
  border-radius: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,.15);
}
#powerBar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg,#69F0AE,#FFD740,#FF5252);
  transition: width .04s linear;
}

/* INVENTORY */
/* INVENTORY PANEL */
#invPanel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 60vh;
  background: rgba(15, 25, 30, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 32px 32px 0 0;
  z-index: 1000;
  transform: translateY(102%);
  transition: transform .4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex; flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  padding: 0;
}

#invPanel.open { transform: translateY(0); }

#invHdr {
  padding: 24px 28px 16px;
  display: flex; align-items: center; justify-content: space-between;
}

.inv-title-wrap {
  display: flex; align-items: center; gap: 12px;
}

.inv-icon { font-size: 28px; }

.inv-title {
  font-family: 'Fredoka One', cursive;
  font-size: 22px; color: #fff; letter-spacing: 0.5px;
}

#invClose {
  background: rgba(255, 255, 255, 0.1);
  border: none; border-radius: 12px;
  width: 36px; height: 36px; color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s;
}

#invClose:hover { background: rgba(255, 0, 0, 0.2); }

#invTabs {
  display: flex; gap: 8px; padding: 0 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.inv-tab {
  padding: 10px 18px; border-radius: 14px; font-size: 14px; font-weight: 700;
  color: var(--tx2); cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 8px; border: 1px solid transparent;
}

.inv-tab.active {
  background: rgba(255, 255, 255, 0.1); color: #fff; border-color: rgba(255, 255, 255, 0.1);
}

.inv-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05); color: var(--tx);
}

.tab-em { font-size: 18px; }

#invContent { flex: 1; overflow-y: auto; padding: 24px; }

#invGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 16px; }

.inv-slot {
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px; padding: 16px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.inv-slot:hover {
  background: rgba(255, 255, 255, 0.1); transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.2);
}

.inv-slot.active { background: rgba(0, 200, 83, 0.15); border-color: var(--g); }
.inv-slot .inv-em { font-size: 32px; }
.inv-slot .inv-nm {
  font-size: 11px; font-weight: 700; color: var(--tx2);
  text-align: center; line-height: 1.2;
}

#invEmpty { text-align: center; padding: 60px 20px; }
.empty-em { font-size: 48px; opacity: 0.2; margin-bottom: 12px; }
.empty-txt { color: var(--tx3); font-size: 14px; }
#invHdr {
  padding: 10px 16px 7px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0; background: rgba(0,0,0,.35);
}
#invHdr span { font-family:'Fredoka One',cursive; font-size:15px; color:#A5D6A7; flex:1; }
#invClose {
  background: rgba(255,255,255,.08); border: none; border-radius: 50%;
  width: 26px; height: 26px; color: #aaa; font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#invGrid {
  display: grid; grid-template-columns: repeat(auto-fill,minmax(78px,1fr));
  gap: 8px; padding: 10px 12px 14px; overflow-y: auto;
}
.inv-slot {
  background: rgba(255,255,255,.06); border: 2px solid rgba(255,255,255,.1);
  border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 8px 4px 5px;
  cursor: pointer; transition: all .15s; position: relative;
  min-height: 70px; justify-content: center;
}
.inv-slot.active  { border-color:#FFD700; background:rgba(255,215,0,.14); box-shadow:0 0 12px rgba(255,215,0,.28); }
.inv-slot.empty   { opacity:.28; cursor:default; }
.inv-slot:hover:not(.empty) { border-color:rgba(255,255,255,.3); }
.inv-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
}
.inv-em { font-size:28px; line-height:1; }
.inv-nm { font-size:9px; font-weight:800; color:#A5D6A7; text-align:center; line-height:1.2; }
.inv-qty {
  position:absolute;
  top:-6px;
  right:-10px;
  min-width:20px;
  height:20px;
  padding:0 5px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:11px;
  font-weight:900;
  color:#fff;
  background:linear-gradient(180deg,#f59e0b,#d97706);
  border:2px solid rgba(255,244,214,.9);
  box-shadow:0 3px 10px rgba(0,0,0,.4);
  z-index:2;
}
.inv-active-lbl {
  position: fixed; bottom: 254px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #FFD700;
  font-size: 12px; font-weight: 900;
  padding: 4px 12px; border-radius: 10px;
  border: 1.5px solid rgba(255,215,0,.4);
  z-index: 295; pointer-events: none; white-space: nowrap;
  display: none;
}
.inv-active-lbl.show { display: block; }

/* permit item */
.inv-slot.permit { border-color: #69F0AE; }

/* TOAST */
#toast {
  position: fixed;
  bottom: 315px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(10, 16, 20, .92);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 16px;
  z-index: 900;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.1);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* NOTIFICATIONS */
#msgNotifWrap {
  position: fixed;
  top: 120px;
  right: 14px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(340px, calc(100vw - 28px));
}
.mn-card {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 11px;
  background: #1a1a2e;
  border: 1.5px solid rgba(255,255,255,.10);
  border-left: 3px solid #25D366;
  border-radius: 14px;
  padding: 10px 12px 10px 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.3);
  cursor: pointer;
  transform: translateX(120%);
  opacity: 0;
  transition: transform .32s cubic-bezier(.22,.68,0,1.2), opacity .28s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  max-width: 100%;
}
.mn-card.mn-in {
  transform: translateX(0);
  opacity: 1;
}
.mn-card.mn-out {
  transform: translateX(120%);
  opacity: 0;
}
.mn-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.mn-body {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.mn-app {
  font-size: 9px;
  font-weight: 900;
  color: #25D366;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 1px;
}
.mn-nm {
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.mn-txt {
  font-size: 12px;
  color: rgba(255,255,255,.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  margin-top: 1px;
}
.mn-txt em { color: rgba(255,255,255,.85); font-style: normal; }
.mn-txt strong { color: #FFD700; }
.mn-x {
  background: rgba(255,255,255,.08);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  color: rgba(255,255,255,.5);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  padding: 0;
  line-height: 1;
}
.mn-x:hover { background: rgba(255,255,255,.18); color: #fff; }
.mn-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: #25D366;
  border-radius: 0 0 14px 14px;
  transform-origin: left;
  animation: mnBar linear forwards;
}
@keyframes mnBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ── ZONA REAL WALLS ── */
.castle-wall {
  position: absolute;
  background: linear-gradient(135deg, #bbb 25%, transparent 25%) -10px 0,
              linear-gradient(225deg, #bbb 25%, transparent 25%) -10px 0,
              linear-gradient(315deg, #ccc 25%, transparent 25%),
              linear-gradient(45deg, #ccc 25%, transparent 25%);
  background-size: 20px 20px;
  background-color: #b0b0b0;
  border: 4px solid #888;
  box-shadow: inset 0 0 15px rgba(0,0,0,.15);
  z-index: 10;
}

.breakable-wall {
  position: absolute;
  cursor: pointer;
  background-color: #795548;
  background-image: 
    linear-gradient(335deg, #5d4037 23px, transparent 23px),
    linear-gradient(155deg, #5d4037 23px, transparent 23px),
    linear-gradient(335deg, #5d4037 23px, transparent 23px),
    linear-gradient(155deg, #5d4037 23px, transparent 23px);
  background-size: 58px 58px;
  background-position: 0px 2px, 4px 35px, 29px 31px, 34px 6px;
  border: 1px solid #3e2723;
  box-shadow: 2px 4px 6px rgba(0,0,0,.3);
  overflow: hidden;
  z-index: 11;
}

/* ── CAVE HOLE & EXCAVABLE ── */
.cave-entrance {
  position: absolute;
  width: 60px;
  height: 60px;
  cursor: pointer;
  z-index: 5;
}

.cave-hole {
  font-size: 40px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.5));
  animation: holePulse 2s ease-in-out infinite;
}

@keyframes holePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.buried-spot.excavable {
  background: radial-gradient(circle, #8d6e63 10%, #6d4c41 40%, transparent 70%);
  border-radius: 50%;
  animation: excavatePulse 3s ease-in-out infinite;
}

@keyframes excavatePulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: .7; }
  50% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
}

/* ── ROAD SIGNS (wooden directional signs) ── */
.road-sign {
  position: absolute;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,.4));
}

.road-sign .sign-post {
  width: 8px;
  height: 40px;
  background: linear-gradient(90deg, #5d4037, #8d6e63, #5d4037);
  border-radius: 2px;
}

.road-sign .sign-board {
  background: linear-gradient(180deg, #a1887f 0%, #8d6e63 30%, #795548 70%, #6d4c41 100%);
  border: 2px solid #4e342e;
  border-radius: 6px;
  padding: 4px 10px;
  white-space: nowrap;
  font-family: 'Fredoka One', cursive;
  font-size: 11px;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0,0,0,.6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 2px 4px rgba(0,0,0,.3);
  letter-spacing: 0.5px;
}

.road-sign .sign-board::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 4px;
  right: 4px;
  height: 1px;
  background: rgba(255,255,255,.2);
border-radius: 1px;
  }

  /* 3-tab layout for the inventory panel */
  #invTabs {
    display: flex;
    gap: 6px;
    padding: 0 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #invTabs::-webkit-scrollbar { display: none; }

  .inv-tab {
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
    color: var(--tx2);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .inv-tab.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.1);
  }

  .inv-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--tx);
  }

  /* Emoji Powers panel uses its own internal layout */
  #invGrid:has(#_ep_panel) {
    display: block !important;
    grid-template-columns: unset !important;
  }

/* ═══════════════════════════════════════
   BLAZE MINIGAME - Animación de llamas
   ═══════════════════════════════════════ */
@keyframes blazeFlicker {
  0% { transform: scale(1) rotate(-2deg); opacity: 0.9; }
  50% { transform: scale(1.1) rotate(2deg); opacity: 1; }
  100% { transform: scale(0.95) rotate(-1deg); opacity: 0.85; }
}

.blaze-flame {
  animation: blazeFlicker 0.5s ease-in-out infinite alternate;
}

/* Efecto de apagado: vapor y gotas de agua */
@keyframes blazeExtinguishUp {
  0% { transform: translateY(0) scale(1); opacity: 0.9; }
  100% { transform: translateY(-40px) scale(1.4); opacity: 0; }
}

@keyframes blazeExtinguishDrop {
  0% { transform: translateY(0) scale(1); opacity: 0.8; }
  50% { opacity: 0.6; }
  100% { transform: translateY(20px) scale(0.6); opacity: 0; }
}

@keyframes blazeFlash {
  0% { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}

.blaze-extinguish-particle {
  animation: blazeExtinguishUp 0.6s ease-out forwards;
}

.blaze-extinguish-drop {
  animation: blazeExtinguishDrop 0.5s ease-in forwards;
}

.blaze-extinguish-flash {
  animation: blazeFlash 0.4s ease-out forwards;
}

