@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&display=swap');

:root {
    --bg-color: #04050e;
    --panel-bg: rgba(13, 16, 33, 0.75);
    --panel-border: rgba(255, 255, 255, 0.08);
    --font-family: 'Outfit', sans-serif;
    
    /* Neon gradients */
    --neon-blue: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    --neon-orange: linear-gradient(135deg, #ffd166 0%, #f77f00 100%);
    --neon-green: linear-gradient(135deg, #06d6a0 0%, #1b9aaa 100%);
    --neon-purple: linear-gradient(135deg, #9d4edd 0%, #7b2cbf 100%);
    --neon-magenta: linear-gradient(135deg, #ff007f 0%, #7b2cbf 100%);
    --neon-yellow: linear-gradient(135deg, #ffee55 0%, #f77f00 100%);
    --neon-cyan: linear-gradient(135deg, #00f2fe 0%, #06d6a0 100%);
    --neon-red: linear-gradient(135deg, #ef233c 0%, #d90429 100%);
    
    /* Glow shadows */
    --glow-blue: 0 0 15px rgba(0, 242, 254, 0.5);
    --glow-orange: 0 0 15px rgba(247, 127, 0, 0.5);
    --glow-green: 0 0 15px rgba(6, 214, 160, 0.5);
    --glow-purple: 0 0 15px rgba(123, 44, 191, 0.6);
    --glow-red: 0 0 15px rgba(217, 4, 41, 0.5);
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
}

/* Zero-flicker premium smooth image loading style */
img {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease-in-out;
}
img.loaded {
    opacity: 1;
    visibility: visible;
}

body {
    background-color: #030307;
    color: #ffffff;
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    width: 100dvw;
}

/* Star background effect */
.starfield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #0a0c20 0%, #030307 100%);
    z-index: -2;
    overflow: hidden;
}

.starfield::after {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background-image: 
        radial-gradient(1px 1px at 20px 30px, #fff, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 40px 70px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 150px 100px, rgba(255,255,255,0.7), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 200px 300px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 300px 80px, #fff, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 400px 400px;
    opacity: 0.35;
    animation: starsRotate 240s linear infinite;
    top: -50%;
    left: -50%;
}

@keyframes starsRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Optimize Starfield and Runes on mobile to save GPU layers and prevent recompositions */
@media (max-width: 480px) {
    .starfield::after {
        animation: none !important;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        transform: none !important;
    }
    .rune-icon {
        filter: none !important; /* Disable heavy real-time CPU/GPU drop-shadow pass on moving board elements */
    }
}

/* Mobile Frame Container */
.game-container {
    width: 100%;
    height: 100dvh;
    max-width: 480px;
    max-height: 100dvh;
    background-color: var(--bg-color);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), 0 0 100px rgba(123, 44, 191, 0.15);
    border-radius: 0;
    border: none;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Desktop-only frame styling */
@media(min-width: 481px) {
    .game-container {
        border-radius: 40px;
        border: 4px solid #1a1e36;
    }
}

/* TOP STATUS PANEL (Stacked Two-Row Dashboard for space efficiency) */
.top-status {
    padding: 10px 14px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: linear-gradient(to bottom, rgba(3, 4, 12, 0.96) 0%, rgba(3, 4, 12, 0.8) 70%, rgba(3, 4, 12, 0) 100%);
    z-index: 10;
}

.avatar-container {
    display: flex;
    align-items: center;
    gap: 10px;
    align-self: flex-start;
}

.avatar-frame {
    position: relative;
    width: 46px; /* slightly scaled down to look balanced with two rows */
    height: 46px;
    border-radius: 50%;
    background: var(--neon-purple);
    padding: 2.5px;
    box-shadow: var(--glow-purple);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #0d1021;
}

.avatar-level-badge {
    position: absolute;
    bottom: -3px;
    right: -3px;
    background: #7b2cbf;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 1px 4.5px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.player-info {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #e0e1dd;
    margin-bottom: 2px;
}

.xp-bar-container {
    width: 90px;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.xp-bar-fill {
    height: 100%;
    background: var(--neon-cyan);
    width: 84.5%;
    border-radius: 3px;
}

.xp-text {
    font-size: 0.52rem;
    color: #8b92b6;
    margin-top: 1.5px;
}

.resource-bar {
    display: flex;
    gap: 6px;
    width: 100%;
    justify-content: space-between;
}

.resource-counter {
    background: rgba(13, 16, 33, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 3px 6px 3px 22px;
    display: flex;
    align-items: center;
    position: relative;
    flex: 1;
    min-width: 0;
    max-width: calc(33.33% - 4px);
    height: 28px;
}

.resource-icon {
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.resource-icon img {
    max-width: 100%;
    max-height: 100%;
}

.resource-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: #ffffff;
    width: 100%;
    text-align: center;
}

.resource-add {
    width: 18px;
    height: 18px;
    background: #00f2fe;
    color: #0b0c16;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    box-shadow: 0 0 5px rgba(0, 242, 254, 0.4);
    transition: all 0.2s ease;
}

.resource-add:active {
    transform: translateY(-50%) scale(0.9);
}

.resource-counter.gems-counter .resource-add {
    background: #7b2cbf;
    color: #fff;
    box-shadow: 0 0 5px rgba(123, 44, 191, 0.4);
}

/* SUB-HEADER HEXAGON BUTTONS */
.sub-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    z-index: 10;
}

.badge-buttons {
    display: flex;
    gap: 12px;
}

.badge-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
}

.badge-hexagon {
    width: 42px;
    height: 48px;
    background: rgba(25, 27, 49, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
}

.badge-btn:hover .badge-hexagon {
    background: rgba(123, 44, 191, 0.3);
    border-color: #7b2cbf;
    transform: scale(1.05);
}

.badge-hexagon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #7b2cbf;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid #04050e;
    box-shadow: var(--glow-purple);
}

.badge-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: #8b92b6;
    margin-top: 5px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* PREMIUM TROPHY HEXAGON SLOT STYLES */
.trophy-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.trophy-hexagon {
    width: 42px;
    height: 48px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.25);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.15);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.25s ease;
}

.trophy-slot:hover .trophy-hexagon {
    background: rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.65);
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.45);
    transform: scale(1.06);
}

.trophy-hexagon img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.55));
}

.trophy-label {
    font-size: 0.55rem;
    font-weight: 800;
    color: #ffee55;
    margin-top: 5px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-shadow: 0 0 5px rgba(255, 238, 85, 0.35);
    max-width: 68px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}



/* LIVING WORLD WINDOW (TOP PANEL) */
.world-view {
    aspect-ratio: 765 / 260;
    margin: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-image: url('../img/ambiente.webp');
    background-size: 100% 100%;
    background-position: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* Portal element in world view */
.world-portal {
    position: absolute;
    left: 50%;
    top: 45%;
    transform: translate(-50%, -50%);
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(123, 44, 191, 0.7) 0%, rgba(0, 242, 254, 0.1) 70%, transparent 100%);
    box-shadow: 0 0 30px rgba(123, 44, 191, 0.8), inset 0 0 20px rgba(0, 242, 254, 0.5);
    animation: portalPulse 6s ease-in-out infinite;
}

.world-portal::after {
    content: '';
    position: absolute;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    animation: rotatePortal 20s linear infinite;
}

@keyframes portalPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; box-shadow: 0 0 50px rgba(123, 44, 191, 0.9), 0 0 30px rgba(0, 242, 254, 0.6); }
}

@keyframes rotatePortal {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Floating islands minor animations */
.floating-island-fx {
    position: absolute;
    width: 60px;
    height: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    filter: blur(8px);
    animation: floatFX 4s ease-in-out infinite;
}

@keyframes floatFX {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* STANDALONE PROGRESS BAR (Between World View and Grid) */
.standalone-progress-container {
    margin: 4px 16px;
    background: rgba(13, 16, 33, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 3px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: 22px;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.standalone-progress-bar {
    flex: 1;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.standalone-progress-fill {
    height: 100%;
    background: var(--neon-blue);
    border-radius: 3px;
    width: 72%;
    transition: width 0.5s ease-out;
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.65);
}

.standalone-progress-text {
    font-size: 0.58rem;
    font-weight: 800;
    color: #8b92b6;
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-shadow: 0 0 5px rgba(139, 146, 182, 0.3);
}


/* 7x7 MAIN PLAYABLE GRID */
.grid-outer-container {
    flex: 1;
    margin: 4px 16px;
    padding: 8px;
    border-radius: 24px;
    background: rgba(13, 16, 33, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    /* Soft premium breathing aura */
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.6),
        inset 0 0 25px rgba(123, 44, 191, 0.12);
    animation: boardCosmicBreath 8s ease-in-out infinite alternate;
}

/* Beautiful breathing neon board aura animation */
@keyframes boardCosmicBreath {
    0% {
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(123, 44, 191, 0.1), 0 0 10px rgba(0, 242, 254, 0.05);
    }
    100% {
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7), inset 0 0 30px rgba(0, 242, 254, 0.2), 0 0 25px rgba(157, 78, 221, 0.15);
    }
}

/* Dynamic rotating laser border (Premium sci-fi visual) */
.grid-outer-container::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 24px;
    padding: 1.5px; /* Border thickness */
    background: linear-gradient(135deg, #00f2fe, #7b2cbf, #ff007f, #00f2fe);
    background-size: 350% 350%;
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    animation: borderLaserRotator 8s linear infinite;
    opacity: 0.65;
    z-index: 1;
}

@keyframes borderLaserRotator {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.grid-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 4px;
    width: 100%;
    height: 100%;
    max-width: 420px;
    max-height: 420px;
    aspect-ratio: 1/1;
    position: relative;
    z-index: 3;
    /* High-tech blueprint cosmic engineering grid pattern background */
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
    background-size: calc(100% / 7) calc(100% / 7);
    border-radius: 16px;
}

.grid-cell {
    background: rgba(25, 27, 49, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    /* GPU Hardware Acceleration */
    will-change: transform, opacity, background-color;
    transform: translate3d(0, 0, 0);
}

.grid-cell:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.03);
}

.grid-cell.highlighted {
    background: rgba(123, 44, 191, 0.12);
    border-color: rgba(123, 44, 191, 0.3);
}

.grid-cell.active-connection {
    background: rgba(0, 242, 254, 0.08);
    border-color: rgba(0, 242, 254, 0.4);
    box-shadow: 
        inset 0 0 12px rgba(0, 242, 254, 0.15),
        0 0 10px rgba(0, 242, 254, 0.1);
    transform: scale(0.96) translate3d(0, 0, 0);
}

/* Grid element / Rune */
.rune-node {
    width: 90%;
    height: 90%;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* GPU Hardware Acceleration */
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

.rune-node:active {
    transform: scale(0.9);
}

.rune-glow {
    position: absolute;
    width: 132%;
    height: 132%;
    top: -16%;
    left: -16%;
    border-radius: 50%;
    z-index: -1;
    transition: all 0.3s ease;
    /* GPU Hardware Acceleration & Magical Breathing Pulse */
    will-change: transform, opacity;
    animation: auraBreathPulse 2.4s ease-in-out infinite alternate;
    pointer-events: none;
}

/* Premium smooth breathing glow aura for runes */
@keyframes auraBreathPulse {
    0% {
        opacity: 0.45;
        transform: scale(0.94) translate3d(0, 0, 0);
    }
    100% {
        opacity: 0.85;
        transform: scale(1.06) translate3d(0, 0, 0);
    }
}

.rune-icon {
    width: 75%;
    height: 75%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
    /* GPU Hardware Acceleration */
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

/* Neon variations of elements (Lag-free hardware-accelerated radial gradients - no box-shadow blur filter) */
.rune-node[data-type="energia"] .rune-glow { background: radial-gradient(circle, rgba(0, 242, 254, 0.7) 0%, transparent 75%); }
.rune-node[data-type="natureza"] .rune-glow { background: radial-gradient(circle, rgba(6, 214, 160, 0.7) 0%, transparent 75%); }
.rune-node[data-type="plasma"] .rune-glow { background: radial-gradient(circle, rgba(157, 78, 221, 0.7) 0%, transparent 75%); }
.rune-node[data-type="cristal"] .rune-glow { background: radial-gradient(circle, rgba(240, 248, 255, 0.95) 0%, transparent 75%); }
.rune-node[data-type="cristal"] .rune-icon {
    /* Pre-colored directly in the image on disk: zero GPU filter lag! */
}
.rune-node[data-type="fogo"] .rune-glow { background: radial-gradient(circle, rgba(247, 127, 0, 0.7) 0%, transparent 75%); }
.rune-node[data-type="terra"] .rune-glow { background: radial-gradient(circle, rgba(217, 4, 41, 0.7) 0%, transparent 75%); }
.rune-node[data-type="terra"] .rune-icon {
    /* Pre-colored directly in the image on disk: zero GPU filter lag! */
}
.rune-node[data-type="sol"] .rune-glow { background: radial-gradient(circle, rgba(255, 238, 85, 0.7) 0%, transparent 75%); }

/* Animation class for spawned elements */
.spawn-anim {
    animation: spawnPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes spawnPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Canvas Overlay for drawing connections */
.grid-canvas-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
    height: calc(100% - 20px);
    z-index: 2;
    pointer-events: none;
}

/* BOTTOM ACTION DASHBOARD */
.bottom-dashboard {
    background-image: url('../img/funco_down.webp');
    background-size: cover;
    background-position: bottom center;
    background-repeat: no-repeat;
    background-color: #03040c;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.action-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    width: 65px;
}

.slot-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(25, 27, 49, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.2s ease;
}

.action-slot:hover .slot-circle {
    border-color: #7b2cbf;
    box-shadow: var(--glow-purple);
    transform: scale(1.05);
}

.slot-circle img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.slot-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background: #7b2cbf;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #04050e;
}

.slot-label {
    font-size: 0.55rem;
    font-weight: 700;
    color: #8b92b6;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.slot-value {
    font-size: 0.65rem;
    font-weight: 800;
    color: #00f2fe;
    margin-top: 1px;
}

/* BIG MAIN FUSION BUTTON */
.fusion-btn-container {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-28px); /* Raised vertically to float premiumly */
}

.fusion-btn-outer-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid rgba(123, 44, 191, 0.3);
    animation: rotateRing 15s linear infinite;
}

.fusion-btn-outer-ring::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00f2fe;
    box-shadow: var(--glow-blue);
}

@keyframes rotateRing {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fusion-btn {
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: radial-gradient(circle, #7b2cbf 0%, #3c096c 100%);
    border: 3px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 25px rgba(123, 44, 191, 0.6), inset 0 0 15px rgba(255, 255, 255, 0.2);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2;
}

.fusion-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 35px rgba(123, 44, 191, 0.8), 0 0 15px rgba(0, 242, 254, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.fusion-btn:active {
    transform: scale(0.95);
    box-shadow: 0 0 15px rgba(123, 44, 191, 0.5);
}

.fusion-title {
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: #ffffff;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.fusion-cost {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #00f2fe;
}

.fusion-cost-icon {
    width: 10px;
    height: 10px;
}


/* POPUP AND MODALS STYLE */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 4, 10, 0.85);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: rgba(16, 18, 38, 0.95);
    border: 1px solid rgba(123, 44, 191, 0.3);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(123, 44, 191, 0.2);
    border-radius: 24px;
    width: 100%;
    max-width: 380px;
    padding: 24px;
    position: relative;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active {
    display: flex;
}

.modal-overlay.auth-blocking-active {
    background: rgba(3, 4, 10, 0.98) !important;
    backdrop-filter: blur(25px) !important;
    z-index: 1000 !important;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
    opacity: 1;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #8b92b6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    background: rgba(217, 4, 41, 0.2);
    color: #ef233c;
    border-color: #ef233c;
}

.modal-close i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    line-height: 1;
    transform: translate(0.5px, 0.5px);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffffff;
    text-align: center;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: linear-gradient(135deg, #00f2fe 0%, #7b2cbf 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-body {
    max-height: 400px;
    overflow-y: auto;
}

/* MOCK ADS OVERLAY */
.ad-banner-overlay {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    background: rgba(13, 16, 33, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    display: none;
    align-items: center;
    justify-content: space-between;
    z-index: 90;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.ad-label {
    background: rgba(255, 255, 255, 0.1);
    color: #8b92b6;
    font-size: 0.5rem;
    padding: 2px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 800;
}

.ad-content {
    font-size: 0.65rem;
    color: #e0e1dd;
    text-align: left;
    flex: 1;
    margin-left: 10px;
}

.ad-button {
    background: var(--neon-purple);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    cursor: pointer;
    border: none;
}

.ad-close {
    color: #5b6286;
    font-size: 0.8rem;
    cursor: pointer;
    margin-left: 10px;
}

/* FLOATING SCORE PARTICLES */
.combo-floater {
    position: absolute;
    color: #ffffff;
    font-weight: 800;
    pointer-events: none;
    z-index: 100;
    animation: floatUpFade 1.2s cubic-bezier(0.25, 1, 0.50, 1) forwards;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8), 0 0 10px var(--color-glow);
}

@keyframes floatUpFade {
    0% { transform: translateY(0) scale(0.6); opacity: 1; }
    50% { transform: translateY(-30px) scale(1.1); opacity: 1; }
    100% { transform: translateY(-60px) scale(0.9); opacity: 0; }
}

/* Grid Board Tactile Shake Keyframes for satisfying merges */
@keyframes boardShakeNormal {
    0%, 100% { transform: translate(0, 0); }
    15%, 45%, 75% { transform: translate(-3px, 2px); }
    30%, 60%, 90% { transform: translate(3px, -2px); }
}

@keyframes boardShakeMega {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-8px, 6px) rotate(-0.5deg); }
    20%, 40%, 60%, 80% { transform: translate(8px, -6px) rotate(0.5deg); }
}

.shake-normal {
    animation: boardShakeNormal 0.35s cubic-bezier(.36,.07,.19,.97) both;
    backface-visibility: hidden;
    perspective: 1000px;
}

.shake-mega {
    animation: boardShakeMega 0.55s cubic-bezier(.36,.07,.19,.97) both;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Satisfying squash-and-stretch pop animation for the main Fusion button */
@keyframes fusionButtonSquash {
    0% { transform: scale(1); }
    15% { transform: scale(0.72); } /* Physical compression on click */
    45% { transform: scale(1.15); } /* Elastic stretch overshoot */
    70% { transform: scale(0.92); } /* Bouncing recovery */
    100% { transform: scale(1); }    /* Rest state */
}

.fusion-btn.clicked {
    animation: fusionButtonSquash 0.5s cubic-bezier(0.25, 0.8, 0.25, 1.4) both;
}

/* PREMIUM PRELOADER LOADING SCREEN */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    background-color: #030307;
    transition: opacity 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.6s;
}

.loading-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    z-index: -1;
}

.loading-bar-container {
    width: 80%;
    max-width: 320px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin-bottom: 80px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #9d4edd, #00f2fe, #7b2cbf);
    background-size: 200% 200%;
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.8);
    animation: loadingProgress 2.2s cubic-bezier(0.25, 0.8, 0.25, 1) forwards, loadingGradient 2s linear infinite;
}

.loading-text {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    font-weight: 800;
    color: #8b92b6;
    letter-spacing: 2px;
    white-space: nowrap;
    text-shadow: 0 0 5px rgba(0, 242, 254, 0.4);
}

@keyframes loadingProgress {
    0% { width: 0%; }
    10% { width: 15%; }
    40% { width: 50%; }
    70% { width: 85%; }
    100% { width: 100%; }
}

@keyframes loadingGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.loading-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* BATTLE LAYOUT ADJUSTMENTS */
.battle-left-area {
    width: 190px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.desafiar-btn-wrapper {
    cursor: pointer;
    width: 170px;
    height: 170px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.desafiar-btn-wrapper:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 0 24px rgba(157, 78, 221, 0.95));
}

.desafiar-btn-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.pulse-anim {
    animation: battleSearchPulse 1.5s ease-in-out infinite alternate;
}

@keyframes battleSearchPulse {
    0% { transform: scale(0.96); filter: brightness(0.8) drop-shadow(0 0 5px rgba(123, 44, 191, 0.4)); }
    100% { transform: scale(1.04); filter: brightness(1.2) drop-shadow(0 0 15px rgba(0, 242, 254, 0.8)); }
}

.battle-vs-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 6px 8px;
    background: rgba(13, 16, 33, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    backdrop-filter: blur(5px);
}

.battle-vs-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

.abandon-btn {
    width: 100%;
    padding: 4px 8px;
    margin-top: 4px;
    background: rgba(239, 35, 60, 0.12);
    border: 1px solid rgba(239, 35, 60, 0.35);
    border-radius: 8px;
    color: #ef233c;
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    cursor: pointer;
    text-transform: uppercase;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 0 10px rgba(239, 35, 60, 0.08);
}

.abandon-btn:hover {
    background: rgba(239, 35, 60, 0.25);
    border-color: rgba(239, 35, 60, 0.7);
    box-shadow: 0 0 15px rgba(239, 35, 60, 0.25);
    transform: scale(1.02);
}

.abandon-btn:active {
    transform: scale(0.98);
}

.battle-player-badge {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.battle-wins-badge {
    position: absolute;
    top: -5px;
    background: linear-gradient(135deg, #ffee55 0%, #ffb703 100%);
    color: #03040e;
    font-size: 0.52rem;
    font-weight: 900;
    padding: 1px 6px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 8px rgba(255, 238, 85, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
    z-index: 5;
    white-space: nowrap;
}

.battle-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    object-fit: cover;
    background: #0d1021;
}

#battle-player-img {
    border-color: #00f2fe;
    box-shadow: 0 0 8px rgba(0, 242, 254, 0.4);
}

#battle-opponent-img {
    border-color: #ff007f;
    box-shadow: 0 0 8px rgba(255, 0, 127, 0.4);
}

.battle-score-lbl {
    font-size: 0.65rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.4);
}

.battle-vs-divider {
    font-size: 0.75rem;
    font-weight: 900;
    color: #ff007f;
    text-shadow: 0 0 5px rgba(255, 0, 127, 0.8);
}

.battle-vs-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.battle-right-area {
    width: 190px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.battle-idle-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    width: 90px;
    height: 68px;
    background: rgba(25, 27, 49, 0.2);
}

.battle-idle-text {
    font-size: 0.52rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #5b6286;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
    text-align: center;
}

.battle-active-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.battle-timer {
    font-size: 0.82rem;
    font-weight: 900;
    color: #ffb703;
    text-shadow: 0 0 10px rgba(255, 183, 3, 0.4);
    background: rgba(0, 0, 0, 0.35);
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 183, 3, 0.2);
    font-family: monospace;
    flex-shrink: 0;
}

/* OPPONENT MINI GRID */
.mini-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 1.5px;
    width: 130px;
    height: 130px;
    background: rgba(13, 16, 33, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 2px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

.mini-cell {
    border-radius: 2px;
    background: rgba(25, 27, 49, 0.4);
    border: 0.5px solid rgba(255, 255, 255, 0.02);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
}

.mini-rune-node {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mini-rune-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    z-index: 1;
    opacity: 0.6;
    pointer-events: none;
}

.mini-rune-icon {
    width: 80%;
    height: 80%;
    object-fit: contain;
    z-index: 2;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}

/* Glowing colors matching real game elements */
.mini-rune-node[data-type="energia"] .mini-rune-glow { background: radial-gradient(circle, rgba(0, 242, 254, 0.95) 0%, rgba(0, 242, 254, 0.2) 60%, transparent 100%); }
.mini-rune-node[data-type="natureza"] .mini-rune-glow { background: radial-gradient(circle, rgba(6, 214, 160, 0.95) 0%, rgba(6, 214, 160, 0.2) 60%, transparent 100%); }
.mini-rune-node[data-type="plasma"] .mini-rune-glow { background: radial-gradient(circle, rgba(157, 78, 221, 0.95) 0%, rgba(157, 78, 221, 0.2) 60%, transparent 100%); }
.mini-rune-node[data-type="cristal"] .mini-rune-glow { background: radial-gradient(circle, rgba(240, 248, 255, 0.95) 0%, rgba(240, 248, 255, 0.25) 60%, transparent 100%); }
.mini-rune-node[data-type="cristal"] .mini-rune-icon {
    filter: saturate(0) brightness(1.4) contrast(1.2) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4)) drop-shadow(0 0 1px rgba(255, 255, 255, 0.6));
}
.mini-rune-node[data-type="fogo"] .mini-rune-glow { background: radial-gradient(circle, rgba(247, 127, 0, 0.95) 0%, rgba(247, 127, 0, 0.2) 60%, transparent 100%); }
.mini-rune-node[data-type="terra"] .mini-rune-glow { background: radial-gradient(circle, rgba(217, 4, 41, 0.95) 0%, rgba(217, 4, 41, 0.2) 60%, transparent 100%); }
.mini-rune-node[data-type="terra"] .mini-rune-icon {
    filter: hue-rotate(155deg) saturate(2.5) brightness(0.9) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}
.mini-rune-node[data-type="sol"] .mini-rune-glow { background: radial-gradient(circle, rgba(255, 238, 85, 0.95) 0%, rgba(255, 238, 85, 0.2) 60%, transparent 100%); }

/* Match animations for opponent mini board */
.mini-cell.mini-matched {
    animation: miniMatchPulse 0.4s ease infinite alternate;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    z-index: 5;
}

.mini-cell.mini-matched .mini-rune-node {
    transform: scale(1.3);
}

.mini-cell.mini-matched .mini-rune-glow {
    opacity: 0.95;
}

@keyframes miniMatchPulse {
    0% { transform: scale(1); box-shadow: 0 0 2px rgba(255, 255, 255, 0.3); }
    100% { transform: scale(1.08); box-shadow: 0 0 6px rgba(255, 255, 255, 0.8); }
}

.mini-rune-node.mini-spawn-anim {
    animation: miniSpawnPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes miniSpawnPop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* ==================== PVP ADVANCED BATTLE DESIGN SYSTEM ==================== */

/* Matchmaking Status Label */
.battle-search-status-lbl {
    font-size: 0.58rem;
    font-weight: 900;
    color: #00f2fe;
    text-shadow: 0 0 5px rgba(0, 242, 254, 0.8);
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    margin-top: 4px;
    animation: battleSearchPulse 1.2s ease-in-out infinite alternate;
}

@keyframes battleSearchPulse {
    0% { opacity: 0.4; text-shadow: 0 0 3px rgba(0, 242, 254, 0.4); }
    100% { opacity: 1.0; text-shadow: 0 0 10px rgba(0, 242, 254, 0.9), 0 0 20px rgba(123, 44, 191, 0.8); }
}

/* Neon Translucent Popup Invitation */
.duel-invite-overlay {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 24px);
    max-width: 380px;
    background: rgba(8, 10, 24, 0.82);
    border: 1.5px solid rgba(0, 242, 254, 0.5);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    backdrop-filter: blur(14px) saturate(180%);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.35), inset 0 0 10px rgba(255, 255, 255, 0.05);
    animation: duelInviteSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), duelInviteNeonPulse 2s linear infinite alternate;
    overflow: hidden;
}

@keyframes duelInviteSlideIn {
    0% { transform: translate(-50%, 40px); opacity: 0; }
    100% { transform: translate(-50%, 0); opacity: 1; }
}

@keyframes duelInviteNeonPulse {
    0% { border-color: rgba(0, 242, 254, 0.5); box-shadow: 0 0 15px rgba(0, 242, 254, 0.35), inset 0 0 10px rgba(0, 242, 254, 0.05); }
    100% { border-color: rgba(255, 0, 127, 0.6); box-shadow: 0 0 22px rgba(255, 0, 127, 0.45), inset 0 0 12px rgba(255, 0, 127, 0.08); }
}

.duel-invite-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(123, 44, 191, 0.15) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.duel-invite-holo-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00f2fe, #ff007f, #00f2fe, transparent);
    opacity: 0.6;
    animation: duelHoloSweep 3s linear infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes duelHoloSweep {
    0% { top: 0%; opacity: 0; }
    5% { opacity: 0.8; }
    95% { opacity: 0.8; }
    100% { top: 100%; opacity: 0; }
}

.duel-invite-content {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 2;
}

.challenger-avatar-container {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    padding: 1.5px;
    background: linear-gradient(135deg, #00f2fe 0%, #ff007f 100%);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.5);
    flex-shrink: 0;
}

.challenger-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #0d1021;
}

.challenger-avatar-frame-glow {
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    animation: challengerPulse 1.5s ease-out infinite;
    pointer-events: none;
}

@keyframes challengerPulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.15); opacity: 0; }
}

.duel-invite-details {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.duel-invite-title {
    font-size: 0.48rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #ffee55;
    text-shadow: 0 0 4px rgba(255, 238, 85, 0.5);
}

.duel-invite-text {
    font-size: 0.65rem;
    color: #e0e5ff;
    line-height: 1.25;
}

.duel-invite-text strong {
    color: #fff;
    font-weight: 800;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.duel-invite-actions {
    display: flex;
    gap: 10px;
    position: relative;
    z-index: 2;
    margin-top: 2px;
}

.duel-btn {
    flex: 1;
    padding: 8px 0;
    border: none;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.duel-btn.accept {
    background: #06d6a0;
    color: #03140e;
    box-shadow: 0 0 10px rgba(6, 214, 160, 0.4);
}

.duel-btn.accept:hover {
    background: #09f5b8;
    box-shadow: 0 0 16px rgba(6, 214, 160, 0.7);
    transform: translateY(-1px);
}

.duel-btn.decline {
    background: rgba(239, 35, 60, 0.15);
    border: 1px solid rgba(239, 35, 60, 0.4);
    color: #ff4d6d;
    box-shadow: 0 0 8px rgba(239, 35, 60, 0.15);
}

.duel-btn.decline:hover {
    background: rgba(239, 35, 60, 0.28);
    border-color: rgba(239, 35, 60, 0.7);
    color: #fff;
    box-shadow: 0 0 14px rgba(239, 35, 60, 0.45);
    transform: translateY(-1px);
}

/* Response Limit Progress Bar */
.duel-invite-progress {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    margin-top: 2px;
}

.duel-invite-progress-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff007f, #00f2fe);
    border-radius: 2px;
    box-shadow: 0 0 4px #00f2fe;
}


/* ==================== OPPONENT MINI GRID PHYSICS ANIMATIONS ==================== */

/* Smooth gravity sliding fall */
.mini-rune-node.mini-falling {
    transition: transform 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Neon matching cell state override */
.mini-cell.mini-matched .mini-rune-glow {
    opacity: 1;
    transform: scale(1.4);
    animation: miniNeonPulse 0.4s ease infinite alternate;
}

@keyframes miniNeonPulse {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.6) drop-shadow(0 0 8px rgba(255,255,255,0.9)); }
}

/* Holographic sweep overlay inside matching cells */
.mini-cell.mini-matched::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    animation: miniCellSweep 0.5s ease-out;
    pointer-events: none;
}

@keyframes miniCellSweep {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Floating Combo indicator label */
.mini-combo-float {
    position: absolute;
    color: #ffb703;
    font-size: 0.45rem;
    font-weight: 900;
    text-shadow: 0 0 4px rgba(255, 183, 3, 0.8), 0 0 8px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 100;
    animation: miniComboRiseFade 1.2s ease-out forwards;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes miniComboRiseFade {
    0% { transform: translateY(0) scale(0.6); opacity: 0; }
    15% { transform: translateY(-8px) scale(1.15); opacity: 1; }
    80% { opacity: 0.9; }
    100% { transform: translateY(-24px) scale(0.9); opacity: 0; }
}

/* Physical Board Combo Shake animation */
.opponent-shake-anim {
    animation: oppBoardShake 0.4s ease-out;
}

@keyframes oppBoardShake {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-1.5px, 1px); }
    20% { transform: translate(1px, -1.5px); }
    30% { transform: translate(-1px, 1px); }
    40% { transform: translate(1px, 1.5px); }
    50% { transform: translate(-1px, -1px); }
    60% { transform: translate(1.5px, 1px); }
    70% { transform: translate(-1px, -1.5px); }
    80% { transform: translate(1px, 1px); }
    90% { transform: translate(-1px, 1px); }
    100% { transform: translate(0, 0); }
}

/* FLUID MATCH-3 PHYSICS & COMBO CASCADES STYLES */
.rune-node.matched {
    transform: scale(0) !important;
    opacity: 0 !important;
    transition: transform 0.28s cubic-bezier(0.3, 0, 0.2, 1), opacity 0.28s ease !important;
}

.rune-node.falling {
    transition: transform 0.55s cubic-bezier(0.25, 1, 0.3, 1), opacity 0.38s ease !important;
}

.rune-node.pop-spawn-anim {
    animation: runePopSpawn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes runePopSpawn {
    0% {
        transform: scale3d(0, 0, 1);
        opacity: 0;
    }
    70% {
        transform: scale3d(1.12, 1.12, 1);
        opacity: 0.95;
    }
    100% {
        transform: scale3d(1, 1, 1);
        opacity: 1;
    }
}

/* ==================== SPECIAL AAA SCI-FI RUNE STYLES ==================== */

/* 1. SUPERNOVA RUNE: Orbiting glowing solar ring and heavy pulse */
.rune-node.special-supernova {
    animation: supernovaScalePulse 2.0s ease-in-out infinite alternate;
}

.rune-node.special-supernova::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 183, 3, 0.85);
    box-shadow: 0 0 12px rgba(255, 183, 3, 0.5), inset 0 0 12px rgba(255, 183, 3, 0.5);
    animation: supernovaRingOrbit 8.0s linear infinite;
    pointer-events: none;
    z-index: 4;
}

@keyframes supernovaScalePulse {
    0% { transform: scale(1.0); box-shadow: 0 0 5px rgba(255, 183, 3, 0.3); }
    100% { transform: scale(1.08); box-shadow: 0 0 20px rgba(255, 183, 3, 0.9); }
}

@keyframes supernovaRingOrbit {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 2. ELECTRIC CORE RUNE: Lightning crackle aura and fast jitter */
.rune-node.special-eletrico {
    animation: electricCorePulse 1.2s ease-in-out infinite alternate;
}

.rune-node.special-eletrico::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 1.5px solid #00f2fe;
    box-shadow: 0 0 15px #00f2fe, inset 0 0 8px #00f2fe;
    animation: electricCrackle 0.25s steps(2) infinite;
    pointer-events: none;
    z-index: 4;
    opacity: 0.9;
}

@keyframes electricCorePulse {
    0% { transform: scale(0.98); }
    100% { transform: scale(1.06); }
}

@keyframes electricCrackle {
    0%, 100% { transform: scale(1.0) rotate(0deg); border-style: solid; border-color: #00f2fe; }
    50% { transform: scale(1.04) rotate(45deg); border-style: dotted; border-color: #ffffff; }
}

/* 3. INFINITE CRYSTAL RUNE: Shifting rainbow cosmic hue and heavy holographic bloom */
.rune-node.special-infinito {
    animation: infiniteCrystalHueChange 6.0s linear infinite, infiniteCrystalPulse 1.8s ease-in-out infinite alternate;
}

.rune-node.special-infinito::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 0 22px #9d4edd, inset 0 0 12px #ff007f;
    animation: infiniteHaloSpin 4s linear infinite;
    pointer-events: none;
    z-index: 4;
}

@keyframes infiniteCrystalHueChange {
    0% { filter: hue-rotate(0deg) saturate(1.5) brightness(1.2); }
    100% { filter: hue-rotate(360deg) saturate(1.5) brightness(1.2); }
}

@keyframes infiniteCrystalPulse {
    0% { transform: scale(0.96); box-shadow: 0 0 8px rgba(157, 78, 221, 0.4); }
    100% { transform: scale(1.1); box-shadow: 0 0 25px rgba(255, 0, 127, 0.95); }
}

@keyframes infiniteHaloSpin {
    0% { transform: rotate(0deg) scale(0.98); opacity: 0.85; }
    50% { transform: rotate(180deg) scale(1.05); opacity: 1.0; }
    100% { transform: rotate(360deg) scale(0.98); opacity: 0.85; }
}

/* 4. CELL SPAWNING: Neon expanding blast ring on creation */
.grid-cell.special-spawning::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2.5px solid #ffffff;
    box-shadow: 0 0 15px #00f2fe;
    transform: translate3d(-50%, -50%, 0) scale(0.1);
    animation: specialSpawnRingBlast 0.8s cubic-bezier(0.1, 0.8, 0.3, 1.0) forwards;
    pointer-events: none;
    z-index: 8;
}

@keyframes specialSpawnRingBlast {
    0% { transform: translate3d(-50%, -50%, 0) scale(0.1); opacity: 1; border-color: #ffffff; }
    50% { border-color: #00f2fe; box-shadow: 0 0 25px #ff007f; }
    100% { transform: translate3d(-50%, -50%, 0) scale(4.8); opacity: 0; border-color: transparent; }
}

/* ==================== RESPONSIVE MOBILE ADJUSTMENTS ==================== */
@media (max-width: 480px) {
    /* Otimizar elementos superiores para economizar espaço vertical */
    .top-status {
        padding: 6px 12px 4px !important;
    }
    .sub-header {
        padding: 0 12px !important;
    }
    .world-view {
        height: 72px !important;       /* Reduzido de 80px para 72px para economizar 8px de altura vertical */
        aspect-ratio: auto !important; /* Desativa a proporção fixa para evitar alongamentos */
        margin: 4px 6px !important;
    }
    .standalone-progress-container {
        margin: 2px 12px !important;
    }

    /* Aumentar o tamanho do tabuleiro principal e manter a proporção perfeita 1:1 (células redondas) */
    .grid-outer-container {
        margin: 2px 6px 6px 6px !important;  /* Margem inferior de 6px para economizar espaço vertical e dar respiro */
        padding: 24px 12px !important;       /* Aumentado o recuo vertical de 12px para 24px para esticar a linha roxa para baixo e desafogar as pedras! */
    }
    .grid-board {
        width: calc(100vw - 72px) !important;  /* Reduzido de 36px para 72px para encolher a grade e caber totalmente dentro do contêiner */
        height: calc(100vw - 72px) !important; /* Altura idêntica para manter a proporção 1:1 absoluta e evitar cortes */
        max-width: 380px !important;
        max-height: 380px !important;
        padding: 6px !important;               /* Margem interna entre as células e a borda brilhante */
        box-sizing: border-box !important;
    }
    .rune-node {
        width: 78% !important;                 /* Pedras ligeiramente menores para ficarem perfeitas e não tocarem na borda */
        height: 78% !important;
    }

    /* Diminuir espaçamentos e preenchimentos do painel inferior */
    .bottom-dashboard {
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom)) !important;
        align-items: center !important;        /* Força o alinhamento centralizado horizontal de todos os slots */
    }
    
    /* Redimensionar área dos avatares e o botão Desafiar */
    .battle-left-area {
        width: 120px !important;               /* Ajustado para 120px simétrico */
        height: auto !important;               /* Ajusta a altura dinamicamente para comportar o botão de abandonar */
        min-height: 120px !important;          /* Mantém o tamanho mínimo padrão */
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;    /* Alinha o conteúdo no centro vertical do slot */
        align-items: center !important;
    }
    .desafiar-btn-wrapper {
        width: 120px !important;               /* Aumentado por mais 2x (de 110px para 120px) preenchendo o slot de forma imponente! */
        height: 120px !important;
    }
    .battle-vs-container {
        width: 120px !important;               /* Ajustado para encaixar perfeitamente os dois avatares e o VS */
        padding: 6px 6px !important;
        gap: 4px !important;
        border-radius: 12px !important;
        flex-direction: column !important;     /* Empilha verticalmente o grupo horizontal de avatares e o botão abandonar */
        align-items: center !important;
        justify-content: center !important;
        background: rgba(13, 16, 33, 0.65) !important;
        border: 1px solid rgba(255, 255, 255, 0.05) !important;
        backdrop-filter: blur(5px) !important;
    }
    .battle-avatar {
        width: 52px !important;                /* Aumentado de 44px para 52px (aumento de ~18%) */
        height: 52px !important;
    }
    .battle-score-lbl {
        font-size: 0.6rem !important;
    }
    .battle-vs-divider {
        font-size: 0.7rem !important;
        font-weight: 900 !important;
        color: #ff007f !important;
        text-shadow: 0 0 5px rgba(255, 0, 127, 0.8) !important;
    }
    
    /* Ajustar tamanho do botão central de Fusão */
    .fusion-btn-container {
        width: 70px !important;
        height: 70px !important;
        transform: translateY(-24px) !important; /* Retorna a flutuar alto e premium no meio (+16px de altura) */
    }
    .fusion-btn-outer-ring {
        width: 70px !important;
        height: 70px !important;
    }
    .fusion-btn {
        width: 56px !important;
        height: 56px !important;
    }
    .fusion-title {
        font-size: 0.72rem !important;
    }
    .fusion-cost {
        font-size: 0.52rem !important;
    }
    
    /* Ajustar área direita (Timer e Mini-tabuleiro) */
    .battle-right-area {
        width: 120px !important;               /* Ajustado para 120px simétrico */
        height: 120px !important;              /* Reduzido de 130px para 120px para alinhamento simétrico total e economia */
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;    /* Alinha o conteúdo de todos os estados no centro vertical */
        align-items: center !important;
    }
    .battle-active-container {
        flex-direction: column !important;
        justify-content: center !important;    /* Alinha no centro vertical */
        align-items: center !important;
        height: 100% !important;
        width: 100% !important;
        /* display: flex !important; REMOVIDO para permitir que o JS oculte/exiba o timer livremente! */
    }
    .battle-idle-indicator {
        width: 90px !important;
        height: 52px !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        border: 1px dashed rgba(255, 255, 255, 0.08) !important;
        border-radius: 12px !important;
        background: rgba(25, 27, 49, 0.2) !important;
        /* display: flex !important; REMOVIDO para permitir que o JS oculte/exiba a indicação de clã livremente! */
    }
    .battle-idle-text {
        font-size: 0.48rem !important;
    }
    .battle-timer {
        font-size: 0.7rem !important;
        padding: 2px 4px !important;
    }
    .mini-board {
        width: 85px !important;                /* Reduzido de 95px para 85px para economizar altura vertical útil */
        height: 85px !important;
        padding: 1.5px !important;
        gap: 1px !important;
        border-radius: 6px !important;
    }
    
    /* Ajustar posicionamento sutil do banner de anúncio para não sobrepor */
    .ad-banner-overlay {
        bottom: 50px !important;
    }
}

/* Premium floating cosmic notification */
.cosmic-alert-overlay {
    position: absolute;
    top: 22%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 1000;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 16px;
    background: rgba(13, 16, 33, 0.85);
    border: 1px dashed rgba(255, 183, 3, 0.45);
    box-shadow: 0 0 25px rgba(255, 183, 3, 0.15), inset 0 0 15px rgba(255, 183, 3, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: alertSlideIn 0.42s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.cosmic-alert-overlay.fade-out {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.85);
    transition: all 0.5s ease;
}

.cosmic-alert-glow {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255, 183, 3, 0.2) 0%, transparent 80%);
    z-index: -1;
    border-radius: 16px;
}

.cosmic-alert-text {
    font-size: 0.85rem;
    font-weight: 900;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 183, 3, 0.8), 0 0 20px rgba(255, 183, 3, 0.4);
    text-align: center;
}

@keyframes alertSlideIn {
    0% { transform: translate(-50%, -100%) scale(0.7); opacity: 0; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* PREMIUM LEVEL UP AVATAR EXPLOSION EFFECTS */
@keyframes avatarLevelUpExplosion {
    0% {
        transform: scale(1);
        box-shadow: 0 0 15px rgba(157, 78, 221, 0.6);
    }
    15% {
        transform: scale(1.35);
        box-shadow: 0 0 35px #00f2fe, 0 0 50px #9d4edd;
        background: linear-gradient(135deg, #00f2fe 0%, #9d4edd 100%);
    }
    30% {
        transform: scale(1.2);
        box-shadow: 0 0 25px #00f2fe, 0 0 35px #ffee55;
    }
    100% {
        transform: scale(1);
        box-shadow: var(--glow-purple);
    }
}

.avatar-frame.level-up-active {
    animation: avatarLevelUpExplosion 1.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes levelBadgeGlow {
    0% { transform: scale(1); background: #7b2cbf; }
    20% { transform: scale(1.6); background: #ffee55; color: #000; box-shadow: 0 0 20px #ffee55; }
    80% { transform: scale(1.3); background: #00f2fe; color: #000; }
    100% { transform: scale(1); background: #7b2cbf; color: #fff; }
}

.avatar-level-badge.level-up-badge-active {
    animation: levelBadgeGlow 1.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* Floating level number text above avatar */
@keyframes avatarFloatUp {
    0% {
        transform: translate3d(0, 0, 0) scale(0.6);
        opacity: 0;
    }
    15% {
        transform: translate3d(0, -30px, 0) scale(1.4);
        opacity: 1;
        text-shadow: 0 0 15px #ffee55, 0 0 25px #00f2fe;
    }
    80% {
        transform: translate3d(0, -55px, 0) scale(1.1);
        opacity: 0.9;
    }
    100% {
        transform: translate3d(0, -70px, 0) scale(0.8);
        opacity: 0;
    }
}

.avatar-lvl-up-floater {
    position: absolute;
    left: 10px;
    top: -12px;
    font-size: 1.05rem;
    font-weight: 900;
    color: #ffee55;
    background: linear-gradient(135deg, #ffee55 0%, #00f2fe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    pointer-events: none;
    z-index: 100;
    font-family: var(--font-family);
    animation: avatarFloatUp 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* Micro sparks exploding around avatar */
@keyframes avatarSparkPop {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

.avatar-lvl-up-spark {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 99;
    animation: avatarSparkPop 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes pulse-aura { 
    0% { 
        box-shadow: 0 0 15px rgba(0, 242, 254, 0.8), inset 0 0 10px rgba(0, 242, 254, 0.4); 
    } 
    50% { 
        box-shadow: 0 0 35px rgba(0, 242, 254, 1), inset 0 0 20px rgba(0, 242, 254, 0.6); 
        transform: scale(1.05); 
    } 
    100% { 
        box-shadow: 0 0 15px rgba(0, 242, 254, 0.8), inset 0 0 10px rgba(0, 242, 254, 0.4); 
        transform: scale(1); 
    } 
}

@keyframes eventBoostPulse {
    0% { filter: drop-shadow(0 0 4px #00f2fe) brightness(1.1); transform: scale(1); }
    100% { filter: drop-shadow(0 0 15px #00f2fe) brightness(1.3); transform: scale(1.05); }
}

.event-boosted .rune-icon {
    animation: eventBoostPulse 1.2s ease-in-out infinite alternate !important;
}
