:root {
    /* Modern Dark Theme Palette */
    --bg-dark: #0f172a;
    /* Slate 900 */
    --bg-card: rgba(30, 41, 59, 0.6);
    /* Slate 800 + Opacity */
    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #94a3b8;
    /* Slate 400 */

    --primary: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --success: #10b981;
    /* Emerald 500 */
    --error: #ef4444;
    /* Red 500 */
    --warn: #f59e0b;
    /* Amber 500 */

    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    margin: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* No scrollbars */
    background-image:
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.15) 0%, transparent 20%);
}

/* --- Shared Components --- */

.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    box-sizing: border-box;
    position: relative;
    justify-content: center;
    gap: 0.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.screen.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Global Utilities */
.hidden {
    display: none !important;
}

.cursor-pointer {
    cursor: pointer;
}

.text-center {
    text-align: center;
}

.flex-center-gap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.w-full {
    width: 100%;
}

.opacity-80 {
    opacity: 0.8;
}

.mb-0-5rem {
    margin-bottom: 0.5rem;
}

.mb-1rem {
    margin-bottom: 1rem;
}

.mb-1-5rem {
    margin-bottom: 1.5rem;
}

.mb-2rem {
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.svg-text-primary {
    color: var(--text-primary);
}

.svg-error {
    color: var(--error);
}

.empty-state-container {
    text-align: center;
    padding: 1.5rem;
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1rem;
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

.empty-state-icon-large {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.modal-info-text {
    margin-bottom: 1.5rem;
    opacity: 0.8;
}

.disconnect-countdown-text {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.faded-info-text {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}

.screen-transition-out {
    opacity: 0 !important;
    transform: translateY(-10px) !important;
    pointer-events: none !important;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 1rem;
    background-image: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: white;
    border: none;
    border-radius: 0.3rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    /* Space for icons */
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.5);
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    background: var(--text-secondary) !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
    opacity: 0.5 !important;
    pointer-events: none;
}

.btn-success {
    background: var(--success) !important;
}

.btn-primary-bg {
    background: #6366f1 !important;
}

.btn-warning {
    background: var(--warn) !important;
    background-image: linear-gradient(135deg, var(--warn) 0%, #d97706 100%) !important;
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.4) !important;
}

.btn-warning:hover {
    box-shadow: 0 10px 15px -3px rgba(245, 158, 11, 0.5) !important;
}

/* Inputs */
.input-field {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 0.3rem;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.2);
    color: white;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

.lang-selected-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nickname-container {
    margin-bottom: 2rem;
}

.avatar-display-area {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.nickname-display-field {
    text-align: center;
    font-weight: bold;
    cursor: default;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.3rem;
    transition: all 0.3s ease;
}

.nickname-display-field.editing {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    cursor: text;
}

.change-nickname-link {
    font-size: 0.8rem;
    opacity: 0.8;
    text-decoration: none;
    display: block;
    margin-top: 0.5rem;
    text-align: center;
    color: var(--text-secondary);
}

.nickname-actions-container {
    margin-top: 0.5rem;
    justify-content: center;
    gap: 0.5rem;
}

.btn-small-action {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-disabled-state {
    opacity: 0.5 !important;
    pointer-events: none !important;
}

.btn-dimmed {
    opacity: 0.7 !important;
}

/* Custom Input PIN */
.input-game-pin {
    width: 100%;
    padding: 1rem;
    color: white;
    border-radius: 0.3rem;
    font-size: 1.5rem;
    /* Copied from inline style */
    font-weight: 600;
    /* Copied from .btn */
    text-align: center;
    /* Copied from inline style */
    text-transform: uppercase;
    /* Copied from inline style */
    display: block;
    /* Similar to btn/input base */
    transition: all 0.2s;
    /* Keeping input-glass properties separate or letting them compose? User said copy btn properties. */
    /* .btn has background-image gradient, but input-glass overrides it usually. */
    /* .btn has border: none. */
    border: 1px solid white;
    /* Matching input-glass generally, or override */
}

.input-game-pin:focus {
    outline: none;
    border-color: var(--primary);
}

/* Custom Language Dropdown */
.lang-dropdown {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    cursor: pointer;
    user-select: none;
    z-index: 10;
}

.lang-dropdown-selected {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 0.3rem;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center the label and flag */
    transition: all 0.3s ease;
    box-sizing: border-box;
    backdrop-filter: blur(8px);
    position: relative;
    /* For absolute arrow */
}

.lang-dropdown-selected:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.lang-dropdown.active .lang-dropdown-selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.lang-dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(20, 21, 28, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid var(--primary);
    border-top: none;
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
    overflow: hidden;
    display: none;
    z-index: 100;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: slideDown 0.2s ease-out;
}

.lang-dropdown.active .lang-dropdown-options {
    display: block;
}

.lang-option {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.2s;
}

.lang-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.lang-option.selected {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    font-weight: bold;
}

.lang-flag {
    font-size: 1.25rem;
    line-height: 1;
    display: inline-block;
}

.lang-dropdown-arrow {
    position: absolute;
    right: 1.5rem;
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    opacity: 0.6;
}

.lang-dropdown.active .lang-dropdown-arrow {
    transform: rotate(180deg);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animations for lists and elements */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes flashGreen {
    0% {
        background-color: rgba(16, 185, 129, 0.5);
    }

    100% {
        background-color: transparent;
    }
}

@keyframes flashRed {
    0% {
        background-color: rgba(239, 68, 68, 0.5);
    }

    100% {
        background-color: transparent;
    }
}

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

    70% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-slide-in {
    animation: slideInRight 0.3s ease-out forwards;
}

.animate-pop-in {
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-out;
}

.flash-increase {
    animation: flashGreen 0.8s ease-out;
    border-radius: 0.3rem;
}

.flash-decrease {
    animation: flashRed 0.8s ease-out;
    border-radius: 0.3rem;
}

/* Screen specific overrides for transitions */
#game-screen.screen {
    transform: scale(0.98);
}

#game-screen.screen.active {
    transform: scale(1);
}

.input-glass {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid white;
    margin-bottom: 1rem;
}



/* --- Utilities & Typography --- */
.text-primary-color {
    color: var(--primary);
}

.landing-title {
    font-size: 3rem;
    font-weight: 800;
    text-align: center;
}

.landing-subtitle {
    font-size: 1rem;
    opacity: 0.7;
    text-align: center;
    margin-bottom: 1rem;
}

.landing-actions {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.flex-row-gap {
    display: flex;
    gap: 1rem;
}

.flex-1 {
    flex: 1;
}

.result-title {
    font-size: 2rem;
}

.result-score {
    font-size: 1.5rem;
    color: var(--success);
}

.max-w-400 {
    width: 100%;
    max-width: 400px;
}

.mt-2 {
    margin-top: 2rem;
}

/* --- Avatar --- */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 0.3rem;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: 800;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    font-size: 1rem;
    flex-shrink: 0;
}

.avatar.sm {
    width: 24px;
    height: 24px;
    font-size: 0.7rem;
    border-width: 1px;
}



/* --- Top Bar (Fixed) --- */
.scoreboard-top {
    display: flex;
    /* Flex to layout items */
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 50;
    height: 70px;
    /* Fixed height */
    flex-shrink: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

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

.player-name {
    font-weight: 700;
    font-size: 1rem;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}



/* --- Live Stats Header (Solo Mode) - In Top Bar --- */
.live-stats-header-topbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.3rem;
    padding: 0.35rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 20px rgba(59, 130, 246, 0.1);
}

.stat-inline {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-variant-numeric: tabular-nums;
}

/* Individual stat colors */
.stat-correct {
    color: #94a3b8;
    /* Neutral gray */
}

.stat-accuracy {
    color: #94a3b8;
    /* Neutral gray */
}

.stat-points {
    color: #94a3b8;
    /* Neutral gray */
}

.stat-streak {
    color: #94a3b8;
    /* Neutral gray */
}

.stat-separator {
    color: rgba(255, 255, 255, 0.4);
    font-weight: 400;
    font-size: 0.7rem;
}


/* --- Main Game Area (Flex) --- */
#game-screen.active {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    padding-top: 6rem;
    /* Space for Fixed Header */
    padding-bottom: 1rem;
    overflow-y: auto;
    /* Allow vertical scrolling on small viewports */
    overflow-x: hidden;
    height: 100dvh;
    width: 100%;
}

/* Centered wrapper for question + options + action bar */
.game-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    /* Limit width on large screens */
    margin: 0 auto;
    flex: 1;
    /* Take available space */
    gap: 0.5rem;
}



/* Question Area */
.question-container {
    flex: 0;
    /* Don't grow aggressively */
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Center text locally */
    align-items: center;
    text-align: center;
    padding: 1rem 0;
    margin-bottom: 1rem;
    position: relative;
    /* For absolute positioning of stats header */
}

.timer-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100px;
    height: 100px;
    margin-top: 0.5rem;
    /* Prevent overlap with stats header */
    margin-bottom: 0.5rem;
    perspective: 1000px;
    /* Added for Flip */
}

/* Circular Timer */
.timer-circular {
    position: relative;
    width: 80px;
    height: 80px;
    /* No rotation on container */
}

.timer-circular svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    /* Rotate SVG only */
}

.timer-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 6;
}

.timer-path {
    fill: none;
    stroke: var(--success);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 283;
    /* 2 * PI * 45 */
    stroke-dashoffset: 0;
    transition: stroke 0.3s;
}

@keyframes drain-timer {
    0% {
        stroke-dashoffset: 0;
    }

    100% {
        stroke-dashoffset: 283;
    }
}

.timer-path.danger-timer {
    stroke: var(--error) !important;
    animation-name: drain-timer, blink-stroke !important;
    animation-duration: inherit, 0.5s !important;
    animation-iteration-count: 1, infinite !important;
    animation-timing-function: linear, ease !important;
    animation-fill-mode: forwards, none !important;
}

.timer-path.paused-timer {
    animation-play-state: paused !important;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
    font-variant-numeric: tabular-nums;
}

/* Status Colors */
.timer-path.warn {
    stroke: #facc15;
}

.timer-path.danger {
    stroke: var(--error);
    animation: blink-stroke 0.5s infinite;
}

.timer-text.blink-red {
    color: var(--error);
    animation: blink 0.5s infinite;
}

@keyframes blink {
    50% {
        opacity: 0.2;
    }
}

@keyframes blink-stroke {
    50% {
        stroke-opacity: 0.2;
    }
}


.question-text {
    font-size: clamp(1.2rem, 4vw, 2rem);
    /* Dynamic Font Size */
    font-weight: 700;
    line-height: 1.3;
}

/* Options Grid */
.options-grid,
#options-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.5rem;
    flex: 0 0 auto;
    /* Do not shrink */
    min-height: 250px;
    /* Prevent layout collapse during question transition */
    align-content: center;
    align-items: stretch;
}

.option-btn {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 0.3rem;
    padding: 1.5rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 50px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

.option-btn:hover {
    background: #334155;
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.option-btn.selected {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.option-btn.correct {
    background: rgba(16, 185, 129, 0.2) !important;
    border-color: var(--success) !important;
}

.option-btn.wrong {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: var(--error) !important;
    opacity: 0.5;
}

/* Player Tags in Option */
.option-player-tags {
    margin-top: 0.5rem;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.option-player-tag {
    background: white;
    color: black;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 0.3rem;
    font-weight: 700;
    opacity: 0.9;
}

/* Action Bar (Bottom Buttons) */
.action-bar {
    width: 100%;
    max-width: 600px;
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 0;
    margin-top: auto;
    min-height: 56px;
    /* Stabilize height for button swaps */
    perspective: 1000px;
    /* Enable 3D transitions */
}

/* Button Flip Transition */
.btn-flipper {
    position: relative;
    width: 100%;
    height: 56px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.btn-flipper.flipped {
    transform: rotateX(180deg);
}

.btn-front,
.btn-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-back {
    transform: rotateX(180deg);
}

.action-bar .btn {
    width: 100%;
    height: 56px;
    font-size: 1.2rem;
    /* Pill shape */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    /* Ensure text is above progress */
    overflow: hidden;
}

/* Reveal Progress Bar inside Button */
.btn-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    /* Anchor Left (Standard) */
    right: auto;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    z-index: 1;
}

.btn-content {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}

/* --- Lobby & Landing (Also Full Height) --- */
.lobby-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* justify-content: flex-start; Removed to allow centering */
    gap: 0.5rem;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Lobby action buttons */
.lobby-actions {
    display: flex;
    gap: 1rem;
    width: 100%;
    margin-top: 1.5rem;
}

/* Mobile: Full width and stack buttons vertically */
@media (max-width: 600px) {
    .lobby-container {
        max-width: 100%;
        padding: 1.5rem 1rem;
    }

    .lobby-actions {
        flex-direction: row;
        /* Force row layout */
    }
}

.pin-display-container {
    display: flex;
    align-items: center;
    gap: 0;
    margin: 0.5rem 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.3rem;
    padding: 0.25rem;
    width: 100%;
}

/* Smaller PIN container variant */
.pin-container-small {
    transform: scale(0.7);
    max-width: 200px;
    margin: 0.1rem auto;
}

/* Link display input */
.link-display {
    font-size: 0.85rem;
    padding: 0.75rem;
    background: transparent;
    border: none;
    color: white;
    flex: 1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: text;
}

.link-display:focus {
    outline: none;
}

/* Muted text styles */
.muted-text {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 0.5rem;
    text-align: center;
}

.muted-text-small {
    font-size: 0.75rem;
    opacity: 0.6;
    margin: 0.5rem 0;
    text-align: center;
}

/* Host player list styling */
.lobby-player-list {
    list-style: none;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: rgb(0 0 0 / 21%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0.3rem;
    max-width: 320px;
    width: 100%;
    margin: 2.5rem auto;
}

.lobby-player-list li {
    padding: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.pin-display {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: 0.2rem;
    color: white;
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    flex: 1;
    text-align: center;
}

/* Smaller PIN display variant */
.pin-display-small {
    color: white;
    background: transparent;
    border: none;
    padding: 0.5rem;
    flex: 1;
    text-align: center;
}

.btn-icon-glass {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    width: 48px;
    height: 48px;
    border-radius: 0.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon-glass:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: none;
}

.btn-icon-glass:active {
    transform: scale(0.95);
}

/* Player List */
.player-list {
    max-height: 300px;
    overflow-y: auto;
}

#host-empty-state {
    padding: 3rem !important;
    /* Force override if needed, or just update logic */
}

/* Player List */
/* Player List (Scoreboard Style) */
/* --- Player Grid (Card Layout) --- */
/* --- Player Premium List (Vertical Hybrid) --- */
.player-ticker {
    flex-direction: column;
    gap: 0.5rem;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    width: 100%;
    max-height: none;
    min-height: 0;
    flex: 1 1 auto;
    /* Absorb all shrink */
    padding: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Hide player ticker in solo mode */
body.solo-mode .player-ticker {
    display: none !important;
}

.player-premium-row {
    display: flex;
    align-items: center;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0.3rem;
    padding: 0.5rem 0.75rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    box-sizing: border-box;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    gap: 1rem;
}

.player-premium-row:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Rank Number */
.player-rank {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-secondary);
    min-width: 1.5rem;
    text-align: center;
    opacity: 0.6;
}

/* Main Content: Avatar + Text */
.player-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.player-avatar-wrapper .avatar {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.player-details {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.player-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.player-score {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* Status Pill (Right Side) */
.player-status-pill {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.25rem 0.6rem;
    border-radius: 0.3rem;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
    min-width: 70px;
    text-align: center;
}

.player-status-pill.ready {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.2);
}

.player-status-pill.thinking {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.2);
    animation: pulse-opacity 1.5s infinite;
}

.player-status-pill.answered {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.player-status-pill.locked {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.player-status-pill.disconnected {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Status Variants */
.player-status {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.3rem 0;
    border-radius: 0.3rem;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
    text-align: center;
    width: 100%;
    display: block;
    letter-spacing: 0.5px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.player-status.ready {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.2);
}

.player-status.thinking {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.2);
    animation: pulse-opacity 1.5s infinite;
}

.player-status.answered {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
}

@keyframes pulse-opacity {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* --- Condensed Mobile Player List --- */
/* Condensed horizontal scrollable player ticker for mobile */
.player-ticker.condensed {
    position: relative;
    flex-direction: row;
    justify-content: center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 0.5rem;
    padding: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* Expand arrows fixed to right corner */
.player-ticker.condensed::after {
    content: '';
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="rgba(255,255,255,0.7)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="7 13 12 18 17 13"></polyline><polyline points="7 6 12 11 17 6"></polyline></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    pointer-events: none;
    opacity: 0.8;
    z-index: 10;
}

/* Hide scrollbar for webkit browsers in condensed mode */
.player-ticker.condensed::-webkit-scrollbar {
    height: 4px;
}

.player-ticker.condensed::-webkit-scrollbar-track {
    background: transparent;
}

.player-ticker.condensed::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0.3rem;
}

/* Compact player card for mobile - much smaller */
.player-card-compact {
    display: flex;
    flex-direction: row;
    /* Horizontal layout */
    align-items: center;
    justify-content: flex-start;
    /* min-width: 160px; */
    /* Bit wider for horizontal flow */
    padding: 0.5rem;
    border-radius: 0.3rem;
    /* border: 1px solid rgba(255, 255, 255, 0.15); */
    background: rgb(0 0 0 / 25%);
    backdrop-filter: blur(4px);
    cursor: default;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    /* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); */
    position: relative;
    overflow: visible;
    gap: 0.3rem;
}

/* Rank Number - Leftmost */
.player-card-compact .compact-rank {
    position: static !important;
    font-size: 0.6rem !important;
    font-weight: 800 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    background: transparent !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    border-radius: 0.3rem;
    box-shadow: none !important;
    text-shadow: none !important;
    padding: 0 !important;
    line-height: 1 !important;
    border: none !important;
    min-width: auto;
    text-align: left;
}

/* Avatar - Next to Rank */
.player-card-compact .compact-avatar {
    width: 28px !important;
    height: 28px !important;
    position: relative;
    z-index: 1;
    border-radius: 0.3rem;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
}

.player-card-compact .compact-avatar .avatar {
    width: 100%;
    height: 100%;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 0.3rem;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Info Column - Right Layout */
.player-card-compact .compact-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
}

/* Points - Top Row of Info */
.player-card-compact .compact-points {
    position: static !important;
    font-size: 0.9rem !important;
    font-weight: 800 !important;
    color: #c084fc !important;
    /* Purple text */
    background: transparent !important;
    padding: 0 !important;
    display: block !important;
    line-height: 1 !important;
    text-align: left !important;
}

/* Pts Label */
.player-card-compact .pts-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 2px;
    text-transform: uppercase;
}

/* Status Text - Bottom Row of Info */
.player-card-compact .compact-status {
    font-size: 0.45rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6) !important;
    letter-spacing: 0.05em;
    line-height: 1;
    margin-top: 0;
}

/* Status specific coloring for Status Text */
.player-card-compact.status-thinking .compact-status {
    color: #f59e0b !important;
}

.player-card-compact.status-answered .compact-status {
    color: #3b82f6 !important;
}

.player-card-compact.status-locked .compact-status {
    color: #10b981 !important;
}

.player-card-compact.status-ready .compact-status {
    color: #10b981 !important;
}

.player-card-compact.status-disconnected .compact-status {
    color: #ef4444 !important;
}

/* Remove old border/shadow status logic */
.player-card-compact.status-thinking {
    box-shadow: none;
}

.player-card-compact.status-answered {
    box-shadow: none;
}

.player-card-compact.status-locked {
    box-shadow: none;
}

.player-card-compact.status-ready {
    box-shadow: none;
}

.player-card-compact.status-disconnected {
    opacity: 0.5;
    box-shadow: none;
}

.player-card-compact.status-waiting {
    box-shadow: none;
}



/* Collapse button for expanded view */
.player-list-collapse-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 0.3rem;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    gap: 0.5rem;
}

.player-list-collapse-btn:active {
    transform: scale(0.98);
    background: rgba(255, 255, 255, 0.12);
}

.player-list-collapse-btn svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
    opacity: 0.7;
}

.player-list-collapse-btn span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    opacity: 0.8;
}

/* Hide collapse button when condensed */
.player-ticker.condensed .player-list-collapse-btn {
    display: none;
}

/* Expanded state - revert to vertical list */
.player-ticker.expanded {
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Hide compact cards when expanded */
.player-ticker.expanded .player-card-compact {
    display: none;
}



/* Hide full cards when condensed */
.player-ticker.condensed .player-premium-row {
    display: none;
}

/* --- Chat Container --- */
.chat-container {
    width: 100%;
    background: rgb(45 50 69 / 30%);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.3rem;
    padding: 0.5rem;
    margin: 0.5rem auto;
    /* Center horizontally */
    max-width: 600px;
    /* Match game card width on desktop */
    max-height: 400px;
    /* Increased to fit ~10 messages */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 100;
}

/* Hide chat in solo mode */
body.solo-mode .chat-container {
    display: none !important;
}

/* Messages Area */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent scrollbar during animation */
    max-height: 350px;
    /* Increased for desktop */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0.3rem;
}

/* Individual Message */
.chat-message {
    display: flex;
    align-items: flex-start;
    /* Align to top */
    gap: 0.25rem;
    font-size: 0.75rem;
    line-height: 1.3;
    /* Removed white-space: nowrap, overflow: hidden to allow wrapping */
}

.chat-avatar {
    width: 18px;
    height: 18px;
    border-radius: 0.3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    flex-shrink: 0;
}

.chat-name {
    font-weight: 700;
    flex-shrink: 0;
}

.chat-text {
    color: var(--text-primary);
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
}

/* Input Wrapper */
.chat-input-wrapper {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    height: 32px;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.3rem;
    color: var(--text-primary);
    font-size: 0.75rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--primary);
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-send-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
}

.chat-send-btn:not(:disabled):hover {
    background: var(--primary-hover);
}

.chat-send-btn:not(:disabled):active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn svg {
    color: white;
}


@keyframes shrink-bar {
    from {
        width: 0%;
    }

    to {
        width: 100%;
    }
}

.anim-shrink {
    animation: shrink-bar 30s linear forwards;
}

@keyframes shrink-bar {
    from {
        width: 0%;
    }

    to {
        width: 100%;
    }
}



/* Multiplayer Status Label */
.multiplayer-status-label {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 5px;
    font-style: italic;
    height: 1.2em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

/* --- Timer Flip Animation --- */
/* .timer-wrapper merged above */

.timer-flipper {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform-style: preserve-3d;
}

.timer-flipper.flipped {
    transform: rotateY(180deg);
}

.timer-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 0;
    left: 0;
}

/* Front is default */
.timer-face.front {
    z-index: 2;
    /* Correct rotation for front face? Default 0 is fine */
}

/* Back starts rotated */
.timer-face.back {
    transform: rotateY(180deg);
}

/* Smiley Icons */
.timer-feedback-icon svg {
    width: 80px;
    height: 80px;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    overflow: visible;
}

.smiley-happy .smiley-mouth {
    stroke: var(--success);
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
}

.smiley-happy .smiley-eye {
    fill: var(--success);
}

.smiley-sad .smiley-mouth {
    stroke: var(--error);
    fill: none;
    stroke-width: 6;
    stroke-linecap: round;
}

.smiley-sad .smiley-eye {
    fill: var(--error);
}

/* Outer circle safety */
.smiley-outer {
    fill: none !important;
}

/* Header Redesign */
.scoreboard-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: auto;
    min-height: 3.5rem;
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-wrap: wrap;
    /* Allow wrapping on mobile */
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Mobile: Stats go to next line */
@media (max-width: 768px) {
    .scoreboard-top {
        padding: 0.5rem 1rem;
    }

    .top-bar .avatar {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.8rem;
        /* Scale down font as well */
    }

    .live-stats-header-topbar {
        order: 3;
        /* Move to end, causing wrap */
        width: 100%;
        /* Full width on new line */
        margin-top: 0.5rem;
        justify-content: center;
        /* Center on mobile */
    }

    /* Apply condensed player ticker by default on mobile */
    .player-ticker:not(.expanded) {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        gap: 0.4rem;
        padding: 0.4rem 0.5rem;
        /* Horizontal padding only */
        max-height: 60px;
        /* Reduced from 80px */
        min-height: 60px;
        order: -1;
        /* Move player list to top on mobile */
        margin: 0 -1rem;
        /* Negative margin to counteract game-screen padding */
        width: calc(100% + 2rem);
        /* Full width plus the negative margins */
        border-radius: 0.3rem;
        /* No border radius for flush appearance */
    }

    /* Keep expanded player ticker at top on mobile */
    .player-ticker.expanded {
        order: -1;
        /* Stay at top when expanded */
    }

    /* Adjust inner avatar radius for concentric corners (6px outer - 2px padding = 4px inner) */
    .player-ticker:not(.expanded) .player-card-compact .compact-avatar .avatar {
        border-radius: 0.3rem;
        /* Force inner radius */
    }

    /* Smaller avatar on mobile - REMOVED to allow full fill */

    /* Smaller text on mobile */
    .player-ticker:not(.expanded) .player-card-compact .compact-rank,
    .player-ticker:not(.expanded) .player-card-compact .compact-points {
        font-size: 0.6rem;
        /* Reduced from 0.65rem */
    }



    /* Hide full player rows on mobile by default */
    .player-ticker:not(.expanded) .player-premium-row {
        display: none;
    }

    /* Keep chat at bottom on mobile */
    /* Fixed Chat at Bottom on Mobile */
    .chat-container {
        order: 10;
        position: fixed;
        bottom: 80px;
        /* Above action bar */
        left: 0;
        transform: none;
        width: 100%;
        /* Full width */
        max-width: none;
        backdrop-filter: blur(12px);
        max-height: 20vh;
        border-radius: 0.3rem;
        /* Remove radius */
        box-shadow: none;
        /* Remove shadow */
        margin: 0;
        z-index: 900;
        border-top-left-radius: 0.8rem;
        border-top-right-radius: 0.8rem;
    }

    /* Ensure game screen has padding so scrolled content is visible above fixed footer */
    #game-screen {
        padding-bottom: 220px !important;
        /* Space for chat (20vh) + action bar (80px) */
    }

    /* Fix Action Bar transparency/visibility on mobile */
    .action-bar {
        position: fixed;
        /* Ensure it stays at bottom on mobile */
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgb(45 50 69 / 35%);
        backdrop-filter: blur(12px);
        padding: 0.75rem 1rem;
        margin: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        width: 100%;
        max-width: 100%;
        /* Full width */
    }

    .solo-mode .action-bar {
        border-top-left-radius: 0.8rem;
        border-top-right-radius: 0.8rem;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: none;
        border-left: none;
        border-right: none;
    }


}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 0, 0, 0.1);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-card {
    background: #212121b5;
    padding: 2rem;
    border-radius: 0.3rem;
    width: 90%;
    max-width: 400px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

#btn-final-answer,
#btn-next-question {
    border-radius: 0.3rem;
}

/* Align lock icon with text in final answer button */
#btn-final-answer svg {
    vertical-align: sub;
}



.btn-danger {
    background: var(--error);
    color: white;
}

@keyframes slideUp {
    to {
        transform: translateY(0);
    }
}

/* Version Footer */
.version-footer {
    position: fixed;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.4;
    z-index: 1000;
    pointer-events: none;
    font-family: monospace;
}

/* Dev Version Override */
.version-footer.dev-version {
    color: var(--warn);
    opacity: 0.8;
    font-weight: bold;
}

/* --- Large Desktop Layout (Sidebar) --- */
@media (min-width: 1024px) {
    .screen {
        max-width: 1400px;
    }

    #game-screen.active {
        display: grid;
        grid-template-columns: 1fr 350px;
        grid-template-rows: auto auto 1fr;
        /* 1fr spacer row implies last item (Action Bar) can be pushed down */
        gap: 2rem;
        align-items: start;
        padding-top: 6rem;
        min-height: calc(100vh - 8rem);
    }

    /* Grid Areas */
    .question-container {
        grid-column: 1;
        width: 100%;
        /* Row 1 Implicit */
    }

    .options-grid {
        grid-column: 1;
        width: 100%;
        /* Row 2 Implicit */
    }

    .player-ticker {
        grid-column: 2;
        grid-row: 1 / 4;
        /* Span 3 rows */
        height: calc(100vh - 8rem);
        max-height: none;
        /* Remove mobile/base limit */
        overflow-y: auto;
        padding: 1rem;
        position: sticky;
        top: 6rem;

        /* Sidebar Styling */
        background: rgba(0, 0, 0, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0.3rem;
        backdrop-filter: blur(10px);
    }

    /* Action Bar: Bottom Aligned */
    .action-bar {
        position: static;
        grid-column: 1;
        align-self: end;
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 1rem 0;
        border: none;
        border-radius: 0.3rem;
        transform: none;
        justify-content: center;
        /* Center the button */
    }

    /* Override grid layout for solo mode - use flexbox for centering */
    body.solo-mode #game-screen.active {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        grid-template-columns: unset;
    }

    .action-bar .btn {
        max-width: 400px;
        margin: 0 auto;
    }

    /* Hide compact player cards on desktop - full list is always visible in sidebar */
    .player-card-compact {
        display: none !important;
    }

    /* Hide expand button on desktop - not needed when sidebar is always visible */
    .player-list-expand-btn {
        display: none !important;
    }

    /* Hide collapse button on desktop - not needed when sidebar is always visible */
    .player-list-collapse-btn {
        display: none !important;
    }
}

/* --- Short Screen Optimizations --- */
@media (max-height: 740px) {
    #game-screen {
        padding-top: 4.5rem;
    }

    .timer-wrapper {
        width: 50px;
        height: 50px;
        margin-bottom: 0.25rem;
    }

    /* Adjust the SVG/Inner timer size to 40px */
    .timer-circular {
        width: 40px;
        height: 40px;
    }

    /* Scale Smiley to match Timer */
    .timer-feedback-icon svg {
        width: 40px;
        height: 40px;
    }

    .timer-text {
        font-size: 0.8rem;
    }

    .question-text {
        font-size: 1rem;
        line-height: 1.2;
        margin-bottom: 0.25rem;
    }

    .options-grid {
        gap: 0.25rem;
        margin-top: 0.25rem;
    }

    .question-container {
        padding: 0.25rem 0;
        margin-bottom: 0.25rem;
    }

    /* Compact Player Row */
    .player-premium-row {
        padding: 0.25rem 0.5rem;
        min-height: 40px;
        gap: 0.5rem;
    }

    .player-premium-row .details h3 {
        font-size: 0.9rem;
    }


}

/* Round Summary Screen */
/* Game Winner Card - Larger and more prominent */
.game-winner-card {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.05));
    border-radius: 0.3rem;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-align: center;
    border: 2px solid rgba(34, 197, 94, 0.4);
    margin-bottom: 1rem;
    box-shadow: 0 8px 32px rgba(34, 197, 94, 0.2);
}

.round-winner-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.3rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 1rem;
}

.trophy-icon {
    font-size: 4rem;
    filter: drop-shadow(0 0 10px gold);
    animation: bounce 2s infinite;
}

.winner-label {
    text-transform: uppercase;
    font-size: 0.8rem;
    opacity: 0.7;
    letter-spacing: 1px;
}

.winner-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--highlight);
}

.winner-score {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success);
}

.summary-lists-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .summary-lists-container {
        grid-template-columns: 1fr;
    }


    /* Mobile: Vertical layout for game winner card (final leaderboard) */
    .state-leaderboard .game-winner-card {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        padding: 1.5rem !important;
        gap: 0.75rem !important;
        transform: none !important;
        margin: 0 0 1rem 0 !important;
    }

    /* Mobile: Vertical layout for round winner card */
    .state-leaderboard .round-winner-card {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        padding: 1rem !important;
        gap: 0.75rem !important;
        transform: none !important;
        margin: 0 !important;
    }

    .state-leaderboard .game-winner-card .trophy-icon,
    .state-leaderboard .round-winner-card .trophy-icon {
        font-size: 3rem !important;
        margin: 0 !important;
        filter: drop-shadow(0 0 8px gold);
        animation: none;
        flex-shrink: 0;
    }

    .state-leaderboard .game-winner-card .avatar,
    .state-leaderboard .round-winner-card .avatar {
        width: 48px !important;
        height: 48px !important;
        font-size: 1.5rem !important;
        flex-shrink: 0;
    }

    /* Game winner details - centered */
    .state-leaderboard .game-winner-card .winner-details {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center !important;
        gap: 0.25rem;
    }

    /* Round winner details - centered */
    .state-leaderboard .round-winner-card .winner-details {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center !important;
        gap: 0.25rem;
    }

    .state-leaderboard .game-winner-card .winner-label {
        font-size: 0.75rem !important;
        margin: 0 !important;
    }

    .state-leaderboard .game-winner-card .winner-name {
        font-size: 1.25rem !important;
        margin: 0 !important;
        line-height: 1.2;
    }

    .state-leaderboard .game-winner-card .winner-score {
        font-size: 1rem !important;
        margin: 0 !important;
    }

    .state-leaderboard .round-winner-card .winner-label {
        font-size: 0.7rem !important;
    }

    .state-leaderboard .round-winner-card .winner-name {
        font-size: 1rem !important;
    }

    .state-leaderboard .round-winner-card .winner-score {
        font-size: 0.9rem !important;
    }

    .state-leaderboard .summary-lists-container {
        gap: 0.5rem;
    }

    .state-leaderboard .summary-list {
        padding: 0.75rem;
    }

    .state-leaderboard .summary-list h3 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .state-leaderboard .summary-row {
        padding: 0.4rem 0;
    }
}

.summary-list {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.3rem;
    padding: 1rem;
}

.summary-list h3 {
    text-align: center;
    margin-bottom: 0.8rem;
    font-size: 1rem;
    text-transform: uppercase;
    opacity: 0.8;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.9rem;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row .rank {
    width: 30px;
    font-weight: 700;
    opacity: 0.6;
}

.summary-row .name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 0.5rem;
}

.summary-row .score {
    font-weight: 700;
    color: var(--highlight);
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}

/* --- Refactored UI Styles --- */

/* Game State Overrides */
/* Applying .state-intermission to #game-screen hides normal game elements */
.state-intermission .question-container,
.state-intermission #player-ticker {
    display: none !important;
}



.fade-out-all {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.4s ease !important;
}

.hidden {
    display: none !important;
}

.transition-hide {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease !important;
}

#btn-next-question,
#btn-final-answer {
    transition: opacity 0.15s ease, transform 0.15s ease, background-color 0.2s ease;
}

.option-btn {
    transition: background-color 0.4s ease, border-color 0.4s ease, transform 0.2s ease, box-shadow 0.2s ease !important;
}

.option-btn:disabled {
    pointer-events: none !important;
    cursor: default;
}

/* Ensure options-container is visible and uses Block/Flex layout for Stats */
/* Ensure options-container is visible and uses Block/Flex layout for Stats */
.state-intermission #options-container {
    display: flex !important;
    flex-direction: column !important;
    background: transparent !important;
    gap: 0 !important;
    padding: 80px 1rem 120px 1rem !important;
    /* Clearing Top Bar */
    margin: 0 !important;
    height: 100dvh !important;
    /* Use dvh for mobile address bar */
    width: 100% !important;
    overflow-y: auto !important;
    position: fixed !important;
    top: 0;
    left: 0;
    left: 0;
    z-index: 50;
    box-sizing: border-box !important;
}

/* Position Action Bar over the Overlay in Intermission (Desktop Only) */
@media (min-width: 601px) {
    .state-intermission #action-bar {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        transform: none !important;
        max-width: none !important;
        background: transparent !important;
        justify-content: center !important;
        z-index: 100 !important;
        backdrop-filter: none !important;
        border: none !important;
        padding: 1rem !important;
    }

    /* Desktop Intermission & Leaderboard: Fix chat above action bar */
    .state-intermission .chat-container,
    .state-leaderboard .chat-container {
        position: fixed !important;
        bottom: 80px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 100% !important;
        max-width: 600px !important;
        z-index: 200 !important;
    }
}

/* Game State: LEADERBOARD (Final Results) */
.state-leaderboard .question-container,
.state-leaderboard #player-ticker {
    display: none !important;
}

.state-leaderboard #options-container {
    display: flex !important;
    flex-direction: column !important;
    background: transparent !important;
    gap: 0 !important;
    padding: 80px 1rem 120px 1rem !important;
    margin: 0 !important;
    height: 100dvh !important;
    width: 100% !important;
    overflow-y: auto !important;
    position: fixed !important;
    top: 0;
    left: 0;
    z-index: 50;
    box-sizing: border-box !important;
}

/* Large Desktop Override: Ensure leaderboard doesn't use the sidebar grid which breaks fixed positioning */
@media (min-width: 1024px) {
    #game-screen.state-leaderboard {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: unset !important;
        grid-template-rows: unset !important;
        justify-content: flex-start !important;
        align-items: center !important;
    }
}

.state-leaderboard #action-bar {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    transform: none !important;
    max-width: none !important;
    justify-content: center !important;
    z-index: 100 !important;
    border: none !important;
    padding: 1rem !important;
}

/* Button Variants */
.btn-success-solid,
#btn-next-question.btn-success-solid {
    background: var(--success) !important;
    color: white !important;
    border: none !important;
    opacity: 1 !important;
}

.btn.btn-ghost-success {
    background: rgba(16, 185, 129, 0.2) !important;
    border: 2px solid var(--success) !important;
    color: #ffffff !important;
    opacity: 1 !important;
}

.btn.btn-ghost-success:disabled {
    opacity: 1 !important;
    cursor: default;
}

/* Lighter progress bar for btn-ghost-success */
.btn.btn-ghost-success .btn-progress-bar {
    background: rgba(255, 255, 255, 0.2) !important;
}

/* Pause State: Stop all animations EXCEPT for modals */
body.app-paused *:not(.modal-overlay):not(.modal-overlay *) {
    animation-play-state: paused !important;
}

/* Pre-Game Countdown Styles */
.pregame-countdown-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    padding: 2rem;
    grid-column: span 2;
    /* Span both columns of the options-grid */
}

.pregame-countdown-label {
    font-size: 1.2rem;
    opacity: 0.9;
    /* Increased from 0.7 for better visibility */
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.pregame-countdown-timer {
    font-size: 8rem;
    font-weight: 900;
    line-height: 1;
    margin: 1rem 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pregame-countdown-sublabel {
    font-size: 1.5rem;
    opacity: 0.9;
    /* Increased from 0.8 for better visibility */
    margin-top: 1rem;
}

@media (max-width: 600px) {
    .pregame-countdown-timer {
        font-size: 5rem;
    }

    .pregame-countdown-label {
        font-size: 1rem;
    }

    .pregame-countdown-sublabel {
        font-size: 1.2rem;
    }
}

/* Host & Join Lobby Mobile Styles */
@media (max-width: 768px) {

    #host-lobby-screen .lobby-container,
    #join-screen .lobby-container {
        padding-bottom: 80px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    #host-lobby-screen .lobby-actions,
    #join-screen .lobby-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 1rem;
        background: var(--background-color);
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2);
        z-index: 100;
        margin-top: 0;
        box-sizing: border-box;
    }
}

/* Global Typography Margins */
h1,
h2,
h3,
h4,
h5 {
    margin: 0.5em 0;
}

/* Desktop Typography Overrides */
@media (min-width: 1024px) {
    h1 {
        font-size: 4rem;
    }

    h2 {
        font-size: 3rem;
    }

    h3 {
        font-size: 2rem;
    }

    h4 {
        font-size: 1.5rem;
    }

    h5 {
        font-size: 1.25rem;
    }
}

/* Rematch Modal */


.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: 0.3rem;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    color: var(--text-color);
}

.modal-content h2 {
    margin-top: 0;
    color: var(--primary-color);
}

.timer-display {
    font-size: 3rem;
    font-weight: bold;
    margin: 1rem 0;
    color: var(--accent-color);
}

.rematch-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.rematch-actions button {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
}

/* Solo Mode Action Bar adjustments */
@media (max-width: 768px) {
    .rematch-actions {
        flex-direction: column;
    }
}