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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

#app {
    width: 100%;
    max-width: 600px;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

.container {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: slideIn 0.5s ease;
    backdrop-filter: blur(10px);
}

h1 {
    font-size: 3em;
    margin-bottom: 40px;
    color: #333;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    animation: slideIn 0.6s ease;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    font-size: 2em;
    margin-bottom: 30px;
    color: #333;
    animation: slideIn 0.5s ease;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    padding: 12px 24px;
    font-size: 16px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.3s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.btn-secondary:active {
    transform: translateY(0);
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.button-group .btn {
    flex: 1;
}

.status-message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    font-weight: 500;
    min-height: 20px;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
}

.status-message.loading {
    background: #cfe2ff;
    color: #084298;
}

/* Game Screen Styles */
.game-container {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 20px;
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.3s ease;
    background: #f9f9f9;
}

.player-info.active {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.05);
}

.player-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
    word-break: break-word;
}

.player-mark {
    font-size: 32px;
    font-weight: bold;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.player-info.active .player-mark {
    animation: bounce 0.6s ease;
}

.game-status {
    flex: 1;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: #667eea;
    min-width: 150px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(102, 126, 234, 0.05);
    transition: all 0.3s ease;
}

.game-status.winner {
    animation: bounce 0.6s ease;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1), rgba(34, 197, 94, 0.05));
    color: #22c55e;
}

.game-status.draw {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(245, 158, 11, 0.05));
    color: #f59e0b;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 30px;
    padding: 10px;
    background: linear-gradient(135deg, #f5f5f5, #f9f9f9);
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
}

.game-board::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    pointer-events: none;
}

.game-board.win::after {
    animation: pulse 0.6s ease;
}

.cell {
    aspect-ratio: 1;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    color: #667eea;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.cell:hover:not(:disabled) {
    background: white;
    border-color: #667eea;
    transform: scale(1.08);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
}

.cell:active:not(:disabled) {
    transform: scale(0.98);
}

.cell:disabled {
    cursor: not-allowed;
}

.cell.x {
    color: #667eea;
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cell.o {
    color: #764ba2;
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cell.winner {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-color: #667eea;
    animation: pulse 0.6s ease infinite;
}

.winning-line {
    position: absolute;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform-origin: center;
    animation: drawLine 0.5s ease forwards;
}

@keyframes drawLine {
    from {
        clip-path: polygon(0 45%, 0 55%, 0 55%, 0 45%);
    }
    to {
        clip-path: polygon(0 45%, 0 55%, 100% 55%, 100% 45%);
    }
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.room-id {
    font-size: 14px;
    color: #666;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 8px;
    word-break: break-all;
}

.button-group-game {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.button-group-game .btn {
    flex: 1;
}

@media (max-width: 480px) {
    h1 {
        font-size: 2em;
        margin-bottom: 30px;
    }

    .container {
        padding: 30px 20px;
    }

    .game-header {
        flex-direction: column;
        gap: 15px;
    }

    .game-status {
        width: 100%;
    }

    .cell {
        font-size: 24px;
    }

    .player-mark {
        font-size: 24px;
        width: 35px;
        height: 35px;
    }
}
