@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700;800&display=swap');

:root {
    --primary-color: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.5);
    --secondary-color: #334155;
    --accent-color: #0ea5e9;
    --background-color: #0f172a;
    --card-background: rgba(30, 41, 59, 0.6);
    --text-color: #f8fafc;
    --light-text-color: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --error-color: #ef4444;
    --success-color: #10b981;
    --hint-color: #f59e0b;
    --conflict-color: #f43f5e;
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    background-image: radial-gradient(circle at 15% 50%, rgba(139, 92, 246, 0.15), transparent 25%), radial-gradient(circle at 85% 30%, rgba(14, 165, 233, 0.15), transparent 25%);
    background-attachment: fixed;
    color: var(--text-color);
    transition: background-color 0.4s ease, color 0.4s ease;
}

body.light-mode {
    --primary-color: #6d28d9;
    --primary-glow: rgba(109, 40, 217, 0.3);
    --secondary-color: #e2e8f0;
    --accent-color: #0284c7;
    --background-color: #f1f5f9;
    --card-background: rgba(255, 255, 255, 0.85);
    --text-color: #0f172a;
    --light-text-color: #475569;
    --border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .btn-outline-light {
    color: var(--text-color);
    border-color: var(--border-color);
}

body.light-mode .btn-outline-light:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-color);
}

.text-muted {
    color: rgba(255, 255, 255, 0.5) !important;
}

body.light-mode .text-muted {
    color: var(--light-text-color) !important;
}

input.form-control, select.form-select {
    background-color: rgba(15, 23, 42, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--text-color) !important;
}

input.form-control::placeholder, select.form-select::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

input.form-control:focus, select.form-select:focus {
    background-color: rgba(15, 23, 42, 0.8) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.25rem rgba(139, 92, 246, 0.25) !important;
}

body.light-mode input.form-control, body.light-mode select.form-select {
    background-color: rgba(255, 255, 255, 0.7) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    color: var(--text-color) !important;
}

body.light-mode input.form-control::placeholder, body.light-mode select.form-select::placeholder {
    color: rgba(0, 0, 0, 0.5) !important;
}

body.light-mode input.form-control:focus, body.light-mode select.form-select:focus {
    background-color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(109, 40, 217, 0.25) !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color)) !important;
    border: none !important;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--primary-glow) !important;
}

#main-container.container-fluid {
    transition: filter 0.3s ease-in-out;
}

.main-header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.main-header h1 {
    margin: 0;
}

#main-container.pre-game {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.card-glass {
    background: var(--card-background);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    color: var(--text-color) !important;
}

.card-glass:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* UI/UX Pro Max Modal Extrapolation */
.modal-content.card-glass {
    background: rgba(17, 24, 39, 0.75) !important; /* Deep glass */
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 1.5rem !important;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

.modal.show .modal-dialog {
    animation: modalPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalPopIn {
    0% {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header.border-0 {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.modal-title {
    background: linear-gradient(135deg, #ffffff 0%, var(--primary-glow) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    letter-spacing: -0.02em;
}

#room-management {
    max-width: 550px;
}

#room-management .card-title {
    font-weight: 700;
    color: var(--text-color);
}


/* ============================================
   WAITING ROOM — Fully self-contained styles
   ============================================ */
#waiting-room {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    background: rgba(10, 15, 30, 0.85);
    backdrop-filter: blur(4px);
}

#waiting-room-card {
    background: #1a2540;
    border: 1px solid rgba(139, 92, 246, 0.5);
    border-radius: 1.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(139, 92, 246, 0.2);
    padding: 2.5rem;
    width: 100%;
    max-width: 480px;
    color: #ffffff;
    text-align: center;
}

#waiting-room-card h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.5rem;
}

#waiting-room-card p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

#waiting-room-card hr {
    border-color: rgba(255, 255, 255, 0.15);
    margin: 1.25rem 0;
}

#waiting-room-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    text-align: left;
}

#waiting-player-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

#waiting-player-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    color: #ffffff;
    font-weight: 600;
}

#waiting-room-card .player-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.3);
    border: 2px solid rgba(139, 92, 246, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

#match-countdown-container {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 1rem;
}

.match-found-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fbbf24;
    margin-bottom: 0.5rem;
}

#match-countdown-timer {
    font-size: 3.5rem;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
    margin-bottom: 0.5rem;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
}

.starting-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}



.room-code-display {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.5);
    padding: 1rem;
    border-radius: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 2px;
    color: #c4b5fd !important;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.room-code-display:hover {
    background: rgba(139, 92, 246, 0.3);
}

.nav-pills .nav-link {
    color: var(--text-color);
    font-weight: 600;
    transition: all 0.3s ease;
    border-radius: 0.75rem;
}

.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.tab-content {
    padding-top: 1rem;
}

.tab-pane {
    animation: fadeIn 0.5s;
}

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

#score-container {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1rem;
    text-align: center;
    color: var(--text-color);
}

#score-container .label {
    font-weight: 600;
    color: var(--light-text-color);
    font-size: 0.85rem;
}

#score {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
}

#timer {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.2;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.label {
    font-weight: 600;
    color: var(--light-text-color);
    font-size: 0.85rem;
}

#player-list .list-group-item, #waiting-player-list .list-group-item {
    font-weight: 600;
    background: rgba(0, 0, 0, 0.35) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    margin-bottom: 8px;
    border-radius: 12px !important;
    transition: background-color 0.2s ease;
}
#player-list .list-group-item:hover, #waiting-player-list .list-group-item:hover {
    background-color: rgba(139, 92, 246, 0.15);
}
#player-list .list-group-item.eliminated, #waiting-player-list .list-group-item.eliminated {
    color: var(--error-color);
    text-decoration: line-through;
    opacity: 0.6;
}

#player-list {
    max-height: 250px;
    overflow-y: auto;
}

.board-container {
    position: relative;
}

#sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    border: 2px solid var(--primary-color);
    border-radius: 1rem;
    overflow: hidden;
    width: 100%;
    max-width: 550px;
    margin: 0 auto;
    aspect-ratio: 1 / 1;
    transition: opacity 0.3s ease;
    z-index: 1;
    box-shadow: 0 0 20px var(--primary-glow);
    background: var(--card-background);
}

.cell {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1.2rem, 4vw, 2rem);
    font-weight: 800;
    color: var(--accent-color);
    background-color: rgba(128, 128, 128, 0.05);
    border: 1px solid var(--border-color);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.cell:nth-child(3n):not(:nth-child(9n)) { border-right: 2px solid var(--primary-color); }
.cell:nth-child(n+19):nth-child(-n+27),
.cell:nth-child(n+46):nth-child(-n+54) {
    border-bottom: 2px solid var(--primary-color);
}

.cell:hover {
    background-color: rgba(139, 92, 246, 0.15);
}

.cell.fixed {
    color: var(--text-color);
    background-color: rgba(128, 128, 128, 0.15);
}

.cell.selected {
    background-color: var(--primary-color) !important;
    color: white;
    transform: scale(1.08);
    z-index: 10;
    box-shadow: 0 0 20px var(--primary-glow);
    border-radius: 0.5rem;
}

.cell.highlight {
    background-color: rgba(139, 92, 246, 0.2);
}

.cell.highlight-active {
    background-color: var(--accent-color);
    color: white;
}

.cell.wrong {
    background-color: var(--error-color) !important;
    color: white !important;
    animation: shake 0.4s;
}

.cell.incorrect {
    color: var(--error-color) !important;
}

.cell.correct-flash {
    animation: flash-green 0.5s;
}

.cell.hint-flash {
    animation: flash-hint 1s;
}

.cell.hint-flash-related {
    animation: flash-hint-related 1s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes flash-green {
    0% { background-color: var(--success-color); color: white; }
    100% { background-color: var(--card-background); color: var(--primary-color); }
}

@keyframes flash-hint {
    0%, 100% { background-color: var(--card-background); }
    50% { background-color: var(--hint-color); color: white; }
}

@keyframes flash-hint-related {
    0%, 100% { background-color: var(--card-background); }
    50% { background-color: rgba(56, 161, 105, 0.3); }
}

.cell .notes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
    text-align: center;
    font-size: clamp(0.6rem, 2vw, 0.8rem);
    line-height: 1.2;
    color: var(--text-color);
    font-weight: 600;
    align-items: center;
    opacity: 0.7; /* Make notes slightly transparent */
}

.cell.has-notes {
    background-color: rgba(255, 255, 0, 0.1); /* Light yellow background for notes */
}

.btn-icon {
    width: 50px;
    height: 50px;
    padding: 0;
    background-color: var(--card-background) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
}

.actions-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.actions-bar .btn {
    width: 50px;
    height: 50px;
    padding: 0;
}

.action-box-item {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 0.75rem;
    padding: 0.5rem;
    color: var(--text-color);
}

#notes-button.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    box-shadow: 0 0 10px var(--accent-color);
}

.number-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.number-button {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 55px;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-color);
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    background-color: rgba(255,255,255,0.05);
    border-radius: 0.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.number-button:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 15px var(--primary-glow);
    border-color: transparent;
}

.number-button.used {
    background-color: rgba(15, 23, 42, 0.6);
    color: var(--secondary-color);
    cursor: not-allowed;
    transform: none;
    text-decoration: none;
    opacity: 0.5;
    box-shadow: none;
}

.number-button.erase svg {
    fill: var(--light-text-color);
    transition: fill 0.2s ease;
}

.number-button.erase:hover {
    background-color: var(--error-color);
}

.number-button.erase:hover svg {
    fill: white;
}

#pause-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.3);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0.75rem;
    backdrop-filter: blur(5px);
}

#finished-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

#finished-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.finished-box {
    text-align: center;
    padding: 2rem 3rem;
    max-width: 500px;
    width: 90%;
    pointer-events: auto;
}

.message-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.message-icon.success {
    color: var(--success-color);
}

.message-icon.eliminated {
    color: var(--error-color);
}

.finished-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.completion-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* Styles for the temporary message display */
#message-display {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
    padding: 15px 30px;
    border-radius: 30px;
    box-shadow: 0 8px 20px var(--primary-glow);
    z-index: 2000;
    font-size: 1.1em;
    font-weight: 700;
    display: none;
    animation: fadeInUp 0.5s ease-out forwards, fadeOutDown 0.5s ease-in 4s forwards;
    border: 1px solid rgba(255,255,255,0.2);
}

@keyframes fadeInUp {
    from { bottom: -50px; opacity: 0; }
    to { bottom: 20px; opacity: 1; }
}

@keyframes fadeOutDown {
    from { bottom: 20px; opacity: 1; }
    to { bottom: -50px; opacity: 0; }
}

@media (max-width: 991.98px) {
    #game-container {
        padding-left: 5px;
        padding-right: 5px;
        padding-bottom: 80px;
    }

    #game-stats-mobile {
        display: flex;
        justify-content: space-around;
        text-align: center;
        background: var(--card-background);
        padding: 0.5rem;
        border-radius: 0.75rem;
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
        margin-bottom: 1rem;
    }

    .game-stat {
        flex: 1;
    }

    .game-stat .label {
        font-size: 0.7rem;
        font-weight: 600;
        color: var(--light-text-color);
    }

    .game-stat .value {
        font-size: 1.4rem;
        font-weight: 700;
        color: var(--text-color);
    }

    #score-container-mobile .value {
        color: var(--primary-color);
    }

    #sudoku-board {
        border-width: 2px;
    }

    .cell {
        font-size: clamp(1rem, 5vw, 1.5rem);
    }

    #mobile-controls {
        margin-bottom: 1rem; /* Add space between controls and board */
    }

    #mobile-actions-container {
        display: flex;
        justify-content: space-between; /* Change to space-between */
        margin-bottom: 1rem;
    }

    #mobile-actions-container .btn-icon {
        width: 40px; /* Make buttons circular */
        height: 40px;
        border-radius: 50%;
        font-size: 0.8rem;
        padding: 0;
        position: relative; /* Needed for positioning the hint count */
    }

    .mobile-hint-count {
        position: absolute;
        top: -5px;
        right: -5px;
        background-color: var(--error-color);
        color: white;
        border-radius: 50%;
        width: 20px;
        height: 20px;
        font-size: 0.8rem;
        display: flex;
        justify-content: center;
        align-items: center;
        font-weight: bold;
    }

    #actions-container #hint-count {
        display: block; /* Ensure it is visible on desktop */
    }

    @media (max-width: 991.98px) {
        #actions-container #hint-count {
            display: none; /* Hide desktop hint count on mobile */
        }
    }

    #mobile-number-palette {
        display: flex; /* Use flexbox for a single line */
        justify-content: space-around;
        gap: 5px;
        margin-top: 1rem; /* Add space above the number palette */
    }

    #mobile-number-palette .number-button {
        flex: 1; /* Allow buttons to grow and fill the space */
        height: auto;
        font-size: 1.2rem;
        padding: 5px 0;
        max-width: 40px; /* Limit button width */
    }

    #mistakes-container-mobile .value {
        font-size: 1rem;
    }

    #mobile-game-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 10px;
        margin-bottom: 1rem;
    }

    #mobile-difficulty-display {
        font-size: 1.1rem;
        font-weight: 700;
        color: var(--text-color);
    }

    #mobile-pause-button {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        padding: 0;
    }

    #mobile-player-list {
        max-height: 120px;
        overflow-y: auto;
    }
}

.player-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    margin-right: 1rem;
    border: 2px solid var(--background-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.player-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

    .player-name {
        font-weight: 600;
        color: var(--text-color);
    }

    .player-status {
        font-size: 0.8rem;
        color: var(--light-text-color);
    }

    .player-status.eliminated {
        color: var(--error-color);
        font-weight: 600;
    }

    .player-status.finished {
        color: var(--success-color);
        font-weight: 600;
    }

    #mobile-player-list .player-score {
        font-size: 1rem;
    }

    #mobile-info-tabs .nav-link {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    #mobile-info-tabs .tab-content {
        background: var(--card-background);
        border: 1px solid var(--border-color);
        border-radius: 1rem;
        padding: 1rem;
    }


#leaderboard-podium {
    display: flex; /* Added display flex */
    justify-content: center; /* Center the podium */
    align-items: flex-end; /* Align items to the bottom */
    gap: 1rem;
    min-height: 250px;
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 120px;
    padding: 1rem;
    border-radius: 0.75rem; /* Slightly more rounded */
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); /* Add shadow to podium places */
    transition: all 0.3s ease;
}

.podium-place:hover {
    transform: translateY(-15px) scale(1.02); /* More pronounced hover */
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

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

.podium-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.5rem;
    word-break: break-word;
}

.podium-score {
    font-size: 0.9rem;
    font-weight: 400;
}

.podium-1 {
    background: linear-gradient(135deg, #FFD700, #DAA520);
    height: 220px;
    order: 2;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.podium-2 {
    background: linear-gradient(135deg, #e2e8f0, #94a3b8);
    height: 180px;
    order: 1;
    box-shadow: 0 0 20px rgba(226, 232, 240, 0.3);
}

.podium-3 {
    background: linear-gradient(135deg, #d97706, #b45309);
    height: 140px;
    order: 3;
    box-shadow: 0 0 20px rgba(217, 119, 6, 0.3);
}

#leaderboard-list .list-group-item {
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    background-color: rgba(255,255,255,0.05);
    color: var(--text-color);
    border: 1px solid rgba(255,255,255,0.05);
    padding: 0.75rem 1.25rem;
}

#leaderboard-list .list-group-item:last-child {
    margin-bottom: 0;
}

#leaderboard-list .badge {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

#gameOverModal .modal-dialog {
    transform: translateY(-50px); /* Start slightly above */
    opacity: 0; /* Start invisible */
    transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

#gameOverModal.show .modal-dialog {
    transform: translateY(0); /* Slide into place */
    opacity: 1; /* Fade in */
}

#gameOverModal .modal-content {
    /* Rely on the new global UI/UX Pro Max .modal-content rules */
    overflow: hidden;
}

#gameOverModal .modal-header {
    background-color: transparent; /* Rely on glassmorphism */
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2rem 2.5rem 1rem;
    position: relative;
    overflow: hidden;
}

#gameOverModal .modal-header::before {
    display: none;
}

#gameOverModal .modal-title {
    font-size: 2.2rem;
    text-align: center;
    width: 100%;
}

#gameOverModal .modal-body {
    padding: 2rem 2.5rem;
}

#gameOverModalMessage {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.85); /* Slightly muted text */
    margin-bottom: 2rem;
    font-weight: 500;
}

#gameOverModal .modal-footer {
    padding: 1.5rem 2.5rem 2.5rem;
    border-top: none;
    justify-content: center;
    gap: 1rem;
}

#gameOverModal .btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    transition: all 0.3s ease;
}

#gameOverModal .btn-primary:hover {
    background-color: #4a55a8;
    border-color: #4a55a8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(90, 103, 216, 0.4);
}

@media screen and (min-width: 1024px) {
#main-container{
    min-height:100vh;
    overflow-y:auto;
}
}

@media screen and (max-width: 1024px) {
    #game-container{
        margin-top: 20px;
    }
    #sudoku-board{
        margin-bottom: 20px;
    }
}

@media screen and (max-width: 768px) {
    #room-management, #waiting-room {
        max-width: 90%;
    }
    .podium-place {
        width: 100px;
    }
    .podium-1 {
        height: 180px;
    }
    .podium-2 {
        height: 150px;
    }
    .podium-3 {
        height: 120px;
    }
}

@media screen and (max-width: 480px) {
    .podium-place {
        width: 80px;
        padding: 0.5rem;
    }
    .podium-rank {
        font-size: 1.5rem;
    }
    .podium-name {
        font-size: 0.9rem;
    }
    .podium-score {
        font-size: 0.7rem;
    }
    .podium-1 {
        height: 150px;
    }
    .podium-2 {
        height: 120px;
    }
    .podium-3 {
        height: 100px;
    }
}

#chat-panel .card-body {
    display: flex;
    flex-direction: column;
    height: 500px; /* Adjust as needed */
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: rgba(15, 23, 42, 0.4);
    border-radius: 0.5rem;
    border: 1px solid rgba(255,255,255,0.05);
}

.chat-message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 15px;
    max-width: 80%;
    word-wrap: break-word;
}

.chat-message .sender {
    font-weight: 600;
    margin-right: 5px;
}

.chat-message.my-message {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.chat-message:not(.my-message) {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    align-self: flex-start;
}

body.light-mode .chat-message:not(.my-message) {
    background-color: rgba(0, 0, 0, 0.05);
}

#chat-pane .chat-messages {
    height: 200px;
}

.pre-chat-messages .btn {
    margin: 2px;
}

#mobile-info-tabs .nav-link#chat-tab {
    position: relative;
}

#mobile-info-tabs .nav-link#chat-tab .badge {
    position: absolute;
    top: 0;
    right: 0;
    transform: translate(50%, -50%);
}

body.solo-mode #chat-panel,
body.solo-mode #chat-tab {
    display: none !important;
}

.player-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.player-list-item:hover {
    background-color: #f1f3f5;
}

.player-list-item.eliminated {
    opacity: 0.6;
    text-decoration: line-through;
}

.player-list-item.finished .player-name {
    color: var(--success-color);
}

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

.player-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 10px;
}

.player-name {
    font-weight: 500;
}

.player-score {
    font-weight: bold;
    color: white;
}

#mobile-player-list .list-group-item {
    background-color: transparent;
    border: none;
    padding: 0.5rem 0;
}

#mobile-player-list .player-info {
    flex-grow: 1;
}

#mobile-player-list .player-score {
    font-size: 1rem;
}

#mobile-player-list .player-avatar {
    width: 35px;
    height: 35px;
}

#mobile-player-list .player-name {
    font-size: 0.9rem;
}

#mobile-player-list .player-status {
    font-size: 0.7rem;
}

#chat-panel, #mobile-info-tabs {
    position: relative;
    z-index: 1051;
}

/* Mobile Chat Slide-out Panel */
#mobile-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 80%;
    max-width: 320px;
    height: 100%;
    background-color: var(--background-color);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    transform: translateX(calc(100% + 20px));
    transition: transform 0.3s ease-in-out;
    z-index: 9990; /* Higher than the overlay */
    display: flex;
    flex-direction: column;
}

#mobile-chat-panel.open {
    transform: translateX(0);
}

#mobile-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--primary-color);
    color: white;
}

#mobile-chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

#mobile-chat-panel .chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

#mobile-chat-panel .input-group {
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
}

/* Floating Chat Toggle Button */
#mobile-chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 9990;
}

#chat-notification-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 12px;
    height: 12px;
    background-color: var(--error-color);
    border-radius: 50%;
    border: 2px solid white;
}

/* Desktop Chat Slide-out Panel */
#desktop-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 450px; /* Adjust as needed */
    height: 100%;
    background-color: var(--background-color);
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    transform: translateX(calc(100% + 20px));
    transition: transform 0.3s ease-in-out;
    z-index: 9990;
    display: flex;
    flex-direction: column;
}

#desktop-chat-panel.open {
    transform: translateX(0);
}

#desktop-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--primary-color);
    color: white;
}

#desktop-chat-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

#desktop-chat-panel .chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

#desktop-chat-panel .input-group {
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
}

/* Floating Desktop Chat Toggle Button */
#desktop-chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 9990;
}

#desktop-chat-notification-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 12px;
    height: 12px;
    background-color: var(--error-color);
    border-radius: 50%;
    border: 2px solid white;
}

#ad-banner {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    height: 50px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

#ad-banner p {
    margin: 0;
    text-align: center;
    width: 100%;
}

/* Mobile specific styles */
@media (max-width: 767.98px) {
    #chat-input {
        font-size: 1.2rem;
        padding: 1rem;
    }

    #player-name-input {
        border: none !important;
        box-shadow: none !important;
    }

    /* Ensure the injected chat panel fits the screen and doesn't expand infinitely */
    #mobile-chat-panel #chat-panel {
        display: flex;
        flex-direction: column;
        height: 100%;
        margin-top: 0 !important;
        border: none;
        box-shadow: none;
        background: transparent;
    }

    #mobile-chat-panel #chat-panel .card-body {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        overflow: hidden;
        padding: 0;
    }

    #mobile-chat-panel #chat-panel .card-title {
        display: none; /* Hide the nested 'Chat' title since mobile-chat-header already has one */
    }

    #mobile-chat-panel .chat-messages {
        flex-grow: 1;
        overflow-y: auto;
        border: none;
    }

}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* Enforce obvious greyed-out disabled states globally */
button:disabled, .btn:disabled {
    opacity: 0.6 !important;
    pointer-events: none !important;
    filter: grayscale(80%) !important;
    box-shadow: none !important;
    transform: none !important;
    cursor: not-allowed !important;
}
/* Daily Rewards & UI Glows */
.glow-btn {
    transition: box-shadow 0.3s ease, transform 0.2s ease;
}
.glow-btn:hover {
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.6);
    transform: translateY(-2px);
}
.glow-animation {
    animation: chestHover 2.5s infinite ease-in-out;
    filter: drop-shadow(0 0 15px rgba(255, 193, 7, 0.8));
}
@keyframes chestHover {
    0% { transform: translateY(0px) scale(1); filter: drop-shadow(0 0 10px rgba(255, 193, 7, 0.5)); }
    50% { transform: translateY(-10px) scale(1.05); filter: drop-shadow(0 0 25px rgba(255, 193, 7, 1)); }
    100% { transform: translateY(0px) scale(1); filter: drop-shadow(0 0 10px rgba(255, 193, 7, 0.5)); }
}

/* Waiting Room Styles */
#waiting-room {
    padding-top: 5vh;
}

#waiting-player-list {
    margin-bottom: 2rem;
}

#waiting-player-list .list-group-item {
    transition: all 0.3s ease;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05); /* Subtle background for better contrast */
}

#waiting-player-list .player-avatar {
    background: rgba(255, 255, 255, 0.2);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#match-countdown-timer {
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 20px rgba(255, 193, 7, 0.4);
}

/* Hard-Boundary Chat Display Overrides */
@media (max-width: 991.98px) {
    #desktop-chat-panel, #desktop-chat-toggle-btn {
        display: none !important;
    }
}

@media (min-width: 992px) {
    #mobile-chat-panel, #mobile-chat-toggle-btn {
        display: none !important;
    }
}
