:root {
    --primary: #38bdf8;
    --primary-dim: rgba(56, 189, 248, 0.5);
    --secondary: #fb7185;
    --bg: #09090b;
    --bg-panel: rgba(18, 18, 23, 0.9);
    --text: #f4f4f5;
    --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --glass: rgba(18, 18, 23, 0.8);
    --fighter-width: 240px;
    --summon-pad: 2rem;
    /* Variable for modal padding */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #000;
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background: radial-gradient(circle at center, #222 0%, #000 80%);
    background-attachment: fixed;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    padding: 0.3rem 1rem;
    text-align: center;
    background:
        linear-gradient(to bottom, rgba(9, 9, 11, 0.7), rgba(9, 9, 11, 0.9)),
        url('../assets/backgrounds/header_ornament.png') center/300px repeat;
    border-bottom: 1px solid var(--primary-dim);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

h1 {
    font-family: var(--font-heading);
    color: var(--primary);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 0;
}



/* Main Layout */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Precision 15px gap requested */
    padding: 1.5rem;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}



/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #111;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Panels */
.panel {
    background: var(--glass);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1.5rem;
    border-top: 2px solid var(--primary-dim);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}



.glass-panel {
    background: var(--glass);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}



h2,
h3 {
    font-family: var(--font-heading);
    margin-bottom: 0.8rem;
    color: var(--primary);
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}



/* Buttons */
.action-btn {
    width: 100%;
    max-width: 400px;
    background: linear-gradient(to bottom, var(--primary) 0%, #0ea5e9 100%);
    color: #000;
    border: none;
    border-bottom: 4px solid #0369a1;
    padding: 0.8rem 1rem;
    margin: 1rem 0;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.1s;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.action-btn:active:not(:disabled) {
    transform: translateY(2px);
    border-bottom-width: 2px;
}

.action-btn:disabled {
    background: #444;
    cursor: not-allowed;
    color: #888;
}

.action-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

#dynamic-start-btn {
    display: block;
    margin: 0.5rem 0;
    width: 100%;
    max-width: 100%;
    animation: battle-btn-glow 2s infinite alternate;
}

@keyframes battle-btn-glow {
    from {
        box-shadow: 0 0 10px var(--primary-dim);
    }

    to {
        box-shadow: 0 0 25px var(--primary);
    }
}

.secondary-btn {
    background: linear-gradient(to bottom, rgba(56, 189, 248, 0.1), rgba(56, 189, 248, 0.05));
    border: 1px solid var(--primary);
    border-bottom: 3px solid var(--primary);
    color: var(--primary);
    padding: 0.5rem 1.2rem;
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: bold;
    border-radius: 30px;
    transition: all 0.1s;
}

.secondary-btn:active {
    transform: translateY(1px);
    border-bottom-width: 1px;
}

.secondary-btn:hover {
    background: var(--primary-dim);
    color: #000;
}

.text-btn {
    background: none;
    border: none;
    color: #888;
    text-decoration: underline;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 30px;
    /* Rounded */
}

.text-btn:hover {
    color: #fff;
}

/* Upload Area */
.upload-area {
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(ellipse at center, rgba(255, 100, 0, 0.3) 0%, rgba(0, 0, 0, 0.8) 70%),
        linear-gradient(to bottom, rgba(40, 20, 10, 0.9) 0%, rgba(80, 40, 20, 0.95) 100%);
    box-shadow:
        inset 0 -20px 40px rgba(255, 80, 0, 0.2),
        inset 0 20px 20px rgba(0, 0, 0, 0.5),
        0 4px 15px rgba(0, 0, 0, 0.7);
}

.upload-area::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 60%;
    background: radial-gradient(ellipse at center, rgba(255, 120, 0, 0.4) 0%, transparent 60%);
    animation: furnace-glow 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes furnace-glow {

    0%,
    100% {
        opacity: 0.6;
        transform: translateX(-50%) scale(1);
    }

    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }
}

/* Loading Animation */
.upload-area.analyzing {
    border-color: var(--primary);
}

.upload-area.success {
    background:
        radial-gradient(ellipse at center, rgba(255, 255, 200, 0.6) 0%, rgba(255, 220, 100, 0.3) 40%, rgba(0, 0, 0, 0.8) 100%),
        linear-gradient(to bottom, rgba(255, 240, 200, 0.4) 0%, rgba(200, 180, 100, 0.6) 100%);
    border-color: #ffd700;
    box-shadow:
        inset 0 0 60px rgba(255, 220, 100, 0.5),
        0 0 30px rgba(255, 215, 0, 0.6);
    animation: holy-glow 2s ease-in-out infinite;
}

@keyframes holy-glow {

    0%,
    100% {
        box-shadow:
            inset 0 0 60px rgba(255, 220, 100, 0.5),
            0 0 30px rgba(255, 215, 0, 0.6);
    }

    50% {
        box-shadow:
            inset 0 0 80px rgba(255, 240, 150, 0.7),
            0 0 40px rgba(255, 215, 0, 0.8);
    }
}

.upload-area.analyzing::before {
    animation: furnace-intense 2s ease-in-out infinite;
}

.upload-area.analyzing #preview-image {
    animation: spin-dissolve 3s ease-in-out forwards;
    mix-blend-mode: screen;
}

@keyframes spin-dissolve {
    0% {
        transform: rotate(0deg) scale(1);
        opacity: 1;
        filter: blur(0px);
    }

    50% {
        transform: rotate(180deg) scale(0.8);
        opacity: 0.5;
        filter: blur(2px);
    }

    90% {
        transform: rotate(360deg) scale(0.5);
        opacity: 0.1;
        filter: blur(5px);
    }

    100% {
        transform: rotate(360deg) scale(0);
        opacity: 0;
        filter: blur(10px);
    }
}

@keyframes furnace-intense {

    0%,
    100% {
        opacity: 0.8;
        transform: translateX(-50%) scale(1);
        filter: brightness(1.2);
    }

    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.2);
        filter: brightness(1.5);
    }
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10;
    flex-direction: column;
    gap: 1rem;
}

.loading-overlay.active {
    display: flex;
}

.loading-overlay.flash {
    background: rgba(255, 255, 255, 1);
    animation: flash-out 0.5s ease-out forwards;
}

@keyframes flash-out {
    0% {
        background: rgba(255, 255, 255, 1);
        opacity: 1;
    }

    100% {
        background: rgba(255, 255, 255, 0);
        opacity: 0;
    }
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 100, 0, 0.3);
    border-top: 4px solid #ff6600;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-text {
    color: #fff;
    font-family: var(--font-heading);
    font-size: 3rem;
    font-weight: bold;
    text-shadow:
        0 0 20px rgba(255, 100, 0, 1),
        0 0 40px rgba(255, 100, 0, 0.8),
        0 0 60px rgba(255, 100, 0, 0.6);
    animation: text-flash 0.8s ease-in-out infinite;
    letter-spacing: 0.5rem;
}

@keyframes text-flash {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
        text-shadow:
            0 0 20px rgba(255, 100, 0, 1),
            0 0 40px rgba(255, 100, 0, 0.8);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
        text-shadow:
            0 0 30px rgba(255, 150, 0, 1),
            0 0 60px rgba(255, 150, 0, 1),
            0 0 90px rgba(255, 100, 0, 0.8);
    }
}

@media (max-width: 768px) {
    .upload-area {
        margin-bottom: 0.5rem;
    }

    .upload-area::before {
        height: 50%;
    }
}

.upload-area:hover {
    border-color: var(--primary);
    box-shadow:
        inset 0 -20px 40px rgba(255, 100, 0, 0.3),
        inset 0 20px 20px rgba(0, 0, 0, 0.5),
        0 4px 15px rgba(0, 247, 255, 0.3);
}

.upload-area img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    z-index: 2;
    border-radius: 4px;
}

.placeholder {
    text-align: center;
    color: #ff9966;
    text-shadow: 0 0 10px rgba(255, 100, 0, 0.5);
    z-index: 1;
    position: relative;
    pointer-events: none;
    /* Let clicks pass through to drop-zone */
}

.placeholder p {
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.upload-icon {
    width: 60px;
    height: 60px;
    position: relative;
    margin: 0 auto 0.5rem;
    /* Reduced margin to move text up */
    animation: icon-pulse 2s ease-in-out infinite;
}

.arrow-up {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 30px solid #ff9966;
    /* Pointing DOWN */
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    filter: drop-shadow(0 0 10px rgba(255, 100, 0, 0.8));
}

.arrow-line {
    width: 15px;
    height: 30px;
    background: #ff9966;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    filter: drop-shadow(0 0 10px rgba(255, 100, 0, 0.8));
}

.upload-text {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: bold;
    color: #ff9966;
    text-shadow: 0 0 10px rgba(255, 100, 0, 0.5);
    margin: 0;
    letter-spacing: 0.1rem;
}

@keyframes icon-pulse {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.8;
    }

    50% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.log-console {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--primary);
    min-height: 40px;
    margin-bottom: 1rem;
    white-space: pre-wrap;
    background: #000;
    padding: 0.5rem;
    border: 1px solid #222;
}

/* Monster Cards */
.monster-card {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #333;
    border-radius: 8px;
    padding: 0;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: row;
    /* Horizontal layout */
    align-items: center;
    gap: 0.5rem;
    /* Reduced from 1rem */
    position: relative;
    /* For absolute positioning of X button */
    overflow: visible !important;
    z-index: 1;
}

.monster-card:hover {
    transform: translateX(5px);
    border-color: var(--primary);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.card-image-wrapper {
    width: 70px;
    /* Reduced from 100px */
    height: 70px;
    /* Reduced from 100px */
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    /* Removed padding to maximize sprite size */
    border-right: 1px solid #222;
    flex-shrink: 0;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.monster-card img {
    width: 64px;
    /* Increased from 50px */
    height: 64px;
    /* Increased from 50px */
    object-fit: contain;
    image-rendering: pixelated;
}

.card-info {
    padding: 0 0.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    /* Aggressively reduced from 8px */
    min-width: 0;
    /* Allow inner content to shrink and scroll */
}

.card-info-main {
    flex-shrink: 0;
    width: 120px;
    /* Reduced from 140px */
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.card-info-main::-webkit-scrollbar {
    display: none;
}

.card-info h4 {
    margin: 0;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: nowrap;
    /* Single line */
}

.type-badge {
    font-size: 0.7rem;
    /* Slightly smaller */
    color: var(--primary-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0px;
    /* Tightest possible to match stat label/value distance */
}

.card-info .stats-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 2px;
    /* Aggressively reduced from 0.4rem */
    flex-grow: 1;
    overflow-x: auto;
    /* Allow scrolling if too many stats */
    padding-bottom: 2px;
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.card-info .stats-grid::-webkit-scrollbar {
    display: none;
    /* Chrome, Safari and Opera */
}

.stat-item {
    text-align: center;
    font-size: 0.85rem;
    /* Increased from 0.75rem */
    border: none;
    padding: 0;
    background: none;
    display: flex;
    flex-direction: column;
}

.stat-item span {
    display: block;
    color: #888;
    font-size: 0.65rem;
    text-transform: uppercase;
}

.stat-item strong {
    color: var(--primary);
    font-size: 1rem;
    /* Increased for readability */
}

.card-actions {
    position: absolute;
    top: -12px;
    right: -12px;
    z-index: 20;
}

.delete-btn {
    background: #222;
    border: 1px solid #444;
    color: #888;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    padding-bottom: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 25;
}

.delete-btn:hover {
    background: #dc2626;
    /* Red for danger/delete */
    color: #fff;
    border-color: #ef4444;
    transform: scale(1.1);
}

.monster-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.stat-label {
    color: #888;
    font-size: 0.8rem;
}

.stat-val {
    font-weight: bold;
    color: #fff;
}

/* Battle Arena */
.battle-setup {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
}

.vs-divider {
    width: 80px;
    height: auto;
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    align-self: center;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.4)) drop-shadow(0 0 30px var(--secondary));
    animation: vs-heavy-glow 3s infinite alternate ease-in-out;
    transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), rotate 0.3s ease;
    rotate: 0deg;
    pointer-events: none;
}

.vs-divider.atk-toward-p2 {
    left: 40%;
    rotate: -15deg;
}

.vs-divider.atk-toward-p1 {
    left: 60%;
    rotate: 15deg;
}

@keyframes vs-heavy-glow {
    from {
        filter: drop-shadow(0 0 10px rgba(255, 255, 150, 0.2)) drop-shadow(0 0 20px var(--secondary)) drop-shadow(0 0 30px rgba(251, 113, 133, 0.2));
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1);
    }

    to {
        filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.6)) drop-shadow(0 0 40px var(--secondary)) drop-shadow(0 0 60px rgba(251, 113, 133, 0.4));
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
}

.selected-champion {
    color: var(--primary);
    font-weight: bold;
}

/* Arena Section Overrides */
#arena.panel {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0 !important;
    /* Force reset for mobile panel padding */
}

#arena h2 {
    display: none;
}

/* Battle Viz */
.battle-viz {
    min-height: auto;
    /* Allow shrinking */
    aspect-ratio: auto;
    max-height: none;
    background: url('../assets/backgrounds/arena_bg.png') center/cover no-repeat;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 0;
    /* Removed top padding to let h2 margin control it */
    position: relative;
    border-radius: 8px;
    overflow: visible;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.5);
}

.fighters-row {
    display: flex;
    width: 100%;
    justify-content: center;
    align-items: center;
    gap: 50px;
    /* 80px sword - 30px total overlap = 50px gap */
    padding-top: 0;
    padding-bottom: 65px;
    /* Matches HP Container bottom: -65px for vertical centering */
    margin-top: 1rem;
    margin-bottom: 15px;
    flex-shrink: 0;
    position: relative;
    /* Base for absolute sword */
}

@media (max-width: 768px) {
    .battle-viz {
        min-height: auto;
        /* Remove 400px restriction */
        aspect-ratio: auto;
        height: auto;
        padding: 0;
        /* Removed top padding */
    }

    .fighters-row {
        padding-top: 0;
        padding-bottom: 55px;
        /* Matches mobile HP offset */
        margin-top: 0.5rem;
        margin-bottom: 15px;
    }
}

#start-battle-btn {
    width: 100%;
    max-width: 300px;
    margin: 1rem auto;
    display: block;
}

/* Fighter Sprites */
.fighter {
    width: var(--fighter-width);
    height: 280px;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
    position: relative;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.fighter.p1 {
    animation: float 3s ease-in-out infinite;
}

.fighter.p2 {
    animation: float 3s ease-in-out infinite 1.5s;
}

/* Spring of Life Specifics */
.spring-overlay {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
    background: radial-gradient(circle at center, rgba(0, 100, 200, 0.2) 0%, rgba(0, 0, 0, 0.4) 100%);
    border-radius: 8px;
    overflow: hidden;
}

.spring-overlay::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 180deg at 50% 50%, transparent 0deg, rgba(0, 247, 255, 0.1) 180deg, transparent 360deg);
    animation: rotate 10s linear infinite;
    pointer-events: none;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.spring-overlay .upload-area {
    border: none;
    background: transparent;
}

.spring-overlay .placeholder p {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.5rem;
}

.spring-overlay .upload-icon {
    opacity: 0.6;
    transform: scale(0.8);
}

.spring-overlay #preview-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px var(--primary));
}

@media (max-width: 768px) {
    :root {
        --fighter-width: 200px;
    }

    .fighter {
        width: var(--fighter-width);
        height: 233px;
        /* Proportional to 240x280 */
    }
}

@keyframes float {

    50% {
        transform: translateY(-10px);
    }
}

.enemy-placeholder {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    font-size: 8rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.1);
    font-family: 'Orbitron', sans-serif;
    text-shadow:
        0 0 10px rgba(255, 255, 255, 0.05),
        2px 2px 0 rgba(255, 0, 255, 0.05),
        -2px -2px 0 rgba(0, 255, 255, 0.05);
    user-select: none;
    pointer-events: none;
    animation: placeholderPulse 4s infinite ease-in-out;
}

@keyframes placeholderPulse {

    0%,
    100% {
        opacity: 0.8;
        transform: scale(1);
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.05);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
        text-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
    }
}

.hp-container {
    width: 100%;
    position: absolute;
    bottom: -65px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 0.4rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    backdrop-filter: blur(4px);
    z-index: 10;
}

@media (max-width: 768px) {
    .hp-container {
        width: 100%;
        /* Align with frame edges */
        bottom: -55px;
        /* Adjust for taller frame if needed */
    }
}

.hp-container .name {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hp-container .hp-text {
    display: block;
    text-align: right;
    font-size: 0.7rem;
    color: #fff;
    margin-top: 2px;
}

.hp-bar {
    height: 12px;
    background: #222;
    width: 100%;
    position: relative;
    border: 1px solid #444;
}

.hp-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, #00f7ff, #0088cc);
    transition: width 0.5s ease-out;
}

.enemy .hp-bar .fill {
    background: linear-gradient(90deg, #ff0055, #cc0033);
}

.battle-log {
    width: 100%;
    max-width: 530px;
    height: 70px;
    overflow: hidden;
    border: 1px solid var(--primary-dim);
    padding: 0.5rem 1rem;
    font-family: monospace;
    font-size: 1.05rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .battle-log {
        max-width: 450px;
        height: 60px;
        font-size: 0.9rem;
        padding: 0.5rem;
    }
}

/* --- EFFECTS & ANIMATIONS --- */

/* Flash Overlay */
#vfx-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

@keyframes flash-white {
    0% {
        background: rgba(255, 255, 255, 0);
    }

    10% {
        background: rgba(255, 255, 255, 1);
    }

    100% {
        background: rgba(255, 255, 255, 0);
    }
}

@keyframes rumble {
    0% {
        transform: translate(0, 0);
    }

    20% {
        transform: translate(-5px, 5px);
    }

    40% {
        transform: translate(5px, -5px);
    }

    60% {
        transform: translate(-5px, -5px);
    }

    80% {
        transform: translate(5px, 5px);
    }

    100% {
        transform: translate(0, 0);
    }
}

@keyframes smoke-puff {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(2.0);
        opacity: 0;
    }
}

.anim-flash {
    animation: flash-white 1.5s ease-out forwards;
}

.anim-rumble {
    animation: rumble 0.5s linear infinite;
}

.smoke-particle {
    position: absolute;
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: smoke-puff 0.8s ease-out forwards;
    z-index: 200;
}

.shatter-shard {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #fff;
    pointer-events: none;
    z-index: 210;
    box-shadow: 0 0 10px #fff;
}

@keyframes shard-burst {
    0% {
        transform: scale(1) translate(0, 0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: scale(0) translate(var(--tx), var(--ty)) rotate(var(--tr));
        opacity: 0;
    }
}


/* Battle Effects */
#battle-field .battle-viz .fighter.dmg-shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both !important;
    z-index: 100;
}

#battle-field .battle-viz .fighter.atk-glow {
    animation: attack-flash 0.5s ease-out both !important;
    z-index: 150;
}

@keyframes shake {

    10%,
    90% {
        transform: translateX(-2px);
    }

    20%,
    80% {
        transform: translateX(4px);
    }

    30%,
    50%,
    70% {
        transform: translateX(-8px);
    }

    40%,
    60% {
        transform: translateX(8px);
    }
}

@keyframes attack-flash {
    0% {
        filter: brightness(1) contrast(1);
        transform: scale(1);
    }

    40% {
        filter: brightness(4) contrast(1.5) drop-shadow(0 0 40px #fff);
        transform: scale(1.2) translateY(-20px);
    }

    100% {
        filter: brightness(1) contrast(1);
        transform: scale(1);
    }
}

#vfx-overlay.anim-flash {
    display: block !important;
    animation: screen-flash 0.5s ease-out forwards;
}

@keyframes screen-flash {
    0% {
        background: transparent;
    }

    20% {
        background: var(--flash-color, rgba(255, 255, 255, 0.4));
    }

    100% {
        background: transparent;
    }
}

/* Unified Responsive Styles */
@media (max-width: 768px) {
    header {
        padding: 1.5rem 0.5rem;
        background:
            linear-gradient(to bottom, rgba(9, 9, 11, 0.7), rgba(9, 9, 11, 0.9)),
            url('../assets/backgrounds/header_ornament.png') center/150px repeat;
    }

    header h1 {
        font-size: 2.2rem;
        /* Adjusted for consistency */
    }

    .battle-log {
        max-width: 450px;
        height: 60px;
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    .battle-viz {
        padding: 0 0.5rem;
    }

    .battle-setup {
        flex-direction: row;
        gap: 0.25rem;
        align-items: center;
        justify-content: space-between;
    }

    .fighter {
        width: 45%;
    }

    .fighter .name {
        font-size: 0.75rem;
    }

    .vs-divider {
        width: 60px;
    }

    .fighters-row {
        gap: 20px;
    }

    .battle-viz .fighter-sprite {
        width: 80px;
        height: 80px;
    }

    /* Barracks Mobile Adjustments */
    .monster-card {
        position: relative;
        flex-direction: row;
        gap: 0.25rem;
        padding: 0;
        overflow: visible !important;
        /* From 375px */
        font-size: 0.85rem;
        /* From 375px */
    }

    .card-image-wrapper {
        width: 50px;
        height: 50px;
    }

    .monster-card img {
        width: 44px;
        height: 44px;
    }

    .card-info {
        gap: 0.5rem;
        padding: 0 0.25rem;
    }

    .card-info-main {
        width: 90px;
    }

    .card-info h4 {
        font-size: 0.75rem;
    }

    .type-badge {
        font-size: 0.6rem;
    }

    .card-info .stats-grid {
        gap: 0.25rem;
    }

    .stat-item {
        font-size: 0.7rem;
    }

    .battle-log {
        max-width: calc(90% + 20px);
    }

    body {
        font-size: 14px;
        /* From 375px */
    }

    .panel {
        padding: 0.5rem;
        /* From 375px */
    }

    .action-btn {
        padding: 0.75rem;
        /* From 375px */
        font-size: 0.9rem;
        /* From 375px */
    }

    #battle-result {
        min-width: 95%;
        /* From 375px */
        padding: 1rem;
        /* From 375px */
    }
}


/* Centered Start Button in Log */
@keyframes jump-joy {

    0%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-30px) scaleX(0.9);
    }

    60% {
        transform: translateY(0) scaleX(1.1);
    }
}

.victory-jump {
    animation: jump-joy 0.5s ease-in-out infinite !important;
    z-index: 100;
}

/* Barracks Delete Button (3D Rounded) */
.card-actions {
    position: absolute;
    top: 5px;
    right: 5px;
}

.delete-btn {
    background: linear-gradient(to bottom, rgba(150, 150, 150, 0.3) 0%, rgba(100, 100, 100, 0.1) 100%);
    border: 1px solid #666;
    border-bottom: 2px solid #444;
    color: #888;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: all 0.1s;
    padding: 0;
}

.delete-btn:active {
    transform: translateY(1px);
    border-bottom-width: 1px;
}

.delete-btn:hover {
    background: var(--secondary);
    color: #fff;
}

/* Summon Modal (Full Screen) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    /* Partial dimming as requested */
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

#summon-modal.is-summoning .summon-container {
    background: transparent;
    border: none;
    box-shadow: none;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    position: fixed;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
    border-radius: 0;
}

.summon-container {
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    /* Set maximum height */
    background: var(--bg-panel);
    border: 2px solid var(--primary);
    box-shadow: 0 0 50px rgba(0, 247, 255, 0.2);
    position: relative;
    overflow-y: auto;
    /* Enable vertical scrolling */
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.summon-phase {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--summon-pad);
    animation: fadeIn 0.5s ease-out;
}

#summon-result {
    animation: none;
    /* Controlled by sequenced reveal */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Enhanced Summon Animation --- */

.summon-vfx {
    width: 80vmin;
    /* Large overflowing size */
    height: 80vmin;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    /* Ensure child elements can overflow */
    overflow: visible;
}

/* Vortex Enhancement */
.vortex-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
}

.vortex-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid transparent;
    border-top-color: var(--primary);
    border-right-color: var(--secondary);
}

.vortex-layer.layer-1 {
    animation: vortex-spin 1.5s linear infinite;
    border-width: 4px;
    filter: brightness(1.5);
}

.vortex-layer.layer-2 {
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    animation: vortex-spin-reverse 2s linear infinite;
    border-top-color: #ffd700;
    /* Gold */
    border-right-color: #ff00ff;
    /* Magenta */
    border-width: 6px;
    opacity: 0.8;
}

.vortex-layer.layer-3 {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    animation: vortex-spin 0.8s linear infinite;
    border-top-color: #fff;
    border-right-color: #00ffff;
    border-width: 2px;
    opacity: 0.9;
}

.vortex-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 40px 20px rgba(255, 255, 255, 0.8), 0 0 80px 40px rgba(255, 215, 0, 0.4);
    animation: pulse-core 0.5s ease-in-out infinite alternate;
}

@keyframes vortex-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes vortex-spin-reverse {
    to {
        transform: rotate(-360deg);
    }
}

@keyframes pulse-core {
    from {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }

    to {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 1;
    }
}

/* Lightning Effects */
.lightning-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    z-index: 10;
}

.lightning-flash {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
    opacity: 0;
    mix-blend-mode: screen;
    animation: flash-storm 2s infinite;
}

.lightning-bolt {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 150px;
    background: #fff;
    transform-origin: top center;
    box-shadow: 0 0 15px #00ffff, 0 0 30px #00ffff;
    opacity: 0;
}

.lightning-bolt:nth-child(2) {
    animation: bolt-strike 1.5s infinite;
    transform: translate(-50%, -50%) rotate(45deg);
}

.lightning-bolt.delay-1 {
    animation: bolt-strike 1.5s infinite 0.5s;
    height: 200px;
    transform: translate(-50%, -50%) rotate(-120deg);
}

.lightning-bolt.delay-2 {
    animation: bolt-strike 1.8s infinite 0.8s;
    height: 120px;
    transform: translate(-50%, -50%) rotate(180deg);
}

@keyframes flash-storm {

    0%,
    90%,
    100% {
        opacity: 0;
    }

    92% {
        opacity: 0.8;
    }

    94% {
        opacity: 0;
    }

    96% {
        opacity: 0.5;
    }
}

@keyframes bolt-strike {
    0% {
        opacity: 0;
        height: 0;
    }

    5% {
        opacity: 1;
        height: 200px;
    }

    10% {
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}

/* Smoke Effects */
.smoke-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 5;
    pointer-events: none;
}

.smoke-puff {
    position: absolute;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(200, 200, 200, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
}

.smoke-puff.p1 {
    top: 70%;
    left: 20%;
    animation: smoke-rise 2s ease-out infinite;
}

.smoke-puff.p2 {
    top: 60%;
    left: 70%;
    animation: smoke-rise 2.5s ease-out infinite 0.5s;
    width: 120px;
    height: 120px;
}

.smoke-puff.p3 {
    top: 80%;
    left: 40%;
    animation: smoke-rise 3s ease-out infinite 1s;
}

@keyframes smoke-rise {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }

    20% {
        opacity: 0.5;
    }

    100% {
        transform: translateY(-100px) scale(2);
        opacity: 0;
    }
}

/* Text Styling */
#summon-loading-text {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 10px var(--primary), 0 0 20px var(--secondary);
    letter-spacing: 0.2em;
    animation: text-pulse-fast 0.2s infinite alternate;
    white-space: nowrap;
}

@keyframes text-pulse-fast {
    from {
        text-shadow: 0 0 10px var(--primary), 0 0 20px var(--secondary);
        transform: translateX(-50%) scale(1);
    }

    to {
        text-shadow: 0 0 20px #fff, 0 0 40px #ffd700;
        transform: translateX(-50%) scale(1.1);
    }
}

.summon-log {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #333;
    padding: 1rem;
    height: 120px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: #00ffcc;
    margin-top: 1rem;
}


.result-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    gap: 0;
    flex-grow: 1;
    /* Allow to take available space */
    justify-content: center;
    /* Center content vertically initially */
}

.result-image-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
}

.reveal-wrapper {
    width: 100%;
}

.result-image-wrapper {
    width: 240px;
    height: 240px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

.result-image-wrapper img {
    max-width: 90%;
    max-height: 90%;
    image-rendering: pixelated;
    filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.3));
}

.name-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: calc(100% - 2rem);
    /* Ensure padding gap on small screens */
    max-width: 360px;
    background: #000;
    border-radius: 4px;
    padding: 0 0.8rem;
    border: 1px solid #222;
    box-sizing: border-box;
    margin: 0 auto;
    /* Center within wrapper */
}

.name-label {
    font-family: var(--font-heading);
    color: var(--primary);
    font-size: 0.9rem;
    /* Smaller */
    font-weight: bold;
    opacity: 0.8;
}

.name-input-large {
    background: #000;
    /* Black background */
    border: none;
    color: #fff;
    font-size: 1.3rem;
    font-family: var(--font-heading);
    font-weight: 800;
    padding: 0.4rem 0.8rem;
    width: auto;
    flex: 1;
    text-align: left;
    outline: none;
    border-radius: 4px;
    min-width: 0;
    /* Critical for shrinking in flex container */
}

.name-input-large::placeholder {
    color: #555 !important;
    /* Lighter gray */
    opacity: 1;
}

/* Stats Layout */
.summon-stats-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    width: 100%;
    padding: 0 1rem;
    margin-top: 15px;
    /* Spacing from Name area */
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    /* Aggressively reduced */
    width: 100%;
}

.stats-row:nth-child(2) {
    grid-template-columns: repeat(4, 1fr);
    padding: 0 12.5%;
    /* Center when 4 items */
}

.stat-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 4px;
    /* Aggressively reduced from 0.4rem */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}

.stat-item span {
    color: #888;
    font-size: 0.65rem;
    margin-bottom: 2px;
}

.stat-item strong {
    color: var(--primary);
    font-size: 1rem;
    /* Increased for readability */
    font-family: 'Orbitron', sans-serif;
}

.result-actions {
    border-top: 1px solid #333;
    padding-top: 15px;
    /* Added spacing from line to text */
    margin-top: 15px;
    /* Spacing from stats to line */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    /* Ensure full width for barracks calculation */
}

.summon-msg {
    font-family: 'Orbitron', sans-serif;
    color: #fff;
    /* Changed to white */
    font-size: 1.1rem;
    letter-spacing: 2px;
    margin-top: 0;
    /* Reset default margin */
    margin-bottom: 15px;
}

.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    width: 100%;
    margin-bottom: 25px;
    /* Space before barracks */
}

/* Force same shape for modal action buttons */
.actions .action-btn,
.actions .secondary-btn {
    width: 140px;
    max-width: none;
    margin: 0;
    padding: 0.6rem 1rem;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.9rem;
}

.actions .action-btn {
    border-bottom: 3px solid #0369a1;
}

.actions .secondary-btn {
    border-bottom: 3px solid var(--primary);
}

.mini-barracks {
    width: calc(100% + (var(--summon-pad) * 2));
    margin-left: calc(var(--summon-pad) * -1);
    margin-right: calc(var(--summon-pad) * -1);
    background: rgba(0, 0, 0, 0.4);
    padding: 1.5rem var(--summon-pad);
    border-top: 1px solid #222;
}

.mini-barracks h3 {
    font-size: 0.8rem;
    color: #fff;
    margin-bottom: 1rem;
    text-align: left;
    font-family: var(--font-heading);
    border-left: 3px solid var(--primary);
    padding-left: 10px;
}

.mini-grid {
    display: flex;
    flex-direction: column;
    /* Revert to vertical layout */
    gap: 10px;
    width: 100%;
}

/* Ensure cards in mini-grid look like main cards */
.mini-grid .monster-card {
    background: rgba(255, 255, 255, 0.03);
    flex: auto;
    width: 100%;
    /* Full width */
    margin: 0;
}

.mini-slot {
    width: 60px;
    height: 70px;
    border: 1px solid #333;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-slot img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

/* --- Unified Responsive Design --- */

@media (max-width: 768px) {
    :root {
        --summon-pad: 1.5rem;
    }

    header {
        padding: 0.15rem 0.5rem !important;
    }

    h1 {
        font-size: 0.9rem !important;
    }

    .main-content {
        padding: 0.5rem;
        gap: 15px;
    }

    .panel,
    .glass-panel {
        padding: 0.75rem;
        border-radius: 4px;
    }

    h2,
    h3 {
        font-size: 0.85rem;
        margin-bottom: 0.4rem;
    }

    .summon-container {
        max-width: 95vw;
        max-height: 90vh;
        /* Slightly more height */
    }

    .result-image-wrapper {
        width: 220px;
        height: 220px;
    }
}

@media (max-width: 480px) {
    :root {
        --summon-pad: 1rem;
    }

    h1 {
        font-size: 0.8rem !important;
    }

    .summon-container {
        height: 100vh;
        max-height: 100vh;
        max-width: 100vw;
        border: none;
        border-radius: 0;
        padding: 10px 0;
        /* Minimal vertical padding */
    }

    .result-image-wrapper {
        width: 35vh;
        /* Scale with height to ensure space for buttons */
        height: 35vh;
        max-width: 180px;
        max-height: 180px;
    }

    .name-input-large {
        font-size: 1.3rem;
        padding: 0.3rem 0.6rem;
    }

    .summon-stats-container {
        padding: 0 0.5rem;
        gap: 0.4rem;
    }

    .stat-item {
        padding: 2px 4px;
        font-size: 0.7rem;
    }

    .actions {
        gap: 0.75rem;
    }

    .actions .action-btn,
    .actions .secondary-btn {
        width: 120px;
        height: 40px;
        font-size: 0.85rem;
    }

    /* Battle Arena Mobile Optimization */
    .fighters-row {
        gap: 10px;
    }

    .fighter {
        width: 48%;
    }

    .vs-divider {
        width: 50px;
    }

    .battle-viz .fighter-sprite {
        width: 80px;
        height: 80px;
    }

    .hp-container .name {
        font-size: 0.75rem;
    }

    /* Barracks Mobile */
    .monster-card {
        gap: 4px;
    }

    .card-image-wrapper {
        width: 50px;
        height: 50px;
    }

    .card-info-main {
        width: 80px;
    }

    .card-info h4 {
        font-size: 0.75rem;
    }

    .stat-item {
        font-size: 0.65rem;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    .summon-container {
        max-height: 100vh;
    }

    .result-layout {
        gap: 10px;
    }

    .result-image-wrapper {
        width: 120px;
        height: 120px;
    }
}

/* Seamless Transition Overlay */
.whiteout-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 5000;
    pointer-events: none;
    opacity: 0;
}

.whiteout-overlay.active {
    display: block !important;
    animation: flash-whiteout 0.5s ease-in-out forwards;
}

@keyframes flash-whiteout {
    0% {
        opacity: 0;
    }

    40% {
        opacity: 1;
        background: #fff;
    }

    60% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* --- Meteor Reveal Animation --- */
.meteor-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.meteor-particle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 10px var(--primary), 0 0 20px #fff;
    opacity: 0;
    will-change: transform, opacity;
}

/* Particles gather from a random offset to the center */
@keyframes meteor-gather {
    0% {
        opacity: 0;
        transform: translate(var(--sx), var(--sy)) scale(0.5);
    }

    20% {
        opacity: 1;
        transform: translate(var(--sx), var(--sy)) scale(1);
    }

    100% {
        opacity: 1;
        transform: translate(0, 0) scale(0.2);
    }
}

/* --- Sequenced Reveal Utilities --- */
.reveal-hidden {
    opacity: 0;
    pointer-events: none;
}

.reveal-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows 0.5s ease, opacity 0.5s ease;
}

.reveal-wrapper.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
}

.reveal-wrapper>* {
    overflow: hidden;
    min-height: 0;
}

.fade-in-up {
    animation: fadeInUp 0.4s ease-out forwards;
    pointer-events: auto;
}


@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


.delayed-value {
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.summon-stats-container.values-visible .delayed-value {
    opacity: 1;
}

.delay-1 {
    animation-delay: 0.1s;
}

.delay-2 {
    animation-delay: 0.2s;
}

.delay-3 {
    animation-delay: 0.3s;
}

/* Final burst flash */
.meteor-burst {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 50px 20px #fff, 0 0 100px 50px var(--primary);
    opacity: 0;
    pointer-events: none;
    z-index: 101;
}

@keyframes meteor-explode {
    0% {
        transform: translate(-50%, -50%) scale(0.1);
        opacity: 1;
    }

    50% {
        transform: translate(-50%, -50%) scale(20);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(30);
        opacity: 0;
    }
}