/* ========================================
   FUTURISTIC UI COMPONENTS
   Arcade-Style Reusable Elements
   ======================================== */

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    font-family: var(--font-primary);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1rem 2.5rem;
    border: none;
    /* Removed standard radius for clip-path look */
    /* border-radius: var(--radius-md); */
    clip-path: polygon(15px 0,
            100% 0,
            100% calc(100% - 15px),
            calc(100% - 15px) 100%,
            0 100%,
            0 15px);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    color: #ffffff;
    border: 2px solid;
    min-width: 200px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

/* Primary Button */
.btn-primary {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.btn-primary:hover {
    background: rgba(0, 255, 255, 0.15);
    box-shadow:
        0 0 20px rgba(0, 255, 255, 0.6),
        0 0 40px rgba(0, 255, 255, 0.4),
        inset 0 0 20px rgba(0, 255, 255, 0.1);
    transform: translateY(-5px) scale(1.05);
}

/* Secondary Button */
.btn-secondary {
    border-color: var(--neon-magenta);
    color: var(--neon-magenta);
    box-shadow: 0 0 10px rgba(255, 0, 255, 0.3);
}

.btn-secondary:hover {
    background: rgba(255, 0, 255, 0.15);
    box-shadow:
        0 0 20px rgba(255, 0, 255, 0.6),
        0 0 40px rgba(255, 0, 255, 0.4),
        inset 0 0 20px rgba(255, 0, 255, 0.1);
    transform: translateY(-5px) scale(1.05);
}

/* Success Button */
.btn-success {
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 10px rgba(57, 255, 20, 0.3);
}

.btn-success:hover {
    background: rgba(57, 255, 20, 0.1);
    box-shadow: var(--shadow-glow-green);
    transform: translateY(-3px);
}

/* Danger Button */
.btn-danger {
    border-color: #ff3366;
    color: #ff3366;
    box-shadow: 0 0 10px rgba(255, 51, 102, 0.3);
}

.btn-danger:hover {
    background: rgba(255, 51, 102, 0.1);
    box-shadow: 0 0 20px rgba(255, 51, 102, 0.5);
    transform: translateY(-3px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Small Button */
.btn-sm {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    min-width: 120px;
}

/* Large Button */
.btn-lg {
    padding: 1.3rem 3rem;
    font-size: 1.3rem;
    min-width: 250px;
}

/* ========================================
   GAME CARDS
   ======================================== */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.game-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    /* border-radius: var(--radius-lg); */
    clip-path: polygon(20px 0,
            100% 0,
            100% calc(100% - 20px),
            calc(100% - 20px) 100%,
            0 100%,
            0 20px);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta), var(--neon-purple));
    /* border-radius: var(--radius-lg); */
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.game-card:hover::before {
    opacity: 1;
}

.game-card:hover {
    transform: translateY(-15px) scale(1.05);
    box-shadow:
        0 15px 50px rgba(0, 255, 255, 0.4),
        0 0 30px rgba(0, 255, 255, 0.3),
        inset 0 0 20px rgba(0, 255, 255, 0.05);
}

.game-card-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: var(--spacing-sm);
    filter: drop-shadow(0 0 10px currentColor);
}

.game-card-title {
    font-family: var(--font-primary);
    font-size: 1.3rem;
    text-align: center;
    color: var(--neon-cyan);
    margin-bottom: var(--spacing-xs);
}

.game-card-desc {
    font-size: 0.9rem;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

/* ========================================
   INPUT FIELDS
   ======================================== */
.input-group {
    margin-bottom: var(--spacing-md);
}

.input-label {
    display: block;
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--neon-cyan);
    margin-bottom: var(--spacing-xs);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-field {
    width: 100%;
    padding: 1rem 1.5rem;
    font-family: var(--font-body);
    font-size: 1.1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: #ffffff;
    transition: all 0.3s ease;
    outline: none;
}

.input-field::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.input-field:focus {
    border-color: var(--neon-cyan);
    box-shadow: var(--shadow-glow-cyan);
    background: rgba(0, 255, 255, 0.05);
}

/* ========================================
   PROGRESS BAR
   ======================================== */
.progress-container {
    margin: var(--spacing-lg) 0;
    margin-bottom: var(--spacing-xl);
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-primary);
    font-size: 1rem;
    color: var(--neon-cyan);
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    text-shadow:
        0 0 5px rgba(0, 255, 255, 0.8),
        0 0 10px rgba(0, 255, 255, 0.4);
    z-index: 10;
    position: relative;
}

.progress-bar-bg {
    width: 100%;
    height: 18px;
    background: rgba(10, 10, 26, 0.8);
    border: 2px solid rgba(0, 255, 255, 0.4);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow:
        inset 0 2px 8px rgba(0, 0, 0, 0.6),
        0 0 10px rgba(0, 255, 255, 0.2);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
    border-radius: 10px;
    transition: width 0.5s ease;
    box-shadow:
        0 0 20px rgba(0, 255, 255, 0.8),
        0 0 10px rgba(255, 0, 255, 0.6);
    position: relative;
    overflow: hidden;
}

.progress-bar-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

/* ========================================
   SCORE DISPLAY
   ======================================== */
.score-display {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 2px solid var(--neon-green);
    border-radius: var(--radius-lg);
    padding: 0.8rem 1.5rem;
    box-shadow: 0 0 15px rgba(57, 255, 20, 0.3);
}

.score-label {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--neon-green);
    text-transform: uppercase;
}

.score-value {
    font-family: var(--font-arcade);
    font-size: 1.5rem;
    color: var(--neon-green);
    text-shadow:
        0 0 10px rgba(57, 255, 20, 0.8),
        0 0 20px rgba(57, 255, 20, 0.6);
    animation: scorePulse 0.5s ease, scoreGlow 2s ease-in-out infinite;
}

@keyframes scoreGlow {

    0%,
    100% {
        text-shadow:
            0 0 10px rgba(57, 255, 20, 0.8),
            0 0 20px rgba(57, 255, 20, 0.6);
    }

    50% {
        text-shadow:
            0 0 15px rgba(57, 255, 20, 1),
            0 0 30px rgba(57, 255, 20, 0.8),
            0 0 45px rgba(57, 255, 20, 0.6);
    }
}

/* ========================================
   HUD (Heads-Up Display)
   ======================================== */
.hud {
    position: relative;
    width: 100%;
    padding: var(--spacing-md);
    background: transparent;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

.timer-display {
    font-family: var(--font-arcade);
    font-size: 2.5rem;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
    min-width: 80px;
    text-align: center;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from {
        text-shadow: 0 0 10px var(--neon-cyan);
    }

    to {
        text-shadow: 0 0 20px var(--neon-cyan), 0 0 30px var(--neon-cyan);
    }
}

.hud-left,
.hud-right {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.hud-button {
    background: var(--glass-bg);
    border: 2px solid var(--neon-cyan);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    color: var(--neon-cyan);
    font-family: var(--font-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    white-space: nowrap;
    min-width: auto;
}

.hud-button:hover {
    background: rgba(0, 255, 255, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

.player-name-display {
    font-family: var(--font-primary);
    color: var(--neon-magenta);
    font-size: 1rem;
    text-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
}

/* ========================================
   OPTION BUTTONS (Multiple Choice)
   ======================================== */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.option-btn {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.option-btn:hover {
    border-color: var(--neon-cyan);
    background: rgba(0, 255, 255, 0.1);
    transform: translateY(-5px) scale(1.02);
    box-shadow:
        0 8px 25px rgba(0, 255, 255, 0.4),
        0 0 20px rgba(0, 255, 255, 0.3),
        inset 0 0 15px rgba(0, 255, 255, 0.05);
}

.option-btn.correct {
    border-color: var(--neon-green);
    background: rgba(57, 255, 20, 0.1);
    box-shadow: var(--shadow-glow-green);
    animation: correctPulse 0.6s ease;
}

.option-btn.wrong {
    border-color: #ff3366;
    background: rgba(255, 51, 102, 0.1);
    box-shadow: 0 0 20px rgba(255, 51, 102, 0.5);
    animation: shake 0.5s ease;
}

.option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* ========================================
   LOGO
   ======================================== */
.logo-container {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.logo {
    max-width: 300px;
    height: auto;
    filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.5));
    animation: logoFloat 3s ease-in-out infinite;
}

/* ========================================
   LEVEL SELECTOR
   ======================================== */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.level-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 2px solid;
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.level-card.easy {
    border-color: var(--neon-green);
}

.level-card.medium {
    border-color: var(--neon-orange);
}

.level-card.hard {
    border-color: #ff3366;
}

.level-card:hover {
    transform: translateY(-8px) scale(1.05);
}

.level-card.easy:hover {
    box-shadow: var(--shadow-glow-green);
}

.level-card.medium:hover {
    box-shadow: 0 0 20px rgba(255, 102, 0, 0.5);
}

.level-card.hard:hover {
    box-shadow: 0 0 20px rgba(255, 51, 102, 0.5);
}

.level-title {
    font-family: var(--font-primary);
    font-size: 1.5rem;
    margin-bottom: var(--spacing-xs);
}

.level-desc {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

/* ========================================
   STATS DISPLAY
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    text-align: center;
}

.stat-label {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: var(--spacing-xs);
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--font-arcade);
    font-size: 2rem;
    color: var(--neon-cyan);
    text-shadow: var(--shadow-glow-cyan);
}

/* ========================================
   LEADERBOARD TABLE
   ======================================== */
.leaderboard-table {
    width: 100%;
    margin: var(--spacing-lg) 0;
    border-collapse: separate;
    border-spacing: 0 var(--spacing-xs);
}

.leaderboard-table thead th {
    font-family: var(--font-primary);
    font-size: 0.9rem;
    color: var(--neon-cyan);
    text-align: left;
    padding: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.leaderboard-table tbody tr {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.leaderboard-table tbody tr:hover {
    background: rgba(0, 255, 255, 0.05);
    border-color: var(--neon-cyan);
}

.leaderboard-table tbody tr.current-player {
    border: 2px solid var(--neon-magenta);
    box-shadow: var(--shadow-glow-magenta);
}

.leaderboard-table tbody td {
    padding: var(--spacing-sm);
    font-family: var(--font-body);
    color: #ffffff;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta));
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 0.9rem;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 768px) {
    .btn {
        padding: 0.8rem 1.5rem;
        font-size: 1rem;
        min-width: 150px;
    }

    .game-grid {
        grid-template-columns: 1fr;
    }

    .hud {
        flex-direction: column;
        gap: var(--spacing-sm);
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   LOADING SPINNER
   ======================================== */
.loading-spinner {
    width: 60px;
    height: 60px;
    margin: 2rem auto;
    border: 4px solid rgba(0, 255, 255, 0.1);
    border-top: 4px solid var(--neon-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow:
        0 0 20px rgba(0, 255, 255, 0.5),
        inset 0 0 20px rgba(0, 255, 255, 0.2);
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ========================================
   CUSTOM MODAL (Glassmorphism)
   ======================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    /* Darker dim */
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 2px solid var(--neon-magenta);
    box-shadow: 0 0 50px rgba(255, 0, 255, 0.4);
    border-radius: var(--radius-lg);
    padding: 3rem;
    text-align: center;
    max-width: 500px;
    width: 90%;
    animation: zoomIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.modal-content h3 {
    font-family: var(--font-primary);
    font-size: 2rem;
    color: var(--neon-cyan);
    margin-bottom: 1rem;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.modal-content p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* ========================================
   AVATAR
   ======================================== */
.avatar-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 150px;
    height: auto;
    z-index: 1000;
    pointer-events: none;
    /* Let clicks pass through if needed */
    transition: all 0.5s ease;
    /* filter: drop-shadow(0 0 15px rgba(0, 255, 255, 0.3)); Removed for cleaner look */
}

.avatar-container.hidden {
    opacity: 0;
    transform: translateY(20px);
}

.avatar-container img {
    width: 100%;
    height: auto;
    display: block;
    animation: avatarFloat 3s ease-in-out infinite;
}

@keyframes avatarFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ========================================
   ASTEROID BUTTON + ASTEROID
   ======================================== */
.asteroid-button {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 9300;
    padding: 0.6rem 1rem;
    min-width: auto;
    font-size: 0.9rem;
}

.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9300;
    padding: 0.6rem 1rem;
    min-width: auto;
    font-size: 0.9rem;
}

.asteroid {
    position: fixed;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #6f6f6f, #3a3a3a 60%, #1f1f1f 100%);
    box-shadow:
        inset -8px -8px 16px rgba(0, 0, 0, 0.6),
        inset 6px 6px 12px rgba(255, 255, 255, 0.1),
        0 0 18px rgba(255, 153, 51, 0.35);
    cursor: pointer;
    z-index: 9200;
    animation: asteroidFloat 3s ease-in-out infinite;
    transform-origin: center;
}

.asteroid::before,
.asteroid::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.8));
    opacity: 0.7;
}

.asteroid::before {
    width: 14px;
    height: 14px;
    top: 18px;
    left: 14px;
}

.asteroid::after {
    width: 10px;
    height: 10px;
    bottom: 16px;
    right: 18px;
}

.asteroid-explode {
    animation: asteroidPop 0.35s ease-out forwards;
}

.asteroid-blast {
    position: fixed;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid rgba(255, 140, 0, 0.9);
    box-shadow:
        0 0 20px rgba(255, 140, 0, 0.8),
        0 0 40px rgba(255, 80, 0, 0.6);
    transform: translate(-50%, -50%);
    z-index: 9100;
    animation: asteroidBlast 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes asteroidFloat {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-8px) rotate(180deg);
    }

    100% {
        transform: translateY(0) rotate(360deg);
    }
}

@keyframes asteroidPop {
    0% {
        transform: scale(1);
        opacity: 1;
        filter: brightness(1);
    }

    80% {
        transform: scale(1.2);
        opacity: 0.6;
        filter: brightness(1.5);
    }

    100% {
        transform: scale(0.3);
        opacity: 0;
        filter: brightness(2);
    }
}

@keyframes asteroidBlast {
    0% {
        transform: translate(-50%, -50%) scale(0.4);
        opacity: 1;
    }

    70% {
        transform: translate(-50%, -50%) scale(6);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(9);
        opacity: 0;
    }
}

/* Interaction Animations */
.avatar-correct {
    animation: avatarHappy 0.5s ease !important;
    /* Override float */
    filter: drop-shadow(0 0 20px rgba(57, 255, 20, 0.8));
}

.avatar-wrong {
    animation: avatarShock 0.5s ease !important;
    /* Override float */
    filter: drop-shadow(0 0 20px rgba(255, 51, 102, 0.8));
}

@keyframes avatarHappy {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2) rotate(-5deg);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes avatarShock {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px) rotate(-5deg);
    }

    50% {
        transform: translateX(10px) rotate(5deg);
    }

    75% {
        transform: translateX(-10px) rotate(-5deg);
    }

    100% {
        transform: translateX(0);
    }
}

.avatar-timeup {
    animation: avatarPulse 0.2s ease infinite !important;
    filter: drop-shadow(0 0 20px rgba(255, 0, 0, 0.8));
}

@keyframes avatarPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Mobile Adjustments for Avatar */
@media (max-width: 768px) {
    .avatar-container {
        width: 100px;
        bottom: 80px;
        /* moved up to avoid overlapping bottom nav if any */
        right: 10px;
    }
}