:root {
    --bg-color: #0b0c15;
    --card-bg: rgba(255, 255, 255, 0.05);
    --primary: #00f3ff;
    --secondary: #bd00ff;
    --text: #ffffff;
    --text-dim: #888;
}

.home-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 1rem;
    z-index: 1000;
    transition: color 0.3s;
}

.home-link:hover {
    color: var(--primary);
    text-shadow: 0 0 5px var(--primary);
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* Fix: allow scrolling to top */
    min-height: 100vh;
    /* Use min-height instead of fixed height */
    padding: 20px 0;
    /* Add padding for vertical spacing */
    overflow-y: auto;
    /* Enable vertical scrolling */
}

.container {
    margin: auto;
    /* Center vertically if space allows */
    width: 100%;
    max-width: 400px;
    padding: 20px;
    text-align: center;
}

.screen {
    opacity: 1;
    transition: opacity 0.5s ease;
}

.hidden {
    display: none;
    opacity: 0;
}

.neon-text {
    font-size: 3rem;
    color: #fff;
    text-shadow:
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--primary),
        0 0 40px var(--primary),
        0 0 80px var(--primary);
    margin-bottom: 40px;
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

input {
    padding: 15px;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: 0.3s;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.neon-btn {
    padding: 15px;
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    transition: 0.3s;
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.neon-btn:hover {
    background: var(--primary);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.6);
}

.neon-btn.secondary {
    border-color: var(--secondary);
    color: var(--secondary);
    box-shadow: 0 0 10px rgba(189, 0, 255, 0.2);
}

.neon-btn.secondary:hover {
    background: var(--secondary);
    color: #fff;
    box-shadow: 0 0 20px rgba(189, 0, 255, 0.6);
}

.neon-btn.danger {
    border-color: #ff0055;
    color: #ff0055;
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.2);
}

.neon-btn.danger:hover {
    background: #ff0055;
    color: #fff;
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.6);
}

/* Notification Banner */
.banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    text-align: center;
    font-weight: bold;
    color: #fff;
    z-index: 2000;
    transform: translateY(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.banner.visible {
    transform: translateY(0);
}

.banner.error {
    background: rgba(255, 0, 85, 0.9);
    border-bottom: 2px solid #ff0055;
}

.banner.info {
    background: rgba(0, 243, 255, 0.9);
    border-bottom: 2px solid var(--primary);
    color: #000;
}

/* Neon Title Animations */
.neon-title {
    font-size: 3.5rem;
    margin-bottom: 40px;
}

@keyframes flicker {

    0%,
    19%,
    21%,
    23%,
    25%,
    54%,
    56%,
    100% {
        text-shadow:
            0 0 5px #fff,
            0 0 10px #fff,
            0 0 20px var(--primary),
            0 0 40px var(--primary),
            0 0 80px var(--primary);
        opacity: 1;
    }

    20%,
    24%,
    55% {
        text-shadow: none;
        opacity: 0.8;
    }
}

.flicker-slow {
    color: #fff;
    animation: flicker 3s infinite alternate;
}

.flicker-fast {
    color: var(--primary);
    animation: flicker 1.5s infinite alternate-reverse;
}

/* Responsive Layout */
.container {
    width: 100%;
    max-width: 600px;
    /* Increased max-width */
    padding: 20px;
    text-align: center;
    box-sizing: border-box;
}

/* Responsive Board */
.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    margin: 20px auto;
    width: 80vmin;
    /* Responsive width */
    height: 80vmin;
    /* Responsive height (square) */
    max-width: 400px;
    max-height: 400px;
}

.cell {
    background: var(--card-bg);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(2rem, 10vmin, 4rem);
    /* Responsive font size */
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.cell:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes pop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    80% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.cell.x,
.cell.o {
    animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.cell.x {
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary);
}

.cell.o {
    color: var(--secondary);
    text-shadow: 0 0 15px var(--secondary);
}

/* Winning Line Highlight */
.cell.win {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 20px #fff;
    z-index: 10;
}

/* Pulse Animation for Turn */
@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 243, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(0, 243, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 243, 255, 0);
    }
}

.turn-active {
    animation: pulse-border 2s infinite;
    border-radius: 5px;
}

/* Media Queries for Mobile */
@media (max-width: 600px) {
    .neon-text {
        font-size: 2.5rem;
    }

    .menu {
        flex-direction: column;
    }

    .game-header {
        font-size: 1rem;
    }

    .neon-btn {
        padding: 12px;
        /* Large touch target */
    }

    input,
    select {
        padding: 12px;
        font-size: 16px;
        /* Prevent zoom on iOS */
    }
}

/* Lobby Cards */
.game-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin: 20px 0;
}

.mode-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    flex: 1 1 250px;
    /* Grow, shrink, base width */
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mode-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 243, 255, 0.1);
    border-color: rgba(0, 243, 255, 0.3);
}

.mode-card h3 {
    margin: 0 0 5px 0;
    color: var(--primary);
    font-size: 1.2rem;
}

.mode-desc {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.full-width {
    width: 100%;
}

.neon-input {
    background: var(--card-bg);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px;
    outline: none;
}

.game-header {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: var(--text-dim);
}

#turn-indicator {
    color: #fff;
    font-weight: bold;
}

.turn-active {
    animation: pulse-border 2s infinite;
    border-radius: 5px;
}

/* Modal Styling */
/* Modal Styling */
.modal {
    /* Hidden by default via .hidden class */
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #1a1b26;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid var(--primary);
    width: 90%;
    max-width: 500px;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.tab-btn {
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 10px 20px;
    color: var(--text-dim);
    font-size: 1rem;
    transition: 0.3s;
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}