/* =============================================
   QUANTUM BUTTON V1.0.0 — COMPONENTS.CSS
   Buttons, cards, themes, modals, animations
   ============================================= */

/* --- BUTTONS --- */
.btn-main {
    background: linear-gradient(180deg, rgba(0, 243, 255, 0.2) 0%, rgba(0, 243, 255, 0) 100%);
    border: 2px solid var(--neon-blue);
    box-shadow: 0 0 15px var(--neon-blue), inset 0 0 20px rgba(0, 243, 255, 0.1);
    text-shadow: 0 0 5px var(--neon-blue);
    clip-path: polygon(10% 0, 100% 0, 100% 80%, 90% 100%, 0 100%, 0 20%);
    transition: all 0.1s ease-out;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    z-index: 10;
    touch-action: manipulation;
}
.btn-main:active { 
    transform: scale(0.95); 
    background: var(--neon-blue); 
    color: black; 
    text-shadow: none; 
}

/* --- APP CONTAINER --- */
#app-container { 
    position: relative; 
    z-index: 1; 
    background: black; 
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.screen { z-index: 200; }

/* --- MODE CARDS --- */
.mode-card {
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(4px);
    cursor: pointer;
    transition: all 0.2s ease;
}
.mode-card:hover {
    box-shadow: 0 0 15px var(--neon-blue);
    border-color: var(--neon-blue);
}
.mode-card:active { transform: scale(0.98); }

/* --- SCROLLBAR --- */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* --- HUD --- */
#game-hud { z-index: 100 !important; pointer-events: none; }
#game-hud button { pointer-events: auto !important; }

/* --- GAME THEMES (border/glow applied to app container) --- */
.theme-neon { border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 0 20px rgba(0, 243, 255, 0.1); }

/* Only show container border on desktop where the app is centered */
@media (min-width: 601px) {
    #app-container {
        border-left: 1px solid rgba(255,255,255,0.05);
        border-right: 1px solid rgba(255,255,255,0.05);
    }
}

.theme-gold {
    border: 3px solid var(--neon-gold) !important;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5), inset 0 0 20px rgba(255, 215, 0, 0.1) !important;
    animation: gold-border-shimmer 3s ease-in-out infinite !important;
}

@keyframes gold-border-shimmer {
    0%, 100% {
        border-color: #ffd700;
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.5), inset 0 0 20px rgba(255, 215, 0, 0.1);
    }
    33% {
        border-color: #fff8dc;
        box-shadow: 0 0 45px rgba(255, 248, 220, 0.7), inset 0 0 30px rgba(255, 215, 0, 0.15);
    }
    66% {
        border-color: #daa520;
        box-shadow: 0 0 35px rgba(218, 165, 32, 0.5), inset 0 0 25px rgba(255, 215, 0, 0.12);
    }
}

.theme-devil { border: 2px solid var(--neon-red) !important; box-shadow: 0 0 40px rgba(255, 0, 0, 0.6); }
.theme-devil #game-area { box-shadow: inset 0 0 100px rgba(255, 0, 0, 0.2); }
.theme-devil #fire-layer { opacity: 0.25 !important; }
.theme-devil #app-container {
    animation: devil-flicker-border 0.8s ease-in-out infinite alternate !important;
}
@keyframes devil-flicker-border {
    0% { border-color: #ff0000; box-shadow: 0 0 30px rgba(255, 0, 0, 0.5); }
    30% { border-color: #ff4400; box-shadow: 0 0 40px rgba(255, 68, 0, 0.6); }
    60% { border-color: #ff2200; box-shadow: 0 0 25px rgba(255, 34, 0, 0.4); }
    100% { border-color: #ff6600; box-shadow: 0 0 35px rgba(255, 102, 0, 0.5); }
}

.theme-glitch { border: 2px solid #0f0 !important; animation: glitch-border 0.2s infinite; }
.glitch-text { 
    animation: glitch-text 0.1s infinite; 
    color: #0f0 !important; 
    text-shadow: 2px 0 red, -2px 0 blue;
    display: inline-block;
}

@keyframes glitch-border {
    0% { border-color: #0f0; } 25% { border-color: #f0f; } 50% { border-color: #0ff; } 100% { border-color: #0f0; }
}
@keyframes glitch-text {
    0% { transform: translate(0); } 20% { transform: translate(-2px, 2px); } 40% { transform: translate(-2px, -2px); } 60% { transform: translate(2px, 2px); } 80% { transform: translate(2px, -2px); } 100% { transform: translate(0); }
}

.theme-neon-rgb { 
    border: none !important; 
    box-shadow: none !important; 
    position: relative;
    z-index: 1;
}

.theme-neon-rgb::before {
    content: '';
    position: absolute;
    inset: -4px;
    background: conic-gradient(from 0deg, #ff0000, #ffd700, #00f3ff, #a855f7, #ff0000);
    filter: blur(10px);
    animation: rotate 4s linear infinite;
    z-index: -1;
    border-radius: inherit;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes rotate-border { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.theme-anime { border: 3px solid #1a1a2e !important; box-shadow: 0 0 25px rgba(232,67,147,0.3); }
.theme-anime #game-area {
    background-image: radial-gradient(circle, rgba(196,78,255,0.1) 1px, transparent 1px);
    background-size: 8px 8px;
}
.theme-anime #app-container {
    border-color: #e84393 !important;
    border-width: 3px !important;
    box-shadow: 0 0 30px rgba(232,67,147,0.3), 0 0 60px rgba(196,78,255,0.12) !important;
}

.theme-cosmic { border: 2px solid #6432ff !important; box-shadow: 0 0 40px rgba(100, 50, 255, 0.4); }
.theme-cosmic #game-area { box-shadow: inset 0 0 100px rgba(0, 200, 255, 0.1); }

/* SKIN-MATCHING GAME BORDERS */
.theme-gold #app-container {
    border-color: var(--neon-gold) !important;
    border-width: 3px !important;
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.4), 0 0 80px rgba(255, 215, 0, 0.15) !important;
    animation: gold-border-shimmer 3s ease-in-out infinite !important;
}

.theme-neon #app-container {
    border-color: var(--neon-blue) !important;
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.3);
}

.theme-glitch #app-container {
    border-color: #0f0 !important;
    animation: glitch-border 0.2s infinite;
}
.theme-glitch #game-area {
    box-shadow: inset 0 0 60px rgba(0,255,0,0.06);
}

/* --- TICKER --- */
.ticker { display: inline-block; padding-left: 100%; animation: ticker 30s linear infinite; white-space: nowrap; }
@keyframes ticker { 0% { transform: translate3d(0, 0, 0); } 100% { transform: translate3d(-100%, 0, 0); } }

/* --- TEXT EFFECTS --- */
.rainbow-text {
    background-image: linear-gradient(to right, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rainbow 4s linear infinite;
    background-size: 200% auto;
}
@keyframes rainbow { 100% { background-position: 200% center; } }

/* --- REUSABLE ANIMATIONS --- */
@keyframes spin-slow { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.animate-spin-slow { animation: spin-slow 4s linear infinite; }

/* S3: Chest-opening animation system */
@keyframes crateShake {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-10deg) scale(1.1); }
    75% { transform: rotate(10deg) scale(1.1); }
}
.animate-crate-shake { animation: crateShake 0.5s ease-in-out infinite; }

/* S3: Shake that builds in intensity over 1.2s */
@keyframes crate-shake-build {
    0%   { transform: translateX(0) rotate(0deg); }
    10%  { transform: translateX(-2px) rotate(-1deg); }
    20%  { transform: translateX(2px) rotate(1deg); }
    30%  { transform: translateX(-3px) rotate(-2deg); }
    40%  { transform: translateX(3px) rotate(2deg); }
    50%  { transform: translateX(-4px) rotate(-3deg); }
    60%  { transform: translateX(5px) rotate(3deg); }
    70%  { transform: translateX(-6px) rotate(-4deg); }
    80%  { transform: translateX(7px) rotate(4deg); }
    90%  { transform: translateX(-8px) rotate(-5deg); }
    100% { transform: translateX(0) rotate(0deg) scale(1.05); }
}
.animate-crate-shake-build { animation: crate-shake-build 1.2s ease-in forwards; }
.animate-crate-shake-build-fast { animation: crate-shake-build 0.6s ease-in forwards; }

/* S3: Lid flies open backward */
@keyframes crate-lid-open {
    0%   { transform: rotateX(0deg) translateY(0); }
    40%  { transform: rotateX(-80deg) translateY(-10px); }
    70%  { transform: rotateX(-110deg) translateY(-30px) scale(0.9); }
    100% { transform: rotateX(-130deg) translateY(-50px) scale(0.7); opacity: 0; }
}
.animate-lid-open { animation: crate-lid-open 0.5s ease-out forwards; }

/* S3: Light burst from inside chest */
@keyframes crate-light-burst {
    0%   { transform: scale(0); opacity: 0; }
    30%  { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(3); opacity: 0; }
}
.animate-light-burst { animation: crate-light-burst 0.6s ease-out forwards; }

/* S3: Light leaks from lid seam during buildup */
@keyframes crate-seam-glow {
    0%, 30% { opacity: 0; box-shadow: 0 0 0 transparent; }
    50%     { opacity: 0.4; box-shadow: 0 0 10px currentColor; }
    70%     { opacity: 0.7; box-shadow: 0 0 20px currentColor; }
    100%    { opacity: 1; box-shadow: 0 0 40px currentColor, 0 -10px 30px currentColor; }
}
.animate-seam-glow { animation: crate-seam-glow 1.2s ease-in forwards; }
.animate-seam-glow-fast { animation: crate-seam-glow 0.6s ease-in forwards; }

/* S3: Reward item rises from the open chest */
@keyframes crate-item-rise {
    0%   { transform: translateY(40px) scale(0.3); opacity: 0; }
    40%  { transform: translateY(-10px) scale(1.1); opacity: 1; }
    60%  { transform: translateY(-20px) scale(0.95); }
    100% { transform: translateY(-30px) scale(1); opacity: 1; }
}
.animate-item-rise { animation: crate-item-rise 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

/* S3: Particles scatter from chest opening */
@keyframes crate-particle {
    0%   { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--px, 30px), var(--py, -60px)) scale(0); opacity: 0; }
}
.animate-crate-particle { animation: crate-particle 0.8s ease-out forwards; }

@keyframes tease {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.2) rotate(10deg); opacity: 1; }
    80% { transform: scale(0.9) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}
.animate-tease { animation: tease 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

@keyframes fortniteDance {
    0%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-30px) rotate(-360deg) scale(1.1); }
    50% { transform: translateY(0) rotate(-180deg) scale(0.9); }
    75% { transform: translateY(-15px) rotate(180deg) scale(1.1); }
}
.animate-fortnite { animation: fortniteDance 0.8s infinite ease-in-out; }

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-50px) scale(1.5); opacity: 0; }
}
.animate-float-up { animation: floatUp 0.8s ease-out forwards; }

@keyframes heartbeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.1); }
    28% { transform: scale(1); }
    42% { transform: scale(1.1); }
    70% { transform: scale(1); }
}
.animate-heartbeat { animation: heartbeat 1.5s infinite ease-in-out; }

/* --- SCREEN SHAKE --- */
@keyframes shake-light {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

.shake-light { animation: shake-light 0.3s ease-in-out; }
.shake-heavy { animation: shake-heavy 0.5s ease-in-out; }

/* --- MEGA SPIN --- */
@keyframes gradient-x {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
.animate-gradient-x {
    background-size: 200% 200%;
    animation: gradient-x 3s ease infinite;
}

/* NEON WHEEL COLORS */
#wheel {
    background: conic-gradient(
        var(--neon-red) 0deg 90deg,
        var(--neon-gold) 90deg 180deg,
        var(--neon-blue) 180deg 270deg,
        #a855f7 270deg 360deg
    ) !important;
}

#modal-spin {
    z-index: 10001 !important;
}

/* Hide mega-spin for non-Pro users */
#mega-spin-btn {
    display: none !important;
}

body.is-pro #mega-spin-btn {
    display: flex !important;
    height: 80px !important;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 0 30px rgba(234,179,8,0.5), 0 0 60px rgba(168,85,247,0.3);
    animation: pulse 2s ease-in-out infinite, gradient-x 3s ease infinite;
}

body.is-pro #go-pro-btn {
    display: none !important;
}

body.is-pro #ad-banner {
    display: none !important;
}

/* --- AVATARS --- */
#unlocked-avatars-grid img {
    width: 44px !important;
    height: 44px !important;
    object-fit: cover;
    border-radius: 8px;
}

/* --- CONFETTI --- */
@keyframes confetti-fall {
    0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffd700;
    top: -10px;
    z-index: 300;
    pointer-events: none;
    animation: confetti-fall 3s linear forwards;
}

/* --- FRIEND BOMB ANIMATIONS --- */
@keyframes bomb-flash {
    0% { opacity: 0; }
    20% { opacity: 0.8; }
    100% { opacity: 0; }
}

@keyframes bomb-particle {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(
            calc(-50% + var(--end-x)), 
            calc(-50% + var(--end-y))
        ) scale(0);
        opacity: 0;
    }
}

@keyframes bomb-ring {
    0% {
        width: 20px;
        height: 20px;
        opacity: 1;
        border-width: 4px;
    }
    100% {
        width: 400px;
        height: 400px;
        opacity: 0;
        border-width: 1px;
    }
}

@keyframes bomb-emoji {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.5) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2) rotate(360deg);
        opacity: 0;
    }
}

/* ==========================================
   G1: PRE-ROUND INVENTORY SCREEN
   ========================================== */

.preround-item-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100px;
    padding: 14px 8px 10px;
    border-radius: 12px;
    border: 1px solid;
    background: rgba(255, 255, 255, 0.04);
    transition: border-color 0.2s, opacity 0.2s;
}

.preround-toggle {
    width: 52px;
    padding: 4px 0;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
    border: 2px solid;
    cursor: pointer;
    transition: all 0.15s;
    text-align: center;
}

.preround-toggle-on {
    color: #fff;
}

.preround-toggle-off {
    background: transparent;
    border-color: #555;
    color: #888;
}

.preround-toggle:disabled {
    cursor: not-allowed;
    border-color: #333;
    color: #444;
    background: transparent;
}

.preround-countdown-ring {
    display: block;
}