/* ==========================================================
   Poké Quest (PHP 8 + MySQL) - Мобильные стили CSS
   ========================================================== */

:root {
  --bg: #0b1020;
  --bg-2: #121933;
  --card: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #e2e8f0;
  --text-mute: #94a3b8;
  --accent: #facc15;
  --accent-2: #f97316;
  --good: #22c55e;
  --bad: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  position: relative;
  isolation: isolate;
  background-color: #071226;
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 90px;
}

/* Общая аниме-долина для всех страниц PHP-версии. */
body::before {
  content: "";
  position: fixed;
  z-index: -2;
  inset: 0;
  background-image: url('assets/anime-flower-meadow.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

body::after {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(2, 6, 23, .58) 0%, rgba(2, 6, 23, .30) 30%, rgba(2, 6, 23, .70) 100%),
    radial-gradient(90% 55% at 50% 0%, rgba(14, 165, 233, .20), transparent 75%),
    radial-gradient(75% 50% at 10% 100%, rgba(34, 197, 94, .18), transparent 72%);
  pointer-events: none;
}

/* Фон полностью статичный: никаких анимаций и сдвигов. */

.glow {
  text-shadow: 0 0 18px rgba(250, 204, 21, 0.35);
}

/* Верхняя шапка */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(11, 16, 32, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 16px;
}
.top-bar-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.logo-icon { font-size: 24px; }
.logo-title { font-size: 17px; font-weight: 700; color: #fff; }

.sound-toggle {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #facc15;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
}

.loading-state {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.card {
  background: linear-gradient(180deg, rgba(10,16,32,.88), rgba(2,6,18,.84));
  border: 1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(16px) saturate(1.05);
  -webkit-backdrop-filter: blur(16px) saturate(1.05);
  border-radius: 20px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.52), inset 0 1px 0 rgba(255,255,255,.04);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 9999px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.15s ease, background 0.2s ease;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, #f97316 0%, #facc15 100%);
  border-color: rgba(255, 255, 255, 0.2);
  color: #111827;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #db2777 100%);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-good {
  background: linear-gradient(135deg, #22c55e 0%, #14b8a6 100%);
  border-color: rgba(255, 255, 255, 0.2);
  color: #042f2e;
}

.w-full { width: 100%; }

.input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  font-size: 14px;
  outline: none;
}
.input:focus { border-color: var(--accent); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Типы покемонов */
.type-Grass { background: #16a34a; color: #fff; }
.type-Fire { background: #dc2626; color: #fff; }
.type-Water { background: #2563eb; color: #fff; }
.type-Electric { background: #eab308; color: #111827; }
.type-Rock { background: #a8a29e; color: #111827; }
.type-Ground { background: #c2a679; color: #111827; }
.type-Psychic { background: #db2777; color: #fff; }
.type-Ghost { background: #6366f1; color: #fff; }
.type-Dragon { background: #4338ca; color: #fff; }
.type-Flying { background: #38bdf8; color: #111827; }
.type-Normal { background: #94a3b8; color: #111827; }
.type-Bug { background: #84cc16; color: #111827; }
.type-Fighting { background: #b91c1c; color: #fff; }
.type-Fairy { background: #f9a8d4; color: #111827; }
.type-Dark { background: #1f2937; color: #fff; }
.type-Ice { background: #67e8f9; color: #111827; }

/* Редкости */
.rarity-common { color: #cbd5e1; }
.rarity-uncommon { color: #34d399; }
.rarity-rare { color: #60a5fa; }
.rarity-epic { color: #c084fc; }
.rarity-legendary { color: #facc15; }

/* Анимации */
@keyframes pulse-slow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.anim-pulse { animation: pulse-slow 2.5s ease-in-out infinite; }

@keyframes pop-in {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.anim-pop { animation: pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* Нижняя панель навигации */
.bottom-nav {
  position: fixed;
  bottom: 12px;
  left: 12px;
  right: 12px;
  z-index: 50;
  max-width: 480px;
  margin: 0 auto;
  /* Изолируем панель от перерисовок контента, чтобы она не дрожала
     во время анимаций (например, вращения покебола). */
  will-change: transform;
  transform: translateZ(0);
  contain: layout paint style;
  backface-visibility: hidden;
}
.bottom-nav.hidden { display: none; }
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 6px 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px 2px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 16px;
  transition: all 0.2s ease;
}
.nav-btn .nav-icon { font-size: 20px; line-height: 1; }
.nav-btn .nav-label { margin-top: 3px; }
.nav-btn.active {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.25), rgba(249, 115, 22, 0.1));
  color: #fde047;
}

/* Toast уведомления */
.toast-container {
  position: fixed;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 90%;
  max-width: 400px;
}
.toast {
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 13px;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  text-align: center;
}
.toast-success { background: rgba(34, 197, 94, 0.25); color: #86efac; border: 1px solid rgba(74, 222, 128, 0.3); }
.toast-error { background: rgba(239, 68, 68, 0.25); color: #fca5a5; border: 1px solid rgba(248, 113, 113, 0.3); }
.toast-info { background: rgba(51, 65, 85, 0.85); color: #e2e8f0; border: 1px solid rgba(148, 163, 184, 0.2); }

/* Модальные окна */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 20px;
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
}

/* Шкала здоровья */
.hp-bar-bg {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  height: 8px;
  overflow: hidden;
  margin-top: 6px;
}
.hp-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}
.hp-good { background: #22c55e; }
.hp-mid { background: #facc15; }
.hp-low { background: #ef4444; }

/* Лут бокс */
.loot-box {
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.15), rgba(34, 197, 94, 0.15));
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 14px;
  padding: 10px;
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Сетки */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
/* =========================================================
   MEADOW / POKEBALL EXPLORATION
   ========================================================= */

/* Панель покебола: фиксированная высота, чтобы появление текста,
   точек и вращение шара не меняли размер страницы. */
.meadow-idle-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 356px;
  padding: 6px 0;
  overflow: hidden;
}

/* ---- Pokéball button ---- */
.pokeball-btn {
  position: relative;
  width: min(72vw, 260px);
  height: min(72vw, 260px);
  border-radius: 50%;
  border: none;
  padding: 0;
  cursor: pointer;
  background: transparent;
  filter: drop-shadow(0 18px 30px rgba(0,0,0,.55));
  transition: transform .25s ease, filter .25s ease;
  overflow: hidden;
  isolation: isolate;
}
.pokeball-btn:active { transform: scale(.96); }
.pokeball-idle { animation: pokeball-breathe 3.2s ease-in-out infinite; }
.pokeball-idle:hover { filter: drop-shadow(0 18px 30px rgba(0,0,0,.55)) drop-shadow(0 0 28px rgba(250,204,21,.45)); }
.pokeball-disabled { filter: grayscale(.7) drop-shadow(0 10px 18px rgba(0,0,0,.4)); cursor: not-allowed; opacity: .75; }
.pokeball-spin {
  animation: pokeball-spin 2.4s cubic-bezier(.2,.9,.2,1) forwards;
  will-change: transform;
  backface-visibility: hidden;
}

.pokeball-top, .pokeball-bottom {
  position: absolute; left: 0; right: 0;
  height: 50%;
}
.pokeball-top {
  top: 0;
  background: radial-gradient(circle at 35% 30%, #ff8a8a 0%, #ef4444 35%, #b91c1c 100%);
  border-radius: 999px 999px 0 0;
}
.pokeball-bottom {
  bottom: 0;
  background: radial-gradient(circle at 40% 80%, #ffffff 0%, #e5e7eb 55%, #9ca3af 100%);
  border-radius: 0 0 999px 999px;
}
.pokeball-band {
  position: absolute; left: 0; right: 0; top: 50%;
  height: 8%; transform: translateY(-50%);
  background: #0f172a;
}
.pokeball-center {
  position: absolute; left: 50%; top: 50%;
  width: 30%; height: 30%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #0f172a;
  display: grid; place-items: center;
  box-shadow: 0 0 0 4px rgba(15,23,42,.35);
}
.pokeball-core {
  width: 60%; height: 60%; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #cbd5e1 60%, #94a3b8);
  box-shadow: inset 0 0 0 3px #0f172a;
  animation: core-glow 2.2s ease-in-out infinite;
}
.pokeball-spin .pokeball-core { animation: core-glow-fast .35s ease-in-out infinite; }
.pokeball-shine {
  position: absolute; left: 12%; top: 8%;
  width: 34%; height: 22%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.75), rgba(255,255,255,0));
  transform: rotate(-25deg);
  pointer-events: none;
}

@keyframes pokeball-breathe {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.02); }
}
@keyframes pokeball-spin {
  0%   { transform: rotate(0deg) scale(1); }
  20%  { transform: rotate(-30deg) scale(1.05); }
  100% { transform: rotate(1800deg) scale(1.08); }
}
@keyframes core-glow {
  0%, 100% { box-shadow: inset 0 0 0 3px #0f172a, 0 0 0 rgba(250,204,21,0); }
  50% { box-shadow: inset 0 0 0 3px #0f172a, 0 0 18px rgba(250,204,21,.85); }
}
@keyframes core-glow-fast {
  0%, 100% { background: radial-gradient(circle at 35% 35%, #fff, #cbd5e1 60%, #94a3b8); }
  50% { background: radial-gradient(circle at 35% 35%, #fef08a, #facc15 60%, #f59e0b); box-shadow: inset 0 0 0 3px #0f172a, 0 0 26px rgba(250,204,21,1); }
}

.dot-bounce {
  width: 8px; height: 8px; border-radius: 50%;
  background: #facc15;
  animation: dot-bounce .9s ease-in-out infinite;
}
@keyframes dot-bounce {
  0%, 100% { transform: translateY(0); opacity: .5; }
  50% { transform: translateY(-6px); opacity: 1; }
}

/* ---- Meadow field ---- */
.meadow-field {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 4.6;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 20px 50px rgba(0,0,0,.5), inset 0 0 60px rgba(0,0,0,.35);
  background: linear-gradient(180deg, var(--bg-from), var(--bg-to));
}
.meadow-reveal { animation: meadow-in 1.6s cubic-bezier(.2,.8,.2,1) both; }
@keyframes meadow-in {
  0% { transform: scale(.6); opacity: 0; filter: blur(12px) brightness(2); border-radius: 50%; }
  60% { transform: scale(1.02); opacity: 1; filter: blur(0) brightness(1.2); border-radius: 30px; }
  100% { transform: scale(1); filter: none; border-radius: 24px; }
}
.meadow-sky {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(180deg, rgba(2, 6, 23, .04) 0%, rgba(2, 6, 23, .04) 43%, rgba(2, 6, 23, .30) 100%),
    radial-gradient(60% 40% at 50% 0%, rgba(255,255,255,.18), transparent 70%),
    url('assets/anime-flower-meadow.jpg');
  background-size: cover, cover, cover;
  background-position: center, center, center 52%;
  background-repeat: no-repeat;
}
.meadow-grass {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 20% 70%, rgba(255,255,255,.12) 0 2px, transparent 3px),
    radial-gradient(circle at 60% 40%, rgba(255,255,255,.10) 0 2px, transparent 3px),
    radial-gradient(circle at 80% 85%, rgba(255,255,255,.10) 0 2px, transparent 3px),
    radial-gradient(circle at 35% 30%, rgba(0,0,0,.18) 0 3px, transparent 4px),
    radial-gradient(circle at 75% 20%, rgba(0,0,0,.14) 0 3px, transparent 4px);
  background-size: 140px 140px, 190px 190px, 160px 160px, 220px 220px, 260px 260px;
  animation: grass-drift 26s linear infinite;
  opacity: .9;
}
.meadow-grass-2 {
  background-image:
    repeating-linear-gradient(115deg, rgba(0,0,0,.06) 0 6px, transparent 6px 26px),
    repeating-linear-gradient(65deg, rgba(255,255,255,.05) 0 3px, transparent 3px 22px);
  background-size: auto;
  animation: grass-sway 6s ease-in-out infinite alternate;
  mix-blend-mode: overlay;
}
@keyframes grass-drift { from { background-position: 0 0; } to { background-position: 140px 140px, -190px 190px, 160px -160px, 220px 0, 0 260px; } }
@keyframes grass-sway { from { transform: skewX(-1.2deg); } to { transform: skewX(1.2deg); } }

.meadow-clouds { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cloud {
  position: absolute;
  width: 34%; height: 12%;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  filter: blur(6px);
  animation: cloud-move linear infinite;
}
@keyframes cloud-move { from { transform: translateX(-60%); } to { transform: translateX(220%); } }

.firefly {
  position: absolute;
  width: 5px; height: 5px; border-radius: 50%;
  background: #fef08a;
  box-shadow: 0 0 10px 3px rgba(250,204,21,.6);
  opacity: 0;
  animation: firefly ease-in-out infinite;
  pointer-events: none;
}
@keyframes firefly {
  0% { transform: translate(0,0) scale(.6); opacity: 0; }
  25% { opacity: .9; }
  50% { transform: translate(18px,-22px) scale(1); opacity: .4; }
  75% { opacity: .9; }
  100% { transform: translate(-14px,14px) scale(.7); opacity: 0; }
}

/* ---- Wild pokemon ---- */
.mon {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  cursor: pointer;
  transition: left .09s linear, top .09s linear, filter .3s ease;
  z-index: 5;
}
.mon-emoji {
  font-size: 34px; line-height: 1;
  filter: drop-shadow(0 6px 6px rgba(0,0,0,.45));
  animation: mon-hop 1.6s ease-in-out infinite;
  display: inline-block;
}
.mon-shadow {
  position: absolute; bottom: -4px;
  width: 30px; height: 10px; border-radius: 50%;
  background: rgba(0,0,0,.35); filter: blur(2px);
  animation: shadow-pulse 1.6s ease-in-out infinite;
}
.mon-tag {
  position: absolute; top: -14px;
  font-size: 9px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px;
  background: rgba(0,0,0,.55); color: #fde68a;
  white-space: nowrap;
}
.mon-ring {
  position: absolute; width: 64px; height: 64px; border-radius: 50%;
  border: 3px solid rgba(250,204,21,.9);
  box-shadow: 0 0 22px rgba(250,204,21,.7), inset 0 0 12px rgba(250,204,21,.4);
  animation: ring-pulse 1s ease-in-out infinite;
  pointer-events: none;
}
/* HD-спрайт настоящего покемона на поляне */
.mon-art {
  display: inline-grid; place-items: center;
  width: 68px; height: 68px;
  animation: mon-hop 1.6s ease-in-out infinite;
}
.mon-art img {
  filter: drop-shadow(0 10px 8px rgba(0,0,0,.55));
  transform-origin: 50% 85%;
}
.mon-sprite-img { filter: drop-shadow(0 10px 8px rgba(0,0,0,.55)); }
.mon-near .mon-emoji, .mon-near .mon-art { animation: mon-hop .7s ease-in-out infinite; }
.rar-rare .mon-emoji { filter: drop-shadow(0 6px 6px rgba(0,0,0,.45)) drop-shadow(0 0 10px rgba(96,165,250,.8)); }
.rar-epic .mon-emoji { filter: drop-shadow(0 6px 6px rgba(0,0,0,.45)) drop-shadow(0 0 12px rgba(192,132,252,.9)); }
.rar-legendary .mon-emoji { filter: drop-shadow(0 6px 6px rgba(0,0,0,.45)) drop-shadow(0 0 16px rgba(250,204,21,1)); animation: mon-hop 1.1s ease-in-out infinite, legend-hue 3s linear infinite; }
.mon-caught { animation: mon-caught 1.1s ease forwards; pointer-events: none; }
.mon-flee { animation: mon-flee .9s ease-in forwards; pointer-events: none; }
@keyframes mon-hop {
  0%, 100% { transform: translateY(0) scaleX(1); }
  50% { transform: translateY(-9px) scaleX(1.05); }
}
@keyframes shadow-pulse { 0%,100% { transform: scale(1); opacity: .35; } 50% { transform: scale(.7); opacity: .2; } }
@keyframes ring-pulse { 0%,100% { transform: scale(.9); opacity: .7; } 50% { transform: scale(1.15); opacity: 1; } }
@keyframes legend-hue { from { filter: hue-rotate(0deg) drop-shadow(0 0 16px rgba(250,204,21,1)); } to { filter: hue-rotate(360deg) drop-shadow(0 0 16px rgba(250,204,21,1)); } }
@keyframes mon-caught {
  0% { transform: translate(-50%,-50%) scale(1); opacity: 1; filter: brightness(1); }
  40% { transform: translate(-50%,-50%) scale(1.3); filter: brightness(3); }
  100% { transform: translate(-50%,-50%) scale(0); opacity: 0; }
}
@keyframes mon-flee {
  0% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-260%) scale(.5); opacity: 0; }
}

.sparkle { position: absolute; transform: translate(-50%,-50%); width: 0; height: 0; z-index: 30; animation: sparkle-life 1.2s ease-out forwards; }
.sparkle i {
  position: absolute; left: 0; top: 0;
  width: 6px; height: 18px; border-radius: 3px;
  background: linear-gradient(#fff, #facc15);
  transform-origin: 50% 0;
  transform: rotate(var(--a)) translateY(0);
  animation: spark 1.2s ease-out forwards;
}
@keyframes spark { to { transform: rotate(var(--a)) translateY(70px) scaleY(.3); opacity: 0; } }
@keyframes sparkle-life { to { opacity: 0; } }

/* ---- Hero ---- */
.hero {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: grid; place-items: center;
  transition: left .08s linear, top .08s linear;
  pointer-events: none;
}
.hero-body {
  font-size: 40px; line-height: 1;
  filter: drop-shadow(0 8px 8px rgba(0,0,0,.55));
  display: inline-block;
  transition: transform .15s ease;
}
.hero-shadow {
  position: absolute; bottom: -6px;
  width: 34px; height: 12px; border-radius: 50%;
  background: rgba(0,0,0,.4); filter: blur(2px);
}
.hero-cap {
  position: absolute; top: -8px; left: 50%;
  width: 26px; height: 8px; border-radius: 6px 6px 2px 2px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #ef4444, #b91c1c);
  box-shadow: 0 0 10px rgba(239,68,68,.6);
}
.hero-left .hero-body { transform: scaleX(-1); }
.hero-walk .hero-body { animation: hero-step .35s ease-in-out infinite; }
.hero-left.hero-walk .hero-body { animation: hero-step-flipped .35s ease-in-out infinite; }
@keyframes hero-step {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-6px) rotate(3deg); }
}
@keyframes hero-step-flipped {
  0%, 100% { transform: translateY(0) rotate(3deg) scaleX(-1); }
  50% { transform: translateY(-6px) rotate(-3deg) scaleX(-1); }
}

/* ---- Reveal curtain ---- */
.meadow-curtain {
  position: absolute; inset: 0; z-index: 40;
  display: grid; place-items: center; gap: 8px;
  background: radial-gradient(circle, rgba(2,6,23,.35), rgba(2,6,23,.9));
  animation: curtain-out 1.6s ease forwards;
  color: #fef08a; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  text-shadow: 0 0 18px rgba(250,204,21,.7);
}
.meadow-curtain-ball {
  width: 90px; height: 90px; border-radius: 50%;
  background: linear-gradient(180deg, #ef4444 50%, #fff 50%);
  box-shadow: 0 0 0 5px #0f172a inset, 0 0 40px rgba(250,204,21,.8);
  animation: curtain-ball 1.2s cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes curtain-ball { 0% { transform: scale(2) rotate(0); } 60% { transform: scale(1) rotate(720deg); } 100% { transform: scale(0) rotate(900deg); opacity: 0; } }
@keyframes curtain-out { 0%, 55% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* ---- D-pad ---- */
.dpad {
  display: grid;
  grid-template-columns: 44px 44px 44px;
  grid-template-rows: 44px 44px 44px;
  gap: 4px;
  touch-action: none;
}
.dpad-btn {
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  color: #fde68a; font-weight: 800; font-size: 16px;
  transition: transform .08s ease, background .15s ease;
  user-select: none;
}
.dpad-btn:active { transform: scale(.9); background: rgba(250,204,21,.25); }
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }
.dpad-center { grid-column: 2; grid-row: 2; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.14), transparent 70%); }

.attack-pulse { animation: attack-pulse 1s ease-in-out infinite; }
@keyframes attack-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250,204,21,.6); }
  50% { box-shadow: 0 0 0 10px rgba(250,204,21,0); }
}

/* ---- Encounter overlay ---- */
.encounter {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 16px;
  animation: enc-in .5s ease both;
}
.encounter-bg { position: absolute; inset: 0; backdrop-filter: blur(6px); }
.encounter-card {
  position: relative;
  width: 100%; max-width: 440px;
  border-radius: 28px;
  background: rgba(15,23,42,.92);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
  padding: 16px;
  animation: enc-card .6s cubic-bezier(.2,.9,.2,1.2) both;
}
@keyframes enc-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes enc-card { from { transform: translateY(40px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

.encounter-stage {
  position: relative;
  height: 190px;
  border-radius: 20px;
  overflow: hidden;
  background:
    radial-gradient(60% 40% at 70% 30%, rgba(255,255,255,.12), transparent 70%),
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.35));
}
.enc-mon {
  position: absolute; right: 14%; top: 22%;
  display: grid; place-items: center;
  animation: enc-mon-in .8s cubic-bezier(.2,.9,.2,1.2) both;
}
.enc-mon-emoji { line-height: 1; display: inline-grid; place-items: center; animation: mon-hop 1.8s ease-in-out infinite; }
.enc-mon-emoji img { filter: drop-shadow(0 12px 10px rgba(0,0,0,.55)); }
.enc-mon-shadow { width: 60px; height: 16px; border-radius: 50%; background: rgba(0,0,0,.45); filter: blur(3px); margin-top: -6px; }
.enc-mon-inside .enc-mon-emoji { animation: enc-suck .5s ease forwards; }
.enc-mon-captured .enc-mon-emoji { animation: enc-suck .5s ease forwards; }
@keyframes enc-mon-in { from { transform: translateX(120px) scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes enc-suck { to { transform: scale(0) translateY(20px); opacity: 0; filter: brightness(4); } }

.enc-hero { position: absolute; left: 10%; bottom: 8%; font-size: 56px; filter: drop-shadow(0 10px 10px rgba(0,0,0,.5)); animation: enc-hero-in .7s ease both; }
@keyframes enc-hero-in { from { transform: translateX(-80px); opacity: 0; } to { transform: none; opacity: 1; } }

.enc-ball {
  position: absolute; left: 16%; bottom: 32%;
  width: 44px; height: 44px; border-radius: 50%;
  overflow: hidden; z-index: 5;
  box-shadow: 0 8px 18px rgba(0,0,0,.5);
}
.enc-ball .pokeball-center { width: 34%; height: 34%; box-shadow: 0 0 0 2px rgba(15,23,42,.35); }
.enc-ball .pokeball-band { height: 10%; }
.enc-ball-great .pokeball-top { background: radial-gradient(circle at 35% 30%, #93c5fd, #2563eb 40%, #1e3a8a); }
.enc-ball-ultra .pokeball-top { background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b 40%, #78350f); }
.enc-ball-fly { animation: ball-fly .9s cubic-bezier(.3,.7,.4,1) forwards; }
.enc-ball-shake { left: auto; right: 19%; bottom: 20%; animation: ball-shake 1.5s ease-in-out; }
.enc-ball-done { left: auto; right: 19%; bottom: 20%; }
.enc-ball-ok { animation: ball-ok .9s ease forwards; }
.enc-ball-fail { animation: ball-fail .9s ease forwards; }
@keyframes ball-fly {
  0% { transform: translate(0,0) rotate(0); }
  50% { transform: translate(120px,-120px) rotate(540deg); }
  100% { transform: translate(210px,-10px) rotate(1080deg); left: 16%; }
}
@keyframes ball-shake {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(-28deg) translateX(-4px); }
  30% { transform: rotate(24deg) translateX(4px); }
  45% { transform: rotate(0); }
  60% { transform: rotate(-22deg) translateX(-3px); }
  75% { transform: rotate(20deg) translateX(3px); }
  90% { transform: rotate(0); }
}
@keyframes ball-ok {
  0% { transform: scale(1); box-shadow: 0 8px 18px rgba(0,0,0,.5); }
  40% { transform: scale(1.25); box-shadow: 0 0 40px rgba(250,204,21,1); }
  100% { transform: scale(1); box-shadow: 0 0 22px rgba(74,222,128,.9); }
}
@keyframes ball-fail {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); filter: brightness(2.5); }
  100% { transform: scale(0) rotate(180deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .pokeball-idle, .meadow-grass, .meadow-grass-2, .firefly, .cloud { animation: none !important; }
}
