/* Modern Games Platform - Dark Theme */

/* Prevent iOS scroll on game canvas */
html, body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
}

/* Lock body when game is active */
body.game-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

canvas {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Game container - prevent scroll */
.game-container {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: contain;
}

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-hover: #1f4068;
    --accent-primary: #e94560;
    --accent-secondary: #0f3460;
    --accent-glow: #e94560;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #6c757d;
    --success: #00d9ff;
    --warning: #ffd700;
    --danger: #ff4757;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(233, 69, 96, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 80%, rgba(233, 69, 96, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(15, 52, 96, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(0, 217, 255, 0.05) 0%, transparent 40%);
    pointer-events: none;
    z-index: -1;
}

/* Header */
header {
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin-bottom: 1rem;
    letter-spacing: -0.5px;
}

/* Navigation */
nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    font-weight: 500;
    position: relative;
    overflow: hidden;
}

nav a::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent-primary), transparent);
    opacity: 0;
    transition: var(--transition);
    z-index: -1;
}

nav a:hover,
nav a.active {
    color: var(--text-primary);
    transform: translateY(-2px);
}

nav a:hover::before,
nav a.active::before {
    opacity: 0.2;
}

nav a.active {
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

/* Main Content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 2rem;
    margin-bottom: 3rem;
}

.hero h2 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text-primary), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
    margin: 3rem 0;
}

/* Game Cards */
.game-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 2rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.1), transparent);
    opacity: 0;
    transition: var(--transition);
}

.game-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-glow);
    border-color: var(--accent-primary);
}

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

.game-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

.game-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.game-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.game-card .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, var(--accent-primary), #ff6b6b);
    color: white;
    padding: 0.875rem 2rem;
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.game-card .btn::after {
    content: '→';
    transition: var(--transition);
}

.game-card .btn:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
}

.game-card .btn:hover::after {
    transform: translateX(4px);
}

/* Game Container */
.game-container {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    margin: 2rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow);
    touch-action: none;
    -webkit-touch-callout: none;
}

.game-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.game-header h2 {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--success));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Score Display */
.score-display {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.score-item {
    text-align: center;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.score-item .label {
    display: block;
    color: var(--text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.score-item .value {
    display: block;
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent-primary);
}

/* Canvas */
canvas {
    display: block;
    margin: 0 auto;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    background: #0a0a0a;
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.game-controls button {
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-start {
    background: linear-gradient(135deg, var(--success), #00a8cc);
    color: white;
}

.btn-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 217, 255, 0.4);
}

.btn-pause {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-pause:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Instructions */
.instructions {
    background: var(--bg-secondary);
    border-radius: var(--border-radius-sm);
    padding: 1.5rem;
    margin-top: 2rem;
}

.instructions h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.instructions ul {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.instructions li {
    color: var(--text-secondary);
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Leaderboard */
.leaderboard-section {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 2.5rem;
    margin: 3rem 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-section h2 {
    text-align: center;
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 1rem 1.5rem;
    text-align: left;
}

.leaderboard-table th {
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 1px;
}

.leaderboard-table tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: var(--transition);
}

.leaderboard-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.leaderboard-table td {
    color: var(--text-secondary);
}

.rank-1 { color: #ffd700; font-weight: 700; }
.rank-2 { color: #c0c0c0; font-weight: 700; }
.rank-3 { color: #cd7f32; font-weight: 700; }

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: var(--border-radius);
    max-width: 450px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-glow);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h3 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--accent-primary);
}

.modal-content .final-score {
    font-size: 3rem;
    font-weight: 800;
    color: var(--success);
    display: block;
    margin: 1rem 0;
}

.modal-content input {
    width: 100%;
    padding: 1rem;
    margin: 1.5rem 0;
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: var(--transition);
}

.modal-content input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}

.modal-content button {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--accent-primary), #ff6b6b);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
}

.modal-content button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(233, 69, 96, 0.4);
}

/* Footer */
footer {
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
}

footer a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: var(--transition);
}

footer a:hover {
    color: var(--success);
}

/* Loading State */
.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Game Over Overlay */
.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 15, 26, 0.95);
    padding: 3rem;
    border-radius: var(--border-radius);
    text-align: center;
    border: 1px solid var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

/* Responsive */
@media (max-width: 768px) {
    .hero h2 {
        font-size: 2rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .score-display {
        gap: 1rem;
    }
    
    .score-item {
        padding: 0.75rem 1.5rem;
    }
    
    canvas {
        max-width: 100%;
        height: auto;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .game-controls button {
        width: 100%;
        max-width: 300px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Selection */
::selection {
    background: var(--accent-primary);
    color: white;
}
