/* ===== TERASTAL EFFECTS ===== */

/* Terastal badge — gradient purple/blue pin */
.terastal-badge {
    background: linear-gradient(135deg, #6a0dad, #1a4fff, #a855f7);
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: bold;
    margin-left: 6px;
    letter-spacing: 0.5px;
    box-shadow: 0 0 8px rgba(140, 60, 255, 0.7);
    border: 1px solid rgba(200, 150, 255, 0.4);
    animation: terastalBadgePulse 2s infinite ease-in-out;
}
@keyframes terastalBadgePulse {
    0%, 100% { box-shadow: 0 0 6px rgba(140,60,255,0.6); }
    50% { box-shadow: 0 0 16px rgba(140,60,255,1), 0 0 30px rgba(100,80,255,0.5); }
}

/* Terastal sprite glow — color set dynamically via JS */
.terastal-sprite {
    animation: terastalGlow 2s infinite ease-in-out;
}
@keyframes terastalGlow {
    0%, 100% { filter: var(--tera-filter-low); }
    50% { filter: var(--tera-filter-high); }
}

/* Sparkle particle */
.tera-sparkle {
    position: absolute;
    pointer-events: none;
    border-radius: 50%;
    animation: teraSparkleAnim var(--dur) ease-out forwards;
    z-index: 999;
}
@keyframes teraSparkleAnim {
    0%   { transform: translate(-50%,-50%) scale(0) rotate(0deg); opacity: 1; }
    40%  { transform: translate(-50%,-50%) scale(1.4) rotate(180deg); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0) rotate(360deg); opacity: 0; }
}

/* Glitter shimmer overlay on sprite */
.tera-shimmer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 50%;
    animation: teraShimmer 1.5s infinite linear;
    z-index: 2;
}
@keyframes teraShimmer {
    0%   { background: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.35) 0%, transparent 60%); }
    25%  { background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.35) 0%, transparent 60%); }
    50%  { background: radial-gradient(circle at 70% 80%, rgba(255,255,255,0.35) 0%, transparent 60%); }
    75%  { background: radial-gradient(circle at 20% 70%, rgba(255,255,255,0.35) 0%, transparent 60%); }
    100% { background: radial-gradient(circle at 20% 30%, rgba(255,255,255,0.35) 0%, transparent 60%); }
}

/* ========== ENHANCED BATTLE IMPACT EFFECTS ========== */
@keyframes floatUp {
    0% { transform: translateY(0) scale(1.4) rotate(-3deg); opacity: 1; }
    30% { transform: translateY(-30px) scale(1.6) rotate(2deg); opacity: 1; }
    70% { transform: translateY(-70px) scale(1.2) rotate(-1deg); opacity: 0.7; }
    100% { transform: translateY(-110px) scale(0.7) rotate(0deg); opacity: 0; }
}
@keyframes floatUpCrit {
    0% { transform: translateY(0) scale(2) rotate(-5deg); opacity: 1; }
    20% { transform: translateY(-20px) scale(2.4) rotate(3deg); opacity: 1; }
    100% { transform: translateY(-120px) scale(0.9) rotate(1deg); opacity: 0; }
}
@keyframes critStampAnim {
    0% { transform: translate(-50%,-50%) scale(3) rotate(-8deg); opacity: 0; }
    15% { transform: translate(-50%,-50%) scale(1.1) rotate(2deg); opacity: 1; }
    70% { transform: translate(-50%,-50%) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%,-50%) scale(0.8) rotate(0deg); opacity: 0; }
}
@keyframes shockwaveExpand {
    0% { transform: translate(-50%,-50%) scale(0); opacity: 1; width: 20px; height: 20px; }
    100% { transform: translate(-50%,-50%) scale(1); opacity: 0; width: 200px; height: 200px; }
}
@keyframes hitFlash {
    0% { opacity: 0; }
    15% { opacity: 0.35; }
    100% { opacity: 0; }
}

.floating-damage {
    position: absolute;
    font-weight: 900;
    font-size: 1.6rem;
    pointer-events: none;
    z-index: 1000;
    animation: floatUp 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    white-space: nowrap;
    font-family: 'Impact', sans-serif;
}
.floating-damage.critical {
    font-size: 2.2rem;
    animation: floatUpCrit 1.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.hit-shockwave {
    position: absolute;
    border-radius: 50%;
    border: 3px solid rgba(255,150,0,0.9);
    pointer-events: none;
    z-index: 999;
    animation: shockwaveExpand 0.6s ease-out forwards;
}
.hit-flash-overlay {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    pointer-events: none;
    z-index: 998;
    animation: hitFlash 0.4s ease-out forwards;
}
.crit-stamp {
    position: absolute;
    font-family: 'Impact', sans-serif;
    font-size: 1.8rem;
    color: #fff;
    text-shadow: 0 0 20px #ffaa00, 3px 3px 0 #cc0000;
    pointer-events: none;
    z-index: 1001;
    animation: critStampAnim 1.2s ease-out forwards;
    white-space: nowrap;
}
.super-effective-stamp {
    position: absolute;
    font-family: 'Impact', sans-serif;
    font-size: 1.6rem;
    color: #fff;
    text-shadow: 0 0 20px #44ff88, 3px 3px 0 #004400;
    pointer-events: none;
    z-index: 1001;
    animation: critStampAnim 1.2s ease-out forwards;
    white-space: nowrap;
}
.shake-effect { animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
.shake-effect-hard { animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; transform: scale(1.1); }

/* --- Overwrite in <style> block --- */
.terastal-sprite {
    animation: teraGlowAnim 2s infinite alternate ease-in-out !important;
}

@keyframes teraGlowAnim {
    from { filter: var(--tera-filter-low) brightness(1); }
    to { filter: var(--tera-filter-high) brightness(1.3); }
}

/* Coin display dark theme */
body.dark-theme #coin-display {
    background: #2d2f3e;
    color: #ffd700;
    border: 1px solid #ffd70033;
}

/* ===== TEAM ICONS BAR ===== */
#battle-team-icons {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 2px;
}

.team-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.6);
    overflow: hidden;
    background: rgba(0,0,0,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: filter 0.3s, border-color 0.3s, transform 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    position: relative;
}

.team-icon-wrap img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    image-rendering: pixelated;
}

/* Active pokemon gets a glowing white border */
.team-icon-wrap.is-active {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.8), 0 2px 8px rgba(0,0,0,0.4);
    transform: scale(1.12);
}

/* Fainted pokemon turns gray */
.team-icon-wrap.is-fainted {
    filter: grayscale(100%) brightness(0.5);
    border-color: rgba(255,255,255,0.2);
    box-shadow: none;
}

/* Small fainted X overlay */
.team-icon-wrap.is-fainted::after {
    content: '✕';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 900;
    color: rgba(255,80,80,0.9);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* ========== DATA SAVER MODE ========== */
/* Data Saver Mode - Reduces data usage */
body.data-saver-mode .btl-sprite,
body.data-saver-mode .encounter-sprite,
body.data-saver-mode .poke-card-img-wrap img {
    image-rendering: crisp-edges;
    filter: none !important;
}

/* Disable all battle effects */
body.data-saver-mode .floating-damage,
body.data-saver-mode .hit-shockwave,
body.data-saver-mode .hit-flash-overlay,
body.data-saver-mode .impact-particle,
body.data-saver-mode .crit-stamp,
body.data-saver-mode .super-effective-stamp {
    display: none !important;
}

/* Disable animations */
body.data-saver-mode .terastal-sprite,
body.data-saver-mode .evolution-animate,
body.data-saver-mode .shake-effect,
body.data-saver-mode .shake-effect-hard {
    animation: none !important;
}

/* Simplify damage numbers */
body.data-saver-mode .floating-damage {
    display: block !important;
    font-size: 0.9rem !important;
    background: rgba(0,0,0,0.7);
    padding: 2px 6px;
    border-radius: 4px;
    animation: none !important;
}

/* Disable background effects */
body.data-saver-mode .hit-flash-overlay {
    display: none !important;
}

/* Use lower quality images */
body.data-saver-mode img {
    image-rendering: pixelated;
}

/* Disable particle effects */
body.data-saver-mode .impact-particle,
body.data-saver-mode .hit-shockwave {
    display: none !important;
}

/* Disable music prompt animation */
body.data-saver-mode .music-prompt {
    animation: none !important;
}

/* Data Saver Mode - Music disabled indicator */
body.data-saver-mode #volume-toggle {
    opacity: 0.6;
    cursor: not-allowed;
}

body.data-saver-mode #volume-toggle:hover::after {
    content: " (Disabled in Data Saver)";
    font-size: 0.7rem;
    position: absolute;
    background: rgba(0,0,0,0.8);
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

/* Optional: Show a visual indicator that music is disabled */
body.data-saver-mode::after {
    content: "📱 Data Saver: Music OFF";
    position: fixed;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.7);
    color: #2ecc71;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    z-index: 9999;
    pointer-events: none;
    font-weight: bold;
}

/* HP and EXP Bar Styles for Modals */
.hp-bar-container, .exp-bar-container {
    margin: 6px 0;
}

.hp-bar-label, .exp-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    margin-bottom: 2px;
    color: var(--text-light);
}

.hp-bar, .exp-bar {
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.hp-fill {
    background: var(--success);
    height: 100%;
    transition: width 0.3s ease;
}

.exp-fill {
    background: #a855f7;
    height: 100%;
    transition: width 0.3s ease;
}

/* Dark theme overrides */
body.dark-theme .hp-bar,
body.dark-theme .exp-bar {
    background: #3d4050;
}

body.dark-theme .hp-fill {
    background: #4cd964;
}

body.dark-theme .exp-fill {
    background: #a855f7;
}

/* ========== CARD-STYLE SCROLLABLE NAVIGATION ========== */
.card-nav {
    background: transparent;
    padding: 12px 5%;
    position: sticky;
    top: 0;
    z-index: 1000;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    overflow-x: hidden;
}

/* Header with logo and hamburger */
.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--primary-dark);
    flex-shrink: 0;
}
.logo img {
    height: 40px;
    width: auto;
    border-radius: 12px;
}

/* Hamburger button */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1100;
    flex-shrink: 0;
    margin-left: auto;
}
.hamburger span {
    width: 100%;
    height: 3px;
    background: var(--text-dark);
    border-radius: 4px;
    transition: all 0.3s ease;
}
.hamburger.open span:nth-child(1) {
    transform: translateY(10px) rotate(45deg);
}
.hamburger.open span:nth-child(2) {
    opacity: 0;
}
.hamburger.open span:nth-child(3) {
    transform: translateY(-10px) rotate(-45deg);
}

/* Collapsible container */
.nav-collapsible {
    transition: max-height 0.4s ease-out, opacity 0.2s ease;
    overflow: hidden;
    width: 100%;
}

/* On desktop: always expanded, hamburger hidden */
@media (min-width: 769px) {
    .nav-collapsible {
        max-height: none !important;
        opacity: 1 !important;
    }
    .hamburger {
        display: none !important;
    }
}

/* On mobile: collapsible hidden by default, hamburger visible */
@media (max-width: 768px) {
    .nav-collapsible {
        max-height: 0;
        opacity: 0;
    }
    .nav-collapsible.open {
        max-height: 500px;
        opacity: 1;
    }
    .hamburger {
        display: flex;
    }
}

/* Each card */
.nav-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 8px 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
}
.nav-card:last-child {
    margin-bottom: 0;
}

/* Scrollable row inside card */
.nav-row {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: thin;
    padding: 6px 0;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
}
.nav-row::-webkit-scrollbar {
    height: 4px;
}
.nav-row::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 4px;
}
.nav-row::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
}

/* Items inside rows */
.nav-link, .nav-item, .volume-btn, .btn-outline {
    flex: 0 0 auto;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 40px;
    transition: 0.2s;
    color: var(--text-dark);
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.nav-link:hover, .nav-item:hover {
    background: #eef2ff;
    color: var(--primary);
}
.volume-btn {
    background: rgba(255,255,255,0.8);
    width: 36px;
    height: 36px;
    justify-content: center;
}
.volume-btn:hover {
    background: white;
    transform: scale(1.05);
}
#user-display {
    background: #eef2ff;
    padding: 4px 10px;
    border-radius: 40px;
    gap: 8px;
}
#level-display, #coin-display {
    background: #fef9e3;
    color: #b45309;
    padding: 4px 12px;
    border-radius: 40px;
    font-weight: bold;
    font-size: 0.85rem;
}
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
}
.btn-outline:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Dark theme adjustments */
body.dark-theme .nav-card {
    background: var(--card-bg);
    border-color: var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
body.dark-theme .nav-link:hover,
body.dark-theme .nav-item:hover {
    background: #2d2f3e;
    color: var(--primary);
}
body.dark-theme #user-display {
    background: #2d2f3e;
    color: var(--text-dark);
}
body.dark-theme #level-display,
body.dark-theme #coin-display {
    background: #1e2230;
    color: #fbbf24;
}
body.dark-theme .volume-btn {
    background: rgba(30,35,50,0.8);
}
body.dark-theme .volume-btn:hover {
    background: var(--primary);
    color: white;
}

/* Responsive */
@media (max-width: 600px) {
    .nav-card {
        padding: 6px 10px;
    }
    .nav-link, .nav-item {
        padding: 4px 10px;
        font-size: 0.8rem;
    }
    .volume-btn {
        width: 32px;
        height: 32px;
    }
}

/* ========== DESKTOP NAVIGATION COLLAPSE ========== */
/* Desktop collapse button */
.nav-collapse-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 40px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-dark);
    flex-shrink: 0;
}

.nav-collapse-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
}

/* When navigation is collapsed on desktop */
body.nav-collapsed .nav-collapsible {
    display: none;
}

/* On mobile, the collapse button is hidden (use hamburger instead) */
@media (max-width: 768px) {
    .nav-collapse-btn {
        display: none;
    }
}

/* On desktop, show collapse button, hide hamburger */
@media (min-width: 769px) {
    .hamburger {
        display: none !important;
    }
    .nav-collapse-btn {
        display: flex;
    }
}

/* Optional: Smooth transition when collapsing */
.nav-collapsible {
    transition: all 0.3s ease;
}

/* When collapsed, show a minimal bar with just the logo and expand button */
body.nav-collapsed .nav-header {
    margin-bottom: 0;
}

/* Floating expand button when nav is collapsed */
body.nav-collapsed .card-nav {
    position: relative;
}

body.nav-collapsed .nav-collapse-btn {
    position: fixed;
    top: 12px;
    right: 20px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

body.nav-collapsed .nav-collapse-btn:hover {
    transform: scale(1.05);
    background: var(--primary-dark);
}

/* Add or verify these CSS rules exist */
.hp-bar {
    background: #e2e8f0;
    height: 8px;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
}

.hp-fill {
    height: 100%;
    background: var(--success);
    width: 100%;
    transition: width 0.3s;
}

.hp-bar-container {
    margin: 8px 0;
}

.hp-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    margin-bottom: 2px;
}

/* Add or verify these CSS rules exist */
.hp-bar {
    background: #e2e8f0;
    height: 8px;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
}

.hp-fill {
    height: 100%;
    background: var(--success);
    width: 100%;
    transition: width 0.3s;
}

.hp-bar-container {
    margin: 8px 0;
}

.hp-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    margin-bottom: 2px;
}


@keyframes galacticFadeIn{from{opacity:0;transform:scale(0.85) translateY(20px)}to{opacity:1;transform:scale(1) translateY(0)}}
@keyframes floatUp{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}
@keyframes rotateSlow{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
@keyframes countdown{from{width:100%}to{width:0%}}
@keyframes starTwinkle{0%,100%{opacity:0.2;transform:scale(1)}50%{opacity:1;transform:scale(1.4)}}
@keyframes pulse{0%,100%{box-shadow:0 0 20px rgba(100,150,255,0.4),0 0 60px rgba(80,100,255,0.2)}50%{box-shadow:0 0 40px rgba(100,180,255,0.7),0 0 100px rgba(80,130,255,0.4)}}

.gal-overlay{position:fixed;inset:0;background:rgba(0,0,20,0.7);display:flex;align-items:center;justify-content:center;z-index:99999;backdrop-filter:blur(4px);}
.gal-modal{
  position:relative;
  background:linear-gradient(135deg,#060b1a 0%,#0a1628 40%,#0d1f3c 70%,#0a1020 100%);
  border:1px solid rgba(100,160,255,0.3);
  border-radius:20px;
  padding:36px 32px 28px;
  width:340px;max-width:90vw;
  text-align:center;
  animation:galacticFadeIn 0.6s cubic-bezier(.22,1,.36,1) both, pulse 4s ease-in-out infinite;
  overflow:hidden;
}
.gal-stars{position:absolute;inset:0;pointer-events:none;overflow:hidden;border-radius:20px;}
.gal-star{position:absolute;border-radius:50%;background:#fff;animation:starTwinkle var(--d,3s) ease-in-out infinite var(--dl,0s);}
.gal-ring{position:absolute;border-radius:50%;border:1px solid rgba(100,160,255,0.1);pointer-events:none;animation:rotateSlow var(--spd,20s) linear infinite;}
.gal-close{position:absolute;top:14px;right:16px;background:rgba(255,255,255,0.07);border:1px solid rgba(255,255,255,0.15);border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:rgba(255,255,255,0.6);font-size:16px;transition:all .2s;}
.gal-close:hover{background:rgba(255,80,80,0.2);border-color:rgba(255,80,80,0.4);color:#ff8080;}
.gal-icon-wrap{position:relative;display:inline-flex;align-items:center;justify-content:center;width:72px;height:72px;margin-bottom:16px;animation:floatUp 3s ease-in-out infinite;}
.gal-icon-ring{position:absolute;inset:0;border-radius:50%;border:1.5px solid rgba(100,180,255,0.5);animation:rotateSlow 6s linear infinite;}
.gal-icon-ring2{position:absolute;inset:-8px;border-radius:50%;border:1px dashed rgba(100,180,255,0.2);animation:rotateSlow 10s linear infinite reverse;}
.gal-icon-core{width:56px;height:56px;border-radius:50%;background:radial-gradient(circle at 35% 35%,rgba(100,180,255,0.3),rgba(30,80,200,0.6));border:1px solid rgba(100,180,255,0.4);display:flex;align-items:center;justify-content:center;font-size:26px;}
.gal-title{font-size:1.15rem;font-weight:700;color:#fff;margin:0 0 10px;text-shadow:0 0 20px rgba(100,180,255,0.6);letter-spacing:0.3px;}
.gal-sub{font-size:0.82rem;color:rgba(180,210,255,0.75);line-height:1.6;margin:0 0 6px;}
.gal-sub strong{color:rgba(200,230,255,0.95);}
.gal-divider{height:1px;margin:16px 0;background:linear-gradient(90deg,transparent,rgba(100,160,255,0.3),transparent);}
.gal-btn{position:relative;overflow:hidden;width:100%;padding:12px 20px;background:linear-gradient(135deg,rgba(50,100,255,0.25),rgba(100,60,255,0.25));border:1px solid rgba(100,160,255,0.5);border-radius:30px;color:#c8e0ff;font-size:0.88rem;font-weight:700;cursor:pointer;letter-spacing:0.5px;transition:all .3s;margin-bottom:12px;}
.gal-btn:hover{background:linear-gradient(135deg,rgba(50,120,255,0.4),rgba(120,80,255,0.4));border-color:rgba(150,200,255,0.8);color:#fff;box-shadow:0 0 20px rgba(80,130,255,0.4);transform:translateY(-2px);}
.gal-btn-shine{position:absolute;inset:0;background:linear-gradient(110deg,transparent 30%,rgba(255,255,255,0.06) 50%,transparent 70%);transform:translateX(-100%);transition:transform .5s;}
.gal-btn:hover .gal-btn-shine{transform:translateX(100%);}
.gal-timer-bar-wrap{height:3px;border-radius:2px;background:rgba(255,255,255,0.08);overflow:hidden;margin-bottom:10px;}
.gal-timer-bar{height:100%;border-radius:2px;background:linear-gradient(90deg,rgba(80,130,255,0.8),rgba(150,100,255,0.8));animation:countdown var(--dur,10s) linear forwards;}
.gal-note{font-size:0.68rem;color:rgba(150,180,220,0.5);letter-spacing:0.3px;}

/* Catch Area Centering */
.catch-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
}

.catch-buttons-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.catch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: 40px;
    color: white;
    font-weight: bold;
    border: none;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.catch-btn:hover {
    transform: translateY(-2px);
}

.catch-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#catch-chance {
    text-align: center;
    margin-top: 4px;
}

/* ========== ANNOUNCEMENT BANNER ========== */
.announcement-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: bold;
    z-index: 10001;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 10px 30px rgba(108, 92, 231, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.3);
    white-space: nowrap;
    max-width: 90vw;
    overflow-x: auto;
    pointer-events: none;
    font-family: 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.5px;
}

.announcement-banner.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.announcement-banner i {
    margin-right: 10px;
    font-size: 1rem;
}

body.dark-theme .announcement-banner {
    background: linear-gradient(135deg, #5a4ad1, #8b7de8);
    box-shadow: 0 10px 30px rgba(90, 74, 209, 0.4);
}

@media (max-width: 768px) {
    .announcement-banner {
        font-size: 0.75rem;
        padding: 8px 16px;
        white-space: normal;
        text-align: center;
        max-width: 85vw;
        top: 60px;
    }
}

/* Add this to your existing CSS */
@keyframes scrollBanner {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

@keyframes ledBlink {
    0%, 100% { opacity: 1; box-shadow: 0 0 6px #00ff88; }
    50% { opacity: 0.3; box-shadow: 0 0 2px #00ff88; }
}

.announcement-banner.show {
    opacity: 1 !important;
}

/* Style variants for different banner types */
.announcement-banner.banner-style-success #banner-message,
.announcement-banner.banner-style-success #banner-message-duplicate {
    color: #55efc4 !important;
    text-shadow: 0 0 5px rgba(85, 239, 196, 0.8), 0 0 10px rgba(85, 239, 196, 0.4), 0 0 20px rgba(85, 239, 196, 0.2) !important;
}

.announcement-banner.banner-style-warning #banner-message,
.announcement-banner.banner-style-warning #banner-message-duplicate {
    color: #fdcb6e !important;
    text-shadow: 0 0 5px rgba(253, 203, 110, 0.8), 0 0 10px rgba(253, 203, 110, 0.4), 0 0 20px rgba(253, 203, 110, 0.2) !important;
}

.announcement-banner.banner-style-danger #banner-message,
.announcement-banner.banner-style-danger #banner-message-duplicate {
    color: #ff7675 !important;
    text-shadow: 0 0 5px rgba(255, 118, 117, 0.8), 0 0 10px rgba(255, 118, 117, 0.4), 0 0 20px rgba(255, 118, 117, 0.2) !important;
}

/* ===== BATTLE SPRITE — SHINY (gold shimmer, distinct from terastal) ===== */
.btl-sprite-shiny {
    animation: btlShinyGlow 2.5s ease-in-out infinite;
}

@keyframes btlShinyGlow {
    0%, 100% {
        filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.7))
                drop-shadow(0 0 12px rgba(255, 180, 0, 0.4))
                brightness(1.05);
    }
    50% {
        filter: drop-shadow(0 0 18px rgba(255, 215, 0, 1))
                drop-shadow(0 0 32px rgba(255, 200, 0, 0.7))
                drop-shadow(0 0 6px rgba(255, 255, 200, 0.5))
                brightness(1.15);
    }
}

/* ===== BATTLE SPRITE — SHINY + TERASTAL (gold + type color alternating) ===== */
.btl-sprite-shiny-tera {
    /* terastal-sprite handles the filter animation already via --tera-filter vars */
    /* this class adds a rotating hue overlay via outline trick */
    outline: none;
    position: relative;
}

/* The terastalGlow keyframe is already on .terastal-sprite, 
   but for shiny-tera we override the CSS vars to include gold blending
   (done in JS above). This class is a marker for any additional CSS needed. */
.btl-sprite-shiny-tera::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 30%, rgba(255,215,0,0.15) 0%, transparent 65%);
    pointer-events: none;
    animation: shinyTeraOverlay 3s ease-in-out infinite;
}

@keyframes shinyTeraOverlay {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* ========== VIRTUAL JOYSTICK ========== */
#vjoy-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0 6px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
#vjoy-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(108,99,255,0.12);
    border: 2px solid rgba(108,99,255,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 20px rgba(108,99,255,0.15), inset 0 0 20px rgba(0,0,0,0.2);
}
#vjoy-knob {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c63ff, #a855f7);
    border: 2px solid rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    transition: box-shadow 0.15s;
    box-shadow: 0 4px 14px rgba(108,99,255,0.5);
    cursor: grab;
}
#vjoy-knob.active {
    cursor: grabbing;
    box-shadow: 0 6px 22px rgba(108,99,255,0.8);
    transition: none;
}
#vjoy-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    opacity: 0.85;
    pointer-events: none;
}
#vjoy-hint {
    font-size: 0.65rem;
    color: rgba(255,255,255,0.3);
    margin-top: 6px;
    letter-spacing: 0.05em;
}
/* hide joystick hint text once used */
#vjoy-container.used #vjoy-hint { display: none; }
/* on desktop show subtle label instead */
@media (hover: hover) {
    #vjoy-hint { display: none; }
}


        .pokeball-bg-with-opacity {
    position: relative;
    overflow: hidden;
}

.pokeball-bg-with-opacity::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('download.png') center/cover no-repeat;
    opacity: 0.5;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

.pokeball-bg-with-opacity > * {
    position: relative;
    z-index: 1;
}

        #view-explore {
    width: 100%;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.map-wrapper {
    width: 100%;
   overflow-x: hidden;
    display: flex;
    justify-content: center;
}
        body.dark-theme footer .support-section a {
    color: var(--primary);
}
body.dark-theme footer .support-section a:hover {
    color: var(--primary-dark);
}
body.dark-theme footer {
    background: rgba(30, 35, 50, 0.9);
    border-top-color: var(--border);
    color: var(--text-light);
}



/* ===== SPECIAL ENCOUNTER CARD BACKGROUNDS ===== */

.encounter-card.encounter-shiny {
    background: linear-gradient(160deg, #1a1200 0%, #2d1f00 30%, #1a1200 60%, #0d1a2e 100%);
    border: 2px solid rgba(255, 215, 0, 0.7);
    box-shadow: 0 0 0 4px rgba(255,215,0,0.15), 0 20px 40px rgba(255,215,0,0.2), 0 0 80px rgba(255,215,0,0.1);
    color: #f0e6c8 !important;
    animation: shinyEncounterPulse 2.5s ease-in-out infinite;
}

.encounter-card.encounter-shiny .encounter-name {
    color: #ffd700 !important;
}

.encounter-card.encounter-tera {
    background: linear-gradient(160deg, #0a0520 0%, #150830 30%, #0a1428 60%, #1a0530 100%);
    border: 2px solid rgba(120, 80, 255, 0.7);
    box-shadow: 0 0 0 4px rgba(100,160,255,0.12), 0 20px 40px rgba(106,13,173,0.25), 0 0 80px rgba(100,80,255,0.12);
    color: #d4c8f0 !important;
    animation: teraEncounterPulse 3s ease-in-out infinite;
}

.encounter-card.encounter-tera .encounter-name {
    color: #a78bfa !important;
}

.encounter-card.encounter-shiny-tera {
    background: linear-gradient(160deg,
        #0d0820 0%,
        #1e0838 20%,
        #08102a 40%,
        #220a1a 60%,
        #081428 80%,
        #0d0820 100%);
    border: 2px solid transparent;
    box-shadow:
        0 0 0 2px rgba(255,215,0,0.6),
        0 0 0 5px rgba(106,13,173,0.4),
        0 20px 50px rgba(255,215,0,0.2),
        0 0 100px rgba(106,13,173,0.15);
    color: #f0d8f8 !important;
    animation: shinyTeraEncounterPulse 4s ease-in-out infinite;
}

.encounter-card.encounter-shiny-tera .encounter-name {
    color: #ffd700 !important;
}

@keyframes shinyEncounterPulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(255,215,0,0.1), 0 20px 35px rgba(255,215,0,0.15);
        border-color: rgba(255,215,0,0.6);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(255,215,0,0.2), 0 20px 60px rgba(255,215,0,0.35);
        border-color: rgba(255,215,0,1);
    }
}

@keyframes teraEncounterPulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(100,160,255,0.1), 0 20px 35px rgba(106,13,173,0.2);
        border-color: rgba(120,80,255,0.6);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(100,160,255,0.2), 0 20px 60px rgba(106,13,173,0.4);
        border-color: rgba(160,120,255,1);
    }
}

@keyframes shinyTeraEncounterPulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(255,215,0,0.4), 0 0 0 5px rgba(106,13,173,0.3),
                    0 20px 40px rgba(255,215,0,0.12);
    }
    33% {
        box-shadow: 0 0 0 3px rgba(255,215,0,0.8), 0 0 0 7px rgba(106,13,173,0.5),
                    0 20px 70px rgba(255,215,0,0.25);
    }
    66% {
        box-shadow: 0 0 0 3px rgba(180,80,255,0.7), 0 0 0 7px rgba(255,200,0,0.4),
                    0 20px 70px rgba(180,80,255,0.2);
    }
}

/* Star particles on shiny encounter */
.encounter-card.encounter-shiny::before,
.encounter-card.encounter-shiny-tera::before {
    content: '✦ ✧ ✦ ✧ ✦';
    position: absolute;
    top: 12px;
    width: 100%;
    left: 0;
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255,215,0,0.6);
    letter-spacing: 8px;
    animation: starRowPulse 2s ease-in-out infinite;
    pointer-events: none;
}

.encounter-card.encounter-tera::before {
    content: '◈ ◇ ◈ ◇ ◈';
    position: absolute;
    top: 12px;
    width: 100%;
    left: 0;
    text-align: center;
    font-size: 0.7rem;
    color: rgba(100,160,255,0.5);
    letter-spacing: 8px;
    animation: starRowPulse 3s ease-in-out infinite;
    pointer-events: none;
}

.encounter-card.encounter-shiny,
.encounter-card.encounter-tera,
.encounter-card.encounter-shiny-tera {
    position: relative;
    overflow: hidden;
}

@keyframes starRowPulse {
    0%, 100% { opacity: 0.4; letter-spacing: 8px; }
    50% { opacity: 1; letter-spacing: 12px; }
}


        html, body {
    touch-action: pan-x pan-y;  /* allows panning but prevents pinch‑zoom */
}
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'Inter', system-ui, sans-serif;
        }
        :root {
            --bg: #f0f2f5;
            --card-bg: #ffffff;
            --primary: #3b4cca;
            --primary-dark: #00238f;
            --accent: #ffde00;
            --text-dark: #2d3748;
            --text-light: #5a6e8a;
            --border: #e2e8f0;
            --success: #48bb78;
            --danger: #f56565;
            --grass: #78cd54;
            --dirt: #c2b280;
            --water: #6390f0;
            --fire: #ff421c;
        }

        /* Dark theme class – applied to body */
body.dark-theme {
  --bg: #1a1e2c;
  --card-bg: #2d2f3e;
  --primary: #6c5ce7;
  --primary-dark: #5a4ad1;
  --accent: #ff7675;
  --text-dark: #e2e8f0;
  --text-light: #a0aec0;
  --border: #3d4050;
  --success: #4cd964;
  --danger: #ff5e5e;
  --grass: #2d6a4f;
  --dirt: #7b5e3b;
  --water: #3b82f6;
  --fire: #f97316;
}
/* Player side: ensure stat box appears above the sprite */
#level-display {
    background: #fef9e3;
    color: #b45309;
    padding: 4px 12px;
    border-radius: 40px;
    font-weight: bold;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}
.container {
    flex: 1;
}
footer {
    margin-top: auto;
}

/* Force player sprite size on desktop */
.side.player-side #p-sprite-btl {
    width: 200px !important;
    height: 200px !important;
    object-fit: contain;
    margin-right: 0px;
    position: relative;
    z-index: 10;
}

/* Ensure stat box stays above */
.side.player-side .stat-box {
    position: relative;
    z-index: 20;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
}
.player-side {
 
    position: relative;
    display: flex;
    align-items: center;
    gap: 0px;
    flex-wrap: nowrap;          /* Prevent wrapping on desktop */
}

.player-side .stat-box {
    position: relative;
    z-index: 20;                /* Bring stat box to the front */
    background: rgba(255, 255, 255, 0.95); /* More opaque for readability */
    backdrop-filter: blur(8px); /* Keep blur but stronger */
    margin-left: 0;             /* No extra margin needed */
    flex-shrink: 0;             /* Prevent shrinking */
}

#p-sprite-btl {
    position: relative;
    z-index: 10;                /* Sprite stays behind the stat box */
    margin-right: -30px;        /* Pull sprite slightly under the stat box if needed */
}

/* On mobile, allow wrap and adjust spacing */
@media (max-width: 768px) {
    .player-side {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .player-side .stat-box {
        width: 100%;
        max-width: 280px;
        order: 2;               /* Move stat box below sprite on small screens */
        margin-top: -20px;      /* Overlap slightly if desired, but keep readable */
        z-index: 20;
    }
    #p-sprite-btl {
        order: 1;
        margin-right: 0;
        width: 180px !important;
        height: 180px !important;
    }
}

        body {
            background: var(--bg);
            min-height: 100vh;
            color: var(--text-dark);
        }
        .hidden { display: none !important; }
        #battle-area {
        overflow: visible !important;
        position: relative;
}
footer {
    text-align: center;
    padding: 20px;
    font-size: 0.8rem;
    color: var(--text-light);
    background: rgba(255,255,255,0.8);

    border-top: 1px solid var(--border);
}
footer p {
    margin-top: 10px;
    font-size: 0.7rem;
}
footer a {
    color: var(--primary);
    text-decoration: none;
}
footer a:hover {
    text-decoration: underline;
}
/* Special effect classes for encounter preview & battle */
.legendary-sprite {
    width: 250px !important;
    height: 250px !important;
    filter: drop-shadow(0 0 20px gold) brightness(1.1);
    animation: legendaryGlow 2s infinite ease-in-out;
}
@keyframes legendaryGlow {
    0%, 100% { filter: drop-shadow(0 0 10px gold) brightness(1); }
    50% { filter: drop-shadow(0 0 25px #ffaa00) brightness(1.15); }
}

.mythical-sprite {
    width: 250px !important;
    height: 250px !important;
    filter: drop-shadow(0 0 20px #ff66cc) drop-shadow(0 0 5px white);
    animation: mythicalSparkle 2.5s infinite;
}
@keyframes mythicalSparkle {
    0%, 100% { filter: drop-shadow(0 0 10px #ff66cc); }
    50% { filter: drop-shadow(0 0 30px #ff99ff) drop-shadow(0 0 10px white); }
}

.mega-sprite {
    width: 250px !important;
    height: 250px !important;
    filter: drop-shadow(0 0 20px #33aaff) drop-shadow(0 0 5px cyan);
    animation: megaPulse 1.8s infinite;
}
@keyframes megaPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); filter: drop-shadow(0 0 25px #33aaff); }
}

.ub-sprite {
    width: 250px !important;
    height: 250px !important;
    filter: drop-shadow(0 0 15px #00cc99) drop-shadow(0 0 5px #00ff99);
    animation: ubWarp 2s infinite;
}
@keyframes ubWarp {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 10px #00cc99); }
    50% { transform: scale(1.07) rotate(1deg); filter: drop-shadow(0 0 30px #33ff99); }
}

#switch-pokemon-list button {
    width: 100%;
    justify-content: flex-start;
}

.gmax-sprite {
    width: 250px !important; 
    height: 250px !important;
    position: relative;
    margin-top: -110px;
    margin-right: -50px;
    filter: drop-shadow(0 0 25px rgba(255, 0, 80, 0.9)) !important;
    animation: gmaxPulse 3s infinite ease-in-out;
}

@keyframes gmaxPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
        /* Auth Screen */
        #auth-screen {
            height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, var(--primary-dark), #790000);
        }
        .auth-card {
            background: var(--card-bg);
            padding: 40px;
            border-radius: 24px;
            width: 360px;
            text-align: center;
            box-shadow: 0 20px 35px -10px rgba(0,0,0,0.2);
            border: 1px solid var(--border);
        }
        .auth-card img { width: 280px; margin-bottom: 10px; border-radius: 20px; }

        input, textarea, select {
            width: 100%;
            padding: 8px 12px;
            margin: 5px 0;
            border: 1px solid var(--border);
            border-radius: 16px;
            font-size: 0.9rem;
        }
        textarea {
            resize: vertical;
            min-height: 60px;
        }
        .btn {
            padding: 8px 16px;
            border: none;
            border-radius: 40px;
            cursor: pointer;
            font-weight: 600;
            transition: 0.2s;
        }
        .btn-primary { background: var(--primary); color: white; }
        .btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
        .btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-light); }
        .btn-danger { background: var(--danger); color: white; }
        .btn-success { background: var(--success); color: white; }

        .back-link {
            display: inline-block;
            margin-bottom: 20px;
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
        }
        .container {
            max-width: 1200px;
            margin: 20px auto;
            background: var(--card-bg);
            border-radius: 32px;
            padding: 30px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
            border: 1px solid var(--border);
        }
        .map-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        .map-card {
            background: var(--card-bg);
            border-radius: 24px;
            border: 1px solid var(--border);
            padding: 20px;
            transition: transform 0.2s, box-shadow 0.2s;
            text-align: center;
            position: relative;
        }
        .map-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 12px 20px rgba(0,0,0,0.1);
        }
        .map-card img {
            width: 100%;
            object-fit: cover;
            border-radius: 16px;
            margin-bottom: 12px;
        }
        .map-card h3 {
            font-size: 1.4rem;
            color: var(--primary-dark);
            margin-bottom: 8px;
        }
        .map-card p {
            color: var(--text-light);
            margin: 8px 0;
            font-size: 0.85rem;
        }
        
        .map-description {
    text-align: justify;
}
        
        .required {
            font-weight: bold;
            margin: 10px 0;
        }

        .logo img {
    height: 40px;
    width: auto;
}


#encounter-preview {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 6000;
    backdrop-filter: blur(4px);
}
.encounter-card {
    background: var(--card-bg);
    border-radius: 32px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 35px rgba(0,0,0,0.3);
    color: var(--text-dark);
    color: #2d3748;
}
.encounter-sprite {
    width: 180px;
    height: 180px;
    object-fit: contain;
}
.encounter-name {
    font-size: 1.8rem;
    font-weight: bold;
    margin: 15px 0;
    color: var(--primary-dark);
}
.encounter-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}
.generation-badge, .special-badge {
    background: #ffde00;
    color: #333;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}
body.dark-theme .generation-badge {
    background: var(--primary);
    color: white;
}
body.dark-theme .special-badge {
    background: #d97c00;
}
        
.special-badge {
    background: #ff8c00;
    color: white;
}
#current-map-name {
    text-align: center;
    color: var(--primary-dark);
    margin: 10px 0;
    font-size: 1.5rem;
}

.generation-badge, .special-badge {
    background: #ffde00;
    color: #333;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
}
.special-badge {
    background: #ff8c00;
    color: white;
}

body.dark-theme .encounter-card {
    background: #2d2f3e;
    color: #e2e8f0;
}

body.dark-theme .encounter-card .encounter-name {
    color: #e2e8f0;
}

body.dark-theme #preview-weaknesses .type-badge,
body.dark-theme #preview-capture-status,
body.dark-theme #preview-encounter-count {
    color: #a0aec0;
}

body.dark-theme #preview-capture-status span[style*="color: var(--success)"] {
    color: #4cd964 !important;
}

body.dark-theme #preview-capture-status span[style*="color: var(--danger)"] {
    color: #ff5e5e !important;
}

        body.dark-theme #battle-area {
    background: linear-gradient(145deg, #2a2f3e 0%, #1e2434 40%, #2d4a2a 100%);
    border-color: #3d4050;
}

body.dark-theme .battle-header {
    background: #5a4ad1;
}

body.dark-theme .stat-box {
    background: rgba(30, 35, 50, 0.95);
    color: #e2e8f0;
    border-left-color: #6c5ce7;
}

body.dark-theme .stat-box .mon-name,
body.dark-theme .stat-box .mon-lvl {
    color: #e2e8f0;
}

body.dark-theme .hp-bar {
    background: #3d4050;
}

body.dark-theme #battle-log {
    background: rgba(0, 0, 0, 0.85);
    color: #cbd5e0;
}

body.dark-theme .catch-chance {
    background: rgba(30, 35, 50, 0.9);
    color: #e2e8f0;
}
body.dark-theme #info-overlay .modal {
    background: #2d2f3e;
    color: #e2e8f0;
}

body.dark-theme #info-stats {
    background: #1e2230;
    color: #a0aec0;
}

body.dark-theme #info-desc {
    color: #cbd5e0 !important;
}
body.dark-theme .stat-box {
    background: rgba(30, 35, 50, 0.95);
    color: #e2e8f0;
    border-left-color: #6c5ce7;
}
body.dark-theme .player-side .stat-box {
    background: rgba(30, 35, 50, 0.95);
    color: #e2e8f0;
}
body.dark-theme .player-side .stat-box {
    background: rgba(30, 35, 50, 0.95);
    color: #e2e8f0;
}
/* Dark theme for map info modal table */
body.dark-theme #map-info-modal .modal {
    background: #2d2f3e;
    color: #e2e8f0;
}

body.dark-theme #map-pokemon-list-container {
    border-color: #3d4050;
}

body.dark-theme #map-pokemon-list-container table {
    background: #2d2f3e;
}

body.dark-theme #map-pokemon-list-container thead {
    background: #1e2230;
}

body.dark-theme #map-pokemon-list-container th {
    color: #e2e8f0;
    border-bottom-color: #3d4050;
}

body.dark-theme #map-pokemon-list-container td {
    color: #cbd5e0;
    border-bottom-color: #3d4050;
}

body.dark-theme #map-pokemon-list-container tr:hover td {
    background: #3d4050;
}

body.dark-theme #map-info-modal .btn-primary {
    background: #6c5ce7;
}

body.dark-theme #map-info-modal .btn-primary:hover {
    background: #5a4ad1;
}
        .required.locked { color: var(--danger); }
        .required.unlocked { color: var(--success); }
        .admin-edit-btn, .admin-delete-btn {
            position: absolute;
            top: 10px;
            background: none;
            border: none;
            font-size: 1rem;
            cursor: pointer;
            color: var(--text-light);
            opacity: 0.6;
            transition: 0.2s;
        }
        .admin-edit-btn { right: 40px; }
        .admin-delete-btn { right: 10px; }
        .admin-edit-btn:hover, .admin-delete-btn:hover {
            opacity: 1;
            color: var(--primary);
        }
        .add-map-btn {
            background: var(--success);
            color: white;
            border: none;
            padding: 8px 20px;
            border-radius: 40px;
            cursor: pointer;
            font-weight: bold;
            margin-bottom: 20px;
        }
        .add-map-btn:hover { background: #3b9e5a; }

        /* Map exploration */
        .map-wrapper { width: 100%; overflow-x: auto; display: flex; justify-content: center; margin: 20px 0; }
        #map-viewport {
    width: min(600px, 100vw - 32px);   /* never wider than screen */
    aspect-ratio: 3 / 2;               /* keep proportions */
    height: auto;
    border: 4px solid var(--primary);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    background: var(--dirt);
    box-shadow: 0 12px 24px rgba(0,0,0,0.1);
    flex-shrink: 0;
}
/* #map-grid {
    display: grid;
    grid-template-columns: repeat(50, var(--tile-size, 50px));
    position: absolute;
    top: 0; left: 0;
    z-index: 1;
    transition: transform 0.15s ease-out;
} */
/* .tile {
    width: var(--tile-size, 50px);
    height: var(--tile-size, 50px);
    border: 1px solid rgba(0,0,0,0.05);
} */
        #player {
    position: absolute;
    width: 60px;
    height: auto;               /* ← was: 60px */
    top: 170px;
    left: 270px;
    z-index: 999;
    pointer-events: none;
    overflow: visible;          /* ← ADD THIS */
    display: flex;
    flex-direction: column;
    align-items: center;
}
        #player-sprite-img {
            width: 60px;
            height: 60px;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
            flex-shrink: 0;
        }
       #player-companion, .other-player-companion {
            position: absolute;
            bottom: 0px;
            right: -30px;
            width: 32px;
            height: 32px;
            object-fit: contain;
            image-rendering: pixelated;
            filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.4));
            animation: companionBob 1.2s ease-in-out infinite;
        }
        @keyframes companionBob {
            0%, 100% { transform: translateY(0px); }
            50% { transform: translateY(-3px); }
        }
        #player-name-label {
            background: rgba(0,0,0,0.65);
            color: #fff;
            font-size: 8px;
            font-weight: bold;
            padding: 1px 5px;
            border-radius: 8px;
            white-space: nowrap;
            margin-top: 1px;
            max-width: 80px;
            overflow: hidden;
            text-overflow: ellipsis;
            letter-spacing: 0.3px;
            line-height: 1.4;
            pointer-events: none;
        }

        /* Battle Area */
        #battle-area {
            max-width: 700px;
            width: 95%;
            margin: 20px auto;
            background: linear-gradient(145deg, #87CEEB 0%, #c0e0ff 40%, #78c850 100%);
            border-radius: 24px;
            box-shadow: 0 12px 28px rgba(0,0,0,0.2);
            border: 1px solid rgba(255,255,255,0.3);
            overflow: hidden;
        }
        .battle-header { background: var(--primary-dark); color: white; text-align: center; padding: 12px; font-weight: bold; font-size: 1rem; }
        .battle-ui { padding: 20px; display: flex; flex-direction: column; gap: 20px; }
        .side { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
        .enemy-side { justify-content: flex-end; }
        .btl-sprite { width: 100px; height: 100px; object-fit: contain; cursor: pointer; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2)); }
        .btl-sprite:hover { transform: scale(1.05); }
        .stat-box { background: rgba(255,255,255,0.9); backdrop-filter: blur(4px); padding: 12px 16px; border-radius: 20px; width: 220px; border-left: 4px solid var(--primary); }
        /* ===== BATTLE STAT BOX SPECIAL THEMES ===== */

/* Shiny stat box — gold glow */
.stat-box.statbox-shiny {
    background: linear-gradient(135deg, rgba(20,12,0,0.95), rgba(40,28,0,0.95));
    border-left: 4px solid #ffd700;
    box-shadow: 0 0 0 1px rgba(255,215,0,0.3), 0 0 16px rgba(255,215,0,0.2), inset 0 0 20px rgba(255,215,0,0.05);
    animation: statboxShinyPulse 2.5s ease-in-out infinite;
    color: #f5e6b8;
}

/* Terastal stat box — crystal purple */
.stat-box.statbox-tera {
    background: linear-gradient(135deg, rgba(8,4,20,0.95), rgba(20,8,40,0.95));
    border-left: 4px solid #a78bfa;
    box-shadow: 0 0 0 1px rgba(100,80,255,0.3), 0 0 16px rgba(106,13,173,0.25), inset 0 0 20px rgba(100,80,255,0.07);
    animation: statboxTeraPulse 3s ease-in-out infinite;
    color: #ddd6fe;
}

/* Shiny + Terastal stat box — gold + purple */
.stat-box.statbox-shiny-tera {
    background: linear-gradient(135deg, rgba(12,4,22,0.97), rgba(30,10,8,0.97), rgba(8,12,28,0.97));
    border-left: 4px solid transparent;
    border-image: linear-gradient(180deg, #ffd700, #a855f7, #ffd700) 1;
    box-shadow:
        0 0 0 1px rgba(255,215,0,0.25),
        0 0 0 2px rgba(168,85,247,0.2),
        0 0 20px rgba(255,215,0,0.15),
        0 0 35px rgba(106,13,173,0.12),
        inset 0 0 25px rgba(255,215,0,0.04);
    animation: statboxShinyTeraPulse 4s ease-in-out infinite;
    color: #f0e0ff;
}

/* Wild stats stat box — green tint */
.stat-box.statbox-wild {
    background: linear-gradient(135deg, rgba(4,16,4,0.95), rgba(8,28,8,0.95));
    border-left: 4px solid #48bb78;
    box-shadow: 0 0 0 1px rgba(72,187,120,0.25), 0 0 12px rgba(72,187,120,0.15), inset 0 0 16px rgba(72,187,120,0.05);
    animation: statboxWildPulse 3s ease-in-out infinite;
    color: #c6f6d5;
}

@keyframes statboxShinyPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(255,215,0,0.25), 0 0 12px rgba(255,215,0,0.15); border-left-color: rgba(255,215,0,0.7); }
    50% { box-shadow: 0 0 0 2px rgba(255,215,0,0.4), 0 0 28px rgba(255,215,0,0.35); border-left-color: #ffd700; }
}

@keyframes statboxTeraPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(100,80,255,0.2), 0 0 12px rgba(106,13,173,0.18); border-left-color: rgba(167,139,250,0.7); }
    50% { box-shadow: 0 0 0 2px rgba(100,80,255,0.4), 0 0 28px rgba(106,13,173,0.35); border-left-color: #a78bfa; }
}

@keyframes statboxShinyTeraPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(255,215,0,0.2), 0 0 0 2px rgba(168,85,247,0.15), 0 0 16px rgba(255,215,0,0.1); }
    33%  { box-shadow: 0 0 0 2px rgba(255,215,0,0.5), 0 0 0 4px rgba(168,85,247,0.3), 0 0 30px rgba(255,215,0,0.25); }
    66%  { box-shadow: 0 0 0 2px rgba(168,85,247,0.5), 0 0 0 4px rgba(255,215,0,0.25), 0 0 30px rgba(168,85,247,0.2); }
}

@keyframes statboxWildPulse {
    0%, 100% { box-shadow: 0 0 0 1px rgba(72,187,120,0.2), 0 0 10px rgba(72,187,120,0.1); }
    50% { box-shadow: 0 0 0 2px rgba(72,187,120,0.35), 0 0 22px rgba(72,187,120,0.25); }
}

/* ===== BATTLE NAME LABELS ===== */
.btl-name-shiny {
    font-size: 0.95rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ffd700, #ffaa00, #ffd700);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 4px rgba(255,215,0,0.6));
    animation: btlNameShinyPulse 2s ease-in-out infinite;
}

.btl-name-tera {
    font-size: 0.95rem;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 4px rgba(100,80,255,0.6));
    animation: btlNameTeraPulse 2.5s ease-in-out infinite;
}

.btl-name-shiny-tera {
    font-size: 0.95rem;
    font-weight: 800;
    background: linear-gradient(90deg, #ffd700, #e879f9, #60a5fa, #ffd700);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: btlNameShinyTeraSlide 3s linear infinite;
}

@keyframes btlNameShinyPulse {
    0%, 100% { filter: drop-shadow(0 0 3px rgba(255,215,0,0.5)); }
    50% { filter: drop-shadow(0 0 10px rgba(255,215,0,1)) drop-shadow(0 0 4px rgba(255,180,0,0.8)); }
}

@keyframes btlNameTeraPulse {
    0%, 100% { filter: drop-shadow(0 0 3px rgba(100,80,255,0.5)); }
    50% { filter: drop-shadow(0 0 10px rgba(160,80,255,1)) drop-shadow(0 0 4px rgba(100,160,255,0.8)); }
}

@keyframes btlNameShinyTeraSlide {
    0% { background-position: 0% 0; }
    100% { background-position: 200% 0; }
}

/* ===== BATTLE STAT PILLS ===== */
.btl-stat-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.btl-stat-pill.atk { background: rgba(255,107,107,0.25); color: #ff6b6b; border: 1px solid rgba(255,107,107,0.4); }
.btl-stat-pill.def { background: rgba(77,171,247,0.25); color: #4dabf7; border: 1px solid rgba(77,171,247,0.4); }
.btl-stat-pill.spd { background: rgba(105,219,124,0.25); color: #69db7c; border: 1px solid rgba(105,219,124,0.4); }
        .hp-bar { background: #e2e8f0; height: 8px; border-radius: 10px; overflow: hidden; margin-top: 8px; }
        .hp-fill { height: 100%; background: var(--success); width: 100%; transition: width 0.3s; }
        #battle-log { background: rgba(0,0,0,0.7); color: #e0e0e0; padding: 12px; font-family: monospace; font-size: 0.8rem; height: 80px; overflow-y: auto; border-radius: 16px; margin: 10px 0; backdrop-filter: blur(4px); }
        #battle-moves { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
        .move-btn {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 10px 12px;
            border: none;
            border-radius: 40px;
            cursor: pointer;
            font-weight: 600;
            color: white;
            text-shadow: 0 1px 1px rgba(0,0,0,0.2);
            font-size: 0.9rem;
            background: var(--type-color, #a0aec0);
        }
        .map-landscape {
        width: 100%;
        height: auto;
        border-radius: 24px;
        margin: 20px 0;
        object-fit: cover;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }

        #battle-summary-modal .modal {
            background: var(--card-bg);
            border-radius: 32px;
            padding: 20px;
        }
        #summary-moves span {
            background: #f0f0f0;
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 0.75rem;
            font-weight: bold;
        }
        .move-btn span:first-child { text-transform: uppercase; }
        .move-btn:hover { filter: brightness(0.9); transform: translateY(-2px); }
        .type-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 16px;
            font-size: 0.7rem;
            font-weight: bold;
            margin: 0 2px;
            color: white;
            text-shadow: 0 1px 1px rgba(0,0,0,0.2);
        }
        .catch-area { margin-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
        .catch-chance { font-size: 0.8rem; background: rgba(255,255,255,0.8); padding: 6px 12px; border-radius: 40px; font-weight: bold; }
        .catch-btn {
            background: #e33535;
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 20px;
            border-radius: 40px;
            color: white;
            font-weight: bold;
            border: none;
            cursor: pointer;
        }
        .catch-btn:disabled { opacity: 0.5; cursor: not-allowed; }
        .map-controls-t { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 15px auto; width: fit-content; }
        .arrow-row { display: contents; }
        .arrow-up, .arrow-down, .arrow-left, .arrow-right { width: 60px; padding: 10px; border-radius: 16px; font-weight: bold; background: var(--primary); color: white; border: none; cursor: pointer; transition: 0.2s; font-size: 1.2rem; }
        .arrow-diagonal { width: 60px; padding: 10px; border-radius: 16px; font-weight: bold; background: var(--primary); color: white; border: none; cursor: pointer; transition: 0.2s; font-size: 1rem; opacity: 0.7; }
        .arrow-diagonal:hover { opacity: 1; filter: brightness(1.1); }
        .arrow-center-blank { width: 60px; padding: 10px; background: transparent; border: none; opacity: 0.15; font-size: 1rem; color: var(--text-light); cursor: default; pointer-events: none; }
        .overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.85);
            display: flex;
            align-items: center;
            justify-content: center;
            z-index: 5000;
            backdrop-filter: blur(4px);
        }
        .modal {
            background: var(--card-bg);
            padding: 30px;
            border-radius: 32px;
            max-width: 700px;
            width: 90%;
            text-align: center;
            box-shadow: 0 25px 40px rgba(0,0,0,0.3);
            max-height: 85vh;
            overflow-y: auto;
        }
        .flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
        .form-group { margin: 15px 0; text-align: left; }
        .form-group label { display: block; margin-bottom: 5px; font-weight: 500; }

        @keyframes shake {
            0% { transform: translate(1px, 1px) rotate(0deg); }
            10% { transform: translate(-1px, -2px) rotate(-1deg); }
            20% { transform: translate(-3px, 0px) rotate(1deg); }
            30% { transform: translate(3px, 2px) rotate(0deg); }
            40% { transform: translate(1px, -1px) rotate(1deg); }
            50% { transform: translate(-1px, 2px) rotate(-1deg); }
            60% { transform: translate(-3px, 1px) rotate(0deg); }
            70% { transform: translate(3px, 1px) rotate(-1deg); }
            80% { transform: translate(-1px, -1px) rotate(1deg); }
            90% { transform: translate(1px, 2px) rotate(0deg); }
            100% { transform: translate(1px, -2px) rotate(-1deg); }
        }
        .shake-effect { animation: shake 0.5s; animation-iteration-count: 1; }

        

        #preview-weaknesses .type-badge {
    margin: 2px;
    font-size: 0.7rem;
}
#preview-capture-status, #preview-encounter-count {
    font-weight: 500;
}

   /* Move selection grid */
#battle-moves {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 15px 0;
}

.move-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: none;
    border-radius: 32px;
    cursor: pointer;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 1px rgba(0,0,0,0.2);
    transition: transform 0.2s, filter 0.2s;
    background: var(--type-color, #a0aec0);
}

.move-btn:hover {
    transform: translateY(-2px);
    filter: brightness(0.95);
}

.move-btn:active {
    transform: translateY(0);
}

.move-btn .move-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    margin-right: 12px;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.2));
}

.move-btn .move-name {
    flex: 1;
    text-align: left;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.move-btn .move-power {
    font-size: 0.85rem;
    font-weight: bold;
    background: rgba(0,0,0,0.3);
    padding: 4px 8px;
    border-radius: 20px;
    margin-left: 8px;
}

@media (max-width: 600px) {
    #battle-moves {
        gap: 8px;
    }
    .move-btn {
        padding: 8px 12px;
    }
    .move-icon {
    width: 28px !important;
    height: 28px !important;
    image-rendering: crisp-edges; /* Keep pixel‑perfect */
}
    .move-name {
        font-size: 0.75rem;
    }
    .move-power {
        font-size: 0.7rem;
        padding: 2px 6px;
    }
}

/* Prevent move buttons from overflowing */
.move-btn {
    overflow: hidden;
    max-width: 100%;
}

.move-name {
    white-space: normal;      /* allow text to wrap */
    word-break: break-word;   /* break long words if needed */
    overflow-wrap: break-word;
    flex-shrink: 1;
    min-width: 0;             /* helps flex children shrink */
}

.move-icon {
    flex-shrink: 0;           /* keep icon from squishing */
}

.move-power {
    flex-shrink: 0;           /* keep power badge from squishing */
    white-space: nowrap;      /* keep "40" etc. on one line */
}

@media (max-width: 400px) {
    #battle-moves {
        grid-template-columns: 1fr;
    }
}

/* Extra small screens – shrink move buttons more */
@media (max-width: 480px) {
    #battle-moves {
        gap: 6px;
    }
    .move-btn {
        padding: 6px 8px;
        gap: 4px;
    }
    .move-icon {
        width: 22px !important;
        height: 22px !important;
        margin-right: 4px;
    }
    .move-name {
        font-size: 0.65rem;
        line-height: 1.2;
        white-space: normal;
        word-break: break-word;
    }
    .move-power {
        font-size: 0.6rem;
        padding: 2px 5px;
        margin-left: 4px;
    }
}
#loading-spinner {
    display: block;
    margin: 0 auto;
    animation: spinBall 1s linear infinite;
}

.paradox-sprite {
    width: 250px !important;
    height: 250px !important;
    filter: drop-shadow(0 0 20px #ff44cc) drop-shadow(0 0 10px #aa22ff);
    animation: paradoxPulse 2s infinite ease-in-out;
}
@keyframes paradoxPulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 15px #ff44cc); }
    50% { transform: scale(1.05); filter: drop-shadow(0 0 35px #ff88ff) drop-shadow(0 0 10px #aa22ff); }
}

/* Support Modal - Centered with backdrop */
.support-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeInBackdrop 0.3s ease-out;
}
.support-modal-content {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 40px 50px;
    border-radius: 48px;
    text-align: center;
    max-width: 500px;
    width: 85%;
    box-shadow: 0 30px 50px rgba(0,0,0,0.4);
    border: 2px solid rgba(255,255,255,0.3);
    position: relative;
    animation: modalPop 0.3s cubic-bezier(0.34, 1.2, 0.64, 1);
}
.support-modal-content i {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
}
.support-modal-content h2 {
    font-size: 2rem;
    margin: 10px 0;
}
.support-modal-content p {
    font-size: 1rem;
    margin: 15px 0;
    opacity: 0.9;
}
.support-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: rgba(0,0,0,0.3);
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.support-modal-close:hover {
    background: rgba(0,0,0,0.6);
    transform: scale(1.1);
}
.support-modal-button {
    background: white;
    color: var(--primary-dark);
    border: none;
    padding: 12px 24px;
    border-radius: 40px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    transition: 0.2s;
}
.support-modal-button:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
@keyframes fadeInBackdrop {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@media (max-width: 600px) {
    #map-pokemon-grid {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 columns on small screens */
    }
}

@media (max-width: 400px) {
    #map-pokemon-grid {
        grid-template-columns: 1fr !important; /* 1 column on very small screens */
    }
}

/* Ensure the card fits well in the grid */
#map-pokemon-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    align-content: start; /* Prevents stretching if there are only a few items */
}

/* Optional: Make the scrollbar look nicer */
#map-pokemon-grid::-webkit-scrollbar {
    width: 6px;
}
#map-pokemon-grid::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

@media (max-width: 375px) {
    #map-pokemon-grid {
        gap: 4px; /* Even tighter gap for very small phones */
    }
    .poke-card-name {
        font-size: 0.65rem !important; /* Smaller text for narrow screens */
    }
    .poke-card-type {
        font-size: 0.5rem !important;
        padding: 1px 3px !important;
    }
}

/* Capture Modal Specific Styles */
.catch-success-glow {
    background: radial-gradient(circle, rgba(255,222,0,0.4) 0%, rgba(255,255,255,0) 70%);
    animation: rotateGlow 10s linear infinite;
}

@keyframes rotateGlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.catch-pop-in {
    animation: catchPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes catchPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.move-tag {
    background: rgba(0,0,0,0.05);
    border-radius: 10px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    border-bottom: 2px solid rgba(0,0,0,0.1);
}
/* Stat Bonus Badges */
.stat-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 800;
    color: white;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.2);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.sb-atk { background: #ef4444; border-bottom: 3px solid #b91c1c; }
.sb-def { background: #3b82f6; border-bottom: 3px solid #1d4ed8; }
.sb-spd { background: #10b981; border-bottom: 3px solid #047857; }

/* Section Header */
.summary-section-title {
    font-size: 0.65rem;
    font-weight: bold;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    margin-top: 12px;
    display: block;
    border-bottom: 1px solid var(--border);
}

.move-tag-colored {
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 0.7rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sb-shiny { 
    background: #ffde00; 
    color: #333 !important; 
    border-bottom: 3px solid #ca9500; 
    text-shadow: none !important;
}

/* Base pill styles (light theme defaults) */
.bonus-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    margin: 2px;
    text-shadow: none;
}
/* Form stats pills – darker, readable on white */
.bonus-pill.form {
    background: #ffcccc;
    color: #b30000;
}
.bonus-pill.form.def {
    background: #cce5ff;
    color: #003d66;
}
.bonus-pill.form.spd {
    background: #ccffcc;
    color: #006600;
}
/* Wild stats pills – original bright style (good for light theme) */
.bonus-pill.wild {
    background: #ff6b6b;
    color: white;
}
.bonus-pill.wild.def {
    background: #4dabf7;
}
.bonus-pill.wild.spd {
    background: #69db7c;
}

/* Dark theme overrides – softer, muted */
body.dark-theme .bonus-pill.form {
    background: rgba(255, 107, 107, 0.2);
    color: #ffa0a0;
}
body.dark-theme .bonus-pill.form.def {
    background: rgba(77, 171, 247, 0.2);
    color: #a0c4ff;
}
body.dark-theme .bonus-pill.form.spd {
    background: rgba(105, 219, 124, 0.2);
    color: #a0ffa0;
}
body.dark-theme .bonus-pill.wild {
    background: #c0392b;
    color: #ffe0e0;
}
body.dark-theme .bonus-pill.wild.def {
    background: #2c6e9e;
}
body.dark-theme .bonus-pill.wild.spd {
    background: #2d6a4f;
}
#summary-details {
    background: #f1f5f9;
}
body.dark-theme #summary-details {
    background: #1e2230;
}

#battle-area {
    max-width: 700px;
    width: 95%;
    margin: 20px auto;
    background: linear-gradient(145deg, #87CEEB 0%, #c0e0ff 40%, #78c850 100%);
    border-radius: 24px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    overflow: hidden;
    position: relative;   /* ← ADD THIS */
}
/* ========== ENHANCED BATTLE EFFECTS ========== */
@keyframes floatUp {
    0% { transform: translateY(0) scale(1.4) rotate(-3deg); opacity: 1; }
    30% { transform: translateY(-30px) scale(1.6) rotate(2deg); opacity: 1; }
    70% { transform: translateY(-70px) scale(1.2) rotate(-1deg); opacity: 0.7; }
    100% { transform: translateY(-110px) scale(0.7) rotate(0deg); opacity: 0; }
}
@keyframes floatUpCrit {
    0% { transform: translateY(0) scale(2) rotate(-5deg); opacity: 1; }
    20% { transform: translateY(-20px) scale(2.4) rotate(3deg); opacity: 1; }
    60% { transform: translateY(-60px) scale(1.8) rotate(-2deg); opacity: 0.9; }
    100% { transform: translateY(-120px) scale(0.9) rotate(1deg); opacity: 0; }
}
@keyframes shockwaveExpand {
    0% { transform: translate(-50%,-50%) scale(0); opacity: 1; width: 20px; height: 20px; }
    100% { transform: translate(-50%,-50%) scale(1); opacity: 0; width: 200px; height: 200px; }
}
@keyframes hitFlash {
    0% { opacity: 0; }
    15% { opacity: 0.35; }
    100% { opacity: 0; }
}
@keyframes impactBurst {
    0% { transform: translate(-50%,-50%) scale(1) translate(0,0); opacity: 1; }
    100% { transform: translate(-50%,-50%) scale(0) translate(var(--dx), var(--dy)); opacity: 0; }
}
@keyframes critStampAnim {
    0% { transform: translate(-50%,-50%) scale(3) rotate(-8deg); opacity: 0; }
    15% { transform: translate(-50%,-50%) scale(1.1) rotate(2deg); opacity: 1; }
    70% { transform: translate(-50%,-50%) scale(1) rotate(0deg); opacity: 1; }
    100% { transform: translate(-50%,-50%) scale(0.8) rotate(0deg); opacity: 0; }
}
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-2px, -3px) rotate(-1deg); }
    20% { transform: translate(-4px, 0px) rotate(1deg); }
    30% { transform: translate(4px, 3px) rotate(0deg); }
    40% { transform: translate(2px, -2px) rotate(1deg); }
    50% { transform: translate(-2px, 3px) rotate(-1deg); }
    60% { transform: translate(-4px, 2px) rotate(0deg); }
    70% { transform: translate(4px, 2px) rotate(-1deg); }
    80% { transform: translate(-2px, -2px) rotate(1deg); }
    90% { transform: translate(2px, 3px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.floating-damage {
    position: absolute;
    font-weight: 900;
    font-size: 1.6rem;
    color: #ff4444;
    text-shadow: 0 0 10px rgba(255,50,0,0.8), 2px 2px 0 rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 1000;
    animation: floatUp 1.1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    white-space: nowrap;
    font-family: 'Impact', sans-serif;
}
.floating-damage.critical {
    color: #ffcc00;
    font-size: 2.2rem;
    text-shadow: 0 0 15px rgba(255,200,0,1), 0 0 30px rgba(255,150,0,0.8);
    animation: floatUpCrit 1.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.floating-damage.heal { color: #44ff88; }
.floating-damage.miss { color: #aaaaaa; font-size: 0.9rem; font-style: italic; }
.hit-shockwave {
    position: absolute;
    border-radius: 50%;
    border: 3px solid rgba(255,150,0,0.9);
    pointer-events: none;
    z-index: 999;
    animation: shockwaveExpand 0.6s ease-out forwards;
}
.hit-flash-overlay {
    position: absolute;
    inset: 0;
    border-radius: 24px;
    pointer-events: none;
    z-index: 998;
    animation: hitFlash 0.4s ease-out forwards;
}
.impact-particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 997;
    animation: impactBurst 0.7s ease-out forwards;
}
.crit-stamp {
    position: absolute;
    font-family: 'Impact', sans-serif;
    font-size: 1.8rem;
    color: #fff;
    text-shadow: 0 0 20px #ffaa00, 0 0 40px #ff6600, 3px 3px 0 #cc0000;
    pointer-events: none;
    z-index: 1001;
    animation: critStampAnim 1.2s ease-out forwards;
    white-space: nowrap;
}
.shake-effect { animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(15deg); }
    75% { transform: rotate(-15deg); }
}

/* Catch Summary Modal Effects */
@keyframes rotateGlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulseCatch {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.3); opacity: 0.8; }
}

@keyframes confettiFall {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--tx, 0), var(--ty, -100px)) rotate(360deg); opacity: 0; }
}

@keyframes starBurst {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--ex, 0), var(--ey, 0)) scale(0); opacity: 0; }
}

@keyframes burstFlash {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

@keyframes spritePopIn {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    70% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes textPopIn {
    0% { transform: scale(0.8); opacity: 0; letter-spacing: -5px; }
    100% { transform: scale(1); opacity: 1; letter-spacing: normal; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shinyPulse {
    0%, 100% { text-shadow: 0 0 5px #ffd700; }
    50% { text-shadow: 0 0 20px #ffd700, 0 0 30px #ffaa00; }
}

@keyframes catchHeaderPop {
    0% { transform: scale(0.8); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Poké Ball glow animation */
@keyframes pokeballGlow {
    0%, 100% { filter: drop-shadow(0 0 5px rgba(255,255,255,0.5)); }
    50% { filter: drop-shadow(0 0 15px rgba(255,255,255,0.8)) drop-shadow(0 0 5px rgba(255,0,0,0.5)); }
}

.pokeball-throw {
    animation: pokeballGlow 0.3s ease-in-out infinite;
}

/* Super Effective Stamp Style for Maps */
.super-effective-stamp {
    position: absolute;
    font-family: 'Impact', 'Arial Black', sans-serif;
    font-size: 1.6rem;
    color: #fff;
    text-shadow: 0 0 20px #44ff88, 0 0 40px #008800, 3px 3px 0 #004400; /* Green Glow */
    pointer-events: none;
    z-index: 1001;
    animation: critStampAnim 1.2s ease-out forwards;
    white-space: nowrap;
}

/* Enhanced Hard Shake */
.shake-effect-hard { animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

#map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    /* canvas is sized by JS — no width/height here */
}

.other-player {
    position: absolute;
    z-index: 998; /* Just below your own player (999) */
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.other-player-name {
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 8px;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 8px;
    white-space: nowrap;
    margin-bottom: 2px; /* Put name ABOVE the sprite */
}

.other-player-sprites {
    position: relative;
    display: flex;
    justify-content: center;
}
.other-player-trainer {
    width: 40px;
    height: 40px;
    object-fit: contain;
    image-rendering: pixelated;
}
.other-player-companion {
    width: 30px;
    height: 30px;
    object-fit: contain;
    image-rendering: pixelated;
    margin-left: -8px;
    margin-bottom: -4px;
}