/* ==========================================================================
   1. VARIABLES & CONFIGURATION
   ========================================================================== */
:root {
    /* --- Colors: Backgrounds --- */
    --bg-primary: #23233f;
    --bg-secondary: #262942;
    --bg-tertiary: #323052;
    --bg-tertiary-rgb: 35, 35, 60;
    --panel-bg: var(--bg-tertiary);

    /* --- Colors: Header Gradient --- */
    --header-bg-start: #4a148c;
    --header-bg-end: #6a1b9a;

    /* --- Colors: Text --- */
    --text-primary: #e0e0e6;
    --text-secondary: #a0a8c0;

    /* --- Colors: Highlights & Accents --- */
    --highlight-primary: #957fe4;
    --highlight-primary-rgb: 138, 111, 240;
    --highlight-secondary: #b8a8f0;
    --accent-blue: #5070b0;

    /* --- Colors: Feedback --- */
    --error-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;

    /* --- UI Elements --- */
    --border-color: #353550;
    --input-bg: var(--bg-primary);
    --input-border: var(--border-color);
    --muted-line: color-mix(in srgb, var(--border-color) 92%, white);

    --scrollbar-track-color: var(--bg-tertiary);
    --scrollbar-thumb-color: var(--highlight-primary);

    /* --- Dimensions & Settings --- */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --slot-height: 56px;
    --player-icon-size: 38px;
    --login-icon-select-size: 48px;
    --login-icon-preview-size: 80px;
    --arrow-size: 8px;
    --order-it-grid-gap: 10px;
    
    /* Layout Sizes */
    --sidebar-width: 300px;
    --sidebar-min-width: 76px;

    /* --- Animations --- */
    --nm-css-transition-duration: 400ms;
    --nm-large-wave-duration: 600ms;
    --gtp-bubble-h-shift: 40%;
}


/* ==========================================================================
   2. RESET & GLOBAL LAYOUT
   ========================================================================== */
* { 
    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;
    overflow-y: auto;
    transition: padding 0.4s ease-in-out;
    padding-top: 1rem;
    padding-left: max(180px, env(safe-area-inset-left));
    padding-right: max(180px, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

body.ads-hidden { 
    padding: 1rem;
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

#background-shader-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
    transform: translateZ(0); /* Forces GPU composite layer */
}

#bg-shader-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
    background-color: var(--bg-primary);
}

.bg-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
    transform: translateZ(0);
}

.bg-canvas.active {
    opacity: 1;
}

h1, h2, h3, h4, h5, p { 
    margin: 0; 
}


/* --- Ad Banners --- */
.ad-banner {
    position: fixed;
    top: 0; bottom: 0;
    width: 160px;
    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; }

.ad-banner-mobile {
    display: none;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    overflow: hidden;
    height: 115px; 
    padding-top: 15px;
    opacity: 1;
    transition: height 0.4s cubic-bezier(0.25, 1, 0.5, 1), 
                padding-top 0.4s cubic-bezier(0.25, 1, 0.5, 1), 
                opacity 0.3s ease-in-out;
}

.ad-banner-mobile ins.adsbygoogle {
    margin: 0 auto;
}

.ad-banner-mobile:has(ins[data-ad-status="unfilled"]),
.ad-banner-mobile:empty {
    height: 0 !important;
    padding-top: 0 !important;
    opacity: 0;
    pointer-events: none;
}

ins.adsbygoogle[data-ad-status="unfilled"] {
    display: none !important;
}

@media (max-width: 1024px) {
    .ad-banner {
        display: none !important;
    }
}


/* ==========================================================================
   3. UI COMPONENTS (Decoupled to components.css)
   ========================================================================== */


/* ==========================================================================
   4. MAIN LAYOUT, HEADER & FOOTER
   ========================================================================== */
.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); 
    min-height: calc(100lvh - 2rem);
    position: relative; 
    padding-top: 100px; 
    overflow: visible; 
    z-index: 6;
}

.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%);
    position: absolute; 
    flex-shrink: 0;
    top: 0; left: 0; 
    width: 100%; 
    height: 100px; 
    z-index: 10;
}

.panel-header > a { 
    display: contents; 
}

#header-logo-img {
    position: sticky; 
    width: 250px; 
    height: auto;
    top: -60px; left: 30px; 
    transform: none; 
    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);
    font-size: 0.95rem; 
    line-height: normal;
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    height: auto; 
    min-height: 34px;
}

.panel-header nav .base-button.header-nav-button:hover {
    background: color-mix(in srgb, var(--header-bg-start) 60%, white); 
    filter: brightness(1.1);
}

.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: var(--sidebar-width) 1fr;
    grid-template-rows: 1fr; 
    gap: 18px; 
    padding: 18px; 
    align-items: stretch; 
    flex: 1 1 auto; 
    position: relative; 
    min-height: 0; 
    transition: grid-template-columns 0.3s ease;
}

.lobby-content.static-view-active { 
    grid-template-columns: 1fr; 
}

.lobby-content.static-view-active > #player-section { 
    display: none; 
}

.lobby-content.player-section-minimized { 
    grid-template-columns: var(--sidebar-min-width) 1fr; 
}

.controls {
    position: relative; 
    display: flex; 
    flex-direction: column;
    gap: 14px; 
    overflow-y: visible; 
    padding: 0; 
    min-width: 0; 
    width: 100%;
}

.controls > .panel, 
#active-game-content {
    flex-grow: 1; 
    transition: opacity 0.3s ease-in-out;
}

.content-faded { 
    opacity: 0; 
    pointer-events: none; 
}

.lobby-footer {
    display: flex; 
    flex-wrap: wrap; 
    justify-content: center; 
    align-items: center;
    gap: 5px 15px; 
    padding: 15px 20px; 
    font-size: 0.85rem;
    color: var(--text-secondary); 
    border-top: 1px solid var(--muted-line);
    margin-top: auto; 
    flex-shrink: 0;
}

.lobby-footer a { 
    color: var(--text-secondary); 
    text-decoration: none; 
    transition: color 0.2s ease; 
}

.lobby-footer a:hover { 
    color: var(--text-primary); 
    text-decoration: underline; 
}


/* ==========================================================================
   5. SIDEBAR: PLAYER LIST
   ========================================================================== */
.player-section { 
    min-width: 0; 
    align-self: stretch; 
    transition: padding 0.3s ease; 
    overflow: hidden; 
} 

.player-section-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 10px;
}

.player-header-title {
    margin: 0; 
    font-size: 14px; 
    color: var(--highlight-secondary);
    letter-spacing: 0.3px; 
    display: flex; 
    justify-content: space-between; 
    flex-grow: 1;
}

#host-status-indicator { 
    font-weight: normal; 
    color: var(--text-secondary); 
}

.circular-toggle-btn {
    display: none; 
    background: var(--bg-secondary); 
    border: 1px solid var(--border-color);
    border-radius: 50%; 
    width: 28px; 
    height: 28px; 
    cursor: pointer;
    align-items: center; 
    justify-content: center; 
    color: var(--text-primary);
    transition: transform 0.3s ease, background 0.2s; 
    flex-shrink: 0; 
    margin-left: 10px;
}

.circular-toggle-btn:hover { 
    background: var(--bg-primary); 
}

.circular-toggle-btn svg { 
    width: 16px; 
    height: 16px; 
    transition: transform 0.3s ease; 
}

.player-list {
    display: grid; 
    grid-auto-rows: var(--slot-height); 
    gap: 0;
    position: relative; 
    overflow-y: auto; 
    overflow-x: hidden; 
    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;
    mask-image: linear-gradient(to bottom, black 0%, black 85%, transparent 100%);
    min-height: 0;
}

.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);
    border-radius: 8px; 
    transition: background-color 180ms, transform 120ms;
    overflow: hidden;
}

.player:hover { 
    background-color: color-mix(in srgb, var(--bg-tertiary) 85%, white); 
    transform: translateY(-2px); 
}

.player.current-turn-player {
    background: color-mix(in srgb, rgb(var(--highlight-primary-rgb)) 15%, var(--bg-secondary));
    border: 1px solid var(--highlight-primary);
    animation: colorPulse 2s ease-in-out infinite alternate;
}

#its-your-turn-message { 
    color: white; 
    margin: 0 auto; 
}

.player.eliminated { 
    opacity: 0.5; 
    background: var(--bg-primary); 
}

.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; 
    overflow-x: auto; 
    scrollbar-width: none; 
    -ms-overflow-style: none;
}

.player-details-center::-webkit-scrollbar { 
    display: none; 
}

.player-tags { 
    display: flex; 
    gap: 5px; 
    font-size: 0.75em; 
    margin-bottom: 2px; 
    white-space: nowrap; 
    flex-shrink: 0; 
}

.host-marker { 
    background-color: var(--accent-blue); 
    color: var(--text-primary); 
    padding: 1px 4px; 
    border-radius: 3px; 
    font-weight: 500; 
}

.you-marker { 
    background-color: var(--text-secondary); 
    color: var(--bg-primary); 
    padding: 1px 4px; 
    border-radius: 3px; 
    font-weight: 500; 
}

.mod-marker { 
    background-color: #FFD700; 
    color: #000; 
    padding: 1px 4px; 
    border-radius: 3px; 
    font-weight: 500; 
}

.player-name { 
    font-weight: 500; 
    white-space: nowrap; 
    display: block; 
    flex-shrink: 0; 
}

.player-name.disconnected-text { 
    font-style: italic; 
}

.player-score { 
    color: var(--highlight-secondary); 
    font-weight: bold; 
    font-size: 1.1em; 
}

.player-score-container { 
    position: relative; 
    display: flex; 
    align-items: center; 
    justify-content: flex-end; 
    min-width: 40px; 
    flex-shrink: 0; 
}

.player-score-change {
    position: absolute; 
    right: 100%; 
    margin-right: 5px; 
    font-weight: bold;
    animation: score-change-animation 1.5s ease-out forwards; 
    white-space: nowrap; 
    z-index: 10;
}

.player-score-change.positive { color: var(--success-color); }
.player-score-change.negative { color: var(--error-color); }

#player-section-footer {
    margin-top: auto; 
    padding-top: 10px;
    display: flex; 
    gap: 8px; 
    justify-content: center; 
    flex-wrap: wrap;
}

#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);
}

#player-section-footer .base-button:hover { 
    background: color-mix(in srgb, var(--bg-secondary) 70%, white); 
    filter: brightness(1); 
}


/* ==========================================================================
   6. VIEWS: LOGIN & PRE-LOBBY AND TABS Settings
   ========================================================================== */
#app-container.login-view-active .lobby-content { 
    grid-template-columns: 1fr; 
}

#app-container.login-view-active .controls { 
    flex-direction: row; 
    justify-content: center; 
    align-items: flex-start;
    gap: 18px; 
    flex-wrap: wrap; 
}

#login-area { 
    text-align: center; 
    flex: 0 1 550px; 
    max-width: 550px; 
    min-height: 0; 
    width: 100%; 
    box-sizing: border-box; 
}

#tips-panel { 
    display: flex; 
    flex-direction: column; 
    flex: 0 1 350px; 
    max-width: 350px; 
    min-height: 0; 
    width: 100%; 
    box-sizing: border-box; 
}

#profile-customization-box {
    padding: 20px; 
    border-radius: 10px; 
    max-width: 500px; 
    width: 100%; 
    box-sizing: border-box;
    margin: 20px auto; 
    display: flex; 
    flex-direction: column; 
    align-items: center;
}

#login-profile-setup { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    margin-bottom: 15px; 
    width: 100%; 
    justify-content: center; 
}

#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; 
    min-width: 0; 
    width: 100%; 
}

#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 + 24px); 
}

.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); 
}

.login-buttons-container { 
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    margin-top: 20px; 
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.login-action-btn { 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    width: 100%;
    flex: 1 1 0;
    min-width: 0;
    box-sizing: border-box;
}

.login-buttons-container.has-two-buttons .login-action-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 12px 18px;
}

.login-btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: currentColor;
    display: inline-block;
    vertical-align: middle;
}


/* --- Rotating Tips Panel --- */
#tips-container {
    --time-per-tip: 20s; 
    --total-tips: 11; 
    --cycle-duration: calc(var(--time-per-tip) * var(--total-tips));
    position: relative; 
    flex-grow: 1; 
    overflow: hidden; 
    margin-top: 15px; 
    min-height: 120px; 
}

.tip {
    position: absolute; 
    inset: 0; 
    opacity: 0;
    animation: rotate-tips var(--cycle-duration) linear infinite;
    display: flex; 
    flex-direction: column; 
    gap: 8px;
    background: var(--bg-secondary); 
    padding: 15px;
    border-radius: 8px; 
    border: 1px solid var(--border-color);
    overflow-y: auto; 
    z-index: 0; 
    pointer-events: none;
}

.tip h3 { color: var(--highlight-secondary); margin-bottom: 5px; }
.tip p { font-size: 0.9em; color: var(--text-secondary); line-height: 1.5; }

.tip:nth-child(1) { animation-delay: calc(var(--time-per-tip) * 0); }
.tip:nth-child(2) { animation-delay: calc(var(--time-per-tip) * 1); }
.tip:nth-child(3) { animation-delay: calc(var(--time-per-tip) * 2); }
.tip:nth-child(4) { animation-delay: calc(var(--time-per-tip) * 3); }
.tip:nth-child(5) { animation-delay: calc(var(--time-per-tip) * 4); }
.tip:nth-child(6) { animation-delay: calc(var(--time-per-tip) * 5); }
.tip:nth-child(7) { animation-delay: calc(var(--time-per-tip) * 6); }
.tip:nth-child(8) { animation-delay: calc(var(--time-per-tip) * 7); }
.tip:nth-child(9) { animation-delay: calc(var(--time-per-tip) * 8); }
.tip:nth-child(10) { animation-delay: calc(var(--time-per-tip) * 9); }
.tip:nth-child(11) { animation-delay: calc(var(--time-per-tip) * 10); }


/* --- Pre-Lobby --- */
#pre-lobby-controls { 
    gap: 10px; 
}

.pre-lobby-grid { 
    display: grid; 
    grid-template-columns: 1fr 340px; 
    gap: 20px; 
    align-items: start; 
    flex-grow: 1; 
}

.pre-lobby-games { 
    display: flex; 
    flex-direction: column; 
    gap: 20px; 
}

.choice-card-container { 
    display: grid; 
    gap: 10px; 
    grid-template-columns: repeat(auto-fill, minmax(min(140px, calc(50% - 5px)), 1fr)); 
}

.choice-card {
    padding: 15px; 
    border-radius: 8px; 
    background-color: var(--bg-secondary);
    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;
}

.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;
}

.game-mode-icon { 
    width: 90%; 
    height: 80%; 
    max-width: 100px; 
    object-fit: contain; 
    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; 
}

.client-game-display {
    display: flex; 
    justify-content: center; 
    align-items: center;
    width: 150px; 
    aspect-ratio: 1 / 1; 
    background: var(--bg-secondary); 
    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; 
    align-self: center; 
    width: 100%; 
    max-width: 350px; 
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    box-sizing: border-box;
}

.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; 
}


/* --- Base Tab Menu Component & Alignment --- */
.pre-lobby-games > h3 {
    height: 24px;
    line-height: 24px;
    margin: 0; padding: 0;
    display: flex; 
    align-items: center;
}

.pre-lobby-settings {
    display: flex;
    flex-direction: column;
    min-width: 0;
    width: 100%;
}

.base-tabs {
    display: flex;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-bottom: none; 
    border-radius: 8px 8px 0 0;
    padding: 4px 4px 0 4px;
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    height: 44px;
    margin-top: 0;
}

.base-tab-button {
    flex: 1 1 0px; 
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 6px 12px; 
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.2s ease;
    font-family: inherit;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: flex-start; 
}

.base-tab-button:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.base-tab-button.active {
    background: var(--highlight-primary);
    color: #fff;
}

.base-tab-content {
    display: none;
}

.base-tab-content.active {
    display: flex;
}


/* --- Settings Containers --- */
:is(#game-specific-settings-area, #lobby-settings-area) {
    background: var(--bg-secondary); 
    border-radius: 0 0 8px 8px; 
    padding: 20px;
    border: 1px solid var(--border-color); 
    min-height: 200px; 
    height: 100%;
    flex-direction: column;
    min-width: 0;
    box-sizing: border-box;
}

:is(#game-specific-settings-area, #lobby-settings-area) .settings-group { 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
    margin-bottom: 15px; 
}

:is(#game-specific-settings-area, #lobby-settings-area) label { 
    font-weight: 500; 
    color: var(--text-secondary); 
    font-size: 1rem; 
    cursor: pointer;
}

#game-specific-settings-area.non-host-view .base-slider { 
    display: none; 
}

/* Strict Row Layout for Toggles & Sliders */
.setting-row { 
    display: flex; 
    align-items: center; 
    gap: 15px; 
    flex-wrap: nowrap !important; 
    max-width: 100%; 
    min-width: 0; 
}

.setting-row label {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

.notification-prompt-field {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 16px;
}

.notification-prompt-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.notification-password-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    background: transparent;
    cursor: pointer;
}

.notification-password-toggle svg { width: 22px; height: 22px; }
.notification-password-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.notification-prompt-field[hidden],
.notification-prompt-input[hidden],
.notification-password-toggle[hidden] { display: none; }

.setting-row input[type="range"],
.setting-row .base-slider {
    flex: 2 1 100px;
    min-width: 50px;
    margin: 0;
}

.setting-row input[type="number"],
.setting-row .base-input {
    width: 70px !important;
    flex: 0 0 70px;
    text-align: center;
    padding: 8px 4px;
}

.setting-row input[type="checkbox"],
.setting-row .base-checkbox {
    flex: 0 0 20px; 
    margin: 0;
}

#game-specific-settings-area.non-host-view .setting-row { 
    justify-content: flex-start; 
}


/* ==========================================================================
   7. ACTIVE GAME VIEWS
   ========================================================================== */
#active-game-content {
    position: relative; 
    flex-grow: 1; 
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    display: flex; 
    flex-direction: column; 
    gap: 15px;
}

.game-view-panel {
    position: relative; 
    flex-grow: 1; 
    padding: 0; 
    display: flex; 
    flex-direction: column;
    min-height: 0; 
    overflow-y: auto;
    overflow-x: hidden;
    gap: 15px;
}

.game-view-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    width: 100%; 
    flex-shrink: 0; 
    background-color: var(--bg-secondary);
    padding: 15px 25px; 
    border-radius: 10px; 
    gap: 20px;
}

.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;
}

.game-view-controls {
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center;
    gap: 15px; 
    width: 100%; 
    margin-top: auto; 
    flex-shrink: 0;
}

/* Countdown */
#countdown-area { 
    display: flex; 
    flex-direction: column; 
    justify-content: center; 
    align-items: center; 
    text-align: center;
}

#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);
}

/* Timers */
.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;
}


/* --- Inter-Round Leaderboard --- */
#inter-round-leaderboard-view {
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    text-align: center; 
    gap: 20px;
}

.leaderboard-container {
    display: flex; 
    flex-direction: column; 
    width: 100%; 
    max-width: 600px;
    position: relative; 
    min-height: 300px;
}

.leaderboard-row {
    display: flex; 
    align-items: center; 
    gap: 15px; 
    background: var(--bg-secondary);
    padding: 12px 20px; 
    border-radius: 10px; 
    border: 1px solid var(--border-color);
    position: absolute; 
    width: 100%; 
    height: 64px; 
    left: 0;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.5s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    opacity: 0;
}

.leaderboard-rank { 
    font-size: 1.4em; 
    font-weight: bold; 
    color: var(--text-secondary); 
    width: 40px; 
    text-align: left; 
    transition: color 0.3s; 
}

.leaderboard-row.rank-1 .leaderboard-rank { color: #FFD700; }
.leaderboard-row.rank-2 .leaderboard-rank { color: #C0C0C0; }
.leaderboard-row.rank-3 .leaderboard-rank { color: #CD7F32; }

.leaderboard-icon { 
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    object-fit: cover; 
    border: 2px solid var(--border-color); 
}

.leaderboard-name { 
    flex-grow: 1; 
    text-align: left; 
    font-size: 1.2em; 
    font-weight: 500; 
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* For narrower mobile devices, scale down leaderboard content */
@media (max-width: 480px) {
    .leaderboard-row {
        padding: 10px 12px;
        gap: 8px;
    }
    .leaderboard-rank {
        font-size: 1.1em;
        width: 30px;
    }
    .leaderboard-icon {
        width: 32px;
        height: 32px;
    }
    .leaderboard-name {
        font-size: 1.0em;
    }
    .leaderboard-score-container {
        min-width: auto;
    }
    .leaderboard-score {
        font-size: 1.1em;
        min-width: 30px;
    }
    .leaderboard-indicator-wrapper {
        gap: 4px;
        margin-right: 6px;
    }
    .leaderboard-indicator-wrapper .indicator-item {
        font-size: 1.0em;
    }
    .leaderboard-indicator-wrapper .indicator-arrow {
        font-size: 1.0em;
    }
    .leaderboard-indicator-wrapper .indicator-points {
        font-size: 1.0em;
    }
}

.leaderboard-score-container { 
    position: relative; 
    display: flex; 
    align-items: center; 
    justify-content: flex-end; 
    min-width: auto; 
    flex-shrink: 0;
}

.leaderboard-score { 
    font-size: 1.4em; 
    font-weight: bold; 
    color: var(--highlight-secondary); 
    min-width: 45px; 
    text-align: right; 
}

.leaderboard-indicator-wrapper {
    position: relative;
    height: 24px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.leaderboard-indicator-wrapper .indicator-item {
    position: relative;
    white-space: nowrap;
    font-weight: bold;
    font-size: 1.3em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.leaderboard-indicator-wrapper .indicator-arrow {
    order: 1;
    font-size: 1.2em;
}

.leaderboard-indicator-wrapper .indicator-points {
    order: 2;
    font-size: 1.3em;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.leaderboard-indicator-wrapper .indicator-points.visible {
    opacity: 1;
    transform: translateY(0);
}

.indicator-points.positive { color: var(--success-color); }
.indicator-points.negative { color: var(--error-color); }

.leaderboard-indicator-wrapper .rank-change-indicator {
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: auto;
    height: auto;
    display: inline-flex;
}

.leaderboard-indicator-wrapper .rank-change-indicator.visible {
    opacity: 1;
    transform: scale(1);
}

.leaderboard-row.current-player {
    background: color-mix(in srgb, rgb(var(--highlight-primary-rgb)) 15%, var(--bg-secondary));
    border: 1px solid var(--highlight-primary);
    animation: colorPulse 2s ease-in-out infinite alternate;
    z-index: 100 !important;
}

.rank-change-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 1.2em;
    font-weight: bold;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rank-change-indicator.visible {
    opacity: 1;
    transform: scale(1);
}

.rank-change-indicator.up { color: var(--success-color); }
.rank-change-indicator.down { color: var(--error-color); }


/* --- Podium Showcase --- */
#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; 
    gap: 10px; 
    flex-direction: row; 
    height: 330px; 
}

.podium-position { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    width: 160px; 
}

.podium-player-info { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 8px; 
    margin-bottom: -2px; 
    position: relative; 
    z-index: 2; 
}

.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)));
    border: 2px solid var(--highlight-primary); 
    border-bottom: none; 
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
    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)));
    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; 
    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; 
}

#podium-others-list {
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    background-color: var(--bg-tertiary);
    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; 
}


/* ==========================================================================
   8. OVERLAYS, STATIC PAGES & BLOGS (Decoupled to blogs.css)
   ========================================================================== */


/* ==========================================================================
   9. NOTIFICATIONS & CONTEXT MENUS
   ========================================================================== */
/* --- Player Interaction Context Menu --- */
.context-menu {
    position: fixed;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    z-index: 4000;
    min-width: 160px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.context-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-weight: bold;
    font-size: 0.9em;
    color: var(--highlight-secondary);
}

.context-menu-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.4em;
    padding: 0 4px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.context-menu-close:hover {
    color: var(--text-primary);
}

.context-menu-body {
    padding: 8px;
}

#player-interaction-menu .base-button {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.85rem;
    box-shadow: none;
    background: color-mix(in srgb, var(--bg-secondary) 85%, white);
}

#player-interaction-menu .base-button:hover {
    background: color-mix(in srgb, var(--bg-secondary) 70%, white);
    filter: brightness(1);
}


/* --- Notifications --- */
#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-close-btn.large-close { 
    top: 10px; right: 10px; width: 32px; height: 32px; font-size: 2.2em; z-index: 10; 
}

.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; 
}

#global-shatter-overlay-canvas { 
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 3001; display: none; 
}


/* --- Game Content Footer --- */
#active-game-content-footer {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; margin-top: auto; gap: 10px; position: relative;
}

#central-waiting-message { 
    max-width: 800px; width: auto; margin-left: auto; margin-right: auto; 
}

.status-message { 
    color: var(--text-secondary); font-style: italic; 
}

#game-round-display {
    white-space: nowrap; margin-left: auto; height: fit-content; width: fit-content;
    background-color: var(--bg-primary); color: var(--text-primary); padding: 6px 12px;
    border-radius: 20px; border: 2px solid var(--highlight-secondary);
    font-size: 0.9em; font-weight: 600; z-index: 100; display: inline-flex; align-items: center; gap: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#current-round-number { 
    color: var(--highlight-secondary); font-weight: bold; 
}


/* --- Game Prompt --- */
#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; width: 44px; height: 44px;
    flex-shrink: 0; opacity: 0; pointer-events: none; transition: opacity 0.4s ease;
}

#persistent-prompt-display.visible { 
    opacity: 1; pointer-events: auto; 
}

#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; 
}

#persistent-prompt-text {
    left: 0; position: absolute; bottom: calc(100% + 10px); 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;
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out; z-index: 50;
}

#persistent-prompt-display:hover #persistent-prompt-text { 
    opacity: 1; transform: translateY(0); pointer-events: auto; 
}


/* --- Unified Popup Overlay --- */
.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; 
}


/* --- Volume Control --- */
#volume-control-container { 
    position: relative; display: flex; align-items: center; 
}

#volume-icon-button {
    background: color-mix(in srgb, var(--header-bg-start) 80%, white); 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); 
}

#volume-icon-button svg { 
    width: 20px; height: 20px; fill: #fff; transition: transform 0.2s ease; 
}

#volume-slider-wrapper {
    position: absolute; z-index: 10; 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);
    opacity: 0; visibility: hidden; transform: translateX(-50%) translateY(-10px); pointer-events: none;
    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;
}

#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;
}

#volume-slider-wrapper::before { transform: translateX(-50%); border-bottom: 8px solid var(--border-color); }
#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; transform: translateX(-50%) translateY(0); pointer-events: auto; transition-delay: 0s;
}

#volume-slider { width: 100%; }


/* --- Expandable / Collapsible Sections --- */
.expandable-header { 
    cursor: pointer; user-select: none; padding: 5px 0; 
    transition: opacity 0.2s; display: flex; justify-content: space-between; align-items: center; 
}

.expandable-header:hover { 
    opacity: 0.8; 
}

.expandable-arrow { 
    display: inline-flex; align-items: center; justify-content: center; 
    transition: transform 0.3s ease; margin-left: 10px; color: var(--text-secondary);  transform: rotate(180deg);
}

.expandable-arrow.rotated { 
    transform: rotate(0deg); 
}

.expandable-body { 
    display: none; overflow: hidden; animation: popInFromTop 0.2s ease-out; 
}

.expandable-body.expanded { 
    display: block; 
}

.patch-section-title { margin-top: 12px; margin-bottom: 4px; color: white; }
.patch-note-item { padding-left: 15px; margin-bottom: 4px; color: var(--text-secondary); line-height: 1.4; }

#landing-start-container {
    display: flex; justify-content: center; width: 100%; margin-top: 40px;
    padding-top: 30px; padding-bottom: 20px; border-top: 2px solid var(--muted-line);
}

.side-tab-section .base-button.side-tab-button, .side-tab-button {
    width: 100%; display: block; margin-bottom: 10px; text-align: left;
    padding: 12px 18px; font-size: 1rem;
    font-family: var(--font-family); line-height: 1.5;
    box-sizing: border-box; text-decoration: none; cursor: pointer; margin-top: 10px;
}


/* ==========================================================================
   10. COOKIE CONSENT BANNER & SPECTATOR MODE
   ========================================================================== */
#cookie-consent-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 700px;
    background: var(--bg-tertiary);
    border: 2px solid var(--highlight-primary);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    z-index: 9999;
    padding: 25px;
    color: var(--text-primary);
    transition: opacity 0.5s ease;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cookie-consent-content h3 {
    margin: 0 0 10px 0;
    color: var(--highlight-secondary);
    font-size: 1.3em;
}

.cookie-consent-content p {
    font-size: 0.95em;
    margin: 0 0 20px 0;
    line-height: 1.5;
    color: var(--text-secondary);
}

.cookie-consent-content strong {
    color: var(--text-primary);
}

.cookie-consent-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.cookie-consent-buttons .base-button {
    padding: 10px 25px;
    font-size: 1em;
    min-width: 120px;
}

#cookie-reject-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: none;
    background-image: none;
}

#cookie-reject-btn:hover {
    background: var(--bg-primary);
    border-color: var(--text-secondary);
    transform: translateY(-2px);
}

body.is-spectator #main-game-button {
    display: none !important;
}


/* ==========================================================================
   11. MEDIA QUERIES
   ========================================================================== */

/* 1. Common Responsive Enhancements (All screens thinner than 1366px) */
@media (max-width: 1366px) {
    .static-page-panel .back-button, 
    .standalone-static-panel .back-link,
    .static-content-panel .back-link {
        position: relative; top: auto; left: auto; align-self: flex-start;
        margin-bottom: 15px; padding: 5px 0;
    }
    .static-content-panel h1, .static-page-panel h1, .standalone-static-panel h1 { margin-top: 0; font-size: 1.8em; }
    .static-page-panel, .standalone-static-panel {
        background-attachment: scroll !important; transform: translateZ(0); will-change: scroll-position; -webkit-overflow-scrolling: touch;
    }
    .game-mode-description-box { flex-direction: column; }
}

/* 2. Tablet & Small Laptops (Side-by-side but narrower) */
@media (max-width: 1366px) and (min-width: 769px) {
    :root {
        --sidebar-width: 280px; 
    }

    .panel-header { padding: 15px 20px; }
    #header-logo-img { width: 180px; top: -40px; }
    .panel-header nav { gap: 12px; }
    .panel-header nav .base-button.header-nav-button { padding: 6px 10px; font-size: 0.85rem; }

    .lobby-content { 
        grid-template-columns: var(--sidebar-min-width) 1fr;
        padding: 10px; gap: 10px; align-items: start; 
    } 

    .controls {
        grid-column: 2;
        width: 100%;
    }

    .circular-toggle-btn {
        display: flex;
    }

    .player-section {
        position: relative;
        z-index: 50;
        width: var(--sidebar-width);
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
        box-shadow: 6px 0 20px rgba(0,0,0,0.4);
    }

    .player-section.minimized {
        width: var(--sidebar-min-width);
        box-shadow: none;
    }

    .player-section.minimized .player-header-title { display: none; }
    .player-section.minimized .player-section-header { justify-content: center; }
    .player-section.minimized .circular-toggle-btn { margin-left: 0; }
    .player-section.minimized .circular-toggle-btn svg { transform: rotate(180deg); }
    .player-section.minimized .player-details-center,
    .player-section.minimized .player-score-container,
    .player-section.minimized #player-section-footer { display: none !important; }
    
    .player-section.minimized .player { padding: 8px 0; justify-content: center; background-color: transparent; box-shadow: none; }
    .player-section.minimized .player:hover { transform: none; background-color: rgba(255,255,255,0.05); }
    .player-section.minimized .player-icon-img { margin: 0; }
    .player-section.minimized .player-list { background-image: none; mask-image: none; }

    .pre-lobby-grid { grid-template-columns: 1fr 280px; }
    #tips-panel { max-width: 100%; width: 100%; }

    #podium-container { flex-direction: column; align-items: center; gap: 20px; justify-content: center; margin-top: 20px; }
    #podium-main { height: 290px; gap: 5px; min-width: 0; max-width: 100%; }
    .podium-position { width: 80px; }
    .podium-player-icon { width: 40px; height: 40px; }
    .podium-player-score { font-size: 1.5em; }

    #podium-others-list-container { width: 100%; transform: none; opacity: 1; animation: none; margin-top: 20px; }
    #podium-others-list { max-height: 200px; overflow-y: auto; }

    .game-mode-screenshot { width: 100%; max-width: 400px; height: auto; }
}

/* 3. Phones (Stacked Layout) */
@media (max-width: 768px) {
    .game-mode-screenshot { width: 100%; max-width: 100%; height: auto; }

    .lobby-content { display: flex !important; flex-direction: column !important; }
    .controls { order: 1; width: 100%; flex: 1 1 auto; }
    
    .player-section { 
        position: relative;
        width: 100%;
        height: auto; 
        max-height: 40vh; 
        order: 2; 
        box-shadow: none;
        z-index: 1;
        left: 0; top: 0;
        flex: 0 0 auto;
    }
    
    .circular-toggle-btn { display: none !important; }
    .pre-lobby-grid { grid-template-columns: 1fr; min-width: 0; width: 100%; }

    body { padding: 0; min-height: 100vh; min-height: 100lvh; } 
    body.ads-hidden { padding: 0; }

    #generic-notification-popup { top: 20px; bottom: auto; transform: translateX(-50%) translateY(-150%); }
    #generic-notification-popup.show { transform: translateX(-50%) translateY(0); }
    #persistent-prompt-text { font-size: 0.75em; width: 500%; }
    
    .lobby-footer { 
        background: var(--bg-primary); 
        border-top: 1px solid rgba(255, 255, 255, 0.1); 
        padding: 12px 0; 
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        margin-top: auto; 
    }
    .panel-wrapper { 
        background: transparent; 
        box-shadow: none; 
        border-radius: 0; 
        padding-top: 60px; 
        min-height: 100vh; 
        min-height: 100lvh; 
        display: flex;
        flex-direction: column;
    }
    
    #app-container.login-view-active .lobby-content {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: 10px; 
        padding: 10px; 
    }
    
    #app-container.login-view-active .controls {
        flex: 1 1 auto; 
        flex-direction: column; 
        justify-content: flex-start;
        align-items: center; 
        gap: 10px; 
    }

    #login-area {
        flex: 0 0 auto; 
        width: 100%;
    }
    
    .login-buttons-container {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    #login-profile-setup { flex-wrap: wrap; }
    #tips-panel { width: 100%; max-width: 100%; flex: 1 1 auto; }
    #tips-container { height: auto; min-height: 280px; flex-grow: 1; }

    .panel-header {
        position: fixed; width: 100%; left: 0; top: 0; border-radius: 0; padding: 0 10px;
        flex-direction: row; justify-content: space-between; align-items: center; height: 60px; z-index: 201;
    }
    #header-logo-img {
        position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: auto;
        max-height: 44px; margin-bottom: 0; margin-left: 0;
    }
    .panel-header nav { display: none; }

    #side-tab-toggle-button { display: inline-flex !important; background: transparent; box-shadow: none; padding: 5px; color: var(--text-primary); font-size: 1.5em; order: -1; }
    #side-tab-toggle-button:hover { background: rgba(255, 255, 255, 0.1); }

    #active-game-content, .game-view-panel { overflow: visible !important; }
    .game-view-header { position: relative; flex-direction: column; align-items: center; overflow: visible !important; }
    .game-view-caption { padding-top: 10px; width: 100%; text-align: justify; }
    .game-view-timer-wrapper { position: absolute; top: 0px; right: 0px; z-index: 10; margin: -10px; }

    .timer-background, .timer-progress { stroke-width: 8; }
    .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; }

    .panel { padding: 15px; max-width: 100%; }
    .game-view-panel { padding-bottom: 60px; }
    #main-controls-area { overflow-x: hidden;}
    .waiting-button { font-size: 0.75em; }
    .joker-card { width: 60px; height: 80px; }
    .joker-icon { font-size: 1.8em; }

    .multi-select-options { top: 100%; bottom: auto; margin-top: 5px; margin-bottom: 0; max-height: 200px; z-index: 1000; }
    .multi-select-options.show { animation: popInFromTop 0.2s ease-out; }
    :is(#game-specific-settings-area, #lobby-settings-area) { overflow: visible !important; }

    .blog-entry-content {
        flex-direction: column;
        gap: 15px;
    }
    .blog-list-image {
        width: 100%;
        max-width: 100%; 
        height: auto;
        order: 1; 
    }
    .blog-body {
        order: 2; 
    }
    #home-blog-preview-panel {
        max-width: 100%;
    }

    .ad-banner-mobile { 
        display: block; 
    }
}

/* 3. Desktop & Tablet Shared Enhancements */
@media (min-width: 769px) {
    #app-container.login-view-active .lobby-content {
        display: flex; 
        flex-direction: column; 
        justify-content: flex-start;
        min-height: 100%;
    }
    
    #app-container.login-view-active .controls {
        display: flex; 
        flex-direction: row; 
        justify-content: center; 
        align-items: flex-start; 
        gap: 20px; 
        flex-wrap: wrap;
        padding-top: max(20px, calc(12vh)); 
        padding-bottom: 40px;
    }
    
    #app-container.login-view-active #tips-panel { align-self: stretch; }
    
    body:not(.standalone-page) #app-container:not(.login-view-active) {
        height: calc(100vh - 2rem);
        height: calc(100lvh - 2rem);
        min-height: 0;
    }

    body:not(.standalone-page) #app-container:not(.login-view-active) .lobby-content { 
        height: 100%;
        flex: 1 1 0;
        min-height: 0;
    }
    
    body:not(.standalone-page) #app-container:not(.login-view-active) .controls { 
        height: 100%;
        flex: 1 1 0;
        min-height: 0;
    }

    body:not(.standalone-page) #app-container:not(.login-view-active) .controls > .panel {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
    }

    body:not(.standalone-page) #app-container:not(.login-view-active) #active-game-content {
        flex: 1 1 0;
        min-height: 0;
    }

    body:not(.standalone-page) #app-container:not(.login-view-active) .game-view-panel {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
    }
}


/* --- Side Tab Menu (Mobile) & Volume Panel --- */
.side-tab-menu {
    position: fixed; top: 0; left: -300px; width: 280px; height: 100vh; height: 100lvh;
    background: var(--bg-secondary); box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
    z-index: 1000; 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; }
.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); 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); }
#volume-icon-button-mobile svg { width: 20px; height: 20px; fill: #fff; }
#volume-slider-mobile { width: 100%; flex-grow: 1; }
#language-selector-container-mobile .base-dropdown { width: 100%; }


/* ==========================================================================
   12. KEYFRAMES & ANIMATIONS (Decoupled to animations.css)
   ========================================================================== */
/* A dismissible scaling notice; never blocks the game behind it. */
#display-scale-warning { position: fixed; bottom: 12px; left: 12px; right: 12px; margin: auto; max-width: 760px; z-index: 10001; padding: 12px 16px; border: 1px solid #e8bf62; border-radius: 10px; background: #30291c; color: #fff1d0; display: flex; align-items: center; gap: 16px; font: 14px/1.4 system-ui, sans-serif; }
#display-scale-warning[hidden] { display: none; }
#display-scale-warning button { flex-shrink: 0; cursor: pointer; }
