:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-color: #f8fafc;
    --accent-color: #38bdf8;
    --accent-glow: rgba(56, 189, 248, 0.5);
    --secondary-accent: #c084fc;
    --font-main: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.1) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(192, 132, 252, 0.1) 0%, transparent 20%);
}

header {
    padding: 2rem;
    text-align: center;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--accent-color), var(--secondary-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 20px var(--accent-glow);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #94a3b8;
    font-size: 1.1rem;
}

main {
    flex: 1;
    padding: 3rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.game-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.03), transparent);
    transform: translateX(-100%);
    transition: 0.5s;
}

.game-card:hover {
    transform: translateY(-5px) scale(1.02);
    border-color: var(--accent-color);
    box-shadow: 0 10px 30px -10px var(--accent-glow);
}

.game-card:hover::before {
    transform: translateX(100%);
}

.game-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    transition: transform 0.3s ease;
}

.game-card:hover .game-icon {
    transform: scale(1.1) rotate(5deg);
}

.game-card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.game-title {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.5rem;
}

.game-score {
    font-size: 0.9rem;
    color: var(--accent-color);
    background: rgba(56, 189, 248, 0.1);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    border: 1px solid rgba(56, 189, 248, 0.2);
}

/* In-game High Score Display */
.highscore-display {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 1.2rem;
    color: var(--accent-color);
    font-weight: 600;
    background: rgba(15, 23, 42, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}

/* Custom Modal Styles */
.game-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.game-modal-content {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    padding: 2rem;
    border: 2px solid var(--accent-color);
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 0 30px var(--accent-glow);
    max-width: 400px;
    width: 90%;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.game-modal h2 {
    color: var(--accent-color);
    margin-bottom: 1rem;
    font-size: 2rem;
    text-shadow: 0 0 10px var(--accent-glow);
}

.game-modal p {
    color: #e2e8f0;
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

.game-modal button {
    background: var(--accent-color);
    color: #0f172a;
    border: none;
    padding: 10px 30px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-modal button:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* Back Button Styles for Game Pages */
.back-button {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: rgba(15, 23, 42, 0.8);
    color: var(--text-color);
    text-decoration: none;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    z-index: 1000;
}

.back-button:hover {
    background: var(--accent-color);
    color: #0f172a;
    border-color: var(--accent-color);
    transform: translateX(-3px);
}

/* Game Container */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

canvas {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
    max-width: 100%;
    touch-action: none;
    /* Prevent zoom/scroll on all game canvases */
}

.game-ui {
    margin-top: 1rem;
    text-align: center;
}

button {
    background: var(--accent-color);
    color: #0f172a;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    touch-action: manipulation;
    /* Prevent double-tap zoom */
}

button:hover {
    background: #7dd3fc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {

    /* Reduce overall spacing for better mobile fit */
    .game-container {
        padding: 0.5rem;
        min-height: 100vh;
        justify-content: flex-start;
    }

    /* Compact header for games */
    h1 {
        font-size: 1.8rem;
        margin: 0.5rem 0;
    }

    /* Reduce back button size */
    .back-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
        top: 0.5rem;
        left: 0.5rem;
    }

    /* Compact high score display */
    .highscore-display {
        font-size: 0.9rem;
        margin: 0.3rem 0;
    }

    /* Reduce game UI spacing */
    .game-ui {
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .game-ui p {
        font-size: 0.9rem;
        margin: 0.3rem 0;
    }

    /* Compact buttons */
    button {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }

    .game-grid {
        font-size: 0.9rem;
    }

    /* Canvas Scaling */
    canvas {
        max-width: 100%;
        height: auto !important;
    }

    /* Whack-a-Mole Responsive */
    .hole {
        width: 120px !important;
        height: 120px !important;
        margin: 0 auto;
    }

    /* Memory Match Responsive */
    .memory-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 5px !important;
        max-width: 100%;
    }

    .memory-card {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1;
    }

    .front-face,
    .back-face {
        font-size: 1.5rem !important;
    }

    /* RPS Responsive */
    .choices {
        gap: 1rem !important;
    }

    .choice-btn {
        width: 80px !important;
        height: 80px !important;
        font-size: 2rem !important;
    }

    /* Clicker Responsive */
    .main-button {
        width: 150px !important;
        height: 150px !important;
        font-size: 3rem !important;
    }
}