:root {
    --bg-color: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --secondary: #10b981;
    --secondary-hover: #059669;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #f59e0b;
    --cell-bg: rgba(51, 65, 85, 0.7);
    --cell-selected: #3b82f6;
    --cell-matched: #10b981;
    --danger: #ef4444;
    --bot-color: #a855f7;
}

* {
    box-sizing: border-box;
}

body.dark-theme {
    background: var(--bg-color);
    background-image: radial-gradient(circle at top right, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.15) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ================================
   GLASS CONTAINERS
   ================================ */
.glass-container {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* ================================
   TYPOGRAPHY
   ================================ */
h1 {
    margin-top: 0;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #60a5fa, #34d399);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ================================
   EMOJI SELECTOR
   ================================ */
.emoji-selector {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.emoji-option {
    font-size: 2rem;
    cursor: pointer;
    transition: transform 0.2s;
    opacity: 0.5;
}

.emoji-option:hover {
    transform: scale(1.2);
}

.emoji-option.selected {
    opacity: 1;
    transform: scale(1.2);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

/* ================================
   GRID SIZE SELECTOR (Landing Page)
   ================================ */
.grid-size-selector {
    margin: 1.25rem 0;
}

.section-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.grid-options {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.grid-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.grid-option::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(16, 185, 129, 0.15));
    opacity: 0;
    transition: opacity 0.3s;
}

.grid-option:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.grid-option:hover::before {
    opacity: 1;
}

.grid-option.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.12);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2), inset 0 0 20px rgba(59, 130, 246, 0.05);
}

.grid-option.selected::before {
    opacity: 1;
}

.grid-icon {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
    position: relative;
    z-index: 1;
}

.grid-label {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--text-main);
    position: relative;
    z-index: 1;
}

.grid-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    position: relative;
    z-index: 1;
}

/* ================================
   GRID SIZE BADGE (Room)
   ================================ */
.grid-size-badge {
    margin-bottom: 1rem;
}

.badge-text {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ================================
   INPUTS
   ================================ */
input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    margin-bottom: 1rem;
    box-sizing: border-box;
    transition: all 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ================================
   BUTTONS
   ================================ */
.btn {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

.btn-primary {
    background: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-bot {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
    border: 1px solid rgba(168, 85, 247, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-bot::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-bot:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(168, 85, 247, 0.5);
}

.btn-bot:hover::before {
    opacity: 1;
}

.btn-play-again {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    color: var(--text-main);
    transition: all 0.3s ease;
}

.btn-play-again:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
    box-shadow: 0 0 15px var(--accent);
    transform: scale(1.05);
}

.btn-play-again:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--secondary);
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

/* ================================
   LAYOUT
   ================================ */
.actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.divider {
    margin: 1rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--glass-border);
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.game-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    box-sizing: border-box;
    margin: 0 auto;
}

.center-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Room info bar — below the grid */
.room-info-bar {
    text-align: center;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

/* Players section */
.players-section {
    width: 100%;
    max-width: 400px;
    margin-top: 1rem;
}

/* Leave button at the bottom */
.btn-leave-bottom {
    margin-top: 1rem;
    max-width: 400px;
    width: 100%;
    background: var(--danger);
}

/* ================================
   BINGO GRIDS — 5×5 and 7×7
   ================================ */
.grid-5x5,
.bingo-board.grid-5x5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
}

.grid-7x7,
.bingo-board.grid-7x7 {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    width: 100%;
    max-width: 480px;
    aspect-ratio: 1;
}

/* Setup grid inherits from grid size classes */
.grid-setup.grid-5x5 {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
}

.grid-setup.grid-7x7 {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 1;
}

/* ================================
   CELLS
   ================================ */
.cell {
    background: var(--cell-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

/* Smaller cells for 7x7 */
.grid-7x7 .cell,
.grid-setup.grid-7x7 .cell {
    font-size: 1rem;
    border-radius: 6px;
}

.cell .manual-input {
    background: rgba(15, 23, 42, 0.8);
    color: #fff;
    text-align: center;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0;
    padding: 0;
}

.grid-7x7 .cell .manual-input,
.grid-setup.grid-7x7 .cell .manual-input {
    font-size: 1rem;
    border-radius: 6px;
}

/* Hide number input spinners */
.manual-input::-webkit-outer-spin-button,
.manual-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.manual-input[type=number] {
    -moz-appearance: textfield;
}

.cell:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.cell.selected {
    background: var(--cell-selected) !important;
    color: white;
    cursor: not-allowed;
    border-color: #60a5fa;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    animation: cellSelect 0.3s ease;
}

@keyframes cellSelect {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.cell.matched {
    background: var(--cell-matched) !important;
    color: white;
    border-color: #34d399;
}

.disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

/* ================================
   OVERLAYS
   ================================ */
.glass-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.setup-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.error-msg {
    color: var(--danger);
    font-size: 0.875rem;
    margin-top: 1rem;
    min-height: 1.2em;
}

/* ================================
   PLAYER LIST
   ================================ */
#playerList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#playerList li {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

#playerList li.current-turn {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid var(--primary);
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

/* Bot badge */
.bot-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--bot-color), #7c3aed);
    color: white;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 1px;
    vertical-align: middle;
    margin-left: 2px;
    text-transform: uppercase;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.3);
}

/* ================================
   BINGO PROGRESS
   ================================ */
.bingo-progress {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    margin-bottom: 1rem;
}

.bingo-progress .letter {
    font-size: 2rem;
    font-weight: 900;
    color: var(--glass-border);
    transition: all 0.5s;
    text-shadow: 0 0 10px transparent;
}

.bingo-progress .letter.active {
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent);
    transform: scale(1.1);
}

/* ================================
   TURN INDICATOR
   ================================ */
.turn-indicator {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    font-weight: bold;
    min-height: 1.5em;
}

.turn-indicator span.your-turn {
    color: var(--primary);
    text-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* ================================
   LEADERBOARD
   ================================ */
.leaderboard .rank {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.rank.first {
    border-left: 4px solid gold;
}

.rank.second {
    border-left: 4px solid silver;
}

/* ================================
   NEW GAME OVERLAY
   ================================ */
.new-game-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-color);
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.5s ease;
    backdrop-filter: blur(10px);
}

.new-game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.new-game-content h2 {
    font-size: 3rem;
    color: var(--accent);
    animation: pulse 1s infinite;
}

/* ================================
   WIN OVERLAY
   ================================ */
.win-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    backdrop-filter: blur(10px);
}

.win-overlay.hidden {
    display: none;
}

.win-content {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.crown {
    font-size: 5rem;
    margin: 0;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

.gold-text {
    font-size: 4rem;
    margin: 1rem 0;
    background: linear-gradient(to right, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

.win-name {
    font-size: 2.5rem;
    color: white;
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 900px) {
    .game-layout {
        padding: 1rem;
    }
}

/* ================================
   REACTION BAR
   ================================ */
.reaction-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
    background: var(--glass-bg);
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    width: 100%;
    max-width: 400px;
}

.reaction-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s, background 0.2s;
    user-select: none;
    position: relative;
}

.sound-indicator {
    font-size: 0.65rem;
    position: absolute;
    top: -2px;
    right: -4px;
    background: var(--accent);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 5px rgba(245, 158, 11, 0.5);
}

.reaction-btn.text-reaction {
    border-radius: 8px;
    width: auto;
    padding: 0 10px;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-main);
}

.reaction-btn:hover {
    transform: scale(1.2);
    background: rgba(255, 255, 255, 0.2);
}

/* Hurry Up button — stands out in orange */
.reaction-btn.hurry {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

.reaction-btn.hurry:hover {
    background: rgba(245, 158, 11, 0.35);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

/* ================================
   FLOATING REACTIONS
   ================================ */
#floatingReactionsContainer {
    position: fixed;
    bottom: 20%;
    left: 10%;
    width: 80%;
    height: 60%;
    pointer-events: none;
    z-index: 1000;
}

.floating-reaction {
    position: absolute;
    font-size: 2.5rem;
    animation: floatUp 3s ease-in-out forwards;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    opacity: 0;
}

.floating-reaction .sender-name {
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 5px;
    white-space: nowrap;
}

.floating-reaction.text-style {
    font-size: 1.5rem;
    font-weight: bold;
    background: var(--primary);
    padding: 5px 15px;
    border-radius: 20px;
    color: white;
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.5);
}

@keyframes floatUp {
    0% {
        transform: translateY(100px) scale(0.5);
        opacity: 0;
    }

    10% {
        transform: translateY(80px) scale(1.2);
        opacity: 1;
    }

    20% {
        transform: translateY(60px) scale(1);
        opacity: 1;
    }

    80% {
        transform: translateY(-150px) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-200px) scale(0.8);
        opacity: 0;
    }
}

/* ================================
   CHAT
   ================================ */
.chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary);
    color: white;
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    z-index: 900;
    backdrop-filter: blur(8px);
    transition: transform 0.2s, background 0.2s;
}

.chat-toggle-btn:hover {
    transform: scale(1.05);
    background: var(--primary-hover);
}

/* Chat notification badge */
.chat-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 5px;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6), 0 0 20px rgba(239, 68, 68, 0.3);
    animation: badgePulse 1.5s ease-in-out infinite;
    border: 2px solid var(--bg-color);
    z-index: 10;
}

@keyframes badgePulse {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(239, 68, 68, 0.6), 0 0 20px rgba(239, 68, 68, 0.3);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 15px rgba(239, 68, 68, 0.8), 0 0 30px rgba(239, 68, 68, 0.5);
        transform: scale(1.15);
    }
}

.chat-toggle-btn.has-unread {
    animation: btnBounce 2s ease-in-out infinite;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4), 0 0 20px rgba(239, 68, 68, 0.3);
}

@keyframes btnBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    15% {
        transform: translateY(-4px);
    }

    30% {
        transform: translateY(0);
    }

    45% {
        transform: translateY(-2px);
    }

    60% {
        transform: translateY(0);
    }
}

.chat-window {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 320px;
    height: 400px;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    padding: 1rem;
}

.chat-window.hidden {
    transform: translateY(120%) scale(0.9);
    opacity: 0;
    pointer-events: none;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px inset var(--glass-border);
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.chat-history::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 6px;
}

.chat-message {
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    word-break: break-word;
    max-width: 85%;
    align-self: flex-start;
    position: relative;
    border-bottom-left-radius: 2px;
}

.chat-message.self {
    background: var(--primary);
    align-self: flex-end;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 2px;
}

.msg-author {
    font-size: 0.7rem;
    opacity: 0.6;
    margin-bottom: 2px;
    display: block;
}

.custom-chat-input {
    background: rgba(0, 0, 0, 0.5);
    min-height: 36px;
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    overflow-x: auto;
    white-space: nowrap;
    border: 1px solid var(--glass-border);
    color: white;
}

.custom-chat-input.placeholder {
    color: var(--text-muted);
}

.custom-keyboard {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.kb-row {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.kb-key {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 10px 0;
    border-radius: 6px;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.1s, transform 0.1s;
    user-select: none;
    flex: 1;
}

.kb-key:active {
    background: var(--primary);
    transform: scale(0.95);
}

.kb-key.action-key {
    background: rgba(255, 255, 255, 0.2);
    font-size: 0.8rem;
    font-weight: 600;
}

.kb-key.kb-key-space {
    flex: 3;
    max-width: 60%;
}

.kb-key.kb-key-send {
    flex: 2;
    max-width: 30%;
    background: var(--secondary);
    color: white;
    border-color: var(--secondary-hover);
    font-weight: 600;
}

@media (max-width: 600px) {
    .chat-window {
        width: 90%;
        bottom: 80px;
        right: 5%;
        left: 5%;
        height: 85%;
        max-height: 550px;
    }
}

/* ================================
   END GAME SCREEN
   ================================ */
.end-game-screen {
    display: none;
    /* Changed via JS */
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    justify-content: center;
    padding: 2rem;
    width: 100%;
    min-height: calc(100vh - 4rem);
    animation: fadeInEnd 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

@keyframes fadeInEnd {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
        filter: blur(5px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

.end-title {
    font-size: clamp(2.5rem, 8vw, 4rem);
    margin: 0;
    text-align: center;
    background: linear-gradient(135deg, #a855f7 0%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(236, 72, 153, 0.3);
    font-weight: 900;
}

.end-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 320px;
}

.end-play-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    font-size: 1.25rem;
    padding: 1.1rem;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
    font-weight: bold;
    color: white;
}

.end-play-btn:hover:not(:disabled) {
    box-shadow: 0 12px 30px rgba(16, 185, 129, 0.6);
    transform: translateY(-3px);
    background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

.end-leave-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.5);
    color: #fca5a5;
    padding: 1rem;
    border-radius: 12px;
}

.end-leave-btn:hover {
    background: rgba(239, 68, 68, 0.4);
    color: white;
}

.end-stats-container {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 900px;
    flex-wrap: wrap;
    justify-content: center;
}

.end-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    flex: 1;
    min-width: 280px;
    backdrop-filter: blur(16px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.end-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.end-card h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 1px;
}

.end-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.end-list li {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.1rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: background 0.2s ease;
}

.end-list li:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .end-game-screen {
        padding: 1rem;
        gap: 1.5rem;
    }

    .end-stats-container {
        flex-direction: column;
        gap: 1.5rem;
    }

    .end-card {
        padding: 1.5rem;
        min-width: 100%;
    }

    .glass-container {
        padding: 1.5rem;
        margin: 1rem;
    }

    .grid-options {
        flex-direction: column;
    }

    .bingo-board.grid-7x7 {
        max-width: 360px;
    }

    .grid-7x7 .cell {
        font-size: 0.85rem;
    }
}