/* assets/css/style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --light: #ecf0f1;
    --dark: #2c3e50;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Navbar */
.navbar {
    background: rgba(44, 62, 80, 0.95);
    padding: 15px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-decoration: none;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    padding: 8px 15px;
    border-radius: 5px;
    transition: background 0.3s;
}

.nav-menu a:hover {
    background: var(--secondary);
}

/* Board Game */
.board-container {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 600px;
    margin: 0px auto;
}

/* === BÀN CỜ TỰ ĐỘNG THU NHỎ === */
.board-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px 0;
}

.board {
    display: grid;
    gap: 2px;
    background: #2c3e50;
    padding: 2px;
    border-radius: 8px;
    width: min(500px, calc(90vw - 40px));
    height: min(500px, calc(90vw - 40px));
    max-height: 65vh;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}

.cell {
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    border-radius: 2px;
    aspect-ratio: 1 / 1;
    user-select: none;
    font-size: clamp(12px, 3vw, 32px);
    min-width: 0;
    min-height: 0;
    transition: all 0.15s ease;
}

.cell:hover:not(.taken):not(.game-over) {
    background: #ecf0f1;
    transform: scale(1.02);
}

.cell.x {
    color: #e74c3c;
    background: #fde8e8;
}

.cell.o {
    color: #3498db;
    background: #e8f0fe;
}

.cell.taken {
    cursor: not-allowed;
}

.cell.game-over {
    cursor: not-allowed;
    opacity: 0.8;
}

.cell.winning {
    background: #ffd700 !important;
    animation: winPulse 0.5s ease-in-out infinite alternate;
}

@keyframes winPulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* Responsive cho từng kích thước màn hình */
@media (max-width: 768px) {
    .board-container {
        padding: 15px;
    }
    .board {
        width: min(450px, calc(95vw - 30px));
        height: min(450px, calc(95vw - 30px));
        max-height: 60vh;
        gap: 1.5px;
        padding: 1.5px;
    }
    .cell {
        font-size: clamp(10px, 2.8vw, 22px);
    }
    .nav-menu {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }
    .nav-menu a {
        margin-left: 5px;
        padding: 5px 10px;
        font-size: 14px;
    }
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .board-container {
        padding: 10px;
    }
    .board {
        width: calc(100vw - 30px);
        height: calc(100vw - 30px);
        max-height: 55vh;
        gap: 1px;
        padding: 1px;
    }
    .cell {
        font-size: clamp(8px, 2.5vw, 16px);
    }
}

@media (max-width: 380px) {
    .board-container {
        padding: 8px;
    }
    .board {
        width: calc(100vw - 20px);
        height: calc(100vw - 20px);
        max-height: 50vh;
        gap: 1px;
        padding: 1px;
    }
    .cell {
        font-size: clamp(6px, 2vw, 12px);
    }
}

/* Forms */
.auth-form {
    background: white;
    max-width: 400px;
    margin: 50px auto;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    border-color: var(--secondary);
    outline: none;
}

.btn {
    background: var(--secondary);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(52, 152, 219, 0.4);
}

.btn-success {
    background: var(--success);
}

.btn-danger {
    background: var(--danger);
}

/* Game Info */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.timer {
    font-size: 24px;
    font-weight: bold;
    color: var(--danger);
    min-width: 60px;
    text-align: center;
}

/* Room List */
.room-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.room-card {
    background: white;
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.room-card:hover {
    transform: translateY(-5px);
}

.room-card h3 {
    margin-bottom: 10px;
    color: var(--primary);
}

.room-card .info {
    color: #666;
    font-size: 14px;
    margin: 5px 0;
}

/* Toast animation */
@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}