html {
    font-size: 16px;
}

body {
    margin-bottom: 60px;
}

/* ── Tic-Tac-Toe Board ─────────────────────────────────────────── */

.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 360px;
    width: 100%;
    position: relative;
}

.ttt-cell {
    aspect-ratio: 1;
    font-size: 3rem;
    font-weight: 900;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    background: #f8f9fa;
    color: #343a40;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: all 0.2s ease;
    line-height: 1;
    position: relative;
    overflow: hidden;
}

.ttt-clickable {
    cursor: pointer;
    background: #fff;
}

.ttt-clickable:hover {
    background: #e9ecef;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ttt-clickable:active {
    transform: scale(0.98);
}

/* X and O styles */
.cell-x {
    color: #0d6efd;
    background: #e7f1ff;
    border-color: #0d6efd;
    animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cell-o {
    color: #dc3545;
    background: #fdf0f0;
    border-color: #dc3545;
    animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

/* Winning line */
.winning-cell {
    position: relative;
}

.winning-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 193, 7, 0.3);
    border: 3px solid #ffc107;
    border-radius: 12px;
    animation: winnerGlow 0.5s ease infinite alternate;
}

@keyframes winnerGlow {
    from {
        box-shadow: 0 0 10px #ffc107;
    }
    to {
        box-shadow: 0 0 25px #ffc107, 0 0 50px rgba(255, 193, 7, 0.5);
    }
}

/* Game result animations */
.result-win {
    animation: celebrateWin 0.6s ease;
}

@keyframes celebrateWin {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.1) rotate(-3deg); }
    50% { transform: scale(1.1) rotate(3deg); }
    75% { transform: scale(1.05) rotate(-1deg); }
}

.result-lose {
    animation: shakeLoss 0.5s ease;
}

@keyframes shakeLoss {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px); }
    40% { transform: translateX(10px); }
    60% { transform: translateX(-10px); }
    80% { transform: translateX(10px); }
}

/* Draw animation */
.result-draw {
    animation: drawPulse 0.8s ease;
}

@keyframes drawPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.95); opacity: 0.7; }
}

/* Status messages */
.status-win {
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ── Enhanced UI ─────────────────────────────────────────── */

.card {
    transition: box-shadow 0.2s ease;
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.1) !important;
}

.btn {
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

/* Hero section */
.bg-dark {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%) !important;
}

/* Leaderboard highlight */
.table-warning {
    background-color: rgba(255, 193, 7, 0.15) !important;
}

/* Badge improvements */
.badge {
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Form improvements */
.form-control:focus {
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
    border-color: #0d6efd;
}

/* Navbar */
.navbar {
    padding: 0.75rem 1rem;
}

/* Footer */
footer {
    font-size: 0.85rem;
}

/* Alert improvements */
.alert {
    border: none;
    border-radius: 8px;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%);
    color: #0c5460;
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    color: #856404;
}

/* Table improvements */
.table {
    font-size: 0.9rem;
}

.table th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    color: #6c757d;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

/* Modal/Dialog improvements */
.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* Room code display */
.room-code {
    font-family: 'Courier New', monospace;
    letter-spacing: 0.2em;
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 2px dashed #adb5bd;
}

/* ── Mobile Responsive Design ─────────────────────────────────────────── */

@media (max-width: 576px) {
    body {
        margin-bottom: 40px;
    }
    
    html {
        font-size: 14px;
    }
    
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .navbar-brand {
        font-size: 1rem;
    }
    
    .navbar {
        padding: 0.5rem 0.75rem;
    }
    
    .navbar-toggler {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Board */
    .ttt-board {
        gap: 4px;
        max-width: 100%;
        padding: 0 0.5rem;
    }
    
    .ttt-cell {
        font-size: 2rem;
        border-radius: 8px;
    }
    
    /* Cards - remove negative margins */
    .card {
        margin: 0;
        border-radius: 8px;
    }
    
    .card-header {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* Tables */
    .table-responsive {
        margin: 0 -0.75rem;
        padding: 0 0.75rem;
    }
    
    /* Buttons */
    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }
    
    /* Alerts */
    .alert {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Forms */
    .form-label {
        font-size: 0.9rem;
    }
    
    .form-control {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Hero card */
    .bg-dark {
        padding: 1rem !important;
    }
    
    /* Modal */
    .modal-body {
        padding: 1rem;
    }
    
    /* Footer */
    footer {
        padding: 1rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 400px) {
    .ttt-cell {
        font-size: 1.75rem;
    }
    
    .navbar-brand {
        font-size: 0.85rem;
    }
}

/* Touch-friendly */
@media (pointer: coarse) {
    .ttt-cell {
        min-height: 50px;
    }
    
    .btn {
        min-height: 44px;
    }
    
    .form-control {
        min-height: 44px;
    }
}

/* Extra small screens */
@media (max-width: 320px) {
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .ttt-cell {
        font-size: 1.5rem;
    }
}