:root {
    --bg-primary: #23233f;
    --bg-secondary: #262942;
    --bg-tertiary: rgb(50, 48, 82);
    --bg-tertiary-rgb: 35, 35, 60;
    --text-primary: #e0e0e6;
    --text-secondary: #a0a8c0;
    --highlight-primary: #957fe4;
    --highlight-primary-rgb: 138, 111, 240;
    --highlight-secondary: #b8a8f0;
    --accent-blue: #5070b0;
    --error-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --border-color: #353550;
    --input-bg: var(--bg-primary); /* Corrected: Added '--' to --bg-primary */
    --input-border: var(--border-color);
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    --panel-bg: var(--bg-tertiary); /* Changed from var(--bg-secondary) to be brighter */
    --muted-line: color-mix(in srgb, var(--border-color) 98%, white); /* Changed from rgba(255, 255, 255, 0.08) */
    --slot-height: 56px;

    --scrollbar-track-color: var(--bg-tertiary); /* Changed from rgba(var(--bg-tertiary-rgb), 0.5) */
    --scrollbar-thumb-color: var(--highlight-primary);

    --player-icon-size: 38px;
    --login-icon-select-size: 48px;
    --login-icon-preview-size: 80px;
    --arrow-size: 8px;

    --nm-css-transition-duration: 400ms;
    --nm-large-wave-duration: 600ms;
    
    --order-it-grid-gap: 10px;

    /* New Header Colors */
    --header-bg-start: #4a148c;
    --header-bg-end: #6a1b9a;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
    margin: 0;
    font-family: var(--font-family);
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-primary);
    color: #fff;
    padding: 1rem 180px; /* Adjusted for ads */
    overflow-y: auto;
    transition: padding 0.4s ease-in-out;
}

body.ads-hidden {
    padding: 1rem;
}

#background-shader-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh; /* Fallback */
    height: 100lvh; /* Use large viewport height to avoid resize on scroll */
    z-index: -1;
}

h1, h2, h3, h4, h5, p {
    margin: 0;
}

/* ---------- AD BANNERS ---------- */
.ad-banner {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 160px; /* Standard vertical banner width */
    padding: 1rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: transform 0.4s ease-in-out;
    overflow: hidden;
}

#left-ad-banner {
    left: 10px;
}

#right-ad-banner {
    right: 10px;
}

body.ads-hidden .ad-banner {
    transform: translateY(100vh);
}


/* ---------- MAIN PANEL (UNIFIED LOBBY) ---------- */
.panel-wrapper {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    border-radius: 14px;
    background: var(--bg-primary);
    box-shadow: -8px -8px 30px rgba(120, 30, 200, 0.03), 10px 18px 40px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 2rem); /* Fallback */
    min-height: calc(100lvh - 2rem); /* Use large viewport height */
    position: relative;
    padding-top: 100px;
    overflow: visible; /* Changed from hidden */
}

.panel {
    background: var(--panel-bg);
    border-radius: 10px;
    padding: 20px;
    position: relative;
    box-shadow: -2px -2px 6px rgba(255, 255, 255, 0.03), 3px 3px 8px rgba(0, 0, 0, 0.45);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: visible; /* Changed from hidden to allow shadows to be visible */
    isolation: isolate;
}
.panel > h2, .panel > h3 {
    margin-bottom: 15px;
    color: var(--highlight-secondary);
}
.panel::before {
    content: "";
    position: absolute; inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 45%);
    mix-blend-mode: overlay;
}
/* New pseudo-element for confetti pattern */
.panel::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-color: color-mix(in srgb, var(--panel-bg) 40%, black); /* Tinted and darkened color for confetti */
    mask-image: url('assets/shaders/confetti.webp');
    -webkit-mask-image: url('assets/shaders/confetti.webp'); /* For Webkit browsers */
    mask-size: 500px 500px; /* Adjust size of the pattern as needed */
    -webkit-mask-size: 500px 500px;
    mask-repeat: repeat;
    -webkit-mask-repeat: repeat;
    opacity: 0.1; /* Adjust for subtlety */
    border-radius: inherit;
    z-index: -1; /* Ensure it's behind content but above the main panel background */
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(90deg, var(--header-bg-start) 0%, var(--header-bg-end) 100%); /* Used variables */
    position: absolute;
    flex-shrink: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100px;
    z-index: 10;
}

/* Add this new rule anywhere in your style.css */
.panel-header > img {
    position: sticky;
    width: 250px;
    height: auto;
    top: -60px;
    left: 30px; /* Changed from 50% to align with header padding */
    transform: none; /* Removed the centering transform */
    z-index: 20;
}

.panel-header h1 {
    margin: 0;
    color: var(--highlight-primary);
    font-size: 35px;
    letter-spacing: 0.6px;
}

.panel-header nav {
    display: flex;
    gap: 24px;
    align-items: center;
    color: #fff;
    font-size: 0.95rem;
}
.header-nav-group {
    display: flex;
    align-items: center;
    gap: 12px;
}
.panel-header nav .base-button.header-nav-button {
    padding: 6px 14px;
    box-shadow: none;
    background: color-mix(in srgb, var(--header-bg-start) 80%, white); /* Brighter version of header start color */
}
.panel-header nav .base-button.header-nav-button:hover {
    background: color-mix(in srgb, var(--header-bg-start) 60%, white); /* Even brighter on hover */
}

.panel-header::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -12px;
    height: 18px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.35), transparent);
    pointer-events: none;
}

.lobby-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 18px;
    padding: 18px;
    align-items: start;
    flex-grow: 1;
}

/* ---------- PLAYER LIST ---------- */
.player-section {
    height: 100%; /* Keep this as it's specific to player-section's layout */
}

/* Ensure player-section stretches to fill its grid cell height */
.lobby-content > #player-section {
    align-self: stretch;
}

.player-section h2 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--highlight-secondary);
    letter-spacing: 0.3px;
    display: flex;
    justify-content: space-between;
}
#host-status-indicator {
    font-weight: normal;
    color: var(--text-secondary);
}

.player-list {
    display: grid;
    grid-auto-rows: var(--slot-height);
    gap: 0;
    position: relative;
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 6px;
    background-image: linear-gradient(to bottom, transparent calc(100% - 1px), var(--muted-line) calc(100% - 1px));
    background-size: 100% var(--slot-height);
    background-repeat: repeat-y;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black 85%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, black 85%, transparent 100%);
    min-height: 0; /* Allow flex item to shrink and enable scrolling */
}

.player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    height: calc(var(--slot-height) - 8px);
    margin: 4px 0;
    background-color: color-mix(in srgb, var(--bg-tertiary) 95%, white); /* Changed from rgba(255, 255, 255, 0.03) */
    border-radius: 8px;
    transition: background-color 180ms, transform 120ms;
}
.player:hover {
    background-color: color-mix(in srgb, var(--bg-tertiary) 85%, white); /* Changed from rgba(255, 255, 255, 0.06) */
    transform: translateY(-2px);
}
.player.current-turn-player {
    background: color-mix(in srgb, rgb(var(--highlight-primary-rgb)) 15%, var(--bg-secondary)); /* Changed from rgba(var(--highlight-primary-rgb), 0.15) */
    border: 1px solid var(--highlight-primary);
}
.player.eliminated {
    opacity: 0.5;
    background: var(--bg-primary); /* Changed from transparent */
}
.player.eliminated .player-name {
    text-decoration: line-through;
}

.player-icon-img {
    width: var(--player-icon-size);
    height: var(--player-icon-size);
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.player-details-center {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.player-tags {
    display: flex;
    gap: 5px;
    font-size: 0.75em;
    margin-bottom: 2px;
}
.host-marker, .you-marker {
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 500;
}
.host-marker { background-color: var(--accent-blue); color: var(--text-primary); }
.you-marker { background-color: var(--text-secondary); color: var(--bg-primary); }
.player-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.player-name.disconnected-text {
    font-style: italic;
}
.player-score {
    color: var(--highlight-secondary);
    font-weight: bold;
    font-size: 1.1em;
}

#player-section-footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--muted-line);
    display: flex;
    gap: 8px;
    justify-content: center;
}
#player-section-footer .base-button {
    flex: 1;
    padding: 8px 10px;
    font-size: 0.85rem;
    box-shadow: none;
    background: color-mix(in srgb, var(--bg-secondary) 85%, white); /* Changed from background-color to background */
}
#player-section-footer .base-button:hover {
    background: color-mix(in srgb, var(--bg-secondary) 70%, white); /* Changed from background-color to background */
    filter: brightness(1); /* Override base-button hover */
}


/* ---------- MAIN CONTROLS ---------- */
.controls {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    height: 100%;
}

/* Generic Panel Style */
.panel {
    background: var(--panel-bg);
    border-radius: 10px;
    padding: 20px;
    position: relative;
    box-shadow: -2px -2px 6px rgba(255, 255, 255, 0.03), 3px 3px 8px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    overflow: visible; /* Changed from hidden to allow shadows to be visible */
}
.panel > h2, .panel > h3 {
    margin-bottom: 15px;
    color: var(--highlight-secondary);
}
.panel::before {
    content: "";
    position: absolute; inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 45%);
    mix-blend-mode: overlay;
}

.subpanel {
    margin-top: 12px;
    padding: 12px;
    border-radius: 8px;
    background: var(--bg-secondary); /* Changed from rgba(0, 0, 0, 0.2) */
    color: #ffd9a6;
    font-size: 0.9rem;
    border: 1px solid rgba(255,255,255,0.05);
}
.subpanel h4 { margin-bottom: 5px; color: var(--highlight-secondary); }
.subpanel p { font-size: 0.9em; color: var(--text-secondary); }


/* ---------- BASE UI ELEMENTS ---------- */
.base-button {
    display: inline-block;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--highlight-primary), var(--highlight-secondary));
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    transition: transform 120ms ease, filter 120ms;
}
.base-button:hover { filter: brightness(1.1); }
.base-button:active { transform: scale(.98); }
.base-button:disabled {
    background: var(--text-secondary);
    color: var(--bg-tertiary);
    cursor: not-allowed;
    transform: none;
    filter: none;
    opacity: 0.5;
}

.waiting-button {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--border-color);
    box-sizing: border-box;
}

.waiting-spinner {
    margin-right: 10px;
    box-sizing: border-box;
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 4px solid rgba(var(--highlight-primary-rgb), 0.2);
    border-top-color: var(--highlight-primary);
    animation: playful-spin 3.0s cubic-bezier(0.55, -0.8, 0.27, 0.5) infinite;
    flex-shrink: 0;
}

@keyframes playful-spin {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(540deg) scale(1.1);
    }
    100% {
        transform: rotate(1080deg) scale(1);
    }
}

.base-input {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--input-bg); /* Changed from var(--bg-tertiary) */
    color: #fff;
    border: 1px solid rgba(255,255,255,0.08);
    font-family: inherit;
    font-size: 1em;
}
.base-input:focus {
    outline: none;
    border-color: var(--highlight-primary);
    box-shadow: 0 0 0 2px rgba(var(--highlight-primary-rgb), 0.3);
}

.base-dropdown {
    -webkit-appearance: none;
    appearance: none;
    padding: 8px 2.5rem 8px 12px;
    border-radius: 8px;
    background-color: var(--input-bg); /* Changed from var(--bg-secondary) */
    color: #fff;
    border: 1px solid rgba(255,255,255,0.08);
    font-family: inherit;
    font-size: 1em;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    background-size: 1em;
    cursor: pointer;
}
.base-dropdown:focus {
    outline: none;
    border-color: var(--highlight-primary);
    box-shadow: 0 0 0 2px rgba(var(--highlight-primary-rgb), 0.3);
}
.base-dropdown:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


.base-slider {
    width: 100%;
    appearance: none;
    height: 6px;
    border-radius: 8px;
    background: var(--border-color); /* Changed from rgba(255, 255, 255, 0.08) */
    outline: none;
    flex-grow: 1;
}
.base-slider::-webkit-slider-thumb {
    appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: linear-gradient(180deg, var(--highlight-secondary), var(--highlight-primary));
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: transform 120ms;
}
.base-slider::-webkit-slider-thumb:hover { transform: scale(1.15); }
.base-slider::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: linear-gradient(180deg, var(--highlight-secondary), var(--highlight-primary));
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    border: none;
    transition: transform 120ms;
}
.base-slider::-moz-range-thumb:hover { transform: scale(1.15); }


/* ---------- MULTIPLE-CHOICE CARDS ---------- */
.choice-card-container {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.choice-card {
    padding: 15px;
    border-radius: 8px;
    background-color: var(--bg-secondary); /* Changed from rgba(255, 255, 255, 0.03) */
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 160ms ease, box-shadow 160ms, border-color 160ms, background-image 160ms;
    text-align: center;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    aspect-ratio: 1 / 1;
}
.choice-card:hover {
    transform: translateY(-4px);
    border-color: var(--highlight-secondary);
}
.choice-card.selected {
    color: #fff;
    font-weight: 600;
    background: linear-gradient(135deg, var(--highlight-primary), var(--highlight-secondary));
    border-color: var(--highlight-secondary);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
    position: relative;
    isolation: isolate; /* contain blend */
}

/* Squiggle overlay for selected state */
.choice-card.selected::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;

    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='8' viewBox='0 0 40 8'><path d='M0 6 L8 2 L16 6 L24 2 L32 6 L40 2' stroke='white' stroke-opacity='0.12' stroke-width='1' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-size: 40px 8px;
    background-repeat: repeat;

    mix-blend-mode: overlay; /* preserve bright gradient + texture */
}

.game-mode-icon {
    width: 80%;
    height: 80%;
    max-width: 100px;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
    -webkit-filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}

.choice-card.selected .game-mode-icon {
    filter: brightness(0) invert(1) drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}

.game-mode-name {
    font-size: 0.9em;
    font-weight: 500;
}

/* ---------- POP-OUT BUTTONS ---------- */
.option-popout {
    background: linear-gradient(135deg, var(--highlight-primary), var(--highlight-secondary));
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    color: #fff;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    border: none;

    transform: translateY(0);
    box-shadow: 0 0 0 color-mix(in oklab, var(--highlight-primary), black 40%);
    transition: transform 230ms cubic-bezier(.2, .8, .2, 1),
                box-shadow 230ms cubic-bezier(.2, .8, .2, 1);
    will-change: transform, box-shadow;

    position: relative;
    isolation: isolate;
}

/* White squiggles pattern overlay */
.option-popout::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;

    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='8' viewBox='0 0 40 8'><path d='M0 6 L8 2 L16 6 L24 2 L32 6 L40 2' stroke='white' stroke-opacity='0.14' stroke-width='1' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-size: 40px 8px;
    background-repeat: repeat;

    mix-blend-mode: overlay;
}
.option-popout:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 0 color-mix(in oklab, var(--highlight-primary), rgb(31, 16, 58) 50%);
}
.option-popout:active {
    transform: translateY(-8px);
    box-shadow: 0 8px 0 color-mix(in oklab, var(--highlight-primary), rgb(31, 16, 58) 50%);
}
.option-popout:disabled {
    transform: translateY(0);
    box-shadow: 0 0 0 rgba(0,0,0,0);
    background-image: none;
    background-color: var(--text-secondary);
    opacity: 0.5;
    cursor: not-allowed;
}


/* ---------- COUNTDOWN ---------- */
#countdown-timer-display-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 120px;
}
.countdown-number {
    font-weight: 900;
    font-size: 6rem;
    color: #fff;
    text-shadow: 0 0 26px rgba(var(--highlight-primary-rgb), 0.35);
    animation: countdownAnim 1s ease-out forwards;
    display: block;
}

#countdown-prompt-text.unified-popup-bubble {
    opacity: 1;
    transform: none;
    transition: none;
    margin: 20px auto 0;
    padding: 15px 25px;
    width: auto;
    max-width: 90%;
    display: inline-block;
    font-size: 1.1em;
    font-weight: 500;
    line-height: 1.4;
    color: var(--highlight-secondary);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes countdownAnim {
    0% { transform: scale(.6); opacity: 0; }
    20% { transform: scale(1.1); opacity: 1; color: var(--highlight-secondary); }
    80% { transform: scale(0.95); color: var(--highlight-primary); }
    100% { transform: scale(0.9); opacity: 0; }
}

/* ---------- LOGIN VIEW ---------- */
#app-container.login-view-active .lobby-content {
    grid-template-columns: 1fr;
}
#app-container.login-view-active .controls {
    justify-content: center;
    align-items: center;
}
#login-area { text-align: center; }
#profile-customization-box {
    padding: 20px;
    border-radius: 10px;
    max-width: 500px;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
#login-profile-setup {
    display: flex; align-items: center; gap: 15px; margin-bottom: 15px;
}
#selected-icon-preview-container {
    width: var(--login-icon-preview-size); height: var(--login-icon-preview-size);
    border-radius: 50%; overflow: hidden;
    border: 3px solid var(--highlight-primary);
    background-color: var(--input-bg); flex-shrink: 0;
}
#selected-icon-preview { width: 100%; height: 100%; object-fit: cover; }
#username-input { flex-grow: 1; max-width: 280px; }
#player-icon-label-container { margin-top: 10px; margin-bottom: 8px; }
#icon-selection-controls {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
#icon-selection-strip {
    display: flex; gap: 8px;
    width: calc(var(--login-icon-select-size) * 4 + 8px * 3);
}
.icon-option-selectable {
    width: var(--login-icon-select-size); height: var(--login-icon-select-size);
    border-radius: 50%; border: 3px solid transparent; cursor: pointer;
    transition: border-color 0.2s ease, transform 0.2s ease;
    background-color: var(--input-bg); object-fit: cover; flex-shrink: 0;
}
.icon-option-selectable:hover {
    border-color: var(--highlight-secondary); transform: scale(1.1);
}
.icon-option-selectable.selected {
    border-color: var(--highlight-primary); transform: scale(1.1);
}
.icon-scroll-arrow {
    background: transparent; border: none; color: var(--text-primary); cursor: pointer;
    padding: 5px; opacity: 0.7; transition: opacity 0.2s ease;
}
.icon-scroll-arrow:hover { opacity: 1; }
.icon-scroll-arrow:disabled { opacity: 0.3; cursor: not-allowed; }
.icon-scroll-arrow::before {
    content: ''; display: inline-block; width: 0; height: 0;
    border-top: var(--arrow-size) solid transparent;
    border-bottom: var(--arrow-size) solid transparent;
}
#icon-scroll-left::before { border-right: calc(var(--arrow-size) * 1.2) solid var(--text-primary); }
#icon-scroll-right::before { border-left: calc(var(--arrow-size) * 1.2) solid var(--text-primary); }

#join-button { margin-top: 20px; }

/* ---------- PRE-LOBBY VIEW ---------- */
#pre-lobby-controls { gap: 10px; }

.pre-lobby-header {
    display: grid;
    grid-template-columns: 1.85fr 1fr;
    gap: 20px;
    margin-bottom: 10px;
}

.pre-lobby-header h3 {
    margin: 0;
}

.pre-lobby-grid {
    display: grid;
    grid-template-columns: 1.85fr 1fr; /* 65% / 35% split */
    gap: 20px;
    align-items: start;
    flex-grow: 1;
}
.pre-lobby-games {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.client-game-display {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 150px;
    aspect-ratio: 1 / 1;
    background: var(--bg-secondary); /* Changed from rgba(0,0,0,0.15) */
    border-radius: 8px;
}

#selected-game-icon-client {
    width: 100px;
    height: 100px;
    object-fit: contain;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}
#waiting-for-host-game-selection {
    color: var(--text-secondary);
    font-style: italic;
}

#start-game-button {
    margin-top: auto; /* Pushes button to bottom of flex container */
    padding-top: 20px;
    align-self: center;
    width: 100%;
    max-width: 350px;
}
.pre-lobby-footer {
    margin-top: auto;
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.pre-lobby-footer .status-message {
    margin-right: auto; /* Push itself to the left */
}
#game-specific-settings-area {
    background: var(--bg-secondary); /* Changed from rgba(0, 0, 0, 0.15) */
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color);
    min-height: 200px; /* give it some base height */
    height: 100%;
    display: flex;
    flex-direction: column;
}
#game-specific-settings-area .settings-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}
#game-specific-settings-area label {
    font-weight: 500;
    color: var(--text-secondary);
}
.setting-row {
    display: flex;
    align-items: center;
    gap: 15px;
}
.setting-row input[type="number"] {
    width: 70px;
    text-align: center;
}

#game-specific-settings-area.non-host-view .base-slider {
    display: none;
}
#game-specific-settings-area.non-host-view .setting-row {
    justify-content: flex-start; /* Align number boxes to the left */
}

.pre-lobby-settings {
    position: relative; /* Add this line */
}

.settings-icon {
    display:none;
}

/* ---------- GAME SPECIFIC STYLES ---------- */
#active-game-content {
    position: relative;
    flex-grow: 1;
    overflow: hidden; /* Add this to contain the canvas */
    
    padding: 20px; /* Add padding to the main content area */
    display: flex; /* Make it a flex container */
    flex-direction: column; /* Stack children vertically */
    gap: 15px; /* Space between game view and footer */
}

.game-view-panel {
    position: relative;
    flex-grow: 1;
    padding: 0; /* Reset padding */
    display: flex; /* Make it a flex container */
    flex-direction: column; /* Stack children vertically */
    min-height: 0; /* Allow shrinking */
    overflow: visible; /* Add this to contain the canvas */
    gap: 15px; /* Add gap between header, main, and controls */
}

.game-view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-shrink: 0;
    background-color: var(--bg-secondary); /* Moved from game-specific headers */
    padding: 15px 25px; /* Moved from game-specific headers */
    border-radius: 10px; /* Moved from game-specific headers */
    gap: 20px; /* Added gap for elements within the header */
}

.game-view-caption {
    flex-grow: 1;
    min-width: 0;
    gap: 20px;
}

.game-view-timer-wrapper {
    flex-shrink: 0;
}

.game-view-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 0;
    gap: 15px;
}

/* Align quiz game main content to the top */
#millionaire-quiz-game-view .game-view-main {
    margin-top: 20px;
    justify-content: flex-start;
}

.game-view-controls {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    width: 100%;
    margin-top: auto; /* Push to the bottom of the game-view-panel */
    /* Removed: margin-bottom, padding-top */
    flex-shrink: 0;
}

#game-round-display {
    white-space: nowrap;
    margin-left: auto;
    height: fit-content;
    width: fit-content;
    background-color: var(--bg-primary); /* Changed from rgba(0,0,0, 0.3) */
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9em;
    z-index: 100;
}
#current-round-number { color: var(--text-primary); font-weight: bold; }

/* Timer Styles (Quiz & Guess The Price) */
#quiz-timer-container,
#gtp-timer-container {
    position: relative;
    width: 80px;
    height: 80px;
}

#quiz-timer-svg,
#gtp-timer-svg {
    transform: rotate(-90deg);
}
.timer-background {
    fill: var(--bg-tertiary);
    stroke: var(--border-color);
    stroke-width: 10;
}
.timer-progress {
    fill: none;
    stroke: var(--warning-color);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke 0.3s ease-in-out, stroke-dashoffset 0.1s linear;
}
#quiz-timer-text,
#gtp-timer-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    font-weight: bold;
    color: var(--text-primary);
}

/* Image Guess */
#image-guess-game-view {
    text-align: center;
}
#image-guess-game-view .game-view-main {
    gap: 0; /* Remove gap between progress bar and image */
}
#image-reveal-progress-bar-container { width: 100%; height: 30px; background-color: var(--bg-tertiary); flex-shrink: 0; position: relative; border-radius: 6px 6px 0 0; overflow: visible; }
#image-reveal-progress-bar { height: 100%; width: 100%; background: linear-gradient(90deg, var(--highlight-primary), var(--highlight-secondary)); float: right; position: relative; overflow: hidden; }
#point-tiers-display { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }
.point-tier { position: absolute; top: 50%; transform: translate(10px, -50%); color: rgba(255,255,255,0.4); font-size: 0.9em; font-weight: bold; transition: color 0.3s ease, transform 0.3s ease, text-shadow 0.3s ease; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); z-index: 2;}
.point-tier::before { content: ''; position: absolute; top: 50%; left: 50%; width: 24px; height: 32px; background: var(--warning-color); transform: translate(-50%, -50%) scale(0.5); opacity: 0; z-index: -1; transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); }
.point-tier.active-tier { color: #fff; transform: translate(10px, -50%) scale(1.6); text-shadow: 0 0 8px rgba(255, 255, 255, 0.7); }
.point-tier.active-tier::before { transform: translate(-50%, -50%) scale(1); opacity: 1; }
@keyframes tier-flash-gradient { from { background-position: 100% 0; opacity: 0.9; } to { background-position: 0% 0; opacity: 0; } }
#image-reveal-progress-bar.flash-active::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: linear-gradient(to right, var(--warning-color) 20%, transparent 80%); background-size: 200% 100%; mix-blend-mode: additive; animation: tier-flash-gradient 0.6s ease-out forwards; pointer-events: none; }
#image-display-container { width: 100%; flex-grow: 1; position: relative; display: flex; justify-content: center; align-items: center; min-height: 250px; background-color: var(--bg-primary); border-radius: 0 0 6px 6px; overflow: hidden; }
#image-display-area { width: 100%; height: 100%; background-color: transparent; display: flex; justify-content: center; align-items: center; }
#glCanvas { display: block; max-width: 100%; max-height: 100%; }
#image-guess-controls-area { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
#game-button-container { display: flex; justify-content: center; align-items: center; gap: 15px; }

/* Guess the Price */
.gtp-product-display {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    width: 100%;
    max-width: 900px;
}
#gtp-product-features {
    flex: 1 1 35%;
    background-color: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    text-align: left;
    align-self: stretch;
}
#gtp-product-features h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--highlight-secondary);
}
#gtp-product-features-list {
    list-style-type: disc;
    padding-left: 20px;
    margin: 0;
    font-size: 0.9em;
}
#gtp-product-features-list li {
    padding: 5px 0;
}
.gtp-image-container {
    flex: 1 1 65%;
    display: flex;
    justify-content: center;
    align-items: center;
}
#gtp-product-name {
    font-size: 1.4em;
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    height: calc(1.4em * 1.2);
}
#gtp-product-image {
    max-width: 100%;
    max-height: 300px; height: auto; border-radius: 8px;
    background-color: var(--bg-tertiary); object-fit: contain;
}
.gtp-input-area { display: flex; align-items: center; gap: 10px; }
.gtp-price-adj-btn { width: 45px; height: 45px; font-size: 1.5em; padding: 0; line-height: 45px; text-align: center; }
.gtp-price-input-wrapper { position: relative; }
.gtp-price-input-wrapper span {
    position: absolute; left: 15px; top: 50%;
    transform: translateY(-50%); font-size: 1.2em;
    color: var(--text-secondary); pointer-events: none;
}
#gtp-price-input {
    width: 200px; font-size: 1.5em; text-align: center; padding-left: 35px;
}
#gtp-lock-in-button { width: 100%; max-width: 310px; }
#gtp-results-area {
    width: 100%; max-width: 800px; padding: 20px;
    background-color: var(--bg-secondary); border-radius: 8px; text-align: center;
}
#gtp-timeline-container { position: relative; height: 80px; margin: 20px 0; }

/* --- MODIFIED/NEW styles for Guess The Price Results --- */
#gtp-timeline-track {
    position: absolute; top: 50%; left: 0; right: 0; height: 8px;
    background: linear-gradient(to right, var(--border-color), var(--highlight-primary), var(--border-color));
    border-radius: 4px; transform: translateY(-50%);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}
#gtp-timeline-guesses { position: relative; height: 100%; }
.gtp-timeline-player-guess {
    position: absolute; top: 50%;
    transform: translate(-50%, -50%);
    display: flex; flex-direction: column;
    align-items: center; gap: 5px;
    transition: transform 0.3s ease;
    transform-origin: bottom center;
    z-index: 2;
}
.gtp-timeline-player-guess img {
    width: 36px; height: 36px; border-radius: 50%;
    border: 2px solid var(--highlight-secondary); background-color: var(--bg-primary);
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.gtp-timeline-player-guess span {
    font-size: 0.8em; color: var(--text-secondary);
    background-color: var(--bg-tertiary); padding: 3px 6px;
    border-radius: 4px;
    font-weight: 500;
}

/* Winner Animation */
@keyframes winnerPulse {
    from { transform: translate(-50%, -50%) scale(1.2); }
    to { transform: translate(-50%, -50%) scale(1.3); }
}
.gtp-timeline-player-guess.winner {
    animation: winnerPulse 1.5s infinite alternate ease-in-out;
}
.gtp-timeline-player-guess.winner img {
    border-color: var(--warning-color);
    box-shadow: 0 0 15px var(--warning-color), 0 0 25px rgba(255, 193, 7, 0.5);
}
.gtp-timeline-player-guess.winner span {
    color: var(--warning-color); font-weight: bold;
}

/* Too high/too low feedback indicators */
.gtp-timeline-player-guess::before {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.gtp-timeline-player-guess.too-high::before {
    border-top: 8px solid var(--error-color); /* Makes a downward-pointing triangle */
    transform: translateX(-50%);
    opacity: 1;
}
.gtp-timeline-player-guess.too-low::before {
    border-bottom: 8px solid var(--success-color); /* Makes an upward-pointing triangle */
    transform: translateX(-50%);
    opacity: 1;
}

/* Correct Price Marker Animation */
#gtp-timeline-correct-price-marker {
    position: absolute; top: 0; bottom: 0;
    transform: translateX(-50%); width: 6px;
    transition: left 1.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    z-index: 1;
}
#gtp-timeline-correct-price-marker .gtp-timeline-correct-price-line {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: var(--highlight-primary);
    border-radius: 3px;
    transform: scaleY(0); transform-origin: bottom;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 10px rgba(var(--highlight-primary-rgb), 0.7);
}
#gtp-timeline-correct-price-marker.revealed .gtp-timeline-correct-price-line {
    transform: scaleY(1);
}
#gtp-timeline-correct-price-marker .gtp-timeline-correct-price-label {
    position: absolute; bottom: 100%; left: 50%;
    transform: translate(-50%, -5px) scale(0); transform-origin: bottom center;
    background-color: var(--highlight-primary);
    color: var(--bg-primary); padding: 8px 12px; border-radius: 6px;
    font-weight: bold; white-space: nowrap; display: flex; flex-direction: column;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.3s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
}
#gtp-timeline-correct-price-marker.revealed .gtp-timeline-correct-price-label {
    transform: translate(-50%, -5px) scale(1);
}
#gtp-timeline-correct-price-marker .gtp-timeline-correct-price-label span:first-child {
    font-size: 0.8em; font-weight: normal; opacity: 0.8;
}
#gtp-timeline-correct-price-marker .gtp-timeline-correct-price-label span:last-child {
    font-size: 1.4em;
}

/* --- END of modified styles --- */

#gtp-timeline-labels { display: flex; justify-content: space-between; padding: 0 5px; font-size: 0.9em; color: var(--text-secondary); }
#gtp-winners-text { font-size: 1.2em; font-weight: 500; color: var(--warning-color); margin: 15px 0 0 0; min-height: 1.5em; }
#central-waiting-message {
    max-width: 800px;
    margin-left: 10px;
    margin-right: 10px;
}
.status-message { color: var(--text-secondary); font-style: italic;}

view .game-view-main {
    justify-content: flex-start;
}

/* ---------- QUIZ GAME STYLES ---------- */
#quiz-question-text {
    text-align: left;
    font-size: 1.4em;
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    height: calc(1.4em * 1.2);
}

/* Scrolling text for long questions/item names */
#quiz-question-text span,
#gtp-product-name span {
    position: absolute;
    top: 50%; /* Vertically center the text */
    left: 0;
    transform: translateY(-50%); /* Adjust for vertical centering */
}

#quiz-question-text span.scrolling-text,
#gtp-product-name span.scrolling-text {
    animation: scroll-text-animation 5s linear infinite alternate; /* Reverted to 20s for slower scroll */
}

@keyframes scroll-text-animation {
    0%, 10% {
        left: 0;
        transform: translateX(0) translateY(-50%);
    }
    90%, 100% {
        left: 100%;
        transform: translateX(-100%) translateY(-50%);
    }
}

#quiz-answers-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    width: 100%;
}

@keyframes stickerSlap {
    0% {
        transform: scale(1.1) rotate(var(--sticker-tilt, 0deg));
        opacity: 0.8;
    }
    50% {
        transform: scale(0.98) rotate(calc(var(--sticker-tilt, 0deg) * -0.5));
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

#quiz-answers-container .choice-card {
    aspect-ratio: auto;
    height: auto;
    min-height: var(--slot-height);
    padding: 10px 20px;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 0;
}

#quiz-answers-container .choice-card.selected {
    animation: stickerSlap 350ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.choice-card-content { display: flex; align-items: center; gap: 15px; width: 100%; }

.quiz-answer-prefix {
    font-weight: bold;
    color: var(--highlight-secondary);
    transition: color 200ms ease, font-weight 200ms ease;
}

#quiz-answers-container .choice-card.selected .quiz-answer-prefix {
    color: var(--text-primary);
    font-weight: 900;
}

.quiz-answer-text { text-align: left; flex-grow: 1; }
.choice-card.locked-in { background-image: linear-gradient(135deg, var(--warning-color), #ffb868), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='8' viewBox='0 0 40 8'><path d='M0 6 L8 2 L16 6 L24 2 L32 6 L40 2' stroke='white' stroke-opacity='0.12' stroke-width='1' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>"); border-color: var(--warning-color); }
.choice-card.correct { background-image: linear-gradient(135deg, var(--success-color), #57e092), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='8' viewBox='0 0 40 8'><path d='M0 6 L8 2 L16 6 L24 2 L32 6 L40 2' stroke='white' stroke-opacity='0.12' stroke-width='1' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>"); border-color: var(--success-color); }
.choice-card.incorrect { background-image: linear-gradient(135deg, var(--error-color), #ff7a6b), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='8' viewBox='0 0 40 8'><path d='M0 6 L8 2 L16 6 L24 2 L32 6 L40 2' stroke='white' stroke-opacity='0.12' stroke-width='1' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>"); border-color: var(--error-color); opacity: 1 !important; }
.choice-card.disabled { opacity: 0.6; pointer-events: none; background-image: none; background-color: color-mix(in srgb, var(--bg-secondary) 97%, white); /* Changed from rgba(255, 255, 255, 0.03) */ transform: none; }
.choice-card.eliminated-by-joker { opacity: 0.3 !important; pointer-events: none; transform: none; }
.quiz-answer-players { position: absolute; bottom: 5px; right: 10px; display: flex; gap: 4px; }
.player-icon-display { position: relative; width: 28px; height: 28px; }
.player-icon-display img { width: 100%; height: 100%; border-radius: 50%; border: 1px solid var(--highlight-secondary); object-fit: cover; }
.player-icon-tooltip { visibility: hidden; width: max-content; background-color: var(--bg-primary); color: var(--text-primary); text-align: center; border-radius: 4px; padding: 5px 8px; position: absolute; z-index: 10; bottom: 125%; left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 0.2s; font-size: 0.8em; }
.player-icon-display:hover .player-icon-tooltip { visibility: visible; opacity: 1; }

#quiz-footer-buttons { display: flex; justify-content: center; align-items: center; gap: 15px; }
#quiz-lock-in-button, #quiz-next-round-button { min-width: 150px; }

#quiz-jokers-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    height: 100px; /* Give it some space */
}

.joker-card {
    position: relative;
    width: 70px;
    height: 90px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    padding: 0;
    font-family: inherit;
    font-weight: bold;
}

.joker-card:not(:disabled):hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 10px 15px rgba(0,0,0,0.4);
}

.joker-icon {
    font-size: 2em;
    color: var(--highlight-secondary);
}

.joker-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.joker-card:hover .joker-tooltip {
    opacity: 1;
    visibility: visible;
}

.joker-card.used {
    background: var(--bg-secondary);
}

.joker-card.used::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top right, 
        transparent calc(50% - 2px), 
        var(--text-secondary) calc(50% - 2px), 
        var(--text-secondary) calc(50% + 2px), 
        transparent calc(50% + 2px)
    );
    pointer-events: none;
}

.joker-card:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ---------- ORDER IT GAME ---------- */
#order-it-player-lives-area {
    display: flex; flex-wrap: wrap; justify-content: center;
    gap: 15px; padding: 10px; background-color: var(--bg-secondary); /* Changed from rgba(0,0,0,0.2) */
    border-radius: 6px;
    flex-grow: 1; /* Changed from width: 100% */
}
.order-it-player-life-entry { display: flex; align-items: center; gap: 8px; }
.order-it-player-life-entry.eliminated { opacity: 0.6; }
.order-it-player-life-entry.current-turn .order-it-player-life-name { color: var(--highlight-secondary); font-weight: bold; }
.order-it-player-life-icon { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.order-it-player-life-name { font-size: 0.9em; font-weight: 500; }
.order-it-player-life-hearts { font-size: 1em; color: var(--error-color); letter-spacing: 1px; }
#order-it-scale-container, #order-it-unplaced-container {
    width: 100%; padding: 10px; background-color: var(--bg-secondary); border-radius: 6px; min-height: 175px;
    display: flex; /* Make them flex containers */
    flex-direction: column; /* Stack their children vertically */
    min-height: 175px; /* Allow flex item to shrink */
}
#order-it-scale-container {
    position: relative;
}
.order-it-direction-indicator {
    position: absolute;
    width: 30px;
    top: 5px;
    bottom: 5px;
    z-index: 200;
    box-sizing: border-box;
    border-radius: 4px;
    background-color: var(--bg-tertiary);
    color: var(--highlight-secondary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5em;
    font-weight: bold;
    user-select: none;
}
#order-it-direction-indicator-left {
    left: 5px;
}
#order-it-direction-indicator-right {
    right: 5px;
}
#order-it-unplaced-container h5 { margin-bottom: 10px; text-align: center; color: var(--text-secondary); }
#order-it-unplaced-items-area {
    display: grid; gap: var(--order-it-grid-gap); padding: 10px;
    border: 1px dashed var(--border-color); border-radius: 4px;
     /* Use dynamic-item-size */
    align-items: center;
    flex-grow: 1; /* Allow it to fill available vertical space in #order-it-unplaced-container */
    min-height: 0; /* Allow flex item to shrink */
}
#order-it-scale-area {
    display: flex;
    gap: var(--order-it-grid-gap);
    min-height: calc(var(--dynamic-item-size, 100px) + 20px); /* Use dynamic-item-size */
    justify-content: center;
    align-items: center;
    position: relative;
    border: 1px dashed var(--border-color); /* Added dotted border */
    border-radius: 4px; /* Added border-radius for consistency */
    flex-grow: 1; /* Allow it to fill available vertical space in #order-it-scale-container */
    min-height: 0; /* Allow flex item to shrink */
}
.order-it-scale-slot {
    border: 2px dashed var(--border-color);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    font-weight: bold;
    color: var(--text-secondary);
    flex-shrink: 0;
    user-select: none;
}
#order-it-unplaced-items-area {
    display: flex;
    flex-wrap: wrap;
    gap: var(--order-it-grid-gap);
    padding: 10px;
    border: 1px dashed var(--border-color);
    border-radius: 4px;
    min-height: calc(var(--dynamic-item-size, 100px) + 20px); /* Use dynamic-item-size */
    justify-content: center;
}
.order-it-scale-slot.drop-hover { background-color: color-mix(in srgb, rgb(var(--highlight-primary-rgb)) 15%, var(--bg-secondary)); /* Changed from rgba(var(--highlight-primary-rgb), 0.15) */ }
.order-it-item {
    min-width: 40px;
    min-height: 40px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    cursor: grab;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    user-select: none;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, border-color 0.2s ease, width 0.2s ease, height 0.2s ease;
    flex-shrink: 0;
}
.order-it-item.dragging { opacity: 0.5 !important; cursor: grabbing !important; transform: scale(1.05); }
.order-it-item.pending-confirmation { border-color: var(--warning-color); border-style: dashed; }
.order-it-item.preview-placement { border-color: var(--highlight-secondary); border-style: dotted !important; opacity: 0.6; }
.order-it-item.order-it-item-awaiting-reveal { border-color: var(--highlight-primary); }
.order-it-item-img-placeholder { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; z-index: 1; background-color: var(--bg-primary); /* Changed from transparent */ }
.order-it-item-info { position: relative; z-index: 2; background: rgba(var(--bg-tertiary-rgb), 0.85); /* Changed from rgba(var(--bg-tertiary-rgb), 0.85) */ padding: 5px; width: 100%; text-align: center; line-height: 20%;}
.order-it-item strong { font-size: 0.8em; line-height: 1.2; word-break: break-word; }
.order-it-item span { font-size: 0.7em; line-height: 1.1; color: var(--text-secondary); }
.order-it-item-shaking { animation: orderItShake 0.5s cubic-bezier(.36,.07,.19,.97) both infinite alternate; }
.order-it-item-glowing { animation: orderItGlow 1s ease-in-out infinite alternate; }
.order-it-item.order-it-item-flash-correct { --feedback-flash-bg-color: var(--success-color); --feedback-flash-border-color: var(--success-color); animation: orderItFlashFeedback 0.5s ease-out; }
.order-it-item.order-it-item-flash-incorrect { --feedback-flash-bg-color: var(--error-color); --feedback-flash-border-color: var(--error-color); animation: orderItFlashFeedback 0.5s ease-out; }
@keyframes orderItShake { 10%, 90% { transform: translate3d(-1px, 0, 0); } 20%, 80% { transform: translate3d(2px, 0, 0); } 30%, 50%, 70% { transform: translate3d(-3px, 0, 0); } 40%, 60% { transform: translate3d(3px, 0, 0); } }
@keyframes orderItGlow { from { box-shadow: 0 0 5px 2px rgba(var(--highlight-primary-rgb), 0.4); } to { box-shadow: 0 0 15px 5px rgba(var(--highlight-primary-rgb), 0.7); } }
@keyframes orderItFlashFeedback { 50% { background-color: var(--feedback-flash-bg-color); border-color: var(--feedback-flash-border-color); transform: scale(1.05); } }
#order-it-controls-area { margin-top: auto; text-align: center; padding-top: 15px; }

.order-it-host-controls-wrapper {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* ---------- SCROLLBAR STYLING ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-tertiary); border-radius: 8px; }
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--highlight-primary), var(--highlight-secondary));
    border-radius: 8px;
    border: 2px solid rgba(0, 0, 0, 0.25);
}
::-webkit-scrollbar-thumb:hover { filter: brightness(1.1); }

/* ---------- NOTIFICATION STYLES ---------- */
#generic-notification-popup {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(150%); 
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 15px 40px 15px 25px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
    z-index: 2000; 
    display: flex;
    align-items: center;
    gap: 15px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--nm-css-transition-duration) cubic-bezier(0.25, 0.8, 0.25, 1),
                transform var(--nm-css-transition-duration) cubic-bezier(0.25, 0.8, 0.25, 1);
    min-width: 280px;
    max-width: 400px;
    text-align: left;
    border-top: 3px solid var(--highlight-primary);
}

#generic-notification-popup.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0); 
    pointer-events: auto;
}
#generic-notification-popup.hide { display: none !important; }

.notification-manager-close-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8em;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-manager-close-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    color: var(--text-primary);
}

.notification-manager-icon-style {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
    border: 2px solid var(--highlight-secondary); flex-shrink: 0;
}
.notification-manager-icon-style.large {
    width: 60px; height: 60px; border-width: 3px; z-index: 1;
    position: relative; display: block;
}
.notification-manager-text-style {
    font-size: 0.95em; margin: 0; line-height: 1.4; color: var(--text-primary);
}
.notification-manager-text-style.large {
    font-size: 1.2em; font-weight: 500; margin-top: 0; z-index: 1;
    position: relative; display: block; min-height: 1.5em;
}

#large-notification-overlay.hide-large { display: none !important; }

#large-notification-popup {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    overflow: visible;
}

#large-notification-popup.large-notification-green-border {
    border-color: var(--success-color) !important;
    box-shadow: 0 0 20px rgba(10, 200, 110, 0.7);
}

#large-notification-popup.large-notification-green-border .wave-animation-element {
    background-color: var(--success-color);
}

.wave-animation-element {
    position: absolute; top: 50%; left: 50%;
    width: 10px; height: 10px;
    background-color: var(--highlight-primary);
    border-radius: 50%; transform: translate(-50%, -50%) scale(0);
    opacity: 0; pointer-events: none; z-index: 0;
}
#large-notification-overlay.show-large .wave-animation-element {
    animation: maskingWave var(--nm-large-wave-duration) cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
}
@keyframes maskingWave {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0.6; }
    70% { opacity: 0.2; }
    100% { transform: translate(-50%, -50%) scale(40); opacity: 0; }
}

#global-shatter-overlay-canvas {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none; z-index: 3001; display: none;
}

/* ---------- VOLUME CONTROL ---------- */
#volume-control-container {
    position: relative;
    display: flex;
    align-items: center;
}

/* This styles the volume icon button itself */
#volume-icon-button {
    background: color-mix(in srgb, var(--header-bg-start) 80%, white); /* Brighter version of header start color */
    border: none;
    box-shadow: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    transition: background-color 0.2s ease;
}

#volume-icon-button:hover {
    background: color-mix(in srgb, var(--header-bg-start) 60%, white); /* Even brighter on hover */
}

/* This styles the SVG icons inside the button, ensuring they render correctly */
#volume-icon-button svg {
    width: 20px;
    height: 20px;
    fill: #fff;
    transition: transform 0.2s ease;
}

/* This is the pop-out box for the slider */
#volume-slider-wrapper {
    position: absolute;
    z-index: 10;
    /* Position the popout 8px below the container, creating just enough space for the arrow */
    top: calc(100% + 8px);
    left: 50%;
    width: 150px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    
    /* --- The core of the hover fix --- */
    opacity: 0;
    visibility: hidden; /* Start hidden */
    transform: translateX(-50%) translateY(-10px);
    pointer-events: none;
    /* Animate opacity and transform, but keep visibility change instant */
    transition: opacity 250ms cubic-bezier(0.25, 0.8, 0.25, 1), 
                transform 250ms cubic-bezier(0.25, 0.8, 0.25, 1),
                visibility 0s 250ms; /* Delay making it invisible, giving you time to move the mouse */
}

/* --- The speech-bubble arrow --- */
#volume-slider-wrapper::before,
#volume-slider-wrapper::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
}

/* Arrow border */
#volume-slider-wrapper::before {
    transform: translateX(-50%);
    border-bottom: 8px solid var(--border-color);
}

/* Arrow fill */
#volume-slider-wrapper::after {
    transform: translateX(-50%) translateY(1px);
    border-bottom: 7px solid var(--bg-secondary);
    border-left-width: 7px;
    border-right-width: 7px;
}
#volume-control-container:hover #volume-slider-wrapper {
    opacity: 1;
    visibility: visible; /* Make it visible */
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    /* Transition instantly to visible, letting the other transitions run smoothly */
    transition-delay: 0s;
}

#volume-slider {
    width: 100%;
}


/* ---------- RESPONSIVE TWEAKS ---------- */
@media (max-width: 980px) {

    .pre-lobby-header {
        display: none;
    }
    body { 
        padding: 8px;
        overflow-x: hidden; /* Prevent horizontal scroll on mobile */
    }
    .ad-banner {
        display: none;
    }
    body.ads-hidden {
        padding: 8px; /* Ensure padding is consistent */
    }

    /* New rule to make main view panels grow within their parent flex container */
    #main-controls-area > .panel,
    #active-game-content {
        flex-grow: 1;
        flex-shrink: 1; /* Allow shrinking if needed */
        min-height: 0; /* Allow flex item to shrink below its content size */
}
    .panel-wrapper { 
        min-height: calc(100vh - 16px); /* Fallback */
        min-height: calc(100lvh - 16px); /* Use large viewport height */
        height: auto;
        padding-top: 80px; /* Adjust for smaller header */
    }
    .panel-header {
        height: auto;
        min-height: 80px;
        padding: 10px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .panel-header > img {
        position: relative;
        top: 0;
        left: 0;
        width: 150px;
        margin-bottom: -45px; /* Pull content below it up */
               margin-left: -5px;
    }
    .panel-header nav {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 10px;
    }
    .lobby-content { 
        
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 10px;
        align-items: stretch; /* Make grid items stretch vertically */
    }
    .player-section { order: 2; min-height: 200px; max-height: 40vh; }
    .controls { order: 1; }

    /* Login */
    #login-profile-setup {
        flex-direction: column;
    }

    /* Pre-Lobby */
    .pre-lobby-grid {
        grid-template-columns: 1fr;
    }
    .pre-lobby-header {
        grid-template-columns: 1fr;
    }

    .settings-icon {
    display: block;
    position:absolute;
    top: 10px;
    right: 10px;
    }   

    /* Quiz */
    #quiz-answers-container {
        grid-template-columns: 1fr;
    }
    #quiz-question-text, #gtp-product-name {
        font-size: 1.2em;
        height: auto;
        min-height: calc(1.2em * 1.2);
        white-space: normal; /* Allows text to wrap */
               overflow: visible; /* Ensure text is not cut off */
        text-overflow: clip; /* Ensure text is not cut off */
        text-align: center;
    }
    #quiz-question-text span, #gtp-product-name span {
        position: relative;
        transform: none;
        top: 0;
        left: 0;
        animation: none !important; /* Disable scrolling text on mobile */
    }

    /* Guess The Price */
    .gtp-product-display {
        flex-direction: column;
    }
    .gtp-input-area {
        flex-wrap: wrap;
        justify-content: center;
    }
    #gtp-price-input {

        width: 150px;
    }

    /* Podium */
    #podium-container {
        flex-direction: column; /* Stack main podium and others list vertically */
        align-items: center; /* Center items horizontally */
        gap: 20px; /* Increase gap for vertical spacing */
        /* Removed flex-wrap: wrap; as it's not needed for column layout */
        justify-content: center;
        margin-top: 20px; /* Add space between title and podium */
    }
    #podium-main {
        height: 290px; /* Set fixed height to prevent pushing content down */
        gap: 5px;
        /* Allow podium-main to flex and shrink within its container */
        min-width: 0; /* Allow content to shrink below its intrinsic size */
        max-width: 100%; /* Ensure it doesn't overflow its parent */
    }
    .podium-position {
        width: 80px;
    }
    .podium-player-icon {
       
        width: 40px;
       
        height: 40px;
    }
    .podium-player-score {
        font-size: 1.5em;
    }
    #podium-others-list-container {
        width: 100%; /* Take full width available */
        /* Removed max-width: 180px; */
        transform: none;
        opacity: 1;
        animation: none;
        margin-top: 20px; /* Add space between main podium and this list */
        margin-left: auto; /* Center horizontally */
        margin-right: auto; /* Center horizontally */
    }
    #podium-others-list {
        max-height: 200px;
        overflow-y: auto; /* Ensure scrollability */
    }
}

@media (max-width: 600px) {
    body {
        padding: 0; /* Remove body padding for full screen header and wrapper */
    }
    body.ads-hidden {
        padding: 0; /* Ensure padding is consistent */
    }

    /* Adjust notification position for mobile */
    #generic-notification-popup {
        top: 20px;
        bottom: auto;
        transform: translateX(-50%) translateY(-150%); /* Start off-screen above */
    }
    #generic-notification-popup.show {
        transform: translateX(-50%) translateY(0); /* Move to on-screen position */
    }

    .panel-wrapper {
        background: transparent; /* Make app container background invisible */
        box-shadow: none; /* Remove box shadow */
        border-radius: 0; /* Remove border radius */
        padding-top: 60px; /* Adjust for smaller header */
        min-height: 100lvh; /* Ensure it takes full viewport height */
        height: 100vh; /* Fallback for older browsers */
    }

    /* Header adjustments for phones */
    .panel-header {
        position: fixed; /* Make header fixed */
        width: 100%;
        left: 0;
        top:  0;
        border-radius: 0; /* Remove border radius */
        padding: 8px 10px; /* Adjusted padding for smaller header */
        flex-direction: row; /* Keep row for logo and toggle */
        justify-content: space-between; /* Space between toggle, logo, and potential right elements */
        align-items: center;
        min-height: 60px; /* Smaller header height */
        z-index: 201; /* Ensure it's above other content and side tab */
    }
    .panel-header > img {
        position: absolute; /* Absolute for centering */
        left: 50%;
        top: 50%; /* Vertically center the logo */
        transform: translate(-50%, -50%); /* Adjust transform for both horizontal and vertical centering */
        width: auto; /* Allow width to adjust based on height */
        max-height: 44px; /* Constrain height to fit within header padding (60px - 8px top - 8px bottom = 44px) */
        margin-bottom: 0; /* Reset margin */
        margin-left: 0; /* Reset margin */
    }
    .panel-header nav {
        display: none; /* Hide desktop nav on phones */
    }
    #side-tab-toggle-button {
        display: inline-flex !important; /* Show toggle button */
        background: transparent;
        box-shadow: none;
        padding: 5px;
        color: var(--text-primary);
        font-size: 1.5em;
        order: -1; /* Place it on the far left */
    }
    #side-tab-toggle-button:hover {
        background: rgba(255,255,255,0.1);
    }

    .panel-wrapper {
        padding-top: 60px; /* Adjust for smaller header */
        min-height: calc(100lvh - 16px); /* Reset min-height */
    }

    /* Mobile Game Header Adjustments */
    .game-view-header {
        position: relative; /* Add for timer positioning context */
        flex-direction: column; /* Stack items vertically */
        align-items: center; /* Center items horizontally in the column */
    }

    .game-view-caption {
        padding-top: 10px;
        width: 100%; /* Allow caption to take full width */
        text-align: justify;
    }
    .game-view-timer-wrapper {
        position: absolute; /* Absolute positioning relative to .game-view-header */
        top: 0px; /* Position within header padding */
        right: 0px; /* Position within header padding */
        z-index: 10; /* Ensure it's above other content */
        margin: -10px;
    }
    #quiz-timer-container,
    #gtp-timer-container {
        width: 48px;
        height: 48px;
    }
    .timer-background,
    .timer-progress {
        stroke-width: 8; /* Thinner stroke for smaller timer */
    }
    #quiz-timer-text,
    #gtp-timer-text {
        font-size: 1.5em; /* Smaller font for smaller timer */
    }

    /* Game selection cards */
    .choice-card-container {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }
    .game-mode-icon {
        width: 70%;
        height: 70%;
    }
    .game-mode-name {
        font-size: 0.85em;
    }

    /* Imprint button is now in side menu, so remove fixed positioning */
    .imprint-button {
        position: static;
        padding: 0;
        background: none;
        color: var(--text-primary);
        font-size: 1em;
        text-align: left;
        display: none; /* Changed from 'block' to 'none' */
        width: auto;
        margin-top: 10px;
    }
    .imprint-button:hover {
        background: none;
        color: var(--highlight-primary);
    }
    body {
        padding-bottom: 8px; /* Reset padding as imprint button is moved */
    }
    .panel-wrapper {
        min-height: calc(100lvh - 16px); /* Reset min-height */
    }

    /* Other adjustments */
    .panel {
        padding: 15px;
        max-width: 100%; /* Ensure panels don't exceed screen width */
    }
    .game-view-panel {
        padding-bottom: 60px; /* Restore space for footer elements */
    }
    #main-controls-area { /* Target the specific main controls area */
        overflow-x: hidden; /* Prevent horizontal scrolling within the main controls */
    }
    .waiting-button
    {
        font-size: 0.75em; /* Slightly larger font for readability */
    }
    .joker-card {
        width: 60px;
        height: 80px;
    }
    .joker-icon {
        font-size: 1.8em;
    }

    /* Order It Game Mobile Layout */
    #order-it-game-view .game-view-main {
        flex-direction: row; /* side-by-side columns */
        align-items: stretch;
        gap: 10px;
        overflow-y: hidden; /* Prevent vertical scroll on main container */
    }

    #order-it-scale-container {
        flex: 1; /* take up half the space */
        display: flex;
        flex-direction: column; /* Stack indicators and scale area vertically */
        align-items: stretch; /* Stretch children to fill width */
        overflow: hidden; /* Prevent internal overflow issues */
        position: relative; /* Keep positioning context */
        padding: 10px;
    }
    .order-it-direction-indicator {
        width: auto;
        left: 5px;
        right: 5px;
    }
    #order-it-direction-indicator-left {
        top:auto;
        bottom: 5px;
    }
    #order-it-direction-indicator-right {
        bottom: auto;
      top: 5px;
  }


    #order-it-unplaced-container {
        flex: 1; /* take up half the space */
        max-height: none; /* remove height limit */
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Prevent internal overflow issues */
    }

    #order-it-scale-area {
        flex-direction: column-reverse; /* MODIFIED: Changed from column to column-reverse */
        flex-grow: 1;
        min-height: 0;
        justify-content: flex-start;
        align-items: center;
        overflow-y: auto; /* Allow scrolling if items exceed height */
        padding: 30px;
    }

    #order-it-unplaced-items-area {
        flex-direction: column; /* Stack items vertically */
        align-items: center;
        justify-content: center;
        flex-grow: 1;
        padding: 5px;
        border: 1px dashed var(--border-color);
        overflow-y: auto; /* Allow scrolling if items exceed height */
        flex-wrap: nowrap;
    }

}

/* Reusable pop-in animation */
@keyframes popInFromTop {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.anim-pop-in {
    animation: popInFromTop 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

/* Initial state for quiz intro animation */
#millionaire-quiz-game-view.intro-animation .game-view-header,
#millionaire-quiz-game-view.intro-animation #quiz-answers-container .choice-card,
#millionaire-quiz-game-view.intro-animation .game-view-controls {
    opacity: 0;
    pointer-events: none; 
}

/* Keyframes for the correct answer celebration */
@keyframes correctAnswerCelebration {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

@keyframes confettiBurst {
    0% {
        opacity: 1;
        transform: scale(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: scale(1.5) rotate(180deg);
    }
}

/* Apply animations to the player's correct choice */
.choice-card.correct.was-my-choice {
    animation: correctAnswerCelebration 600ms ease-in-out forwards;
}

/* Confetti pseudo-elements setup */
.choice-card.correct.was-my-choice::before,
.choice-card.correct.was-my-choice::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 4px;
    height: 8px;
    background: transparent;
    pointer-events: none;
    animation: confettiBurst 800ms ease-out forwards;
    z-index: 10;
}

/* Confetti particles using box-shadow */
.choice-card.correct.was-my-choice::before {
    box-shadow: 
        -69px -42px 0px 0px #ffc700, 48px -51px 0px 2px #3498db, 
        -49px 24px 0px 2px #e74c3c, 62px 48px 0px 2px #2ecc71, 
        -39px -75px 0px 0px #ffc700, -78px 18px 0px 1px #3498db, 
        -43px 58px 0px 1px #e74c3c, -27px -35px 0px 2px #2ecc71, 
        -69px 18px 0px 0px #ffc700, 36px -69px 0px 2px #3498db, 
        88px -15px 0px 1px #e74c3c, 50px 72px 0px 0px #2ecc71;
}

.choice-card.correct.was-my-choice::after {
     box-shadow: 
        75px -19px 0px 2px #ffc700, 24px 63px 0px 1px #3498db, 
        -88px 36px 0px 0px #e74c3c, -2px -60px 0px 1px #2ecc71, 
        -8px 43px 0px 1px #ffc700, -69px -50px 0px 1px #3498db, 
        84px 50px 0px 0px #e74c3c, 48px -30px 0px 2px #2ecc71, 
        -1px 81px 0px 2px #ffc700, 16px -62px 0px 0px #3498db, 
        -85px -12px 0px 0px #e74c3c, -88px 65px 0px 2px #2ecc71;
}

.unified-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: 3000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.unified-popup-bubble {
    position: relative;
    background: var(--bg-tertiary);
    border: 2px solid var(--highlight-primary);
    border-radius: 12px;
    padding: 30px 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    transform: scale(0.8);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                opacity 0.3s ease-in-out;
}

.unified-overlay.visible,
.unified-overlay.show-large {
    opacity: 1;
    pointer-events: auto;
}

.unified-overlay.visible .unified-popup-bubble,
.unified-overlay.show-large .unified-popup-bubble {
    transform: scale(1);
       opacity: 1;
}

/* ---------- PROMPT SYSTEM STYLES ---------- */
#active-game-content {
    position: relative;
}

#prompt-bubble::after {

    content: '';
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    border: 9px solid transparent;
    border-top-color: var(--highlight-primary);
}

#prompt-text {
    font-size: 1.8em;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

#persistent-prompt-display {
    position: relative;
    margin-right: auto;
    min-width: 44px;
    min-height: 44px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#persistent-prompt-display.visible {
    opacity: 1;
    pointer-events: auto;
}

/* The '?' icon */
#persistent-prompt-toggle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 2px solid var(--highlight-secondary);
    box-shadow: 0 2px 10px rgba(0,0,0,0.4);
    cursor: help;
    
    display: flex;
    justify-content: center;
    align-items: center;
    
    font-size: 1.8em;
    font-weight: bold;
    color: var(--highlight-secondary);
    
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

#persistent-prompt-display:hover #persistent-prompt-toggle {
    background-color: var(--highlight-primary);
    border-color: #fff;
}

/* The prompt text bubble */
#persistent-prompt-text {
    left: 0;
    position: absolute; /* Ensure it's absolutely positioned */
    bottom: calc(100% + 10px); /* Position 10px above the parent */
    
    width: max-content;
    max-width: 300px;
    padding: 12px 15px;
    
    background: var(--bg-primary);
    border-radius: 6px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.5);

    font-size: 0.9em;
    color: var(--text-secondary);
    
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none; /* Crucial: cannot be interacted with when hidden */
    
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

/* On hover of the MAIN container, fade in the text bubble */
#persistent-prompt-display:hover #persistent-prompt-text {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ---------- PODIUM STYLES ---------- */
#podium-view {
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    text-align: center;
}

#podium-title {
    font-size: 2.5em;
    color: var(--highlight-secondary);
    text-shadow: 0 0 10px rgba(var(--highlight-primary-rgb), 0.5);
}

#podium-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    width: 100%;
    flex-grow: 1;
}

#podium-main {
    display: flex;
    align-items: flex-end;
    justify-content: center; /* Center podium positions horizontally */
    gap: 10px;
    flex-direction: row;
    height: 330px; /* Fixed height for player info + tallest column */
}

/* This is the new wrapper for each winner spot */
.podium-position {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 160px;
}

/* This block sits on top of the column and does NOT animate */
.podium-player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: -2px; /* Slight overlap with column border */
    position: relative;
    z-index: 2;
}

/* The growing column, now only contains the score */
.podium-column {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(180deg, color-mix(in srgb, rgb(var(--highlight-primary-rgb)) 20%, var(--bg-secondary)), color-mix(in srgb, rgb(var(--highlight-primary-rgb)) 5%, var(--bg-secondary))); /* Changed from rgba(var(--highlight-primary-rgb), 0.2) and rgba(var(--highlight-primary-rgb), 0.05) */
    border: 2px solid var(--highlight-primary);
    border-bottom: none; /* Bottom border removed for seamless look */
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
    
    /* Animation setup */
    height: 0;
    overflow: hidden;
    transition: height 3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.podium-position-2 { order: 1; }
.podium-position-1 { order: 2; }
.podium-position-3 { order: 3; }

.podium-column-1 { background: linear-gradient(180deg, color-mix(in srgb, #FFD700 30%, var(--bg-secondary)), color-mix(in srgb, #FFD700 10%, var(--bg-secondary))); /* Changed from rgba(255, 215, 0, 0.3) and rgba(255, 215, 0, 0.1) */ border-color: #FFD700; }

.podium-column-1.grow { height: 180px; }
.podium-column-2.grow { height: 130px; }
.podium-column-3.grow { height: 90px; }

.podium-place {
    font-size: 2em;
    font-weight: bold;
    color: var(--highlight-secondary);
}
.podium-position-1 .podium-place { color: #FFD700; }

.podium-player-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
}

.podium-player-name {
    font-size: 1.2em;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.podium-player-score {
    font-size: 2.8em; /* Slightly larger score text */
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

#podium-others-list-container {
    width: 250px;
    opacity: 0;
    transform: translateX(20px);
}

#podium-others-list-container.animate-fade-in {
    animation: fadeInRight 0.5s ease forwards 2.5s;
}

@keyframes fadeInRight {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

#podium-others-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-color: var(--bg-tertiary); /* Changed from rgba(0,0,0,0.2) */
    padding: 10px;
    border-radius: 8px;
    max-height: 280px;
    overflow-y: auto;
    text-align: left;
}

.podium-other-player {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
}

.podium-other-player-rank {
    font-weight: bold;
    color: var(--text-secondary);
    width: 25px;
    text-align: right;
}

.podium-other-player-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.podium-other-player-details {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}
.podium-other-player-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.podium-other-player-score {
    font-weight: bold;
    color: var(--highlight-secondary);
}

#podium-footer {
    min-height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ---------- IMPRINT BUTTON ---------- */
.imprint-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 0.85em;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
    z-index: 100;
}

.imprint-button:hover {
    background: color-mix(in srgb, var(--bg-secondary) 80%, white);
    color: var(--text-primary);
}

/* ---------- SIDE TAB MENU ---------- */
.side-tab-menu {
    position: fixed;
    top: 0;
    left: -300px; /* Hidden by default */
    width: 280px;
    height: 100lvh; /* Use lvh for stable height */
    height: 100vh; /* Fallback */
    background: var(--bg-secondary);
    box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    z-index: 1000; /* Increased z-index to be on top of everything */
    transition: left 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
}

.side-tab-menu.open {
    left: 0;
}

.side-tab-close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8em;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: color 0.2s ease;
}

.side-tab-close-button:hover {
    color: var(--text-primary);
}

.side-tab-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: 40px; /* Space for close button */
}

.side-tab-section {
    padding-bottom: 15px;
    border-bottom: 1px solid var(--muted-line);
}

.side-tab-section:last-child {
    border-bottom: none;
}

#volume-control-container-mobile {
    display: flex;
    align-items: center;
    gap: 10px;
}

#volume-icon-button-mobile {
    background: color-mix(in srgb, var(--bg-tertiary) 90%, white); /* Slightly brighter version of its original color */
    border: none;
    box-shadow: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    transition: background-color 0.2s ease;
}

#volume-icon-button-mobile:hover {
    background: color-mix(in srgb, var(--bg-tertiary) 80%, white); /* Even brighter on hover */
}

#volume-icon-button-mobile svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

#volume-slider-mobile {
    width: 100%;
    flex-grow: 1; /* Allow slider to take available space */
}

#language-selector-container-mobile .base-dropdown {
    width: 100%;
}

.side-tab-button {
    width: 100%;
    display: block;
    margin-top: 10px;
}

/* New footer for active game content */
#active-game-content-footer {
    display: flex;
    align-items: center;
    width: 100%;
}