/* ═════════ Character panel (JG-003) — tap a rider on the map ═════════ */
.aa-char {
  --char: #2a9d8f;
  position: fixed;
  z-index: 40; /* over the HUD + control bar, under overlays / mini-games */
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 56vh;
  max-height: 56dvh;
  display: flex;
  padding: 0 max(0.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
  color: #263238;
  transform: translateY(105%);
  transition: transform 0.28s cubic-bezier(0.34, 1.2, 0.64, 1);
  pointer-events: none;
}
.aa-char[hidden] {
  display: none;
}
.aa-char.is-open {
  transform: none;
}
.aa-char__card {
  pointer-events: auto;
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: 1.6rem 1.6rem 1.2rem 1.2rem;
  background: #fffaf0;
  border: 5px solid #263238;
  box-shadow: 0 -4px 0 rgba(38, 50, 56, 0.18), 0 8px 0 rgba(38, 50, 56, 0.35);
  overflow: hidden;
}

/* Desktop / landscape tablets: a half-page panel on the right */
@media (min-width: 760px) and (min-aspect-ratio: 1/1) {
  .aa-char {
    left: auto;
    top: 0;
    width: min(46vw, 32rem);
    max-height: none;
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) 0;
    transform: translateX(105%);
  }
  .aa-char.is-open {
    transform: none;
  }
  .aa-char__card {
    border-radius: 1.6rem;
  }
}

.aa-char__close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  border: 4px solid #fff;
  background: #ff9800;
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(38, 50, 56, 0.35);
  cursor: pointer;
}
.aa-char__close:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(38, 50, 56, 0.35);
}

.aa-char__hero {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 3.8rem 0.8rem 0.9rem;
  background: var(--char);
  background: linear-gradient(180deg, color-mix(in srgb, var(--char) 78%, #fff), var(--char));
  border-bottom: 4px solid #263238;
}
.aa-char__portrait {
  flex-shrink: 0;
  width: 6.2rem;
  height: 6.2rem;
  padding: 0;
  border-radius: 50%;
  border: 4px solid #263238;
  background: #fff8e1;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(38, 50, 56, 0.35);
}
.aa-char__live {
  display: block;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 35%, #fffde7, #ffe0b2);
}
.aa-char__live canvas {
  display: block;
}
.aa-char__portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
  display: block;
}
.aa-char__portrait img.is-wiggle {
  animation: aa-char-wiggle 0.6s ease;
}
@keyframes aa-char-wiggle {
  0%, 100% { transform: rotate(0) scale(1); }
  25% { transform: rotate(-8deg) scale(1.06); }
  50% { transform: rotate(7deg) scale(1.08); }
  75% { transform: rotate(-4deg) scale(1.03); }
}
.aa-char__who {
  flex: 1;
  min-width: 0;
  color: #fff;
  text-shadow: 0 2px 0 rgba(38, 50, 56, 0.45);
}
.aa-char__title {
  margin: 0;
  display: inline-block;
  padding: 0.05rem 0.6rem;
  border-radius: 999px;
  background: #fff3c4;
  border: 3px solid #263238;
  color: #263238;
  text-shadow: none;
  font-weight: 700;
  font-size: 0.9rem;
}
.aa-char__name {
  margin: 0.15rem 0 0;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.05;
}
.aa-char__status {
  margin: 0.2rem 0 0;
  font-weight: 700;
  font-size: 0.95rem;
}
.aa-char__say {
  flex-shrink: 0;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  border: 4px solid #263238;
  background: #ffd54f;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(38, 50, 56, 0.35);
}
.aa-char__say:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(38, 50, 56, 0.35);
}

.aa-char__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.8rem 1rem 1.1rem;
}
.aa-char__hi {
  margin: 0 0 0.7rem;
  padding: 0.55rem 0.8rem;
  border-radius: 1rem;
  background: #fff;
  border: 3px solid #263238;
  font-weight: 700;
  font-size: 1.1rem;
}
.aa-char__facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.5rem;
}
.aa-char__facts li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.65rem;
  border-radius: 1rem;
  background: #fff;
  border: 3px solid color-mix(in srgb, var(--char) 55%, #263238);
  font-size: 1rem;
  line-height: 1.25;
}
.aa-char__facts b {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #607d8b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.aa-char__ico {
  flex-shrink: 0;
  font-size: 1.6rem;
}
.aa-char__story {
  margin-top: 0.8rem;
}
.aa-char__story h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 800;
}
.aa-char__story p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
  .aa-char {
    transition: none;
  }
  .aa-char__portrait img.is-wiggle {
    animation: none;
  }
}

/* ═════════ Speech bubbles (JG-005) — tiny Kairosoft-style ═════════ */
.aa-quips {
  position: fixed;
  inset: 0;
  z-index: 24; /* over the map, under the HUD + panels */
  pointer-events: none;
  overflow: hidden;
}
.aa-quip {
  position: absolute;
  left: 0;
  top: 0;
  margin-top: -10px;
  padding: 0.18rem 0.5rem 0.2rem;
  border-radius: 0.55rem;
  background: #fff;
  border: 3px solid #263238;
  box-shadow: 0 3px 0 rgba(38, 50, 56, 0.3);
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.15;
  color: #263238;
  white-space: nowrap;
  will-change: transform;
}
.aa-quip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 10px;
  height: 10px;
  margin-left: -6px;
  background: #fff;
  border-right: 3px solid #263238;
  border-bottom: 3px solid #263238;
  transform: rotate(45deg);
}
.aa-quip {
  animation: aa-quip-pop 0.28s cubic-bezier(0.34, 1.6, 0.64, 1) both;
}
.aa-quip.is-out {
  opacity: 0;
  transition: opacity 0.25s;
}
@keyframes aa-quip-pop {
  0% { scale: 0.3; }
  100% { scale: 1; }
}

/* Train-car camera: big ✕ to leave + what you're riding along with */
.aa-carcam {
  position: fixed;
  z-index: 26;
  top: max(4.6rem, calc(env(safe-area-inset-top) + 4rem));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.35rem 0.3rem 0.9rem;
  border-radius: 999px;
  background: #fffaf0;
  border: 4px solid #263238;
  box-shadow: 0 4px 0 rgba(38, 50, 56, 0.35);
  font-family: "Fredoka", "Nunito", system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: #263238;
}
.aa-carcam--tunnel {
  padding: 0.45rem 1rem;
  pointer-events: none;
}
.aa-carcam[hidden] {
  display: none;
}
.aa-carcam__close {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #ff9800;
  color: #fff;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(38, 50, 56, 0.35);
}

/* ═════════ Wish bubbles (JG-072) — a big picture over someone's head ═════════ */
.aa-wishes {
  position: fixed;
  inset: 0;
  z-index: 25; /* over the map + quips, under the HUD + panels */
  pointer-events: none;
  overflow: hidden;
}
.aa-wish {
  position: absolute;
  left: 0;
  top: 0;
  margin-top: -34px; /* above the little speech bubbles */
  padding: 0;
  border: 0;
  background: none;
  pointer-events: auto;
  cursor: pointer;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
}
.aa-wish__pic {
  position: relative;
  display: grid;
  place-items: center;
  width: 3.3rem;
  height: 3.1rem;
  border-radius: 1.4rem;
  background: #fff;
  border: 4px solid #263238;
  box-shadow: 0 4px 0 rgba(38, 50, 56, 0.3);
  font-size: 1.85rem;
  line-height: 1;
  animation: aa-wish-bob 2.4s ease-in-out infinite;
}
/* thought-bubble dots */
.aa-wish__pic::before,
.aa-wish__pic::after {
  content: "";
  position: absolute;
  left: 50%;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #263238;
}
.aa-wish__pic::before {
  width: 12px;
  height: 12px;
  bottom: -15px;
  margin-left: -9px;
}
.aa-wish__pic::after {
  width: 7px;
  height: 7px;
  bottom: -25px;
  margin-left: -3px;
}
.aa-wish.is-new .aa-wish__pic {
  animation: aa-wish-pop 0.5s cubic-bezier(0.34, 1.6, 0.64, 1) both, aa-wish-bob 2.4s ease-in-out 0.5s infinite;
}
.aa-wish.is-new::after {
  content: "✨";
  position: absolute;
  right: -0.9rem;
  top: -0.8rem;
  font-size: 1.3rem;
  animation: aa-wish-sparkle 1.6s ease-out 3 both;
  pointer-events: none;
}
.aa-wish.is-fade .aa-wish__pic {
  animation: aa-wish-shrink 1.5s ease-in both;
}
.aa-wish.is-done .aa-wish__pic {
  animation: aa-wish-yay 0.45s ease-in both;
}
@keyframes aa-wish-bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -5px; }
}
@keyframes aa-wish-pop {
  0% { scale: 0.2; }
  100% { scale: 1; }
}
@keyframes aa-wish-sparkle {
  0% { opacity: 0; scale: 0.4; rotate: -20deg; }
  30% { opacity: 1; scale: 1.15; }
  100% { opacity: 0; scale: 0.8; rotate: 20deg; }
}
@keyframes aa-wish-shrink {
  0% { scale: 1; opacity: 1; }
  60% { scale: 0.7; opacity: 1; }
  100% { scale: 0.2; opacity: 0; }
}
@keyframes aa-wish-yay {
  0% { scale: 1; }
  40% { scale: 1.35; }
  100% { scale: 0; opacity: 0; }
}
/* hearts floating up when a wish comes true */
.aa-wish-heart {
  position: fixed;
  z-index: 40;
  font-size: 1.6rem;
  pointer-events: none;
  translate: -50% -50%;
  animation: aa-wish-heart 1.5s ease-out both;
}
@keyframes aa-wish-heart {
  0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
  15% { opacity: 1; transform: translate(calc(var(--dx) * 0.2), -20px) scale(1.15); }
  100% { opacity: 0; transform: translate(var(--dx), -140px) scale(0.9); }
}
@media (prefers-reduced-motion: reduce) {
  .aa-wish__pic,
  .aa-wish.is-new .aa-wish__pic { animation: none; }
}

/* the Wish row in the character panel (JG-072) */
.aa-char__wish {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.8rem;
  padding: 0.55rem 0.7rem;
  border-radius: 1rem;
  background: #fffde7;
  border: 3px dashed #f9a825;
}
.aa-char__wish-pic {
  font-size: 2.4rem;
  line-height: 1;
}
.aa-char__wish-arrow {
  font-size: 1.3rem;
  color: #8d6e63;
  font-weight: 900;
}
.aa-char__wish-hint {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  font-size: 1.8rem;
  line-height: 1;
  flex: 1;
}
.aa-char__wish-say {
  flex-shrink: 0;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  border: 3px solid #263238;
  background: #ffd54f;
  font-size: 1.25rem;
  cursor: pointer;
}

/* JG-073: friendship hearts under the name */
.aa-char__hearts {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem 0.4rem;
  margin: 0.35rem 0 0;
  padding: 0.18rem 0.55rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.92);
  border: 2px solid #263238;
  color: #263238;
  font-weight: 800;
  font-size: 0.8rem;
  line-height: 1.2;
  text-shadow: none;
  -webkit-text-stroke: 0;
}
.aa-char__hearts-dots {
  font-size: 1rem;
  letter-spacing: 0.05em;
}
.aa-char__meter {
  position: relative;
  width: 3.4rem;
  height: 0.55rem;
  border-radius: 1rem;
  background: #fce4ec;
  border: 2px solid #263238;
  overflow: hidden;
}
.aa-char__meter i {
  position: absolute;
  inset: 0 auto 0 0;
  background: #f06292;
  transition: width 0.5s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.aa-char__hearts-n {
  font-size: 0.8rem;
  opacity: 0.85;
}
.aa-char__hearts.is-best .aa-char__hearts-label {
  color: #d81b60;
}
.aa-char__hearts.is-levelup {
  animation: aa-hearts-bump 0.6s cubic-bezier(0.34, 1.6, 0.64, 1);
}
.aa-char__hearts-pop {
  position: absolute;
  left: 1.2rem;
  top: -0.4rem;
  font-size: 2.6rem;
  pointer-events: none;
  animation: aa-hearts-pop 1.4s ease-out both;
}
@keyframes aa-hearts-bump {
  0% { scale: 1; }
  40% { scale: 1.12; }
  100% { scale: 1; }
}
@keyframes aa-hearts-pop {
  0% { opacity: 0; transform: scale(0.3); }
  25% { opacity: 1; transform: scale(1.3); }
  100% { opacity: 0; transform: translateY(-40px) scale(1); }
}
.aa-char__dbg-heart {
  margin-top: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: 1rem;
  border: 2px solid #263238;
  background: #fff9c4;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

/* JG-074: friendship story lines (one per friend level) */
.aa-char__more {
  margin-top: 0.9rem;
}
.aa-char__more h3 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.35rem;
  font-size: 1rem;
}
.aa-char__more-say {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  border: 3px solid #263238;
  background: #ffd54f;
  font-size: 0.95rem;
  cursor: pointer;
}
.aa-char__more ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}
.aa-char__line {
  padding: 0.45rem 0.65rem;
  border-radius: 0.8rem;
  background: #fce4ec;
  border: 2px solid #f8bbd0;
  line-height: 1.35;
}
.aa-char__line.is-locked {
  background: #eceff1;
  border: 2px dashed #b0bec5;
  color: #607d8b;
  font-weight: 700;
}
.aa-char__line.is-new {
  background: #fff9c4;
  border-color: #ffca28;
  animation: aa-line-glow 1.6s ease-in-out 3;
}
.aa-char__new {
  padding: 0.05rem 0.4rem;
  border-radius: 0.6rem;
  background: #e91e63;
  color: #fff;
  font-size: 0.75rem;
}
@keyframes aa-line-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 202, 40, 0); }
  50% { box-shadow: 0 0 0 5px rgba(255, 202, 40, 0.55); }
}
/* JG-075 follow-up: the wish in words — what they wish for + how to make it happen */
.aa-char__wish-words {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.aa-char__wish-text {
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.3;
}
.aa-char__wish-tip {
  font-size: 0.88rem;
  line-height: 1.3;
  color: #5d4037;
}

/* JG-079: 🎁 Give a gift (the bag's gifts as big buttons; 💭 = they'd love it) */
.aa-char__gifts {
  margin: 0 0 0.8rem;
  padding: 0.5rem 0.6rem 0.6rem;
  border-radius: 1rem;
  background: #fce4ec;
  border: 3px solid #f06292;
}
.aa-char__gifts h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: #ad1457;
}
.aa-char__gift-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.aa-char__gift {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  width: 4.6rem;
  padding: 0.35rem 0.2rem 0.3rem;
  border-radius: 0.9rem;
  border: 3px solid #263238;
  background: #fff;
  box-shadow: 0 3px 0 #263238;
  font: inherit;
  color: #263238;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.aa-char__gift:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #263238;
}
.aa-char__gift.is-love {
  background: #fff8e1;
  border-color: #f9a825;
  box-shadow: 0 3px 0 #f9a825, 0 0 0 3px rgba(249, 168, 37, 0.25);
}
.aa-char__gift-love {
  position: absolute;
  top: -0.55rem;
  right: -0.4rem;
  font-size: 1.1rem;
}
.aa-char__gift-pic {
  font-size: 1.9rem;
  line-height: 1.1;
}
.aa-char__gift-name {
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}
.aa-char__gift-empty {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
}

/* JG-083: 👗 My things — what they keep; ✅ = wearing it */
.aa-char__things {
  margin: 0 0 0.8rem;
  padding: 0.5rem 0.6rem 0.5rem;
  border-radius: 1rem;
  background: #ede7f6;
  border: 3px solid #9575cd;
}
.aa-char__things h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: #5e35b1;
}
.aa-char__thing.is-on {
  background: #e8f5e9;
  border-color: #43a047;
  box-shadow: 0 3px 0 #43a047;
}
.aa-char__things-tip {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #5e35b1;
}

/* gift art (giftArt.js): pictures of the real parts, not emoji */
.aa-char__gift-pic img,
.aa-char__wish-pic img {
  display: block;
  width: 2.7rem;
  height: 2.4rem;
  object-fit: contain;
}
.aa-wish__img {
  display: block;
  width: 2.7rem;
  height: 2.5rem;
  object-fit: contain;
  pointer-events: none;
}
