:root {
    --bg-color: #0d0e15;
    --surface-color: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.1);
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --color-x: #38bdf8;
    --color-o: #f43f5e;
    --color-fading: rgba(255, 255, 255, 0.4);

    --glow-x: 0 0 15px rgba(56, 189, 248, 0.6);
    --glow-o: 0 0 15px rgba(244, 63, 94, 0.6);

    --font-main: 'Outfit', sans-serif;
}

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

.hidden {
    display: none !important;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    background-image:
        radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(244, 63, 94, 0.1) 0%, transparent 50%);
}

#app {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    position: relative;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Views */
.view {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    animation: fadeIn 0.4s ease forwards;
}

.view.active {
    display: flex;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typography */
.glow-text {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
}

h2.glow-text {
    font-size: 2.2rem;
}

/* Buttons */
.btn {
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 500;
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 300px;
    margin-bottom: 1rem;
    outline: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn.primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn.primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn.secondary {
    background: var(--surface-color);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.btn.secondary:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn.text-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.btn.text-btn:hover {
    color: var(--text-main);
}

/* Main Menu */
.mode-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 12px;
}

.mode-selector label {
    cursor: pointer;
    position: relative;
}

.mode-selector input[type="radio"] {
    display: none;
}

.mode-selector span {
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    display: block;
    color: var(--text-muted);
    transition: all 0.2s;
}

.mode-selector input[type="radio"]:checked+span {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.menu-options {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Multiplayer Lobby */
.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.action-card {
    background: var(--surface-color);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
    backdrop-filter: blur(10px);
}

.action-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.action-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

input[type="text"] {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-family: var(--font-main);
    font-size: 1.2rem;
    text-align: center;
    margin-bottom: 1rem;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--primary-color);
}

/* Game Waiting */
.code-display {
    background: var(--surface-color);
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 2rem;
    width: 100%;
}

.code-box {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 12px;
}

#display-room-code {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.2rem;
    color: var(--text-main);
}

.icon-btn {
    width: auto;
    padding: 0.5rem;
    margin: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 1.2rem;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.loader {
    color: var(--primary-color);
    font-weight: 500;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* Game Board */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--surface-color);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.player-info.active {
    opacity: 1;
}

.symbol {
    font-size: 2rem;
    font-weight: 700;
}

.symbol-x {
    color: var(--color-x);
    text-shadow: var(--glow-x);
}

.symbol-o {
    color: var(--color-o);
    text-shadow: var(--glow-o);
}

.name {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.turn-indicator {
    font-size: 1.2rem;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.variant-badge {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    margin: 0 auto;
}

.cell {
    background: var(--surface-color);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.board.ultimate {
    max-width: 600px;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 16px;
}

.board.ultimate .cell {
    font-size: 2.5rem;
    border-radius: 8px;
}

.mini-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px;
    background: var(--bg-color);
    border-radius: 12px;
    padding: 4px;
    position: relative;
    transition: all 0.3s ease;
}

.mini-board.active-board {
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.mini-board.inactive-board {
    opacity: 0.5;
}

.mini-board.won-x::after {
    content: "X";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 8rem;
    font-weight: 700;
    color: var(--color-x);
    text-shadow: var(--glow-x);
    background: rgba(13, 14, 21, 0.8);
    border-radius: 12px;
    z-index: 10;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mini-board.won-o::after {
    content: "O";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 8rem;
    font-weight: 700;
    color: var(--color-o);
    text-shadow: var(--glow-o);
    background: rgba(13, 14, 21, 0.8);
    border-radius: 12px;
    z-index: 10;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mini-board.drawn::after {
    content: "-";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 8rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(13, 14, 21, 0.8);
    border-radius: 12px;
    z-index: 10;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}


.cell:hover {
    background: var(--surface-hover);
}

.cell.x {
    color: var(--color-x);
    text-shadow: var(--glow-x);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.o {
    color: var(--color-o);
    text-shadow: var(--glow-o);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cell.winner {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.3);
}

.cell.fading {
    opacity: 0.3;
    animation: fadePulse 1s infinite alternate;
}

@keyframes fadePulse {
    0% {
        opacity: 0.2;
        transform: scale(0.95);
    }

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

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

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

/* Modals & Toasts */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 14, 21, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: fadeIn 0.3s ease forwards;
}

.modal.hidden {
    display: none;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2.5rem;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    width: 90%;
    max-width: 400px;
}

.glass-panel h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.glass-panel p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.footer-actions {
    margin-top: 2rem;
    width: 100%;
    text-align: center;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

@media (max-width: 480px) {
    .board {
        max-width: 300px;
    }

    .cell {
        font-size: 4rem;
    }

    .board.ultimate {
        max-width: 350px;
        gap: 4px;
        padding: 4px;
    }

    .board.ultimate .cell {
        font-size: 1.5rem;
    }

    .mini-board.won-x::after,
    .mini-board.won-o::after,
    .mini-board.drawn::after {
        font-size: 5rem;
    }

    .glow-text {
        font-size: 2.5rem;
    }
}