:root {
    /* Color Palette - Dark Theme (Default) */
    --bg-gradient-1: #0f2027;
    --bg-gradient-2: #203a43;
    --bg-gradient-3: #2c5364;

    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;

    --accent-color: #00d4ff;
    /* Neon Blue */
    --accent-glow: 0 0 10px #00d4ff, 0 0 20px #00d4ff;

    --player-x-color: #ff0055;
    /* Neon Red */
    --player-x-glow: 0 0 15px #ff0055;

    --player-o-color: #00ffaa;
    /* Neon Green */
    --player-o-glow: 0 0 15px #00ffaa;

    --font-main: 'Outfit', sans-serif;

    --cell-size: 100px;
    --gap-size: 15px;
}

[data-theme="light"] {
    --bg-gradient-1: #e0eafc;
    --bg-gradient-2: #cfdef3;
    --bg-gradient-3: #ffffff;

    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);

    --text-primary: #1a1a1a;
    --text-secondary: #555555;

    --accent-color: #4a90e2;
    --accent-glow: none;

    --player-x-color: #ff3b30;
    --player-x-glow: none;

    --player-o-color: #34c759;
    --player-o-glow: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2), var(--bg-gradient-3));
    height: 100vh;
    overflow: hidden;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.5s ease;
}

.app-container {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* Glassmorphism Logic */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    padding: 30px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.glass-panel-sm {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 15px;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    font-size: 1.5rem;
    font-weight: 800;
}

.accent {
    color: var(--accent-color);
    text-shadow: var(--accent-glow);
}

.theme-toggle {
    cursor: pointer;
    font-size: 1.2rem;
    padding: 10px;
    border-radius: 50%;
    transition: background 0.3s;
}

.theme-toggle:hover {
    background: var(--glass-bg);
}

/* Screens */
.screen {
    position: absolute;
    top: 58%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    max-width: 400px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s ease;
}

.screen.active-screen {
    opacity: 1;
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.title-lg {
    font-size: 2.5rem;
    margin-bottom: 30px;
    font-weight: 800;
}

.title-md {
    font-size: 2rem;
    margin-bottom: 20px;
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent-color);
    color: #fff;
    border: none;
}

.btn-text {
    background: transparent;
    border: none;
    box-shadow: none;
    width: auto;
    margin: 20px auto 0;
    color: var(--text-secondary);
}

.btn-text:hover {
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

.btn-icon {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
}

/* Board */
.game-board-container {
    position: relative;
    margin: 30px auto;
    width: fit-content;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap-size);
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.cell:hover:not(.taken) {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.cell.x {
    color: var(--player-x-color);
    text-shadow: var(--player-x-glow);
}

.cell.o {
    color: var(--player-o-color);
    text-shadow: var(--player-o-glow);
}

.cell.taken {
    cursor: default;
}

/* Scoreboard */
.scoreboard {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 20px;
}

.player-score {
    text-align: center;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.player-score.active-turn {
    opacity: 1;
    font-weight: bold;
    transform: scale(1.1);
}

.p-score {
    display: block;
    font-size: 1.5rem;
    margin-top: 5px;
}

.vs-badge {
    font-weight: 800;
    color: var(--text-secondary);
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.turn-indicator {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal {
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: bounceIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 400px) {
    :root {
        --cell-size: 80px;
        --gap-size: 10px;
    }
}