:root {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --primary-color: #3b82f6;
    --secondary-color: #64748b;
    --accent-x: #f43f5e;
    /* Rose-500 */
    --accent-o: #22d3ee;
    /* Cyan-400 */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* Background Animation */
.background-globes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    filter: blur(80px);
}

.globe {
    position: absolute;
    border-radius: 50%;
    animation: float 10s infinite ease-in-out alternate;
}

.globe-1 {
    width: 400px;
    height: 400px;
    background: var(--accent-x);
    opacity: 0.2;
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.globe-2 {
    width: 500px;
    height: 500px;
    background: var(--accent-o);
    opacity: 0.15;
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

.globe-3 {
    width: 300px;
    height: 300px;
    background: var(--primary-color);
    opacity: 0.2;
    top: 40%;
    left: 40%;
    transform: translate(-50%, -50%);
    animation: pulse 8s infinite ease-in-out;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 50px);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.2;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.3;
    }
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Start Screen */
#start-screen {
    text-align: center;
    max-width: 400px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.game-title {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin-bottom: 0.5rem;
}

.game-title .highlight {
    background: linear-gradient(to right, var(--accent-x), var(--accent-o));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--secondary-color);
    font-size: 1.1rem;
}

.input-group {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 16px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.range-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="range"] {
    flex: 1;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.highlight-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 30px;
    text-align: center;
}

.description {
    font-size: 0.8rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.mode-btn,
.diff-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--secondary-color);
    padding: 0.8rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.mode-btn.active,
.diff-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    border-color: var(--primary-color);
}

.mode-btn:hover:not(.active),
.diff-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-color);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-x), violet);
    border: none;
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(244, 63, 94, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-text {
    background: none;
    border: none;
    color: var(--secondary-color);
    padding: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.btn-text:hover {
    color: var(--text-color);
    text-decoration: underline;
}

/* Game Screen */
#game-screen.hidden,
#start-screen.hidden {
    display: none;
}

.header-glass {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 1.5rem;
    background: var(--glass-bg);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.player-info.active {
    opacity: 1;
    font-weight: 700;
}

.vs {
    font-size: 0.8rem;
    color: var(--secondary-color);
    font-weight: 700;
}

.mark {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.2rem;
}

.x-mark {
    color: var(--accent-x);
}

.o-mark {
    color: var(--accent-o);
}

.board-container {
    padding: 1rem;
    /* Limit board size to fit well */
    max-height: 70vh;
    overflow: auto;
    display: flex;
    justify-content: center;
    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--secondary-color) transparent;
}

.game-board {
    display: grid;
    /* Will be set dynamically based on grid size */
    gap: 4px;
    background-color: transparent;
}

.cell {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.cell:hover {
    background: rgba(255, 255, 255, 0.08);
}

.cell.x {
    color: var(--accent-x);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.o {
    color: var(--accent-o);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.win {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.controls {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    text-align: center;
    padding: 3rem;
    max-width: 400px;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    0% {
        transform: translateY(50px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: white;
}

.modal-actions {
    display: flex;
    justify-content: center;
}