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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 600px;
    width: 90%;
    margin: 20px auto;
}

h1 {
    color: #333;
    margin-bottom: 25px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-mode {
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    gap: 30px;
}

.game-mode label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #555;
}

.game-mode input[type="radio"] {
    transform: scale(1.2);
}

/* Header button styling */
.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: #3498db;
    transform: rotate(90deg);
    box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3);
}

/* Settings Modal Styles */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 1.5em;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: #999;
    transition: color 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #e74c3c;
}

.settings-content {
    max-height: 60vh;
    overflow-y: auto;
}

.settings-section {
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    border: 2px solid rgba(52, 152, 219, 0.2);
}

.settings-section h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

/* Piece color customization styles */
.piece-colors {
    margin-bottom: 25px;
    background: rgba(255, 255, 255, 0.7);
    padding: 20px;
    border-radius: 10px;
    border: 2px solid rgba(52, 152, 219, 0.2);
}

.piece-colors h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.color-pickers {
    display: flex;
    justify-content: space-around;
    gap: 20px;
}

.color-picker-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.color-picker-group label {
    font-weight: 500;
    color: #555;
    font-size: 0.9em;
}

.color-picker-group input[type="color"] {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.color-picker-group input[type="color"]:hover {
    transform: scale(1.1);
}

.color-preview {
    font-size: 2em;
    font-weight: bold;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

.current-player {
    font-weight: bold;
    color: #333;
    font-size: 1em;
}

.current-player span {
    color: #667eea;
    font-size: 1.15em;
}

.score {
    display: flex;
    gap: 12px;
    font-size: 0.85em;
    color: #666;
}

.score div {
    font-weight: 500;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 10px;
    margin: 0 auto 15px;
    background: #333;
    padding: 10px;
    border-radius: 10px;
    max-width: 400px;
}

.cell {
    aspect-ratio: 1;
    width: 100%;
    min-height: 100px;
    background: #fff;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(2.5em, 5vw, 3.5em);
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s ease;
    position: relative;
}

.cell:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}

.cell.x {
    color: #e74c3c;
}

.cell.o {
    color: #3498db;
}

.cell.winning {
    background: #f1c40f !important;
    animation: pulse 1s infinite;
}

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

.game-status {
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 20px;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-status.winner {
    color: #27ae60;
    animation: bounce 0.5s ease;
}

.game-status.draw {
    color: #f39c12;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

button {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
}

#resetBtn {
    background: #3498db;
    color: white;
}

#resetBtn:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

#resetScoreBtn {
    background: #e74c3c;
    color: white;
}

#resetScoreBtn:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

/* Login Modal Styles */
.modal {
    display: block;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    margin: 10% auto;
    padding: 40px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.modal-content h2 {
    color: #333;
    margin-bottom: 30px;
    font-size: 2em;
}

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

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

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-help {
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 5px;
    display: block;
}

#loginForm button {
    background: #667eea;
    color: white;
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
    margin-top: 10px;
}

#loginForm button:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.login-status {
    margin-bottom: 20px;
    padding: 10px;
    border-radius: 5px;
    font-weight: 500;
    min-height: 20px;
}

.login-status.error {
    background: #ffe6e6;
    color: #d63384;
    border: 1px solid #f5c6cb;
}

.login-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.login-status.info {
    background: #cce7ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

/* Header and User Info Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.logged-users {
    display: flex;
    gap: 15px;
    font-size: 0.9em;
}

.user-slot {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 500;
    color: #555;
    min-width: 160px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.user-slot.active {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border-color: rgba(102, 126, 234, 0.3);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-symbol {
    font-size: 1.2em;
    font-weight: bold;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.player-symbol.x-symbol {
    color: #e74c3c;
}

.player-symbol.o-symbol {
    color: #3498db;
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-label {
    font-size: 0.7em;
    color: #777;
    font-weight: 400;
}

.player-name {
    font-size: 0.9em;
    font-weight: 600;
    color: #333;
}

#logoutBtn {
    background: #e74c3c;
    color: white;
    padding: 8px 16px;
    font-size: 0.9em;
}

#logoutBtn:hover {
    background: #c0392b;
    transform: translateY(-2px);
}

/* Game disabled state */
.game-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.waiting-message {
    background: rgba(255, 193, 7, 0.1);
    border: 2px solid #ffc107;
    color: #856404;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-weight: 600;
}

@media (max-width: 500px) {
    .container {
        margin: 20px;
        padding: 20px;
    }

    .cell {
        width: 80px;
        height: 80px;
        font-size: 2em;
    }

    .game-info {
        flex-direction: column;
        gap: 10px;
    }

    .game-mode {
        flex-direction: column;
        gap: 10px;
    }

    .controls {
        flex-direction: column;
    }
}

/* Move pieces feature styles */
.cell.selected {
    background: linear-gradient(135deg, #ffd700, #ffed4e) !important;
    border: 3px solid #ff6b35 !important;
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 15px rgba(255, 107, 53, 0.6);
}

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

.game-phase-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    margin: 15px 0;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.game-phase-display strong {
    font-size: 16px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Auth0 and Registration Styles */
.login-methods {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-button {
    padding: 15px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.auth-button.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.auth-button.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.auth-button.secondary {
    background: #f8f9fa;
    color: #495057;
    border: 2px solid #dee2e6;
}

.auth-button.secondary:hover {
    background: #e9ecef;
    transform: translateY(-2px);
}

.divider {
    text-align: center;
    position: relative;
    margin: 25px 0;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #dee2e6;
}

.divider span {
    background: white;
    padding: 0 15px;
    color: #6c757d;
    font-size: 0.9em;
    font-weight: 500;
}

/* Room Selection Styles */
.room-selection {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.room-option {
    background: rgba(102, 126, 234, 0.05);
    border: 2px solid rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.room-option h3 {
    color: #667eea;
    margin-bottom: 8px;
    font-size: 1.2em;
}

.room-option p {
    color: #6c757d;
    margin-bottom: 15px;
    font-size: 0.9em;
}

.room-option-content {
    margin-top: 0;
}

.room-option-content .form-group {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.room-option-content .form-group label {
    display: inline-block !important;
    font-size: 0.9em;
    color: #6c757d;
    white-space: nowrap;
    margin: 0 !important;
    margin-bottom: 0 !important;
}

.room-option-content .form-group input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 6px;
    font-size: 0.9em;
    box-sizing: border-box;
    max-width: 180px;
}

.room-option-content .auth-button {
    width: 100%;
    margin-top: 8px;
    padding: 12px;
}

.room-divider {
    text-align: center;
    position: relative;
    margin: 15px 0;
}

.room-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #dee2e6;
}

.room-divider span {
    background: rgba(255, 255, 255, 0.95);
    padding: 0 15px;
    color: #6c757d;
    font-size: 0.8em;
    font-weight: 500;
}

#roomCodeInput {
    text-align: center;
    font-size: 1.1em;
    letter-spacing: 2px;
    font-weight: bold;
}

/* Room Info Display */
.room-info {
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    padding: 8px 15px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    font-size: 0.9em;
}

.room-label {
    color: #667eea;
    font-weight: 600;
}

.room-code {
    background: rgba(102, 126, 234, 0.2);
    border-radius: 4px;
    padding: 4px 8px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    letter-spacing: 1px;
    color: #333;
}

.share-room-btn {
    background: #667eea;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    color: white;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.share-room-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.legacy-form,
.local-form {
    margin-top: 10px;
}

.registration-info,
.username-info {
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin: 20px 0;
    font-size: 0.9em;
    color: #495057;
    line-height: 1.5;
}

.form-actions {
    display: flex;
    gap: 15px;
    justify-content: space-between;
    margin-top: 20px;
}

.form-actions button {
    flex: 1;
}

.form-actions button[type="button"] {
    background: #6c757d;
    color: white;
}

.form-actions button[type="button"]:hover {
    background: #5a6268;
}

.username-change-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.username-change-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Highscores Modal Styles */
.highscores-btn {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-right: 10px;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.2);
}

.highscores-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(243, 156, 18, 0.3);
    background: linear-gradient(135deg, #e67e22 0%, #d68910 100%);
}

/* Enhanced Modal Styling */
.highscores-modal {
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.65);
}

.highscores-modal-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: none;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    max-width: 800px;
    width: 95%;
    max-height: 85vh;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

.highscores-modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #f39c12, #e74c3c, #9b59b6, #3498db, #2ecc71, #f1c40f);
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Modal Header */
.modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #2c3e50;
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

.trophy-icon {
    font-size: 32px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% { transform: translateY(0); }
    40%, 43% { transform: translateY(-8px); }
    70% { transform: translateY(-4px); }
    90% { transform: translateY(-2px); }
}

.title-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

/* Content Layout */
.highscores-content {
    max-height: 70vh;
    overflow-y: auto;
    padding: 0 25px 25px 25px;
    scroll-behavior: smooth;
}

.highscores-content::-webkit-scrollbar {
    width: 8px;
}

.highscores-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.highscores-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.highscores-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4c93 100%);
}

/* Section Styling */
.highscores-section {
    margin-bottom: 40px;
    background: white;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.highscores-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.3), transparent);
}

.top-players-section::before {
    background: linear-gradient(90deg, transparent, rgba(241, 196, 15, 0.5), transparent);
}

.personal-stats-section::before {
    background: linear-gradient(90deg, transparent, rgba(52, 152, 219, 0.5), transparent);
}

.section-header {
    margin-bottom: 25px;
    text-align: center;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #2c3e50;
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px 0;
}

.section-icon {
    font-size: 24px;
}

.section-subtitle {
    color: #7f8c8d;
    font-size: 14px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Loading Animation */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 15px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #7f8c8d;
    font-weight: 500;
    font-size: 16px;
}

/* No Data Styling */
.no-data {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 40px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin: 20px 0;
    border: 2px dashed #dee2e6;
    font-size: 16px;
    font-weight: 500;
}

/* Leaderboard List */
.highscores-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.highscore-item {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.highscore-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 0%, rgba(102, 126, 234, 0.02) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.highscore-item:hover::before {
    opacity: 1;
}

.highscore-item:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: rgba(102, 126, 234, 0.3);
}

.highscore-item.top-three {
    background: linear-gradient(135deg, #fff9e6 0%, #ffeaa7 100%);
    border-color: #fdcb6e;
    box-shadow: 0 4px 15px rgba(253, 203, 110, 0.25);
}

.highscore-item.top-three:hover {
    box-shadow: 0 8px 30px rgba(253, 203, 110, 0.4);
    transform: translateY(-4px) scale(1.03);
}

.rank {
    font-size: 28px;
    font-weight: 800;
    margin-right: 20px;
    min-width: 50px;
    text-align: center;
    color: #2c3e50;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.player-info {
    flex-grow: 1;
    min-width: 0;
}

.player-name {
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 8px;
    font-size: 18px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.player-stats {
    display: flex;
    gap: 12px;
    font-size: 13px;
    flex-wrap: wrap;
}

.player-stats span {
    background: rgba(0, 0, 0, 0.08);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.wins {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%) !important;
    color: #155724 !important;
    box-shadow: 0 2px 8px rgba(21, 87, 36, 0.2);
}

.total-games {
    background: linear-gradient(135deg, #e2e3e5 0%, #d6d8db 100%) !important;
    color: #383d41 !important;
}

.win-rate {
    background: linear-gradient(135deg, #cce7ff 0%, #b3d9ff 100%) !important;
    color: #004085 !important;
    box-shadow: 0 2px 8px rgba(0, 64, 133, 0.2);
}

/* Personal Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.stat-item {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 16px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #e9ecef, #dee2e6);
}

.stat-item:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-color: rgba(102, 126, 234, 0.3);
}

.stat-item.featured {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.stat-item.featured::before {
    background: linear-gradient(90deg, rgba(255,255,255,0.2), rgba(255,255,255,0.4), rgba(255,255,255,0.2));
}

.stat-item.featured:hover {
    transform: translateY(-6px) scale(1.08);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    color: #2c3e50;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-item.featured .stat-value {
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 12px;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.stat-item.featured .stat-label {
    color: rgba(255, 255, 255, 0.9);
}

/* Responsive Design */
@media (max-width: 768px) {
    .highscores-modal-content {
        width: 98%;
        max-height: 90vh;
        border-radius: 16px;
    }

    .highscores-content {
        padding: 0 15px 15px 15px;
    }

    .highscores-section {
        padding: 20px;
        margin-bottom: 25px;
    }

    .modal-title {
        font-size: 24px;
    }

    .section-title {
        font-size: 20px;
    }

    .highscore-item {
        padding: 16px;
    }

    .player-stats {
        flex-direction: column;
        gap: 8px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .rank {
        font-size: 24px;
        min-width: 40px;
        margin-right: 15px;
    }

    .stat-value {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .highscores-modal-content {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .player-name {
        font-size: 16px;
    }

    .rank {
        font-size: 20px;
        min-width: 35px;
        margin-right: 12px;
    }
}

/* iOS Safari Safe Area Insets and Mobile Responsive Design */

/* Enhanced mobile modal styles */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: 400px;
        margin: 5% auto;
        padding: 25px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 60px));
        border-radius: 12px;
        max-height: 90vh;
        overflow-y: auto;
        box-sizing: border-box;
    }

    .modal-content h2 {
        font-size: 1.6em;
        margin-bottom: 20px;
    }

    /* Room selection modal improvements */
    .room-selection {
        gap: 15px;
        margin-bottom: calc(60px + env(safe-area-inset-bottom, 50px));
    }

    .room-option {
        padding: 15px;
        border-radius: 8px;
    }

    .room-option h3 {
        font-size: 1.2em;
        margin-bottom: 8px;
    }

    .room-option p {
        font-size: 0.9em;
        margin-bottom: 12px;
    }

    .auth-button {
        padding: 12px 20px;
        font-size: 0.95em;
        margin-bottom: 8px;
    }

    .form-group {
        margin-bottom: 15px;
    }

    .form-group input {
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 500px) {
    .container {
        margin: 10px;
        padding: 15px;
        border-radius: 10px;
    }

    .game-board {
        max-width: 300px;
        grid-gap: 8px;
        padding: 10px;
    }

    .cell {
        width: 85px;
        height: 85px;
        font-size: 2em;
    }

    .game-info {
        flex-direction: column;
        gap: 12px;
    }

    .modal-content {
        width: 98%;
        margin: 2% auto;
        padding: 20px;
        padding-bottom: calc(90px + env(safe-area-inset-bottom, 70px));
        max-height: 96vh;
        overflow-y: auto;
        box-sizing: border-box;
    }

    .room-selection {
        gap: 12px;
        margin-bottom: calc(70px + env(safe-area-inset-bottom, 60px));
    }

    .room-option {
        padding: 12px;
    }

    .game-mode {
        flex-direction: column;
        gap: 10px;
    }

    .controls {
        flex-direction: column;
    }
}

/* Ultra-small screens and iPhone 16 Pro with maximum safe area padding */
@media (max-width: 430px) {
    .modal-content {
        width: 100%;
        margin: 0;
        padding: 15px;
        padding-bottom: calc(120px + env(safe-area-inset-bottom, 100px));
        border-radius: 0;
        min-height: 100vh;
        max-height: 100vh;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        box-sizing: border-box;
    }

    .modal-content h2 {
        font-size: 1.4em;
        margin-bottom: 15px;
    }

    .room-selection {
        gap: 12px;
        margin-bottom: calc(100px + env(safe-area-inset-bottom, 80px));
    }

    .room-option {
        padding: 12px;
    }

    .room-option h3 {
        font-size: 1.1em;
    }

    .room-option p {
        font-size: 0.85em;
    }

    .auth-button {
        padding: 14px 16px;
        font-size: 0.9em;
        width: 100%;
        margin-bottom: 10px;
    }

    .cell {
        width: 75px;
        height: 75px;
        font-size: 1.8em;
    }
}

/* Landscape orientation fixes for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        margin: 2% auto;
        max-height: 95vh;
        overflow-y: auto;
    }

    .room-selection {
        gap: 10px;
        margin-bottom: calc(15px + env(safe-area-inset-bottom, 15px));
    }
}

/* My Games Section Styles */
.my-games-section {
    border: 2px solid #4CAF50;
    background: linear-gradient(135deg, #f5f9f5 0%, #e8f5e9 100%);
}

.my-games-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
}

.my-game-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.my-game-item:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.game-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.game-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.room-code-badge {
    font-weight: bold;
    font-size: 1.1em;
    color: #2c3e50;
}

.your-turn {
    background: #4CAF50;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: bold;
}

.their-turn {
    background: #ff9800;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: bold;
}

.game-ended {
    background: #9e9e9e;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: bold;
}

.game-details {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.opponent-name {
    font-size: 0.95em;
    color: #555;
}

.game-phase {
    font-size: 0.85em;
    color: #777;
    font-style: italic;
}

.game-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85em;
    color: #999;
    flex-wrap: wrap;
}

.game-score {
    font-weight: bold;
    color: #666;
}

.game-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}

.rejoin-btn {
    padding: 10px 20px;
    white-space: nowrap;
}

.delete-btn {
    padding: 8px 10px;
    background: #f44336;
    font-size: 1em;
    min-width: auto;
    width: auto;
    line-height: 1;
}

.delete-btn:hover {
    background: #d32f2f;
    transform: scale(1.05);
}

/* Mobile responsive for My Games */
@media (max-width: 768px) {
    .my-game-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .game-actions {
        width: 100%;
    }

    .rejoin-btn {
        flex: 1;
    }

    .delete-btn {
        flex-shrink: 0;
    }

    .game-header,
    .game-details,
    .game-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

/* ================================================
   DESKTOP/LAPTOP RESPONSIVE IMPROVEMENTS
   ================================================ */

/* Tablets and Small Desktops (769px+) */
@media (min-width: 769px) {
    .container {
        max-width: 380px;
        padding: 15px;
    }

    h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }

    .game-board {
        max-width: 260px;
        grid-gap: 6px;
        padding: 6px;
        margin-bottom: 12px;
    }

    .cell {
        min-height: 65px;
        font-size: 2em;
    }

    button {
        padding: 8px 16px;
        font-size: 0.9em;
    }

    .game-info {
        font-size: 0.75em;
        margin: 5px 0;
        padding: 6px 8px;
        margin-bottom: 6px;
    }

    .player-info {
        margin-bottom: 4px;
        padding: 4px 6px;
        font-size: 0.7em;
        gap: 6px;
    }

    .player-symbol {
        font-size: 1em;
        width: 20px;
        height: 20px;
    }

    .player-label {
        font-size: 0.7em;
    }

    .player-name {
        font-size: 0.9em;
    }

    .current-player {
        font-size: 0.85em;
    }

    .current-player span {
        font-size: 0.95em;
    }

    .score {
        font-size: 0.7em;
        gap: 8px;
    }

    .game-board {
        margin-bottom: 8px;
    }

    .game-actions {
        margin-top: 8px;
    }

    .game-actions button {
        margin: 4px;
    }

    .modal-content {
        max-width: 450px;
        padding: 20px;
        margin: 3% auto;
    }

    .modal-content h2 {
        margin-bottom: 15px;
        font-size: 1.5em;
    }

    .room-selection {
        gap: 8px;
    }

    .room-option {
        padding: 12px;
        min-height: 75px;
    }

    .room-option h3 {
        font-size: 1em;
        margin-bottom: 4px;
    }

    .room-option p {
        font-size: 0.8em;
        margin-bottom: 8px;
    }

    .auth-button {
        padding: 10px 20px;
        font-size: 0.95em;
    }

    .my-games-section h3 {
        font-size: 1em;
        margin-bottom: 8px;
    }

    .active-game-item {
        padding: 6px 12px;
        margin: 6px 0;
        font-size: 0.85em;
    }

    .highscores-modal-content {
        max-width: 900px;
    }
}

/* Large Desktops (1200px+) */
@media (min-width: 1200px) {
    .container {
        max-width: 400px;
        padding: 16px;
    }

    h1 {
        font-size: 1.6em;
        margin-bottom: 12px;
    }

    .game-board {
        max-width: 280px;
        grid-gap: 6px;
        padding: 6px;
    }

    .cell {
        min-height: 70px;
        font-size: 2.2em;
    }

    .modal-content {
        max-width: 480px;
        padding: 22px;
        margin: 3% auto;
    }

    .room-selection {
        gap: 10px;
    }

    .room-option {
        padding: 14px;
        min-height: 70px;
    }

    .highscores-modal-content {
        max-width: 1000px;
    }
}

/* Ultra-Wide Monitors (1920px+) */
@media (min-width: 1920px) {
    .container {
        max-width: 420px;
        padding: 18px;
    }

    h1 {
        font-size: 1.7em;
    }

    .game-board {
        max-width: 300px;
        grid-gap: 8px;
        padding: 8px;
    }

    .cell {
        min-height: 75px;
        font-size: 2.3em;
    }
}