/* ===================================
   DUEL-SPECIFIC COMPONENTS & EFFECTS
   =================================== */

/* Ensure preview containers can contain the absolute-positioned loader */
.loadout-item-preview, .store-item-preview {
    position: relative;
}

/* --- Power-up Indicators & Icons --- */
.power-up-indicator { display: flex; align-items: center; gap: 0.5rem; background: rgba(255, 215, 0, 0.1); border: 1px solid rgba(255, 215, 0, 0.3); border-radius: 9999px; padding: 2px 8px 2px 2px; margin-top: 4px; width: fit-content; }
.power-up-indicator-icon { font-size: 16px; width: 24px; height: 24px; background: rgba(255, 215, 0, 0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.power-up-indicator-bar-container { width: 80px; height: 6px; background: rgba(0,0,0,0.3); border-radius: 9999px; overflow: hidden; }
.power-up-indicator-bar { 
    height: 100%;
    width: 100%; /* Set initial width for the transition to work from */
    background: var(--accent-gold);
    border-radius: 9999px; 
    transition: width 2s linear; /* Duration should be overridden by JS, but this provides a fallback */
}

.ai-pilot-indicator {
    font-size: 0.75rem;
    font-weight: 700;
    color: #f59e0b; /* amber-400 */
    text-shadow: 0 0 8px #f59e0b80;
    animation: pulse-yellow 2s infinite ease-in-out;
    margin-top: 4px;
}

.profile-avatar-bg {
    /* --accent-cyan is #00e5ff */
    background-image: radial-gradient(circle, rgba(0, 229, 255, 0.1) 0%, transparent 70%);
}

/* --- HUD Player Cards --- */
.hud-card {
    background-color: rgba(1, 4, 9, 0.5);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    padding: 0.75rem;
    transition: background-image 0.5s ease-in-out;
    background-size: cover;
    background-position: center;
}
.hud-avatar-container {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    background-color: rgba(0,0,0,0.5);
    border: 2px solid transparent;
    flex-shrink: 0;
    position: relative;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.9), 0 0 10px rgba(0,0,0,0.7);
    background-image: linear-gradient(rgba(1, 4, 9, 0.8), rgba(1, 4, 9, 0.8)), 
                      linear-gradient(45deg, var(--accent-cyan), var(--price-green));
    background-origin: border-box;
    background-clip: content-box, border-box;
}
.hud-avatar-container.mobile {
    width: 80px;
    height: 80px;
    border-width: 1px;
}

.card-bg-carbon {
    background-color: #1a1a1a;
    background-image: 
        linear-gradient(45deg, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.05) 75%, rgba(255,255,255,0.05)),
        linear-gradient(-45deg, rgba(255,255,255,0.05) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.05) 75%, rgba(255,255,255,0.05));
    background-size: 20px 20px;
}
.card-bg-holo {
    background: linear-gradient(160deg, #00d2ff 0%, #3a47d5 100%);
    animation: holo-shift 8s ease infinite;
    background-size: 400% 400%;
}
.card-bg-gradient { background: linear-gradient(45deg, #243949 0%, #517fa4 100%); }

/* --- In-Duel Action Bar & Buttons --- */
#abilities-wrapper {
    position: relative;
    display: flex;
    gap: 0.5rem; /* 8px */
    background: rgba(1, 4, 9, 0.5);
    padding: 0.5rem;
    border-radius: 9999px;
    border: 1px solid var(--panel-border);
}
/* This is for the spectator view, might be good to keep it general */
#abilities-wrapper.grid { 
    padding: 0.5rem; 
    background: rgba(1, 4, 9, 0.75); 
    border-radius: 0.75rem; 
}

/* --- Redesigned In-Duel Ability Buttons --- */
.ability-btn-action.ability-btn {
    position: relative;
    width: 64px; height: 64px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 40%, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 70%), 
                rgba(1, 4, 9, 0.6);
    border: 2px solid var(--panel-border);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6), 0 5px 15px rgba(0,0,0,0.5);
}
.ability-btn-action.ability-btn > svg {
    width: 32px; height: 32px;
    transition: transform 0.2s ease-out;
}

/* Add color to the icons */
.ability-btn-action.ability-btn.yellow { color: var(--accent-gold); }
.ability-btn-action.ability-btn.blue { color: #00BFFF; }
.ability-btn-action.ability-btn.red { color: var(--price-red); }
.ability-btn-action.ability-btn.purple { color: #BA55D3; }
.ability-btn-action.ability-btn.special {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.6), 0 0 25px var(--accent-gold-glow), 0 5px 15px rgba(0,0,0,0.5);
}

.ability-btn-action.ability-btn.disabled {
    cursor: not-allowed;
    background: #21262d !important;
    border-color: #30363d !important;
    color: #484f58 !important;
    opacity: 0.6;
    filter: grayscale(0.5);
    pointer-events: none;
}

.ability-btn-action.ability-btn.active {
    animation: pulse-glow 1.5s infinite ease-in-out;
    border-color: var(--accent-cyan);
}
.ability-btn-action.ability-btn.active.yellow { border-color: var(--accent-gold); }
.ability-btn-action.ability-btn.active.blue { border-color: #00BFFF; }
.ability-btn-action.ability-btn.active.red { border-color: var(--price-red); }
.ability-btn-action.ability-btn.active.purple { border-color: #BA55D3; }
.ability-btn-action.ability-btn.active.special {
    border-color: var(--accent-gold);
    /* Stop the special pulse animation when the ability is active to show the standard pulse */
    animation: pulse-glow 1.5s infinite ease-in-out;
}

/* Tooltip for abilities */
.ability-btn .tooltip {
    position: absolute;
    bottom: 110%; /* Position above the button */
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-color);
    color: var(--text-light);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-out, visibility 0.2s ease-out;
    pointer-events: none;
    z-index: 10;
    border: 1px solid var(--panel-border);
}

.trade-action-btn {
    padding: 0.75rem 1.25rem;
    font-weight: 900;
    font-size: 1.125rem; /* lg */
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem; 
    border-radius: 0.5rem; /* 8px */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 150px;
    border: 1px solid transparent;
    border-bottom-width: 4px;
    cursor: pointer;
}
.trade-action-btn:active:not(.disabled) { transform: translateY(1px); filter: brightness(0.95); border-bottom-width: 2px; }
.trade-action-btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-long { background-color: #10B981; color: white; border-color: #059669; box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3); }
.btn-short { background-color: #EF4444; color: white; border-color: #DC2626; box-shadow: 0 5px 15px rgba(239, 68, 68, 0.3); }
.btn-close { background-color: #4B5563; color: white; border-color: #374151; box-shadow: 0 5px 15px rgba(75, 85, 99, 0.3); }

/* --- In-Duel HUD --- */
.hud-value { font-family: 'Roboto Mono', monospace; font-weight: 700; font-size: 1.125rem; }
@media (min-width: 768px) { 
    .hud-value { font-size: 1.5rem; } 
    .trade-action-btn { min-width: 180px; padding: 1rem 1.5rem; } 
    #bottom-controls .btn-close { min-width: 372px; } 
}

/* --- In-Duel Effects --- */
.overclocked-text {
    color: #FFD700;
    animation: pulse-yellow 1.5s infinite ease-in-out;
}

/* Overtime: highlight/pulse the timer when extended */
#duel-timer.overtime-active-anim,
#duel-timer-mobile.overtime-active-anim {
    animation: overtime-timer-pulse 1.3s ease-out 1;
    color: #BA55D3; /* Ability purple highlight during pulse */
    text-shadow: 0 0 14px rgba(186,85,211,0.8), 0 0 6px rgba(255,255,255,0.8);
}

/* Opponent name effects for abilities */
.frozen-text {
    color: #CFEFFF;
    text-shadow: 0 0 8px rgba(135, 206, 250, 0.8), 0 0 16px rgba(0, 191, 255, 0.5);
    animation: frozen-text-pulse 1.2s ease-in-out infinite;
}

@keyframes frozen-text-pulse {
    0%, 100% { filter: drop-shadow(0 0 0 rgba(135, 206, 250, 0.0)); opacity: 1; }
    50%      { filter: drop-shadow(0 0 6px rgba(135, 206, 250, 0.6)); opacity: 0.9; }
}

.smoked-text {
    color: #E5E7EB;
    text-shadow: 0 0 10px rgba(200, 210, 220, 0.35);
    animation: smoked-text-fade 1.4s ease-in-out infinite;
}

@keyframes smoked-text-fade {
    0%, 100% { opacity: 0.85; filter: blur(0px); }
    50%      { opacity: 0.55; filter: blur(0.4px); }
}

.frozen-overlay {
    position: absolute;
    inset: 0;
    z-index: 50; /* Ensure above name text and icons */
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.frozen-icon {
    color: #E6F7FF;
    font-size: 64px;
    text-shadow: 0 0 12px rgba(0, 191, 255, 0.9), 0 0 24px rgba(135, 206, 250, 0.6);
    opacity: 0;
    transform: scale(0);
}
.shake-once { animation: screen-shake 0.12s linear 1; }

@keyframes frozen-pop-in {
    0% { opacity: 0; transform: scale(0.6); }
    100% { opacity: 1; transform: scale(1); }
}
.frozen-overlay:not(.hidden) .frozen-icon {
    animation: frozen-icon-effect 5s ease-out forwards;
}

#opponent-invisibility-effect-desktop:not(.hidden) .ghost-icon,
#opponent-invisibility-effect-mobile:not(.hidden) .ghost-icon {
    animation: ghost-float-fade 6s ease-in-out forwards;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.7);
}

.smoke-effect-container {
    position: absolute;
    top: 50%; left: 50%;
    width: 140px; height: 140px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 50; /* Ensure above name text */
}
.smoke-effect-container span {
    position: absolute;
    bottom: 0; left: 50%;
    width: 10px; height: 10px;
    background: transparent;
    border-radius: 50%;
    opacity: 0;
    transform-origin: center bottom;
    box-shadow: 0 0 15px 8px rgba(200, 210, 220, 0.7), -20px 10px 20px 8px rgba(180, 190, 200, 0.6), 20px 5px 25px 8px rgba(190, 200, 210, 0.5);
    animation: smoke-rise-and-fade 4s infinite ease-in-out;
}

/* Initial poof burst for smoke */
.smoke-poof {
    position: absolute;
    width: 160px; height: 160px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(220,230,240,0.7) 0%, rgba(220,230,240,0.0) 70%);
    filter: blur(10px);
    animation: smoke-poof-burst 0.5s ease-out forwards;
    pointer-events: none;
    z-index: 60; /* over name */
}
@keyframes smoke-poof-burst {
    0% { opacity: 0.9; transform: translate(-50%, -50%) scale(0.4); }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1.4); }
}
.smoke-effect-container span:nth-child(1) { animation-delay: 0s; transform: translateX(-50%); }
.smoke-effect-container span:nth-child(2) { animation-delay: 0.8s; transform: translateX(-70%) scale(0.8); }
.smoke-effect-container span:nth-child(3) { animation-delay: 1.5s; transform: translateX(-30%) scale(1.1); }
.smoke-effect-container span:nth-child(4) { animation-delay: 2.2s; transform: translateX(-60%) scale(0.9); }
.smoke-effect-container span:nth-child(5) { animation-delay: 3s; transform: translateX(-40%) scale(1); }

.smoke-animation-layer { pointer-events: none; }
.smoke-wisp {
    position: absolute;
    background: radial-gradient(circle, rgba(224, 231, 239, 0.7) 0%, rgba(224, 231, 239, 0) 70%);
    border-radius: 50%;
    filter: blur(25px);
    opacity: 0;
    transform-origin: center center;
    animation: drift-and-fade linear infinite;
}

/* --- Mobile Duel Controls --- */
.ability-btn-mobile-rebuilt {
    width: 48px;
    height: 48px;
    background: radial-gradient(circle at 50% 40%, rgba(255,255,255,0.1) 0%, transparent 70%), rgba(1, 4, 9, 0.7);
    border: 1.5px solid var(--panel-border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-out;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
    backdrop-filter: blur(3px);
}
.ability-btn-mobile-rebuilt > svg {
    width: 24px; height: 24px; /* Adjust icon size */
    transition: transform 0.2s ease-out;
}

/* Add color to the mobile icons */
.ability-btn-mobile-rebuilt.yellow { color: var(--accent-gold); }
.ability-btn-mobile-rebuilt.blue { color: #00BFFF; }
.ability-btn-mobile-rebuilt.red { color: var(--price-red); }
.ability-btn-mobile-rebuilt.purple { color: #BA55D3; }
.ability-btn-mobile-rebuilt.special {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.5), 0 0 10px var(--accent-gold-glow);
}

.ability-btn-mobile-rebuilt.disabled {
    opacity: 0.4;
    filter: grayscale(0.8);
}

.ability-btn-mobile-rebuilt.active {
    animation: pulse-glow 1.5s infinite ease-in-out;
    border-color: var(--accent-cyan);
}
.ability-btn-mobile-rebuilt.active.yellow { border-color: var(--accent-gold); }
.ability-btn-mobile-rebuilt.active.blue { border-color: #00BFFF; }
.ability-btn-mobile-rebuilt.active.red { border-color: var(--price-red); }
.ability-btn-mobile-rebuilt.active.purple { border-color: #BA55D3; }
.ability-btn-mobile-rebuilt.active.special {
    border-color: var(--accent-gold);
    animation: pulse-glow 1.5s infinite ease-in-out;
}

.trade-action-btn-mobile-rebuilt {
    height: 56px;
    font-size: 1.125rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid transparent;
    border-bottom-width: 5px;
    transition: all 0.15s ease-out;
}
.trade-action-btn-mobile-rebuilt:active:not(.disabled) {
    transform: translateY(3px);
    border-bottom-width: 2px;
    filter: brightness(0.95);
}
.trade-action-btn-mobile-rebuilt.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.trade-action-btn-mobile-rebuilt.btn-close { height: 56px; }

.action-toast-mobile {
    position: absolute;
    bottom: 0.5rem;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: white;
    font-size: 0.75rem;
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(5px);
    display: none;
    border: 2px solid transparent;
}
.action-toast-mobile.show { display: block; animation: slide-and-fade 3s ease-out forwards; }
.toast-long { background-color: rgba(16, 185, 129, 0.5); }
.toast-short { background-color: rgba(239, 68, 68, 0.5); }
.toast-close { background-color: rgba(75, 85, 99, 0.5); }
#player-action-toast-mobile.show { border-color: var(--player-blue); }
#opponent-action-toast-mobile.show { border-color: var(--house-cyan); }

/* --- Hover States for Desktop --- */
@media (hover: hover) and (pointer: fine) {
    .ability-btn-action.ability-btn:hover:not(.disabled) {
        transform: translateY(-4px) scale(1.05);
        border-color: var(--accent-cyan);
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 25px var(--accent-glow), 0 8px 20px rgba(0,0,0,0.4);
    }
    .ability-btn-action.ability-btn.yellow:hover:not(.disabled) { box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 25px var(--accent-gold-glow), 0 8px 20px rgba(0,0,0,0.4); border-color: var(--accent-gold); }
    .ability-btn-action.ability-btn.blue:hover:not(.disabled) { box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 25px #00BFFF, 0 8px 20px rgba(0,0,0,0.4); border-color: #00BFFF; }
    .ability-btn-action.ability-btn.red:hover:not(.disabled) { box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 25px var(--red-glow), 0 8px 20px rgba(0,0,0,0.4); border-color: var(--price-red); }
    .ability-btn-action.ability-btn.purple:hover:not(.disabled) { box-shadow: inset 0 2px 4px rgba(0,0,0,0.5), 0 0 25px #BA55D3, 0 8px 20px rgba(0,0,0,0.4); border-color: #BA55D3; }
    .ability-btn-action.ability-btn.special:hover:not(.disabled) {
        /* Override the animation on hover to provide a more responsive feel */
        animation: none;
    }
    
    .ability-btn:hover .tooltip {
        opacity: 1;
        visibility: visible;
    }

    .trade-action-btn:hover:not(.disabled) { transform: translateY(-2px); filter: brightness(1.1); }

    .ability-btn-mobile-rebuilt:active:not(.disabled) {
        transform: scale(0.95);
        background: var(--accent-glow);
        border-color: var(--accent-cyan);
    }
    .ability-btn-mobile-rebuilt.special:active:not(.disabled) {
        background: var(--accent-gold-glow);
        border-color: var(--accent-gold);
    }
}

/* --- Chart Controls --- */
.chart-option-btn {
    background: rgba(1, 4, 9, 0.7);
    border: 1px solid var(--panel-border);
    color: var(--text-dark);
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 4px;
    transition: all 0.2s ease-out;
}
.chart-option-btn:hover:not(.active) {
    color: var(--text-light);
    border-color: var(--accent-cyan);
}
.chart-option-btn.active {
    background: var(--accent-cyan);
    color: var(--bg-color);
    font-weight: 700;
    border-color: var(--accent-cyan);
}

/* --- Game Over Screen Redesign --- */
#game-over-screen {
    background: radial-gradient(ellipse at center, rgba(13, 37, 63, 0.5) 0%, var(--bg-color) 70%);
    backdrop-filter: blur(5px);
    justify-content: space-evenly;
}

/* Animation for the content wrapper */
#game-over-screen:not(.is-visible) #game-over-content > * {
    opacity: 0;
}

#game-over-screen.is-visible #game-over-header {
    animation: pop-in-focus 0.8s cubic-bezier(0.2, 1, 0.3, 1) 0.2s forwards;
}

#game-over-screen.is-visible #game-over-players {
    animation: delayed-fade-in 0.6s 0.6s ease-out forwards;
}

#game-over-screen.is-visible #game-over-rewards {
    animation: delayed-fade-in 0.6s 0.8s ease-out forwards;
}

#game-over-screen.is-visible #game-over-actions,
#game-over-screen.is-visible #share-section {
    animation: delayed-fade-in 0.6s 1s ease-out forwards;
}

/* The individual player card */
.game-over-player-card {
    display: flex;
    flex-direction: column; /* Always stack vertically */
    align-items: center;
    gap: 1rem;
    padding: 1.5rem; /* Use consistent padding */
    border-radius: 0.75rem; /* 12px */
    background-color: rgba(1, 4, 9, 0.5);
    border: 2px solid var(--panel-border);
    transition: all 0.5s cubic-bezier(0.2, 1, 0.3, 1);
}

.game-over-player-card .game-over-player-details {
    text-align: center; /* Center the text details below the avatar */
}

/* Avatar styling */
.game-over-avatar-wrapper {
    position: relative;
    flex-shrink: 0;
}

.game-over-avatar-container {
    width: 96px;
    height: 96px;
    position: relative;
    border-radius: 50%;
    background-color: rgba(0,0,0,0.3);
    border: 2px solid var(--panel-border);
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.7);
}

@media (min-width: 768px) { /* md breakpoint */
    .game-over-avatar-container {
        width: 128px;
        height: 128px;
    }
}

/* Winner and Loser card states */
#game-over-screen.is-visible.victory #game-over-title {
    animation: victory-animation 1s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

#game-over-screen.is-visible.defeat #game-over-title {
    animation: defeat-animation 1.2s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}

#game-over-screen.is-visible .winner-col {
    transform: scale(1.05);
    border-color: var(--price-green);
    background-color: rgba(26, 247, 175, 0.05);
    box-shadow: 0 0 30px rgba(26, 247, 175, 0.3);
    z-index: 1; /* Bring winner to the front */
}
#game-over-screen.is-visible .winner-col .game-over-avatar-container {
    border-color: var(--price-green);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.7), 0 0 20px var(--price-green);
}
#game-over-screen.is-visible .loser-col {
    transform: scale(0.95);
    opacity: 0.7;
    filter: saturate(0.3) blur(1px);
    border-color: rgba(125, 133, 144, 0.3);
}

/* Mobile adjustments for game over screen to prevent overflow */
@media (max-width: 767px) { /* Below md breakpoint */
    #game-over-screen {
        overflow-y: hidden; /* Prevent scrolling as requested */
        justify-content: center; /* Re-center content vertically */
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    #game-over-content {
        gap: 0.5rem; /* Reduce space between elements */
    }

    #game-over-header {
        margin-bottom: 0.5rem; /* Reduce margin */
    }

    #game-over-title {
        font-size: 3rem; /* text-5xl */
    }

    #game-over-subtitle {
        font-size: 0.875rem; /* text-sm */
    }

    #game-over-players {
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .game-over-player-card {
        padding: 0.5rem;
        gap: 0.75rem;
        flex-direction: row; /* Align avatar and text horizontally */
    }

    .game-over-player-details {
        text-align: left; /* Align text to the left */
    }

    .game-over-avatar-container {
        width: 64px;
        height: 64px;
    }

    #game-over-rewards {
        margin-top: 0.5rem;
        margin-bottom: 0.75rem;
        gap: 1.5rem;
    }

    #game-over-actions {
        margin-top: 0.5rem;
    }

    #share-section {
        margin-top: 0.75rem;
    }
}

/* --- Special Ability Highlight Animation --- */
@keyframes special-ability-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.6), 0 0 25px var(--accent-gold-glow), 0 5px 15px rgba(0,0,0,0.5);
    }
    50% {
        transform: scale(1.05);
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.6), 0 0 40px var(--accent-gold), 0 8px 25px rgba(255, 215, 0, 0.4);
    }
}

@keyframes special-ability-pulse-mobile {
    0%, 100% {
        transform: scale(1);
        box-shadow: inset 0 1px 3px rgba(0,0,0,0.5), 0 0 10px var(--accent-gold-glow);
    }
    50% {
        transform: scale(1.05);
        box-shadow: inset 0 1px 3px rgba(0,0,0,0.5), 0 0 20px var(--accent-gold);
    }
}

/* Apply the animation specifically to the special ability buttons when they are ready to use */
#desktop-ability-special.special:not(.disabled):not(.active) {
    animation: special-ability-pulse 2.5s infinite ease-in-out;
}

#mobile-ability-special.special:not(.disabled):not(.active) {
    animation: special-ability-pulse-mobile 2.5s infinite ease-in-out;
}

/* --- Special Ability Active Indicator --- */
.special-ability-active-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: rgba(255, 215, 0, 0.2);
    border: 1px solid var(--accent-gold);
    border-radius: 6px;
    padding: 4px 6px;
    box-shadow: 0 0 15px var(--accent-gold-glow);
    min-width: 60px;
}

.special-ability-active-indicator .blinking-text {
    font-size: 9px;
    font-weight: 900;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    animation: special-ability-blink 1.2s infinite ease-in-out;
}

.special-ability-active-indicator .progress-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(0,0,0,0.4);
    border-radius: 2px;
    overflow: hidden;
}

.special-ability-active-indicator .progress-bar-fill {
    width: 100%;
    height: 100%;
    background: var(--accent-gold);
    border-radius: 2px;
    transform-origin: left;
    animation: deplete-progress linear forwards;
}

/* --- VS Particle Burst --- */
.vs-particle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan), 0 0 15px white;
    opacity: 0;
    animation: vs-particle-burst 0.8s ease-out forwards;
    pointer-events: none;
}

@keyframes vs-particle-burst {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* --- Friends List Redesign --- */
.friend-entry {
    display: flex;
    align-items: center;
    gap: 0.75rem; /* 12px */
    padding: 0.5rem;
    background: rgba(1, 4, 9, 0.5);
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    transition: background-color 0.2s, border-color 0.2s;
}
.friend-entry:hover {
    background-color: rgba(1, 4, 9, 0.8);
    border-color: var(--accent-cyan);
}

.friend-avatar-container {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background-color: rgba(0,0,0,0.5);
    border: 2px solid var(--panel-border);
    flex-shrink: 0;
    position: relative;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.7);
}

.friend-name {
    font-weight: 700;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.online-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #6B7280; /* gray-500 */
    transition: background-color 0.3s;
}
.online-status-indicator.online {
    background-color: var(--price-green);
    box-shadow: 0 0 5px var(--price-green);
}
.online-status-indicator.in-duel {
    background-color: #f59e0b; /* amber-500 */
    box-shadow: 0 0 5px #f59e0b;
}

/* --- New Emote Button on HUD --- */
.emote-button-hud {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--panel-border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.emote-button-hud:hover {
    background: var(--accent-glow);
    border-color: var(--accent-cyan);
    transform: scale(1.1);
}
.emote-button-hud.mobile {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    font-size: 16px;
    z-index: 10;
}

/* --- Redesigned Emote Picker --- */
.emote-picker-panel {
    background: rgba(1, 4, 9, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.15);
    padding: 1.5rem;
    width: 90%;
    max-width: 500px;
    text-align: center;
}
.emote-picker-scroll-container {
    position: relative;
    width: 100%;
}
.emote-picker-scroll-container::before,
.emote-picker-scroll-container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    z-index: 2;
    pointer-events: none;
}
.emote-picker-scroll-container::before { left: 0; background: linear-gradient(to right, rgba(1, 4, 9, 0.85), transparent); }
.emote-picker-scroll-container::after { right: 0; background: linear-gradient(to left, rgba(1, 4, 9, 0.85), transparent); }

.emote-picker-grid-flex {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem 1.5rem;
    margin: 0 -1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-cyan) transparent;
}
.emote-picker-grid-flex::-webkit-scrollbar { height: 8px; }
.emote-picker-grid-flex::-webkit-scrollbar-track { background: transparent; }
.emote-picker-grid-flex::-webkit-scrollbar-thumb { background-color: var(--accent-cyan); border-radius: 4px; border: 2px solid rgba(1, 4, 9, 0.85); }

/* --- Centered Emote Display --- */
.emote-display-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 25;
}
.emote-on-chart {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    animation: emote-pop-in-center 2.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.emote-icon {
    font-size: 6rem; /* 96px */
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}
.emote-player-name {
    font-size: 1rem; /* 16px */
    font-weight: 700;
    color: var(--text-light);
    background: rgba(1, 4, 9, 0.7);
    padding: 0.25rem 1rem;
    border-radius: 9999px;
    border: 1px solid var(--panel-border);
    text-shadow: none;
    margin-top: -0.5rem; /* Pull it up a bit closer to the icon */
}
/* --- Mobile-specific Event Announcement Styles --- */
@media (max-width: 639px) { /* Targets screens smaller than Tailwind's 'sm' breakpoint */
    #event-announcement {
        top: 25%; /* Move it up a bit on smaller screens */
    }
    #event-announcement .menu-panel {
        padding: 0.75rem !important; /* Tailwind: !p-3 */
        max-width: 90%; /* Use percentage for better fit */
    }
    #event-title {
        font-size: 1.5rem; /* Tailwind: text-2xl */
        line-height: 2rem;
    }
    #event-description {
        font-size: 0.875rem; /* Tailwind: text-sm */
        line-height: 1.25rem;
        margin-top: 0.25rem; /* Tailwind: mt-1 */
    }
    #event-timer {
        width: 40px; /* Tailwind: w-10 */
        height: 40px; /* Tailwind: h-10 */
        top: -0.5rem; /* Tailwind: -top-2 */
        right: -0.5rem; /* Tailwind: -right-2 */
    }
}

/* --- Power-up Icons on Chart --- */
.power-up-icon {
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 215, 0, 0.2);
    border: 2px solid var(--accent-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 20;
    animation: power-up-spawn 0.5s ease-out forwards;
    transition: transform 0.2s ease-out, box-shadow 0.2s ease-out;
    box-shadow: 0 0 15px var(--accent-gold-glow);
}
.power-up-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px var(--accent-gold);
}

/* --- Opponent Ability Icons --- */
.ability-icon {
    width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.1); border: 1px solid var(--panel-border); transition: all 0.3s ease;
}
.ability-icon.yellow { color: var(--accent-gold); }
.ability-icon.blue { color: #00BFFF; }
.ability-icon.red { color: var(--price-red); }
.ability-icon.purple { color: #BA55D3; }
.ability-icon.used {
    opacity: 0.3; filter: grayscale(1); background: rgba(255, 255, 255, 0.05);
}

/* --- Power-up Collected Toast --- */
.power-up-collected-toast {
    position: absolute;
    transform: translate(-50%, -100%);
    background: rgba(1, 4, 9, 0.7);
    backdrop-filter: blur(4px);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: bold;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    animation: power-up-toast-anim 2s ease-out forwards;
    box-shadow: 0 0 10px var(--accent-gold-glow);
}

/* ------------------------------
   Friends Invite Panel (Responsive)
   ------------------------------ */
#friends-invite-panel .invite-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
#friends-invite-panel .invite-row .menu-btn { white-space: nowrap; }
#friends-invite-panel #friends-share-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
#friends-invite-panel #friends-share-buttons .share-platform-btn { width: 44px; height: 44px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--panel-border); background: rgba(255,255,255,0.06); line-height: 0; transition: transform .12s ease, filter .12s ease, box-shadow .12s ease; box-shadow: 0 2px 10px rgba(0,0,0,0.25); }
#friends-invite-panel #friends-share-buttons .share-platform-btn svg { width: 22px; height: 22px; color: #fff; display: block; }
#friends-invite-panel #friends-share-buttons .share-platform-btn:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.05); }
#friends-invite-panel #friends-share-buttons .share-twitter { background-color: #1DA1F2; border-color: #1DA1F2; }
#friends-invite-panel #friends-share-buttons .share-telegram { background-color: #26A5E4; border-color: #26A5E4; }
#friends-invite-panel #friends-share-buttons .share-whatsapp { background-color: #25D366; border-color: #25D366; }
#friends-invite-panel #friends-share-buttons .share-native { 
  background: rgba(255,255,255,0.08);
  border-color: var(--panel-border);
  box-shadow: none;
}
#friends-invite-btn.invite-cta {
  background: linear-gradient(135deg, #00e5ff, #1AF7AF);
  border-color: rgba(255,255,255,0.2);
  color: #001016;
  box-shadow: 0 0 12px rgba(0,229,255,0.35);
}
#friends-invite-btn.invite-cta:hover { filter: brightness(1.05); transform: translateY(-1px); }

.invite-screen-panel { animation: slide-in-up 220ms cubic-bezier(0.25, 1, 0.5, 1) both; }
@keyframes slide-in-up {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
#invite-screen .invite-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 120% at 10% -10%, rgba(0, 225, 255, 0.10) 0%, rgba(0, 225, 255, 0.04) 35%, transparent 60%),
              radial-gradient(120% 120% at 110% 110%, rgba(26, 247, 175, 0.10) 0%, rgba(26, 247, 175, 0.04) 35%, transparent 60%);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  animation: invite-backdrop-fade 360ms ease-out forwards;
}
@keyframes invite-backdrop-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Animated bonus badge */
#invite-bonus-badge.invite-bonus-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 900;
  font-size: 12px;
  color: #001016;
  background: linear-gradient(135deg, #FFE27A, #FFBE3B);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 16px rgba(255, 207, 64, 0.35), inset 0 0 8px rgba(255, 255, 255, 0.25);
  transform-origin: center;
  animation: badge-pop 500ms cubic-bezier(.2,1.2,.2,1) 60ms both, badge-float 2.8s ease-in-out 700ms infinite;
}
#invite-bonus-badge .coin { filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25)); }
#invite-bonus-badge .amount { letter-spacing: 0.5px; color: #001016; text-shadow: 0 1px 0 rgba(255,255,255,0.35); }
@keyframes badge-pop {
  0% { transform: scale(0.7) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.06) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes badge-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
#friends-invite-panel #friends-share-buttons .share-platform-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
@media (max-width: 480px) {
    #friends-invite-panel .invite-row { flex-direction: column; align-items: stretch; }
    #friends-invite-panel .invite-row input { width: 100%; }
    #friends-invite-panel .invite-row .menu-btn { width: 100%; }
    #friends-invite-panel #friends-share-buttons { justify-content: center; flex-wrap: wrap; }
}

/* Invite screen subtitle with subtle glow */
.invite-subtitle {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-weight: 800;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--accent-cyan);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.45);
  animation: invite-subtle-glow 2.6s ease-in-out infinite alternate;
}
.invite-subtitle .icon { filter: drop-shadow(0 0 6px rgba(0,229,255,0.35)); }
@keyframes invite-subtle-glow {
  from { opacity: 0.9; text-shadow: 0 0 6px rgba(0,229,255,0.35); }
  to   { opacity: 1;   text-shadow: 0 0 12px rgba(0,229,255,0.55); }
}

/* Invite screen redesign */
.invite-container { gap: 12px; padding: 16px; display: flex; flex-direction: column; min-height: 0; }
.invite-footer { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--panel-border); position: sticky; bottom: 0; background: rgba(0,0,0,0.15); }
.invite-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.invite-header .title-row { display: inline-flex; align-items: center; gap: 8px; }
.invite-section { background: rgba(255,255,255,0.04); border: 1px solid var(--panel-border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.invite-section .section-label { font-size: 12px; color: #9db8bd; letter-spacing: .02em; }
.code-section .code-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.code-display { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 18px; letter-spacing: 0.08em; color: var(--accent-cyan); background: rgba(0,0,0,0.35); border: 1px solid var(--panel-border); border-radius: 10px; padding: 10px 12px; text-align: center; user-select: all; }
.code-display:active { filter: brightness(1.1); }
.copy-btn { white-space: nowrap; }
.message-section .message-preview { width: 100%; resize: none; background: rgba(0,0,0,0.35); border: 1px solid var(--panel-border); border-radius: 10px; color: #d8f4f6; padding: 10px 12px; font-size: 13px; line-height: 1.45; min-height: 72px; }
.message-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.message-actions { width: 100%; }
.message-actions .menu-btn { flex: 0 0 auto; }
#invite-share-buttons { width: 100%; display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.share-buttons { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.share-buttons .share-platform-btn { width: 44px; height: 44px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--panel-border); background: rgba(255,255,255,0.06); line-height: 0; transition: transform .12s ease, filter .12s ease, box-shadow .12s ease; box-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.share-buttons .share-platform-btn svg { width: 22px; height: 22px; color: #fff; display: block; }
.share-buttons .share-platform-btn:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.05); }
.share-buttons .share-twitter { background-color: #1DA1F2 !important; border-color: #1DA1F2 !important; }
.share-buttons .share-telegram { background-color: #26A5E4 !important; border-color: #26A5E4 !important; }
.share-buttons .share-whatsapp { background-color: #25D366 !important; border-color: #25D366 !important; }

/* Extra-specific rules to ensure invite screen buttons adopt colors/spacing */
#invite-share-buttons .share-platform-btn { width: 48px; height: 48px; margin-right: 12px; }
#invite-share-buttons .share-platform-btn:last-child { margin-right: 0; }
#invite-share-buttons .share-twitter { background-color: #1DA1F2 !important; border-color: #1DA1F2 !important; }
#invite-share-buttons .share-telegram { background-color: #26A5E4 !important; border-color: #26A5E4 !important; }
#invite-share-buttons .share-whatsapp { background-color: #25D366 !important; border-color: #25D366 !important; }

/* Extra safety: enforce brand colors on mobile via id + class selector */
#invite-screen .share-platform-btn.share-twitter { background-color: #1DA1F2 !important; border-color: #1DA1F2 !important; }
#invite-screen .share-platform-btn.share-telegram { background-color: #26A5E4 !important; border-color: #26A5E4 !important; }
#invite-screen .share-platform-btn.share-whatsapp { background-color: #25D366 !important; border-color: #25D366 !important; }

/* Desktop layout: reduce bottom whitespace by top-aligning the panel */
@media (min-width: 768px) {
  #invite-screen { justify-content: flex-start !important; align-items: center !important; overflow-y: auto; padding-top: 24px; padding-bottom: 24px; }
  #invite-screen .menu-panel { margin: 0 !important; }
}

@media (min-width: 1024px) {
  /* Center copy button and keep shares centered without excessive edges */
  .message-actions { justify-content: center; flex-direction: column; align-items: center; gap: 16px; }
  #invite-share-buttons { justify-content: center; }
}
.invite-tip { margin-top: 4px; font-size: 12px; color: #91a9ad; text-align: center; }

@media (min-width: 640px) {
  .invite-container { padding: 18px; }
  .code-display { font-size: 20px; }
}

/* On mobile, center the Copy Message button and keep share buttons centered */
@media (max-width: 640px) {
  #invite-screen .message-actions { justify-content: center; gap: 12px; }
  #invite-screen #invite-copy-message-btn { margin-left: auto; margin-right: auto; display: block; }
}

/* Global compact share buttons (e.g., landing/fallback sections) */
.share-option-btn { width: 44px; height: 44px; border-radius: 9999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--panel-border); background: rgba(255,255,255,0.06); line-height: 0; margin-right: 12px; transition: transform .12s ease, filter .12s ease, box-shadow .12s ease; box-shadow: 0 2px 10px rgba(0,0,0,0.25); }
.share-option-btn:last-child { margin-right: 0; }
.share-option-btn svg { width: 22px; height: 22px; color: #fff; display: block; }
.share-option-btn:hover { transform: translateY(-2px) scale(1.03); filter: brightness(1.05); }
.share-option-btn[data-platform="twitter"] { background-color: #1DA1F2 !important; border-color: #1DA1F2 !important; }
.share-option-btn[data-platform="facebook"] { background-color: #1778F2 !important; border-color: #1778F2 !important; }
.share-option-btn[data-platform="linkedin"] { background-color: #0A66C2 !important; border-color: #0A66C2 !important; }

/* Invite screen redesign */
.invite-container { gap: 10px; padding: 14px 16px; }
.invite-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.invite-header .title-row { display: flex; align-items: center; gap: 8px; }
.invite-section { background: rgba(0,0,0,0.25); border: 1px solid var(--panel-border); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.invite-section .section-label { font-size: 12px; color: #9db8bd; letter-spacing: .02em; }
.code-section .code-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.code-display { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 18px; letter-spacing: 0.08em; color: var(--accent-cyan); background: rgba(0,0,0,0.35); border: 1px solid var(--panel-border); border-radius: 8px; padding: 8px 10px; text-align: center; }
.copy-btn { white-space: nowrap; }
.message-section .message-preview { width: 100%; resize: none; background: rgba(0,0,0,0.35); border: 1px solid var(--panel-border); border-radius: 8px; color: #d8f4f6; padding: 8px 10px; font-size: 13px; line-height: 1.35; }
.message-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.share-buttons { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.invite-tip { margin-top: 8px; font-size: 12px; color: #91a9ad; }

@media (min-width: 640px) {
  .invite-container { padding: 16px 18px; }
  .code-display { font-size: 20px; }
}
