* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 50%, #0a0a2a 100%);
    font-family: 'Poppins', sans-serif;
    overflow-x: hidden;
    color: white;
}

/* Animated star background */
.stars, .twinkling {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.stars {
    background: 
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1px 1px at 230px 80px, #fff, transparent),
        radial-gradient(2px 2px at 300px 150px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 350px 200px, #fff, transparent),
        radial-gradient(2px 2px at 420px 50px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 500px 180px, #fff, transparent),
        radial-gradient(2px 2px at 580px 90px, rgba(255,255,255,0.9), transparent);
    background-repeat: repeat;
    background-size: 600px 300px;
    animation: twinkle 8s ease-in-out infinite;
}

.twinkling {
    background: 
        radial-gradient(3px 3px at 100px 200px, rgba(100, 200, 255, 0.8), transparent),
        radial-gradient(2px 2px at 250px 100px, rgba(255, 100, 200, 0.6), transparent),
        radial-gradient(3px 3px at 400px 250px, rgba(100, 255, 200, 0.7), transparent),
        radial-gradient(2px 2px at 550px 150px, rgba(255, 200, 100, 0.6), transparent);
    background-repeat: repeat;
    background-size: 700px 400px;
    animation: twinkle 12s ease-in-out infinite reverse;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 50px;
}

.title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 900;
    background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff, #ff6b6b);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 5s ease infinite;
    text-shadow: 0 0 30px rgba(255, 107, 107, 0.3);
    letter-spacing: 4px;
}

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

.subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 15px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    max-width: 1200px;
    width: 100%;
    padding: 0 20px;
}

/* Game Cards */
.game-card {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    padding: 30px;
    text-decoration: none;
    color: white;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.game-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
}

/* Card Glow Effect */
.card-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.game-card:hover .card-glow {
    opacity: 0.15;
}

/* Archer Card Glow */
.archer .card-glow {
    background: radial-gradient(circle, #ff6b35 0%, transparent 70%);
}
.archer {
    border-color: rgba(255, 107, 53, 0.3);
}
.archer:hover {
    border-color: rgba(255, 107, 53, 0.6);
    box-shadow: 0 30px 60px rgba(255, 107, 53, 0.2);
}

/* Geometry Card Glow */
.geometry .card-glow {
    background: radial-gradient(circle, #00d4ff 0%, transparent 70%);
}
.geometry {
    border-color: rgba(0, 212, 255, 0.3);
}
.geometry:hover {
    border-color: rgba(0, 212, 255, 0.6);
    box-shadow: 0 30px 60px rgba(0, 212, 255, 0.2);
}

/* Space Card Glow */
.space .card-glow {
    background: radial-gradient(circle, #a855f7 0%, transparent 70%);
}
.space {
    border-color: rgba(168, 85, 247, 0.3);
}
.space:hover {
    border-color: rgba(168, 85, 247, 0.6);
    box-shadow: 0 30px 60px rgba(168, 85, 247, 0.2);
}

/* Ice Sled Card Glow */
.ice-sled .card-glow {
    background: radial-gradient(circle, #87CEEB 0%, transparent 70%);
}
.ice-sled {
    border-color: rgba(135, 206, 235, 0.3);
}
.ice-sled:hover {
    border-color: rgba(135, 206, 235, 0.6);
    box-shadow: 0 30px 60px rgba(135, 206, 235, 0.2);
}

/* Ball Runner Card Glow */
.ball-runner .card-glow {
    background: radial-gradient(circle, #00ff00 0%, transparent 70%);
}
.ball-runner {
    border-color: rgba(0, 255, 0, 0.3);
}
.ball-runner:hover {
    border-color: rgba(0, 255, 0, 0.6);
    box-shadow: 0 30px 60px rgba(0, 255, 0, 0.2);
}

/* Castle Defense Card Glow */
.castle-defense .card-glow {
    background: radial-gradient(circle, #ffd700 0%, transparent 70%);
}
.castle-defense {
    border-color: rgba(255, 215, 0, 0.3);
}
.castle-defense:hover {
    border-color: rgba(255, 215, 0, 0.6);
    box-shadow: 0 30px 60px rgba(255, 215, 0, 0.2);
}

/* Square Dodge Card Glow */
.square-dodge .card-glow {
    background: radial-gradient(circle, #00ff00 0%, transparent 70%);
}
.square-dodge {
    border-color: rgba(0, 255, 0, 0.3);
}
.square-dodge:hover {
    border-color: rgba(0, 255, 0, 0.6);
    box-shadow: 0 30px 60px rgba(0, 255, 0, 0.2);
}

/* Trench Runner Card Glow */
.trench-runner .card-glow {
    background: radial-gradient(circle, #00aaff 0%, transparent 70%);
}
.trench-runner {
    border-color: rgba(0, 170, 255, 0.3);
}
.trench-runner:hover {
    border-color: rgba(0, 170, 255, 0.6);
    box-shadow: 0 30px 60px rgba(0, 170, 255, 0.2);
}

/* Math Academy Card */
.math-academy .card-glow {
    background: radial-gradient(circle, #7ed957 0%, transparent 70%);
}
.math-academy {
    border-color: rgba(126, 217, 87, 0.3);
}
.math-academy:hover {
    border-color: rgba(126, 217, 87, 0.6);
    box-shadow: 0 30px 60px rgba(126, 217, 87, 0.2);
}

/* Card Content */
.card-content {
    position: relative;
    z-index: 1;
}

.game-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
    filter: drop-shadow(0 0 20px rgba(255,255,255,0.3));
    animation: float 3s ease-in-out infinite;
}

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

.game-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.game-description {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
    margin-bottom: 20px;
}

/* Tags */
.game-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 25px;
}

.tag {
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.archer .tag {
    background: rgba(255, 107, 53, 0.2);
    border-color: rgba(255, 107, 53, 0.4);
}

.geometry .tag {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.4);
}

.space .tag {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.4);
}

.ice-sled .tag {
    background: rgba(135, 206, 235, 0.2);
    border-color: rgba(135, 206, 235, 0.4);
}

.ball-runner .tag {
    background: rgba(0, 255, 0, 0.2);
    border-color: rgba(0, 255, 0, 0.4);
}

.castle-defense .tag {
    background: rgba(255, 215, 0, 0.2);
    border-color: rgba(255, 215, 0, 0.4);
}

.square-dodge .tag {
    background: rgba(0, 255, 0, 0.2);
    border-color: rgba(0, 255, 0, 0.4);
}

.trench-runner .tag {
    background: rgba(0, 170, 255, 0.2);
    border-color: rgba(0, 170, 255, 0.4);
}

.math-academy .tag {
    background: rgba(126, 217, 87, 0.2);
    border-color: rgba(126, 217, 87, 0.4);
}


/* Play Button */
.play-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    border-radius: 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 2px;
    transition: all 0.3s ease;
}

.archer .play-button {
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
}

.geometry .play-button {
    background: linear-gradient(135deg, #00d4ff, #00a8cc);
}

.space .play-button {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
}

.ice-sled .play-button {
    background: linear-gradient(135deg, #87CEEB, #5DADE2);
}

.ball-runner .play-button {
    background: linear-gradient(135deg, #00ff00, #00aa00);
}

.castle-defense .play-button {
    background: linear-gradient(135deg, #ffd700, #ff9800);
}

.square-dodge .play-button {
    background: linear-gradient(135deg, #00ff00, #00cc00);
}


.game-card:hover .play-button {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.arrow-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.game-card:hover .arrow-icon {
    transform: translateX(5px);
}

/* Footer */
footer {
    margin-top: 50px;
    text-align: center;
}

footer p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    letter-spacing: 1px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Floating Particles */
.particle {
    position: fixed;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    pointer-events: none;
    animation: rise 5s ease-in infinite;
    z-index: 0;
}

@keyframes rise {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) scale(1);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .game-card {
        padding: 25px;
    }
    
    .game-icon {
        font-size: 3rem;
    }
    
    .title {
        letter-spacing: 2px;
    }
}

/* Hover sound effect indicator */
.game-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, currentColor, transparent);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.archer::after {
    background: linear-gradient(90deg, transparent, #ff6b35, transparent);
}

.geometry::after {
    background: linear-gradient(90deg, transparent, #00d4ff, transparent);
}

.space::after {
    background: linear-gradient(90deg, transparent, #a855f7, transparent);
}

.ice-sled::after {
    background: linear-gradient(90deg, transparent, #87CEEB, transparent);
}

.ball-runner::after {
    background: linear-gradient(90deg, transparent, #00ff00, transparent);
}

.castle-defense::after {
    background: linear-gradient(90deg, transparent, #ffd700, transparent);
}

.square-dodge::after {
    background: linear-gradient(90deg, transparent, #00ff00, transparent);
}

.trench-runner::after {
    background: linear-gradient(90deg, transparent, #00aaff, transparent);
}

.math-academy::after {
    background: linear-gradient(90deg, transparent, #7ed957, transparent);
}

.game-card:hover::after {
    transform: scaleX(1);
}

/* Math Challenge Gate */
.math-gate {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 50%, #0a0a2a 100%);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.math-gate.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.math-gate-content {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    padding: 50px;
    text-align: center;
    backdrop-filter: blur(15px);
    max-width: 500px;
    width: 90%;
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.math-gate-content.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-15px); }
    40% { transform: translateX(15px); }
    60% { transform: translateX(-10px); }
    80% { transform: translateX(10px); }
}

.math-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.math-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 900;
    background: linear-gradient(135deg, #ff6b6b, #ffd93d, #6bcb77, #4d96ff);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 5s ease infinite;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.math-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    margin-bottom: 30px;
}

.math-problem {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.math-problem span {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.math-input-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.math-input {
    width: 100%;
    max-width: 200px;
    padding: 15px 25px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    color: white;
    outline: none;
    transition: all 0.3s ease;
}

.math-input:focus {
    border-color: #4d96ff;
    box-shadow: 0 0 20px rgba(77, 150, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
}

.math-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-size: 1rem;
}

/* Remove number input spinners */
.math-input::-webkit-outer-spin-button,
.math-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.math-input[type=number] {
    -moz-appearance: textfield;
}

.math-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 35px;
    font-family: 'Orbitron', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: white;
    background: linear-gradient(135deg, #6bcb77, #4d96ff);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.math-submit:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(107, 203, 119, 0.3);
}

.math-submit:active {
    transform: scale(0.98);
}

.math-submit .arrow-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.math-submit:hover .arrow-icon {
    transform: translateX(5px);
}

.math-feedback {
    margin-top: 20px;
    font-size: 1.1rem;
    font-weight: 600;
    min-height: 30px;
    transition: all 0.3s ease;
}

.math-feedback.success {
    color: #6bcb77;
    text-shadow: 0 0 10px rgba(107, 203, 119, 0.5);
}

.math-feedback.error {
    color: #ff6b6b;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.math-hint {
    margin-top: 15px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
}

/* Arcade container initially hidden */
#arcade-container {
    opacity: 0;
    transition: opacity 0.5s ease;
}

#arcade-container.visible {
    opacity: 1;
}

@media (max-width: 500px) {
    .math-gate-content {
        padding: 30px 20px;
    }
    
    .math-problem {
        gap: 10px;
        padding: 15px;
    }
    
    .math-input {
        max-width: 150px;
    }
}
