:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --x-color: #38bdf8;
    --o-color: #fb7185;
    --cell-size: 100px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Header & Logo */
header {
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-logo {
    height: 50px;
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

/* Screens */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    transition: all 0.3s ease;
}

.hidden {
    display: none !important;
}

/* Lobby */
h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    width: 100%;
    max-width: 600px;
    margin-bottom: 2.5rem;
}

.mode-card {
    background: var(--surface);
    border: 2px solid transparent;
    padding: 1.5rem;
    border-radius: 1rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
}

.mode-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.mode-card.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.mode-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.mode-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-box {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input {
    padding: 1rem;
    border-radius: 0.75rem;
    border: none;
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    outline: none;
    border: 2px solid transparent;
}

input:focus {
    border-color: var(--primary);
}

button {
    padding: 1rem;
    border-radius: 0.75rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary-btn {
    background: var(--primary);
    color: white;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--text-muted);
    color: var(--text);
}

/* Game Board */
.board {
    display: grid;
    grid-template-columns: repeat(3, var(--cell-size));
    grid-template-rows: repeat(3, var(--cell-size));
    gap: 10px;
    position: relative;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    margin: 2rem 0;
}

.cell {
    background: var(--surface);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cell:hover {
    background: rgba(255, 255, 255, 0.1);
}

.cell[data-symbol="X"] { color: var(--x-color); }
.cell[data-symbol="O"] { color: var(--o-color); }

.board-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    background-image: url('img/logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.05;
    pointer-events: none;
}

/* Matchmaking Loader */
.loader {
    width: 48px;
    height: 48px;
    border: 5px solid var(--text-muted);
    border-bottom-color: var(--primary);
    border-radius: 50%;
    animation: rotation 1s linear infinite;
    margin-bottom: 2rem;
}

@keyframes rotation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.screen.active {
    animation: fadeIn 0.5s ease forwards;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: var(--surface);
    padding: 2.5rem;
    border-radius: 1.5rem;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-content h2 { margin-bottom: 1rem; }
.modal-content p { color: var(--text-muted); margin-bottom: 2rem; }
.modal-content button { width: 100%; margin-bottom: 0.5rem; }

@media (max-width: 480px) {
    :root {
        --cell-size: 80px;
    }
    h1 { font-size: 2rem; }
}
