/* Bods Journey — Mobile analog joystick + walking character */

.joy-wrap {
  position: fixed;
  top: 5rem;
  right: 0.8rem;
  z-index: 400;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Cinzel', serif;
  user-select: none;
  -webkit-user-select: none;
}

@media (max-width: 900px), (pointer: coarse) {
  .joy-wrap { display: flex; }
  .hotspot::after { display: none; }
  /* Hide the desktop mouse-following character on mobile */
  .character { display: none !important; }
}

/* LCD screen */
.joy-screen {
  width: 130px;
  padding: 0.4rem 0.55rem;
  background: linear-gradient(180deg, #1a2410 0%, #0d1606 100%);
  border: 2px solid #d4af37;
  border-radius: 5px;
  box-shadow:
    0 0 18px rgba(212,175,55,0.35),
    inset 0 0 12px rgba(0,0,0,0.7),
    0 4px 12px rgba(0,0,0,0.6);
  text-align: center;
  color: #89E900;
  text-shadow: 0 0 6px rgba(137,233,0,0.7);
}

.joy-eyebrow {
  font-size: 0.5rem;
  letter-spacing: 0.15em;
  color: #d4af37;
  text-shadow: 0 0 4px rgba(212,175,55,0.9);
  margin-bottom: 0.2rem;
}

.joy-name {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-height: 0.9rem;
  line-height: 1.1;
}

.joy-name.flash { animation: joyFlash 0.35s ease; }

@keyframes joyFlash {
  0% { opacity: 0.3; transform: scale(0.92); }
  100% { opacity: 1; transform: scale(1); }
}

/* Joystick base */
.joy-base {
  position: relative;
  width: 115px;
  height: 115px;
  background:
    radial-gradient(circle at 35% 30%, rgba(212,175,55,0.12) 0%, transparent 50%),
    linear-gradient(180deg, rgba(26,15,8,0.95) 0%, rgba(10,5,3,0.98) 100%);
  border: 3px solid #d4af37;
  border-radius: 50%;
  box-shadow:
    0 0 24px rgba(212,175,55,0.4),
    inset 0 0 30px rgba(0,0,0,0.75),
    inset 0 0 60px rgba(212,175,55,0.08),
    0 8px 18px rgba(0,0,0,0.65);
  touch-action: none;
}

.joy-base.dragging {
  box-shadow:
    0 0 40px rgba(212,175,55,0.7),
    inset 0 0 30px rgba(0,0,0,0.75),
    inset 0 0 60px rgba(212,175,55,0.18),
    0 8px 18px rgba(0,0,0,0.65);
}

.joy-ring {
  position: absolute;
  inset: 14px;
  border: 1px dashed rgba(212,175,55,0.35);
  border-radius: 50%;
  pointer-events: none;
}

.joy-compass { position: absolute; inset: 0; pointer-events: none; }
.joy-cp {
  position: absolute;
  font-size: 0.62rem;
  color: #b89a5e;
  letter-spacing: 0.08em;
  font-weight: 700;
  text-shadow: 0 0 6px rgba(0,0,0,0.8);
}
.joy-cp-n { top: 6px;    left: 50%; transform: translateX(-50%); }
.joy-cp-s { bottom: 6px; left: 50%; transform: translateX(-50%); }
.joy-cp-w { left: 7px;   top: 50%;  transform: translateY(-50%); }
.joy-cp-e { right: 7px;  top: 50%;  transform: translateY(-50%); }

/* Draggable knob */
.joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 35% 28%, #f4e8c1 0%, #d4af37 45%, #8b6f1f 100%);
  border: 2px solid #f4e8c1;
  border-radius: 50%;
  box-shadow:
    0 6px 14px rgba(0,0,0,0.8),
    inset 0 -6px 12px rgba(0,0,0,0.45),
    inset 0 4px 8px rgba(255,255,255,0.35),
    0 0 24px rgba(212,175,55,0.5);
  pointer-events: none;
  transition: transform 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.joy-base.dragging .joy-knob {
  transition: none;
  box-shadow:
    0 3px 8px rgba(0,0,0,0.8),
    inset 0 -4px 8px rgba(0,0,0,0.45),
    inset 0 3px 6px rgba(255,255,255,0.35),
    0 0 40px rgba(212,175,55,0.8);
}

/* ENTER button (below the joystick) — kept as visual indicator but auto-triggered */
.joy-enter {
  width: 130px;
  padding: 0.5rem 0.7rem;
  background: linear-gradient(180deg, rgba(40,30,15,0.9) 0%, rgba(20,12,6,0.95) 100%);
  border: 2px solid #7a6535;
  border-radius: 6px;
  color: #7a6535;
  font-family: 'Cinzel', serif;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: not-allowed;
  opacity: 0.55;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.1;
}

.joy-enter.ready {
  cursor: pointer;
  opacity: 1;
  color: #f4e8c1;
  border-color: #d4af37;
  background: linear-gradient(180deg, rgba(212,175,55,0.25) 0%, rgba(139,0,0,0.4) 100%);
  box-shadow:
    0 0 20px rgba(212,175,55,0.5),
    0 4px 10px rgba(0,0,0,0.6),
    inset 0 0 12px rgba(212,175,55,0.2);
  animation: joyEnterPulse 1.4s ease-in-out infinite;
}

@keyframes joyEnterPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(212,175,55,0.5), 0 4px 10px rgba(0,0,0,0.6), inset 0 0 12px rgba(212,175,55,0.2); }
  50%      { box-shadow: 0 0 30px rgba(212,175,55,0.85), 0 4px 10px rgba(0,0,0,0.6), inset 0 0 18px rgba(212,175,55,0.3); }
}

.joy-enter.ready:active,
.joy-enter.pressed {
  transform: translateY(2px) scale(0.96);
  background: linear-gradient(180deg, rgba(212,175,55,0.4) 0%, rgba(139,0,0,0.55) 100%);
}

.joy-hint {
  font-size: 0.55rem;
  color: #b89a5e;
  letter-spacing: 0.05em;
  text-align: center;
  font-style: italic;
  opacity: 0.75;
}

/* ==== CHARACTER on the map ==== */
.town-character {
  position: absolute;
  width: 35px;
  height: auto;
  transform: translate(-50%, -82%);
  transform-origin: center bottom;
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.85)) drop-shadow(0 0 18px rgba(212,175,55,0.35));
  transition: filter 0.3s ease;
  display: none;
}

/* Show character only on mobile */
@media (max-width: 900px), (pointer: coarse) {
  .town-character { display: block; }
}

.town-character.facing-left {
  transform: translate(-50%, -82%) scaleX(-1);
}

.town-character.walking {
  animation: charBob 0.4s ease-in-out infinite;
}

.town-character.facing-left.walking {
  animation: charBobLeft 0.4s ease-in-out infinite;
}

@keyframes charBob {
  0%, 100% { transform: translate(-50%, -82%); }
  50%      { transform: translate(-50%, -85%); }
}

@keyframes charBobLeft {
  0%, 100% { transform: translate(-50%, -82%) scaleX(-1); }
  50%      { transform: translate(-50%, -85%) scaleX(-1); }
}

.town-character.on-tower {
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.85)) drop-shadow(0 0 28px rgba(212,175,55,0.95));
}

.town-character.entering {
  animation: charEnter 0.26s ease forwards;
}

@keyframes charEnter {
  to {
    transform: translate(-50%, -82%) scale(1.4);
    opacity: 0;
    filter: drop-shadow(0 0 60px rgba(212,175,55,1));
  }
}

/* ==== Smaller phones ==== */
@media (max-width: 480px) {
  .joy-wrap {
    top: 4.5rem;
    right: 0.4rem;
    transform: scale(0.82);
    transform-origin: top right;
  }
  .town-character { width: 28px; }
}
