:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(30, 30, 45, 0.6);
    --purple-primary: #8b5cf6;
    --purple-light: #a78bfa;
    --purple-dark: #6d28d9;
    --purple-glow: rgba(139, 92, 246, 0.4);
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(139, 92, 246, 0.2);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    user-select: none;
}

/* Backgrounds */
.bg-gradient {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.grid-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: 
        linear-gradient(rgba(139, 92, 246, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(139, 92, 246, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 1;
}

#confettiCanvas {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* Layout */
.container {
    position: relative;
    z-index: 10;
    max-width: 1200px;
    margin: 0 auto;
    padding: 80px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}
.view.active { display: block; }

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

/* Typography */
h1, h2, h3 { font-family: 'Space Grotesk', sans-serif; }

.hero-title {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    background: linear-gradient(135deg, white, var(--purple-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: center;
}

.hero-subtitle {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 40px;
    font-size: 1.1rem;
}

/* UI Elements */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 30px;
    max-width: 400px;
    margin: 0 auto;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
}

.input-group { margin-bottom: 15px; }
.input-label { display: block; margin-bottom: 8px; font-size: 0.85rem; color: var(--text-muted); }
.input-field {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: 0.3s;
    text-align: center;
}
.input-field:focus {
    border-color: var(--purple-primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--purple-primary), var(--purple-dark));
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.2s;
    margin-bottom: 10px;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(139, 92, 246, 0.4); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary { background: rgba(255,255,255,0.05); border: 1px solid var(--border); }
.btn-secondary:hover { background: rgba(255,255,255,0.1); }

.code-display {
    background: #000;
    padding: 15px;
    border-radius: 12px;
    font-family: monospace;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-cyan);
    letter-spacing: 2px;
    margin: 15px 0;
    cursor: pointer;
    border: 1px dashed var(--border);
}

/* Game Board */
.game-ui {
    max-width: 500px;
    margin: 0 auto;
}

.score-board {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.player-score {
    text-align: center;
    width: 45%;
    padding: 10px;
    border-radius: 12px;
    transition: 0.3s;
}
.player-score.active { background: rgba(139, 92, 246, 0.1); border: 1px solid var(--purple-primary); }

.score-val { font-size: 1.5rem; font-weight: bold; margin-top: 5px; }

.game-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.cell {
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}
.cell:hover:not(.taken) { background: rgba(255,255,255,0.05); }
.cell.x { color: var(--purple-light); }
.cell.o { color: var(--accent-cyan); }
.cell.win { background: rgba(16, 185, 129, 0.2); border-color: var(--success); }

/* Status Bar */
.status-bar {
    text-align: center;
    padding: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

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

.result-modal {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 20px;
    border: 1px solid var(--purple-primary);
    text-align: center;
    max-width: 90%;
    width: 350px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.9rem;
    transition: 0.3s;
    z-index: 3000;
}
.toast.active { transform: translateX(-50%) translateY(0); }
