/* ═══════════════════════════════════════════════════════════════════════════════
   PlayVersusAI - Global Styles
   ═══════════════════════════════════════════════════════════════════════════════ */

:root {
    /* Colors */
    --bg-dark: #060912;
    --bg-mid: #0d1322;
    --bg-light: #141c2e;
    --panel-bg: #0c1220;
    --panel-border: #2a3a5a;
    
    --primary: #53a6f5;
    --primary-glow: rgba(83, 166, 245, 0.3);
    --secondary: #7ad8ff;
    --accent: #faca52;
    --accent-glow: rgba(250, 202, 82, 0.3);
    
    --red: #e82b42;
    --yellow: #fabe31;
    --green: #4ade80;
    
    --text: #eaf4ff;
    --text-muted: #78929c;
    --text-dim: #4a5a6a;
    
    /* Board colors */
    --board-face: #102d6c;
    --board-lit: #3d77ce;
    --board-dark: #040e24;
    
    /* Mancala colors */
    --wood-dark: #3e2612;
    --wood-mid: #623e1e;
    --wood-light: #8a5c2e;
    
    /* Spacing */
    --nav-height: 64px;
    --container-width: 1200px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--bg-mid) 50%, var(--bg-dark) 100%);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Typography
   ═══════════════════════════════════════════════════════════════════════════════ */

h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.2;
}

h1 { font-size: 3rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Layout
   ═══════════════════════════════════════════════════════════════════════════════ */

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Navigation
   ═══════════════════════════════════════════════════════════════════════════════ */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(6, 9, 18, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--panel-border);
    z-index: 1000;
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

.navbar-brand svg {
    width: 32px;
    height: 32px;
}

.navbar-brand span {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 32px;
    list-style: none;
}

.navbar-nav a {
    color: var(--text-muted);
    font-weight: 500;
    transition: color var(--transition-fast);
}

.navbar-nav a:hover,
.navbar-nav a.active {
    color: var(--text);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #3d8ae8);
    color: white;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--primary-glow);
}

.btn-secondary {
    background: var(--panel-bg);
    color: var(--text);
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: var(--bg-light);
    border-color: var(--primary);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #e8a020);
    color: #1a1a1a;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--accent-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 8px 16px;
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1.125rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Hero Section
   ═══════════════════════════════════════════════════════════════════════════════ */

.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: calc(var(--nav-height) + 40px) 24px 80px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
    opacity: 0.4;
    pointer-events: none;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(83, 166, 245, 0.1);
    border: 1px solid rgba(83, 166, 245, 0.3);
    border-radius: 100px;
    font-size: 0.875rem;
    color: var(--primary);
    margin-bottom: 24px;
}

.hero h1 {
    font-size: 4rem;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--text) 0%, var(--primary) 50%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 40px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-buttons {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Game Cards
   ═══════════════════════════════════════════════════════════════════════════════ */

.games-section {
    padding: 80px 0;
}

.section-header {
    text-align: center;
    margin-bottom: 48px;
}

.section-header h2 {
    margin-bottom: 16px;
}

.section-header p {
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 32px;
    max-width: 900px;
    margin: 0 auto;
}

.game-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 24px;
    transition: all var(--transition-normal);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.game-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.game-card:hover::before {
    opacity: 1;
}

.game-card-preview {
    aspect-ratio: 16/10;
    background: var(--bg-dark);
    border-radius: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.game-card-preview canvas {
    width: 100%;
    height: 100%;
}

.game-card h3 {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.game-card h3 .badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    background: var(--accent);
    color: #1a1a1a;
    border-radius: 6px;
    font-weight: 600;
}

.game-card p {
    color: var(--text-muted);
    font-size: 0.9375rem;
    margin-bottom: 20px;
}

.game-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.game-card-stats {
    display: flex;
    gap: 16px;
    font-size: 0.875rem;
    color: var(--text-dim);
}

.game-card-stats span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Leaderboard Preview
   ═══════════════════════════════════════════════════════════════════════════════ */

.leaderboard-section {
    padding: 80px 0;
    background: linear-gradient(180deg, transparent 0%, rgba(83, 166, 245, 0.03) 50%, transparent 100%);
}

.leaderboard-preview {
    max-width: 600px;
    margin: 0 auto;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    overflow: hidden;
}

.leaderboard-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(83, 166, 245, 0.1), rgba(122, 216, 255, 0.05));
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.leaderboard-header h3 {
    display: flex;
    align-items: center;
    gap: 12px;
}

.leaderboard-list {
    list-style: none;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background var(--transition-fast);
}

.leaderboard-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border-radius: 12px;
    margin-right: 16px;
}

.leaderboard-rank.gold {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #1a1a1a;
}

.leaderboard-rank.silver {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #1a1a1a;
}

.leaderboard-rank.bronze {
    background: linear-gradient(135deg, #cd7f32, #a05a2c);
    color: white;
}

.leaderboard-rank.normal {
    background: var(--bg-light);
    color: var(--text-muted);
}

.leaderboard-player {
    flex: 1;
}

.leaderboard-player-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.leaderboard-player-games {
    font-size: 0.8125rem;
    color: var(--text-dim);
}

.leaderboard-wins {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--accent);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Features Section
   ═══════════════════════════════════════════════════════════════════════════════ */

.features-section {
    padding: 80px 0;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.feature-card {
    padding: 32px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    text-align: center;
    transition: all var(--transition-normal);
}

.feature-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
}

.feature-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary-glow), rgba(122, 216, 255, 0.1));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.feature-card h4 {
    margin-bottom: 12px;
}

.feature-card p {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Auth Modal
   ═══════════════════════════════════════════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    transform: translateY(20px);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    text-align: center;
    margin-bottom: 32px;
}

.modal-header h2 {
    margin-bottom: 8px;
}

.modal-header p {
    color: var(--text-muted);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 10px;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════════════════════════════════════════ */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem;
    transition: all var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-control::placeholder {
    color: var(--text-dim);
}

.form-footer {
    margin-top: 24px;
}

.form-footer .btn {
    width: 100%;
}

.form-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
}

.form-switch a {
    color: var(--primary);
    font-weight: 500;
}

.form-error {
    color: var(--red);
    font-size: 0.875rem;
    margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════════════════════════════════════════ */

.footer {
    padding: 48px 0 24px;
    border-top: 1px solid var(--panel-border);
    background: var(--bg-dark);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.footer-links {
    display: flex;
    gap: 24px;
    list-style: none;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.footer-links a:hover {
    color: var(--text);
}

.footer-copyright {
    width: 100%;
    text-align: center;
    padding-top: 24px;
    margin-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    font-size: 0.875rem;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Utilities
   ═══════════════════════════════════════════════════════════════════════════════ */

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-primary { color: var(--primary); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════════
   Animations
   ═══════════════════════════════════════════════════════════════════════════════ */

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px var(--primary-glow); }
    50% { box-shadow: 0 0 40px var(--primary-glow); }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .navbar-nav {
        display: none;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Game Page Specific
   ═══════════════════════════════════════════════════════════════════════════════ */

.game-page {
    min-height: 100vh;
    padding-top: var(--nav-height);
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 24px;
    gap: 24px;
}

.game-header {
    text-align: center;
}

.game-header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
}

.game-canvas-wrapper {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.game-canvas {
    display: block;
    border-radius: 16px;
}

.game-controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

.game-status {
    text-align: center;
    padding: 16px 32px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
}

.game-status-text {
    font-size: 1.125rem;
    font-weight: 600;
}

.game-status.thinking .game-status-text {
    color: var(--accent);
}

.game-status.win .game-status-text {
    color: var(--green);
}

.game-status.lose .game-status-text {
    color: var(--red);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   Replay Controls
   ═══════════════════════════════════════════════════════════════════════════════ */

.replay-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
}

.replay-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.replay-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.replay-progress {
    flex: 1;
    height: 8px;
    background: var(--bg-dark);
    border-radius: 4px;
    overflow: hidden;
}

.replay-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: width 0.1s linear;
}

.replay-speed {
    display: flex;
    gap: 8px;
}

.replay-speed button {
    padding: 6px 12px;
    background: var(--bg-light);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.replay-speed button.active,
.replay-speed button:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   User Profile
   ═══════════════════════════════════════════════════════════════════════════════ */

.profile-header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 32px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    margin-bottom: 32px;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
}

.profile-info h1 {
    font-size: 1.75rem;
    margin-bottom: 4px;
}

.profile-info p {
    color: var(--text-muted);
}

.profile-stats {
    display: flex;
    gap: 32px;
    margin-left: auto;
}

.profile-stat {
    text-align: center;
}

.profile-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.profile-stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 3000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-color: var(--green);
}

.toast.error {
    border-color: var(--red);
}
