/* Fix VS player box sizing inside arena-flex-layout */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&display=swap');

/* site toast styles moved to css/toast.css */

/* Muted, less colorful style for the Find Random Opponent button */
#findRandomOpponentBtn {
    display: block;
    margin: 12px auto;
    padding: 10px 18px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    color: var(--text);
    font-weight: 700;
    border: 1px solid rgba(45, 252, 86, 0.4);
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
    will-change: transform, box-shadow;
    /* animation: subtle-pulse 2800ms ease-in-out infinite; */
    position: relative;
    overflow: hidden;
    --gradient-overlay-opacity: 0.08;
    text-align: center;
}

#findRandomOpponentBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.14);
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.015));
        animation-play-state: paused;
}

#findRandomOpponentBtn:active { transform: translateY(-1px) scale(0.997); animation-play-state: paused; }
#findRandomOpponentBtn:focus { outline: 2px solid rgba(124,92,255,0.06); outline-offset: 2px; animation-play-state: paused; }

/* Very light, moving gradient overlay (subtle) */
#findRandomOpponentBtn::before {
        content: "";
        position: absolute;
        top: -30%;
        left: -50%;
        width: 200%;
        height: 160%;
        background: linear-gradient(120deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02) 50%, rgba(255,255,255,0.06));
        opacity: var(--gradient-overlay-opacity);
        pointer-events: none;
        filter: blur(10px);
        transform: translateX(-30%);
        transition: opacity 180ms ease, transform 300ms ease;
        /* animation: gradient-slide 8s linear infinite; */
}

#findRandomOpponentBtn:hover::before,
#findRandomOpponentBtn:focus::before,
#findRandomOpponentBtn:active::before {
        animation-play-state: paused;
        opacity: calc(var(--gradient-overlay-opacity) + 0.02);
}

@keyframes gradient-slide {
    0% { transform: translateX(-30%); }
    50% { transform: translateX(30%); }
 100% { transform: translateX(-30%); }
}

@media (prefers-reduced-motion: reduce) {
    #findRandomOpponentBtn::before,
    #findRandomOpponentBtn::after { animation: none !important; display: none; }
}

/* Subtle passing glare (sheen) similar to bracket .share-bracket-btn */
#findRandomOpponentBtn::after {
    content: '';
    position: absolute;
    top: -30%;
    left: 0;
    width: 60%;
    height: 160%;
    background: linear-gradient(120deg, rgba(255,255,255,0.0) 0%, rgba(255,255,255,0.28) 42%, rgba(255,255,255,0.14) 58%, rgba(255,255,255,0.0) 100%);
    transform: translateX(-140%) skewX(-18deg);
    filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
    animation: glareMoveFind 20s ease-in-out infinite;
    transition: opacity 180ms ease, transform 300ms ease;
}

#findRandomOpponentBtn:hover::after,
#findRandomOpponentBtn:focus::after,
#findRandomOpponentBtn:active::after {
    animation-play-state: paused;
    opacity: 0.9;
}

@keyframes glareMoveFind {
    0% { transform: translateX(-140%) skewX(-18deg); opacity: 0; }
    5% { opacity: 0.9; }
    10% { transform: translateX(120%) skewX(-18deg); opacity: 0.9; }
    14% { opacity: 0; }
    100% { transform: translateX(-140%) skewX(-18deg); opacity: 0; }
}

@keyframes subtle-pulse {
    0% {
        transform: translateY(0) scale(1);
        box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    }
    50% {
        transform: translateY(-1px) scale(1.006);
        box-shadow: 0 10px 26px rgba(0,0,0,0.14);
    }
    100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    }
}

@media (prefers-reduced-motion: reduce) {
    #findRandomOpponentBtn { animation: none !important; transition: none !important; }
}

.public-announcement {
    margin: 10px 0 16px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(32, 58, 47, 0.2);
    background: linear-gradient(135deg, rgba(230, 246, 238, 0.95), rgba(243, 249, 246, 0.92));
    color: #1b3a2d;
    font-size: 0.95rem;
    font-weight: 600;
}

.public-announcement.is-warning {
    border-color: rgba(140, 90, 0, 0.3);
    background: linear-gradient(135deg, rgba(255, 245, 219, 0.98), rgba(255, 250, 238, 0.95));
    color: #6b4b00;
}

.public-announcement.is-danger {
    border-color: rgba(153, 32, 32, 0.28);
    background: linear-gradient(135deg, rgba(255, 235, 235, 0.98), rgba(255, 246, 246, 0.95));
    color: #7f1d1d;
}

.public-announcement.is-success {
    border-color: rgba(22, 101, 52, 0.28);
    background: linear-gradient(135deg, rgba(220, 252, 231, 0.98), rgba(240, 253, 244, 0.95));
    color: #14532d;
}

/* Full-width, centered top banner used for admin-disabled feature notices */
.public-announcement.feature-disabled-banner {
    /* default: fixed floating banner used on some contexts */
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: min(980px, calc(100% - 40px));
    z-index: 9999;
    border-radius: 8px;
    text-align: center;
    padding: 12px 16px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}

.public-announcement.feature-disabled-banner.is-danger {
    background: linear-gradient(135deg, #831313, #b22222);
    border-color: rgba(120,16,16,0.45);
    color: #fff;
    font-weight: 700;
}

/* Slightly smaller on mobile to avoid covering content */
@media (max-width: 520px) {
    .public-announcement.feature-disabled-banner {
        top: 8px;
        padding: 10px 12px;
        width: calc(100% - 24px);
        border-radius: 6px;
        font-size: 0.95rem;
    }
}

/* Push-mode banner: occupies normal flow and pushes content down.
   We insert this before the main `.container` so it takes space at top. */
.public-announcement.feature-disabled-banner.push {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: 100%;
    max-width: 1120px; /* match common container width */
    margin: 0 auto 12px;
    border-radius: 8px;
    box-shadow: none;
}

.public-announcement.feature-disabled-banner.push .banner-close {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border: 0;
    background: transparent;
    color: rgba(255,255,255,0.9);
    font-weight: 700;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
}

.public-announcement.feature-disabled-banner.push .banner-close:hover {
    background: rgba(255,255,255,0.04);
}

/* Admin alert banner (visible to admins only) */
.admin-alert-banner {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    /* keep responsive width but cap to a smaller max for readability */
    width: calc(100% - 70px);
    max-width: 560px;
    z-index: 12000;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-alert-banner .admin-alert-title {
    font-weight: 700;
    margin-right: 8px;
}
.admin-alert-banner .admin-alert-msg {
    flex: 1 1 auto;
    font-size: 0.96rem;
}
.admin-alert-banner .admin-alert-actions {
    margin-left: 8px;
    display: flex;
    gap: 8px;
}
.admin-alert-banner .banner-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
}
.admin-alert-banner.is-warning { background: linear-gradient(135deg,#fff7ed,#fffaf0); color: #7c4a00; border: 1px solid rgba(124,74,0,0.12); }
.admin-alert-banner.is-danger { background: linear-gradient(135deg,#fff0f0,#fff5f5); color: #7f1d1d; border: 1px solid rgba(127,29,29,0.12); }
.admin-alert-banner.is-info { background: linear-gradient(135deg,#eef2ff,#f8fbff); color: #153e75; border: 1px solid rgba(21,62,117,0.08); }

@media (max-width: 520px) {
    .admin-alert-banner { top: 8px; padding: 10px 12px; width: calc(100% - 24px); border-radius: 6px; font-size: 0.95rem; }
}

/* transition helpers for sliding the banner up when closed */
.feature-disabled-banner.slide-up {
    transition: max-height 260ms ease, padding 200ms ease, margin 200ms ease, opacity 200ms ease;
    overflow: hidden;
}

.create-room-disabled {
    opacity: 0.68;
}

.create-room-disabled .room-form input,
.create-room-disabled .room-form button {
    /* Allow pointer events so disabled controls can show the not-allowed cursor.
       Actual interactivity is controlled via the `disabled` attribute set by JS. */
    pointer-events: auto;
}

.create-room-disabled-hint {
    margin-top: 10px;
    color: #7f1d1d;
    font-size: 0.9rem;
    font-weight: 600;
}

.arena-flex-layout .vs-players-redesign {
    width: 100%;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}
.arena-flex-layout .vs-player-box {
    min-width: 0;
    flex: 1 1 0;
    width: auto;
    padding: 12px 10px;
    box-sizing: border-box;
}
/* --- Responsive Arena Layout: Spectator | VS | Problem --- */
.arena-flex-layout {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: stretch;
        gap: 24px;
}

/* Allow the arena layout to wrap when viewport is constrained so
   the VS block doesn't overflow neighboring sections. */
.arena-flex-layout {
    flex-wrap: wrap;
}
.arena-flex-layout > .spectator-panel {
        flex: 1 1 0;
        max-width: 260px;
        min-width: 180px;
}
.arena-flex-layout > .vs-players-redesign {
        flex: 2 1 0;
        min-width: 260px;
        max-width: 480px;
        align-self: center;
}

/* Prevent the standalone VS component's generous width rules from
   pushing the adjacent problem card when the VS block is used inside
   the arena layout. This enforces a strict max-width while allowing
   the internal VS styling to remain for other contexts. */
.arena-flex-layout > .vs-players-redesign {
    width: auto !important;
    max-width: 520px !important;
    box-sizing: border-box;
}
.arena-flex-layout > .problem-card {
        flex: 1 1 0;
        max-width: 320px;
        min-width: 180px;
        align-self: flex-start;
}

/* Responsive layout adjustments:
   - Between 641px and 900px: show Spectator (left) and Problem (right) side-by-side,
     and move the VS block below spanning both columns.
   - At 640px and below: fall back to stacked column layout (problem, VS, spectator)
     to preserve readability on very small screens. */

@media (max-width: 989.98px) {
    /* For viewports under 990px: show the VS block on top spanning full width,
       and place Spectator (left) + Problem (right) side-by-side beneath it. */
    .arena-flex-layout {
        display: grid;
        grid-template-columns: minmax(160px, 1fr) minmax(220px, 1fr);
        /* make the second row (spectator + problem) share remaining height so
           both panels become equal-height when placed side-by-side */
        grid-template-rows: auto 1fr;
        gap: 18px;
        align-items: start;
    }
    .arena-flex-layout > .vs-players-redesign {
        grid-column: 1 / -1;
        grid-row: 1;
        width: 100%;
        max-width: 100%;
        align-self: stretch;
    }
    .arena-flex-layout > .spectator-panel {
        grid-column: 1;
        grid-row: 2;
        width: 100%;
        max-width: 100%;
        align-self: stretch;
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    .arena-flex-layout > .problem-card {
        grid-column: 2;
        grid-row: 2;
        width: 100%;
        max-width: 100%;
        align-self: stretch;
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    /* ensure inner scrolling lists don't force panel height growth */
    .arena-flex-layout > .spectator-panel .spectator-list,
    .arena-flex-layout > .problem-card .problems-list {
        overflow: auto;
    }
}

@media (max-width: 640px) {
    /* very small screens: stacked column (problem first, VS, then spectator)
       keeps components readable and allows inner shrink rules to apply */
    .arena-flex-layout {
        display: flex;
        flex-direction: column;
        gap: 14px;
        align-items: stretch;
    }
    .arena-flex-layout > .problem-card { order: 1; width: 100%; max-width: 100%; }
    .arena-flex-layout > .vs-players-redesign { order: 2; width: 100%; max-width: 100%; }
    .arena-flex-layout > .spectator-panel { order: 3; width: 100%; max-width: 100%; }
}

/* Intermediate responsiveness: prefer shrinking the VS container rather than stacking.
   The VS block will reduce its max-width progressively on narrower viewports. */
@media (max-width: 1200px) {
    .arena-flex-layout > .vs-players-redesign,
    .arena-flex-layout .vs-players-redesign {
        min-width: 0;
        max-width: 420px; /* cap width so it doesn't push the problem card */
        width: 100%;
        box-sizing: border-box;
    }
    .vs-players-redesign {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 20px;
        padding-left: 14px;
        padding-right: 14px;
        justify-content: center;
    }
    .vs-player-box {
        min-width: 0;
        flex: 1 1 200px;
        max-width: 240px;
        padding: 12px;
    }
    .vs-center-vs {
        margin: 0;
        align-self: center;
    }
}

@media (max-width: 1000px) {
    .arena-flex-layout > .vs-players-redesign,
    .arena-flex-layout .vs-players-redesign {
        max-width: 360px;
    }
    .vs-player-box {
        flex: 1 1 180px;
        max-width: 220px;
    }
    .vs-glow { font-size: 2rem; padding: 14px 22px; }
    .vs-player-avatar { width: 56px; height: 56px; font-size: 1.9rem; }
}

/* Small screens: stack vertically only when space is very small */
@media (max-width: 700px) {
    .vs-players-redesign {
        flex-direction: column-reverse;
        gap: 18px;
        padding: 14px 10px;
        align-items: stretch;
        max-width: 100%;
        width: 100%;
    }
    .vs-player-box { width: 100%; max-width: 100%; flex: 1 1 auto; padding: 12px; }
    .vs-center-vs { margin: 8px 0; }
    .vs-glow { padding: 12px 18px; font-size: 1.8rem; }
    .vs-player-avatar { width: 48px; height: 48px; font-size: 1.6rem; }
}

/* The VS block width now scales via the main rule using viewport width. */
/* Make both sections equal height in row layout */
@media (min-width: 901px) {
    .config-validation-row {
        display: flex;
        flex-direction: row;
        align-items: stretch;
    }
    .config-validation-row > section,
    .config-dashboard,
    .validation-section {
           flex: 1 1 0%;
           height: 110%;
    }
}
@media (max-width: 900px) {
    .config-validation-row {
        flex-direction: column !important;
        gap: 18px;
        align-items: stretch;
    }
    .config-validation-row > section,
    body.in-room .config-dashboard,
    body.in-room .validation-section {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: 0 !important;
        float: none !important;
        clear: both !important;
        position: static !important;
    }
    .start-battle-vs-redesign {
        margin-top: 18px;
        margin-bottom: 0;
    }
    .vs-players-redesign {
        flex-direction: column;
        gap: 18px;
        padding: 18px 10px 18px 10px;
        min-width: 0;
    }
    .vs-player-box {
        min-width: 0;
        width: 100%;
        padding: 10px 8px;
    }
    .vs-center-vs {
        min-width: 0;
        min-height: 0;
        margin: 10px 0;
    }
}
/* Start Battle VS Redesign */
.start-battle-vs-redesign {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 38px;
}
.vs-player-input {
    background: transparent;
    border: none;
    color: #f3f5f8;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    width: 180px;
    padding: 12px 10px;
    border-radius: 10px;
    box-shadow: none;
}
.vs-player-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 0 1 320px;
    max-width: 360px;
    background: #232b3b;
    border: 2.5px solid var(--player-border, #ffb84d);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 4px 24px 0 var(--player-border-glow, #181e2a55);
    position: relative;
    transition: transform 0.18s;
    cursor: pointer;
    box-sizing: border-box;
    min-width: 0;
}

/* Handle setup subtitle list (signup / reset instructions) */
#handleSetupSubtitle .handle-setup-list {
    display: inline-block;
    text-align: left;
    max-width: 520px;
    margin: 6px auto 0;
    padding: 0 0 0 18px;
    line-height: 1.25;
    font-size: 0.88rem;
    color: rgba(255,255,255,0.92);
    list-style: disc;
}
#handleSetupSubtitle .handle-setup-list li {
    margin: 6px 0;
}
#handleSetupSubtitle .handle-setup-list strong {
    font-weight: 700;
    color: #fff;
}

@media (max-width: 640px) {
    #handleSetupSubtitle .handle-setup-list {
        max-width: calc(100% - 40px);
        font-size: 0.84rem;
        padding-left: 14px;
    }
}

/* Modern redesign for signup/reset/login modal */
.password-content.handle-setup-content {
    width: min(520px, 100%);
    padding: 28px 28px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(8,12,18,0.98), rgba(6,9,14,0.94));
    border: 1px solid rgba(255,255,255,0.04);
    box-shadow: 0 18px 40px rgba(0,8,18,0.6);
    color: #e6f0fb;
}

#handleSetupTitle {
    font-size: 1.45rem;
    line-height: 1.12;
    margin: 0 0 6px 0;
    color: #ffffff;
    font-weight: 800;
}

/* Left-aligned, soothing subtitle */
#handleSetupSubtitle {
    color: rgba(177,196,212,0.95);
    font-size: 0.88rem;
    margin: 0 0 12px 0;
    text-align: left;
    line-height: 1.32;
    opacity: 0.98;
    background: rgba(255,255,255,0.01);
    padding: 10px 16px;
    border-radius: 8px;
    border-left: 4px solid rgba(96,165,250,0.14);
    box-shadow: none;
}

.password-content.handle-setup-content .password-input {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: #eaf6ff;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 0.97rem;
}

.password-content.handle-setup-content .password-input::placeholder {
    color: rgba(230,240,255,0.45);
}

.password-content.handle-setup-content .password-buttons {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.password-content.handle-setup-content .password-btn {
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
    border: none;
    cursor: pointer;
}

.password-content.handle-setup-content .password-btn.confirm-btn,
.password-content.handle-setup-content .password-btn.primary {
    background: linear-gradient(90deg,#7dd3fc,#60a5fa);
    color: #05202a;
    box-shadow: 0 8px 20px rgba(37,99,235,0.12), inset 0 -2px 0 rgba(0,0,0,0.08);
}

.password-content.handle-setup-content .password-btn.cancel-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    color: rgba(230,240,255,0.92);
}

.password-content.handle-setup-content .password-generator-btn,
.password-content.handle-setup-content .auth-mode-toggle-btn {
    background: transparent;
    border: none;
    color: #9fd3ff;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

/* Tighter layout on small screens */
@media (max-width: 520px) {
    .password-content.handle-setup-content { padding: 18px; }
    #handleSetupTitle { font-size: 1.25rem; }
    #handleSetupSubtitle { font-size: 0. nineem; }
}

/* Global safeguard: prevent long unbroken content from producing horizontal overflow */
html, body { -webkit-text-size-adjust: 100%; }
img, video, table, pre, code { max-width: 100%; height: auto; }
* { box-sizing: border-box; }
td, th, .panel { overflow-wrap: anywhere; word-break: break-word; }
/* keep the page from sliding horizontally due to occasional layout glitches */
body { overscroll-behavior-x: contain; }
.vs-player-box:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 8px 32px 0 var(--player-border-glow, #ffb84d44), 0 0 0 2px var(--player-border, #ffb84d);
}
.vs-player-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffb84d 60%, #ff7d1a 100%);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 2px 12px 0 var(--player-border-glow, #ffb84d55);
    border: 3px solid var(--player-border, #fff2);
}

/* Avatar image inside the avatar container should fill and preserve aspect ratio */
.vs-player-avatar img.vs-player-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.vs-center-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    min-height: 90px;
}
.vs-glow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ff7d1a;
    color: #fff;
    font-size: 2.5rem;
    font-weight: 900;
    border-radius: 16px;
    padding: 16px 36px;
    border: none;
    box-shadow: none;
    text-shadow: none;
    letter-spacing: 0.08em;
    transition: background 0.2s;
}

.vs-glow:hover {
    background: #ffb84d;
    color: #181e2a;
}
/* Redesigned VS Player Section */
.vs-players-redesign {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 48px;
    background: linear-gradient(135deg, #232b3b 60%, #181e2a 100%);
    border-radius: 32px;
    box-shadow: 0 8px 32px 0 #181e2a99, 0 0 0 2px #232b3b;
    padding: 40px 32px 32px 32px;
    margin-bottom: 40px;
    position: relative;
    min-height: 160px;
    flex-wrap: wrap; /* allow internal wrapping to avoid overflowing adjacent panels */
    overflow: visible;
    /* Keep the whole VS block proportional to viewport: shrink the container
       as the screen narrows without changing internal element sizes. */
    width: min(480px, 90vw);
}

/* Keep visual proportions identical while reducing overall block size
   on narrower viewports. `zoom` preserves internal layout/look while
   scaling the container. (Note: `zoom` is non-standard but works
   in Chromium-based browsers.) */
.vs-players-redesign {
    transform-origin: top center;
}

@media (max-width: 1200px) {
    .vs-players-redesign { zoom: 0.92; }
}
@media (max-width: 1000px) {
    .vs-players-redesign { zoom: 0.85; }
}
@media (max-width: 800px) {
    .vs-players-redesign { zoom: 0.78; }
}
@media (max-width: 600px) {
    .vs-players-redesign { zoom: 0.72; }
}

/* VS breakpoints: adjust sizing and layout across viewport widths */
@media (min-width: 1200px) {
    .vs-players-redesign { gap: 56px; }
    .vs-player-box { flex: 0 1 340px; max-width: 380px; padding: 28px; }
    .vs-glow { padding: 28px 40px; font-size: 3rem; }
    .vs-player-avatar { width: 72px; height: 72px; font-size: 2.6rem; }
    /* At wide widths, prefer a single-row layout */
    .vs-players-redesign { flex-wrap: nowrap; }
}

@media (min-width: 900px) and (max-width: 1199px) {
    .vs-players-redesign { gap: 36px; }
    .vs-player-box { flex: 1 1 280px; max-width: 320px; }
    .vs-glow { padding: 20px 30px; font-size: 2.2rem; }
    .vs-player-avatar { width: 60px; height: 60px; font-size: 2rem; }
}

/* Increase VS block width and prevent handle wrapping on moderately large viewports
   This keeps the handle text on a single line and gives the VS block more room
   when the viewport is wider than ~980px. */
@media (min-width: 981px) {
    .vs-players-redesign {
        width: min(760px, 78vw) !important;
        max-width: 760px !important;
        padding-left: 18px;
        padding-right: 18px;
    }
    .vs-player-box {
        flex: 0 1 360px !important;
        max-width: 380px !important;
        min-width: 220px;
    }
    /* Keep handle text on one line, ellipsize if too long */
    .vs-player-handle {
        display: inline-block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .vs-player-label, .vs-player-handle {
        word-break: normal;
    }
}

    /* Protective rules for mid-range viewports to prevent VS block from
       pushing the adjacent problem card. This lives late in the file and
       uses specific selectors + !important to avoid accidental overrides. */
    @media (min-width: 700px) and (max-width: 990px) {
        .arena-flex-layout > .vs-players-redesign {
            /* force the VS block to behave as a full-width row below the
               top columns without growing beyond available space */
            grid-column: 1 / -1 !important;
            width: 100% !important;
            max-width: 100% !important;
            box-sizing: border-box !important;
            flex: 0 1 100% !important;
            margin: 0 auto !important;
            /* neutralize zoom/transform scaling that could create overflow */
            zoom: 1 !important;
            transform: none !important;
            overflow: visible !important;
            padding-left: 12px !important;
            padding-right: 12px !important;
        }

        /* ensure the problem card keeps a usable width and is not pushed
           off-screen by overly large VS rules */
        .arena-flex-layout > .problem-card {
            min-width: 200px !important;
            max-width: 420px !important;
            flex: 1 1 320px !important;
            box-sizing: border-box !important;
        }

        /* also limit internal player boxes so they don't force the container
           wider than available space */
        .arena-flex-layout > .vs-players-redesign .vs-player-box {
            min-width: 0 !important;
            flex: 1 1 180px !important;
            max-width: 320px !important;
        }
    }

@media (max-width: 899px) {
    /* stack vertically with p2 on top, VS center in middle, p1 at bottom */
    .vs-players-redesign {
        flex-direction: column-reverse;
        gap: 18px;
        padding: 18px 12px;
        align-items: stretch;
    }
    .vs-player-box { width: 100%; max-width: 100%; flex: 1 1 auto; padding: 14px; }
    .vs-center-vs { margin: 8px 0; }
    .vs-glow { padding: 14px 22px; font-size: 1.9rem; }
    .vs-player-avatar { width: 48px; height: 48px; font-size: 1.6rem; }
}

/* Ensure VS elements can shrink and not force overflow into problem card */
.vs-player-box { flex-shrink: 1; min-width: 0; }
.vs-glow { max-width: 100%; box-sizing: border-box; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs-player-label {
    color: #bfc7d6;
    font-size: 1.1rem;
    margin-bottom: 6px;
    opacity: 0.7;
}

/* Make the entire VS player box clickable in the in-battle arena layout
   by adding an invisible full-area anchor overlay. This does not affect
   the start-battle / join-room VS block which lives outside
   `.arena-flex-layout`. */
.arena-flex-layout .vs-player-box {
    position: relative; /* allow absolute overlay to cover the box */
}
.arena-flex-layout .vs-player-box .vs-full-link {
    position: absolute;
    inset: 0;
    display: block;
    background: transparent;
    border-radius: inherit;
    text-decoration: none;
    color: inherit;
    z-index: 2;
    pointer-events: auto;
}
.arena-flex-layout .vs-player-box .vs-player-handle {
    position: relative;
    z-index: 3; /* keep text / handle visuals above the overlay */
}

/* Ensure config dashboard and validation section remain hidden unless in a room.
   This avoids responsive rules accidentally showing the ready-check outside a joined room. */
#configDashboard,
#validationSection {
    display: none;
}

body.in-room #configDashboard,
body.in-room #validationSection {
    display: block;
}

/* When a battle is active, always hide config/validation even if in-room */
body.in-room.in-battle #configDashboard,
body.in-room.in-battle #validationSection {
    display: none !important;
}
.vs-player-handle {
    color: #fff;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    margin-bottom: 4px;
    text-shadow: 0 2px 8px #181e2a99;
    text-decoration: none;
}
.vs-player-handle:hover {
    cursor: pointer;
    text-decoration: none;
}

.vs-player-handle:hover {
    cursor: pointer;
}
.player1-vs {
    border-color: var(--player-border, #f8c15f);
}
.player2-vs {
    border-color: var(--player-border, #f8c15f);
}
.vs-center-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    min-height: 110px;
    margin: 0 8px;
}
.vs-glow {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, #ffb84d 0%, #ff7d1a 70%, #232b3b 100%);
    color: #fff;
    font-size: 2.8rem;
    font-weight: 900;
    border-radius: 50%;
    padding: 24px 32px;
    box-shadow: 0 0 40px 10px #ffb84d99, 0 0 0 6px #ffb84d33;
    border: 3px solid #ffb84d;
    text-shadow: 0 0 18px #ffb84d, 0 2px 2px #ff7d1a;
    letter-spacing: 0.06em;
    transition: background 0.2s, color 0.2s;
    flex: 0 0 auto;
    box-sizing: border-box;
}
.vs-glow:hover {
    background: radial-gradient(circle, #ff7d1a 0%, #ffb84d 80%, #232b3b 100%);
    color: #232b3b;
}

/* Enforce a perfect circular VS center while preserving visual style.
   This override makes the element square via `aspect-ratio` and an explicit
   width; padding is removed so the circle shape is preserved. Font sizes
   are tuned at breakpoints below to keep the look consistent. */
.vs-glow {
    border-radius: 50% !important;
    aspect-ratio: 1 / 1 !important;
    /* smaller default circle */
    width: min(120px, 18vw) !important;
    height: auto !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

@media (min-width: 1200px) {
    .vs-glow { width: 120px !important; font-size: 2.4rem !important; }
}
@media (min-width: 900px) and (max-width: 1199px) {
    .vs-glow { width: 110px !important; font-size: 1.9rem !important; }
}
@media (max-width: 899px) and (min-width: 700px) {
    .vs-glow { width: 88px !important; font-size: 1.6rem !important; }
}
@media (max-width: 699px) {
    .vs-glow { width: 72px !important; font-size: 1.4rem !important; }
}

/* Config/Validation Row Layout */
.config-validation-row {
    display: flex;
    flex-direction: row;
    gap: 32px;
    margin-bottom: 24px;
    align-items: stretch;
    justify-content: center;
.config-dashboard,
.validation-section {
    min-height: 100%;
}
}
.config-validation-row > section {
    flex: 1 1 0%;
    min-width: 180px;
    padding: 10px 18px;
    border-radius: 14px;
    box-shadow: 0 0 12px 0 #181e2a;
    height: auto;
    /* removed accidental nested block */
}
/* Share Room Button - Green Background */
.share-room-btn {
    background: linear-gradient(180deg, #67d69a, #4dbd82) !important;
    color: #06120b !important;
    border-color: #5acb8a !important;
    /* even more compact */
    padding: 4px 8px !important;
    font-size: 0.82rem !important;
    border-radius: 6px !important;
    min-width: 44px !important;
    height: auto !important;
    line-height: 1 !important;
}
.active-blitz-empty-state {
    position: relative;
    overflow: hidden;
}
.active-blitz-empty-state .empty-bg-anim {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
    animation: emptyBgPulse 4s ease-in-out infinite alternate;
}
@keyframes emptyBgPulse {
    0% { opacity: 0.13; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0.22; transform: translate(-50%, -50%) scale(1.08); }
}
.active-blitz-empty-state > *:not(.empty-bg-anim) {
    position: relative;
    z-index: 1;
}
.active-blitz-empty-state .empty-quote {
    margin: 18px 0 8px 0;
    font-size: 1.05rem;
    color: #b3c7e6;
    font-style: italic;
    text-align: center;
    opacity: 0.92;
}
.active-blitz-empty-state .empty-quote span {
    display: block;
    font-size: 0.95rem;
    color: #7fa7e6;
    margin-top: 2px;
    font-style: normal;
}
.active-blitz-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    min-height: 220px;
    padding: 24px 12px 18px 12px;
    background: linear-gradient(180deg, #151d2b 80%, #121720 100%);
    border-radius: 18px;
    border: 1.5px dashed var(--border);
    box-shadow: 0 2px 16px 0 rgba(20,30,50,0.08);
    margin: 18px auto; /* occupy its own space in normal flow */
    max-width: 720px; /* allow wider layout before constraining */
    position: relative; /* keep inside flow and avoid overlapping other components */
    transform: none;
}
.active-blitz-empty-state .empty-illustration {
    margin-bottom: 18px;
    opacity: 0.92;
}
.active-blitz-empty-state .empty-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
    text-align: center;
}
.active-blitz-empty-state .empty-desc {
    color: var(--muted);
    font-size: 1.02rem;
    margin-bottom: 18px;
    text-align: center;
}
.active-blitz-empty-state .empty-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}
.active-blitz-empty-state .primary-btn,
.active-blitz-empty-state .results-btn {
    font-size: 1rem;
    padding: 8px 20px;
    border-radius: 999px;
    font-weight: 600;
    box-shadow: 0 2px 8px 0 rgba(110,168,254,0.08);
}

/* Apply modern modal-like button styles to result and primary buttons */
.primary-btn,
.results-btn {
    padding: 10px 16px;
    border-radius: 10px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    background: linear-gradient(90deg,#7dd3fc,#60a5fa);
    color: #05202a;
    box-shadow: 0 10px 24px rgba(37,99,235,0.10), inset 0 -2px 0 rgba(0,0,0,0.06);
    transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}
.primary-btn:hover,
.results-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(37,99,235,0.14), inset 0 -2px 0 rgba(0,0,0,0.06);
}
.primary-btn:active,
.results-btn:active {
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(37,99,235,0.08);
}

/* Secondary / outline variant (keep cancel buttons readable) */
.cancel-btn,
.results-btn.outline {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    color: rgba(230,240,255,0.92);
}
.active-blitz-empty-state .empty-tips {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.98rem;
    list-style: disc inside;
    text-align: left;
    padding-left: 0;
}
.active-blitz-empty-state .empty-tips li {
    margin-bottom: 4px;
}
.active-blitz-empty-state .empty-tips a {
    color: #9dc4ff;
    text-decoration: underline;
}
/* Responsive tweaks for small screens: make empty state flow with page
   and reduce sizes so it fits nicely on phones. */
@media (max-width: 600px) {
    .active-blitz-empty-state {
        position: static;
        top: auto;
        left: auto;
        transform: none;
        width: calc(100% - 24px);
        max-width: none;
        margin: 12px auto;
        padding: 16px 12px;
        border-radius: 12px;
        min-height: auto;
        box-shadow: 0 6px 18px rgba(0,0,0,0.28);
    }
    .active-blitz-empty-state .empty-bg-anim {
        opacity: 0.08;
        transform: scale(1);
        display: none; /* reduce visual clutter on small screens */
    }
    .active-blitz-empty-state .empty-illustration {
        max-width: 160px;
        width: 60%;
        margin-bottom: 12px;
    }
    .active-blitz-empty-state .empty-title {
        font-size: 1.05rem;
    }
    .active-blitz-empty-state .empty-desc {
        font-size: 0.98rem;
    }
    .active-blitz-empty-state .empty-actions {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
        width: 100%;
    }
    .active-blitz-empty-state .primary-btn,
    .active-blitz-empty-state .results-btn {
        width: 100%;
        padding: 10px 12px;
        font-size: 0.98rem;
    }
    .active-blitz-empty-state .empty-tips {
        font-size: 0.95rem;
        text-align: left;
        padding-left: 14px;
    }
}
@media (max-width: 1024px) {
    .active-blitz-empty-state {
        max-width: 520px;
        padding: 20px 14px;
    }
    .active-blitz-empty-state .empty-illustration {
        max-width: 200px;
        width: 50%;
    }
    .active-blitz-empty-state .empty-title {
        font-size: 1.15rem;
    }
    .active-blitz-empty-state .empty-actions {
        gap: 10px;
    }
}
@media (min-width: 800px) and (max-width: 1080px) {
    .active-blitz-empty-state {
        /* center via margin/width instead of absolute/transform */
        max-width: 560px;
        width: min(720px, 88%);
        padding: 22px 16px;
        margin: 18px auto;
        transform: none;
    }
    .active-blitz-empty-state .empty-illustration {
        max-width: 220px;
        width: 48%;
    }
    .active-blitz-empty-state .empty-title {
        font-size: 1.18rem;
    }
    .active-blitz-empty-state .empty-desc {
        font-size: 1rem;
    }
    .active-blitz-empty-state .empty-actions {
        gap: 12px;
    }
    .active-blitz-empty-state .primary-btn,
    .active-blitz-empty-state .results-btn {
        min-width: 150px;
    }
}
/* Tweak specifically around 960px viewports to ensure the empty-state is centered */
@media (min-width: 920px) and (max-width: 1000px) {
    .active-blitz-empty-state {
        max-width: 640px;
        width: 70%;
        margin-left: auto;
        margin-right: auto;
        padding: 22px 18px;
        box-shadow: 0 8px 30px rgba(0,0,0,0.35);
    }
    .active-blitz-empty-state .empty-illustration {
        max-width: 220px;
        width: 40%;
    }
    .blitz-list {
        /* ensure the grid doesn't push the empty-state off-center */
        grid-template-columns: 1fr;
        justify-items: center;
    }
}
@media (max-width: 800px) {
    .active-blitz-empty-state {
        position: static;
        transform: none;
        width: calc(100% - 32px);
        max-width: none;
        margin: 14px auto;
        padding: 18px 12px;
    }
    .active-blitz-empty-state .empty-illustration {
        width: 55%;
        max-width: 180px;
    }
    .active-blitz-empty-state .empty-title {
        font-size: 1.08rem;
    }
    .active-blitz-empty-state .empty-actions {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    .active-blitz-empty-state .primary-btn,
    .active-blitz-empty-state .results-btn {
        min-width: 140px;
        width: auto;
    }
}
@media (max-width: 420px) {
    .active-blitz-empty-state .empty-illustration {
        width: 70%;
        max-width: 140px;
    }
    .active-blitz-empty-state .empty-title {
        font-size: 1rem;
    }
    .active-blitz-empty-state .empty-desc {
        font-size: 0.95rem;
    }
    .active-blitz-empty-state .empty-actions {
        gap: 8px;
    }
    .active-blitz-empty-state .primary-btn,
    .active-blitz-empty-state .results-btn {
        padding: 9px 10px;
        font-size: 0.95rem;
    }
    .active-blitz-empty-state .empty-tips {
        font-size: 0.9rem;
        padding-left: 12px;
    }
}
.room-side-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
:root {
    --bg: #0b0d12;
    --panel: #121720;
    --panel-soft: #171d28;
    --border: #252d3b;
    --text: #f3f5f8;
    --muted: #97a3b6;
    --primary: #6ea8fe;
    --success: #5acb8a;
    --danger: #ff7d7d;
    --warning: #f8c15f;
    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

/* Permanently hide validation UI in room info bar and validation section
   to ensure the validation problem never appears to users. */
.room-info-bar .room-validation-mini,
.room-info-bar #roomValidationMini {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* When viewport is narrow and the user is not in a room, hide room-only UI.
   This prevents the VS block, problem list, and spectator panel from showing
   on small devices when not joined to a room. */
@media (max-width: 989.98px) {
    /* On narrow viewports, always hide room-only UI (spectator, VS, problems, config, validation, arena)
       regardless of room state. Restored automatically on wider viewports. */
    .spectator-panel,
    #problemsDisplaySection,
    #arenaPanel,
    .arena-flex-layout,
    .problem-card,
    #configDashboard,
    #validationSection {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
    /* If user is in-room or in-battle, ensure arena and problems remain visible */
    body.in-room #problemsDisplaySection,
    body.in-room #arenaPanel,
    body.in-room .problem-card,
    body.in-battle #arenaPanel,
    body.in-battle .problem-card {
        display: block !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

     /* Also restore config dashboard and validation UI when user is in-room
         so room creators immediately see the full room UI on small viewports. */
     body.in-room #configDashboard,
     body.in-room #validationSection {
        display: block !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    /* Prevent duplicate VS on narrow viewports during an active battle: hide
       the start-battle block (the arena VS is the primary in-battle UI). */
    body.in-battle #startBattleVSBlock,
    body.in-room.in-battle #startBattleVSBlock,
    body.in-battle .start-battle-vs-redesign,
    body.in-room.in-battle .start-battle-vs-redesign {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

/* Never show validation (ready-check) while a battle is active */
/* Never show validation (ready-check) or problem set while a battle is active */
body.in-battle #validationSection,
body.in-room.in-battle #validationSection,
body.in-battle #problemsDisplaySection,
body.in-room.in-battle #problemsDisplaySection {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* (start-battle VS block shown always) */

* {
    box-sizing: border-box;

/* Room handle chip for active room cards */
.room-handle-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px; /* keep sizing */
    border-radius: 16px; /* glass card radius */
    /* Darker, standard chip */
    background: linear-gradient(180deg, rgba(20,24,30,0.85), rgba(3, 40, 90, 0.85));
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6), inset 0 2px 6px rgba(255,255,255,0.02);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.03);
    color: #e6eef8; /* light text on dark chip */
    font-weight: 700;
    font-size: 0.70rem; /* keep current size */
    line-height: 1;
    margin-right: 6px;
}
.room-handle-chip a,
.room-handle-chip span {
    color: inherit;
    text-decoration: none;
    font-weight: 700;
}
    margin: 0;
    padding: 0;
    font-family: Inter, Segoe UI, Roboto, system-ui, sans-serif;
}

body {
    background: radial-gradient(circle at 20% 0%, #131824 0%, #0b0d12 45%, #090b0f 100%);
    color: var(--text);
    min-height: 100vh;
    padding: 24px;
}

.cup-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

.quick-nav {
    position: sticky;
    top: 10px;
    z-index: 120;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(18, 23, 32, 0.86), rgba(18, 23, 32, 0.68));
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
    margin-bottom: 18px;
}

.quick-nav-account {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.quick-nav-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: 0.2s ease;
}

.quick-nav-btn:hover {
    border-color: #3a4b67;
    color: var(--text);
    background: rgba(110, 168, 254, 0.08);
}

.quick-nav-account .logged-info,
.quick-nav-account #setHandleBtn {
    white-space: nowrap;
}

/* Global handle chip (used in other pages) - ensure index header shows same styling */
.global-handle-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

html:not([data-auth-chip-ready="1"]) .global-handle-chip[data-global-handle-chip] {
    visibility: hidden;
}

.global-handle-chip.not-verified {
    display: inline-block;
    background: linear-gradient(180deg, #79afff, #5a94ef);
    color: #081223;
    border-color: #6ea8fe;
    font-weight: 600;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13.3333px;
    line-height: normal;
    transition: 0.2s ease;
}

.global-handle-chip.not-verified:hover {
    transform: translateY(-1px);
    border-color: #3b4660;
}

.global-handle-avatar {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid var(--border);
    object-fit: cover;
}

.blitz-header,
.create-room-section,
.join-room-section,
.active-blitz-section,
.room-info-bar,
.config-dashboard,
.validation-section,
.problems-section,
.match-status-bar,
.standings,
.vs-players,
.problem-card,
.password-content,
.match-countdown-card,
.celebration-content {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Make the standings (standings) panel expand to available container width
   so it matches the match status bar width and is responsive. */
.standings {
    width: 100%;
    max-width: 100%;
    margin-bottom: 15px;
}

@media (min-width: 1100px) {
    /* keep layout consistent with container max-width when viewport is wide */
    .standings {
        /* Allow standings to take full available width on wide screens
           instead of capping at 1100px so the table can expand horizontally. */
        max-width: none;
        width: 100%;
    }
}

/* Make standings (battle standings) horizontally scroll on narrow viewports,
   matching the admin table behavior. */
.standings .standings-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.standings .standings-table {
    /* On wide viewports prefer the table fill the container so it uses available space.
       Keep a sensible minimum for narrow screens. */
    min-width: 640px;
    min-width: max-content;
    width: 100%;
}

.standings .standings-table th,
.standings .standings-table td {
    white-space: nowrap;
    padding: 8px 6px;
}

.blitz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px;
    margin-bottom: 24px;
}

.logo h1 {
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo span {
    display: inline-flex;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    color: var(--muted);
    border: 1px solid var(--border);
    font-size: 0.82rem;
}

.user-panel {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.handle-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel);
}

.handle-input label {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.handle-input input {
    border: none;
    background: transparent;
    color: var(--text);
    width: 140px;
    outline: none;
}

.handle-input.invalid {
    border-color: var(--danger);
    animation: shake 0.25s ease;
}

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

button,
.primary-btn,
.results-btn,
.leave-room-btn,
.cancel-game-btn,
.join-this-room-btn,
.password-btn,
#closeCelebration,
.details-btn,
.close-btn,
.add-problem-btn-small {
    border: 1px solid transparent;
    background: var(--panel-soft);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
    text-decoration: none;
}

button:hover,
.primary-btn:hover,
.results-btn:hover,
.leave-room-btn:hover,
.cancel-game-btn:hover,
.join-this-room-btn:hover,
.password-btn:hover,
#closeCelebration:hover,
.details-btn:hover,
.close-btn:hover,
.add-problem-btn-small:hover {
    transform: translateY(-1px);
    border-color: #3b4660;
}

#setHandleBtn,
.join-this-room-btn,
.details-btn,
.problem-link a {
    background: linear-gradient(180deg, #79afff, #5a94ef);
    color: #0a1220;
    border-color: #6ea8fe;
}

.primary-btn,
.start-battle button,
.add-problem-btn-small {
    background: linear-gradient(180deg, #67d69a, #4dbd82);
    color: #06120b;
    border-color: #5acb8a;
}

/* Override: use feedback page's modern primary button styling for results/login chips */
.results-btn {
    background: linear-gradient(180deg,#3b82f6,#2563eb);
    color: #ffffff;
    border-color: rgba(59,130,246,0.18);
    box-shadow: 0 10px 24px rgba(59,130,246,0.12);
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 700;
    transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}
.results-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(59,130,246,0.16); }

/* Global override so the Login chip uses the same modern gradient style across pages */
.global-handle-chip.not-verified {
    display: inline-block;
    background: linear-gradient(180deg,#60a5fa,#3b82f6);
    color: #071325;
    border-color: rgba(59,130,246,0.28);
    font-weight: 700;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13.3333px;
    line-height: normal;
    transition: transform 140ms ease, box-shadow 140ms ease;
}
.global-handle-chip.not-verified:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(59,130,246,0.12); }

.leave-room-btn,
.cancel-game-btn,
.confirm-btn {
    background: linear-gradient(180deg, #ff9a9a, #ff7d7d);
    color: #230505;
    border-color: #ff7d7d;
}

.logged-info {
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 12px;
}

/* Hide Cancel Game in room header but keep Auto Start visible */
.room-info-bar .cancel-game-btn:not(.auto-start-btn) { display: none !important; }

/* Auto Start: emphasize for admins (fiery bold) */
.auto-start-btn {
    background: linear-gradient(180deg,#ff6b00,#ff2d00) !important;
    color: #ffffff !important;
    border-color: rgba(255,110,40,0.22) !important;
    box-shadow: 0 12px 36px rgba(255,90,20,0.14), 0 0 18px rgba(255,110,40,0.06);
    font-weight: 800 !important;
    text-transform: none;
    letter-spacing: 0.01em;
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.auto-start-btn:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 18px 44px rgba(255,90,20,0.22), 0 0 26px rgba(255,110,40,0.12); }

/* Invite: make more eye-catching (teal/green glow) */
#inviteRoomBtn {
    background: linear-gradient(180deg,#61f1c8,#17b89f) !important;
    color: #04221b !important;
    border-color: rgba(23,184,159,0.24) !important;
    font-weight: 800 !important;
    box-shadow: 0 10px 30px rgba(23,184,159,0.12);
    padding: 10px 14px;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}
/* subtle continuous pulse to attract attention */
#inviteRoomBtn { animation: invitePulse 3s infinite ease-in-out; }
#inviteRoomBtn:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(23,184,159,0.18); }

/* sheen pseudo-element (moving glare) */
#inviteRoomBtn::before {
    content: '';
    position: absolute;
    top: -30%;
    left: 0;
    width: 60%;
    height: 160%;
    background: linear-gradient(120deg, rgba(255,255,255,0.0) 0%, rgba(255,255,255,0.36) 42%, rgba(255,255,255,0.14) 58%, rgba(255,255,255,0.0) 100%);
    transform: translateX(-140%) skewX(-18deg);
    filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    mix-blend-mode: screen;
}

/* pulsing box-shadow animation */
@keyframes invitePulse {
    0% { box-shadow: 0 8px 24px rgba(17,128,98,0.06); }
    50% { box-shadow: 0 16px 36px rgba(23,184,159,0.12); }
    100% { box-shadow: 0 8px 24px rgba(17,128,98,0.06); }
}

/* moving glare that sweeps occasionally to attract attention */
@keyframes inviteGlareMove {
    0% { transform: translateX(-140%) skewX(-18deg); opacity: 0; }
    6% { opacity: 0.85; }
    12% { transform: translateX(120%) skewX(-18deg); opacity: 0.85; }
    16% { opacity: 0; }
    100% { transform: translateX(140%) skewX(-18deg); opacity: 0; }
}

/* periodically run the glare animation (long cycle so it passes occasionally) */
#inviteRoomBtn::before { animation: inviteGlareMove 20s ease-in-out infinite; }

/* reduce motion/animation on small screens for performance */
@media (max-width: 640px) {
    #inviteRoomBtn::before { display: none; }
    #inviteRoomBtn { animation: none; }
}

.logged-info.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.logged-avatar {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid var(--border);
    object-fit: cover;
}

.handle-setup-content {
    max-width: 560px;
    text-align: left;
}

.handle-setup-actions {
    justify-content: flex-end;
}

.password-field-wrap {
    position: relative;
}

.password-field-wrap .password-input {
    padding-right: 44px;
}

.password-toggle-btn {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 999px;
    background: rgba(157, 196, 255, 0.12);
    color: #9dc4ff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.password-toggle-btn:hover {
    background: rgba(157, 196, 255, 0.24);
    color: #d6e6ff;
}

.password-toggle-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.password-generator-wrap {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}

.password-generator-btn {
    font-size: 0.82rem;
}

.password-strength-wrap {
    margin-top: 10px;
    display: none;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.password-strength-instruction {
    margin-bottom: 6px;
    font-size: 0.78rem;
    color: var(--muted);
}

.password-strength-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: #2a3142;
    overflow: hidden;
}

.password-strength-fill {
    width: 0%;
    height: 100%;
    background: #ef4444;
    transition: width 0.18s ease, background-color 0.18s ease;
}

.password-strength-fill[data-strength='weak'] {
    background: #ef4444;
}

.password-strength-fill[data-strength='medium'] {
    background: #f59e0b;
}

.password-strength-fill[data-strength='strong'] {
    background: #22c55e;
}

.password-strength-meta {
    margin-top: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.78rem;
    color: var(--muted);
    max-width: 340px;
}

#passwordStrengthLabel {
    font-weight: 700;
    min-width: 52px;
}

.auth-mode-toggle {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    color: var(--muted);
    font-size: 0.86rem;
}

.auth-sep {
    opacity: 0.5;
}

.auth-mode-toggle-btn {
    border: none;
    background: transparent;
    color: #9dc4ff;
    font-size: 0.86rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.auth-mode-toggle-btn:hover {
    color: #c8dcff;
}

.handle-verification-block {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    background: var(--panel);
}

#handleVerificationProblemLink {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

#handleVerificationProblemLink:hover {
    text-decoration: underline;
}

.handle-verification-status {
    margin-top: 10px;
    color: var(--muted);
}

.user-profile-content {
    max-width: 560px;
    text-align: left;
}

.user-profile-actions {
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.user-profile-actions .user-profile-logout-btn {
    margin-right: 0;
}

.user-profile-body {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    padding: 12px;
    margin-top: 10px;
    /* max-height: min(70vh, 560px); */
    overflow-y: auto;
}

.user-profile-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-profile-head-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    text-align: left;
}

.user-profile-handle-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
}

.user-profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid var(--border);
    object-fit: cover;
}

.user-profile-handle {
    font-size: 1.05rem;
    font-weight: 700;
    text-align: left;
}

.user-profile-rank {
    color: var(--muted);
    font-size: 0.9rem;
}

.user-presence {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    margin-top: 2px;
}

.presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
    background: #8a8f99;
}

.user-presence.status-active {
    color: #5acb8a;
}

.user-presence.status-active .presence-dot {
    background: #5acb8a;
}

.user-presence.status-offline {
    color: var(--muted);
}

.user-recent-wrap {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    background: #141b27;
}

.user-recent-title {
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 6px;
}

.user-recent-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.user-recent-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 8px;
    align-items: center;
    font-size: 0.86rem;
}

.user-recent-outcome {
    min-width: 22px;
    text-align: center;
    border-radius: 999px;
    padding: 1px 6px;
    border: 1px solid var(--border);
    font-weight: 700;
}

.user-recent-outcome.win {
    color: #5acb8a;
}

.user-recent-outcome.loss {
    color: #ff7d7d;
}

.user-recent-outcome.tie {
    color: #9dc4ff;
}

.user-recent-opponent {
    color: var(--text);
}

.user-recent-score {
    color: var(--muted);
}

.user-recent-link {
    color: #9dc4ff;
    text-decoration: none;
}

.user-recent-empty {
    color: var(--muted);
    font-size: 0.85rem;
}

.user-profile-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 8px;
}

.user-profile-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #141b27;
    padding: 8px 10px;
}

.user-profile-item span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.user-profile-item strong {
    font-size: 0.95rem;
}

.user-profile-links {
    margin-top: 10px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.user-profile-links a {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

.user-profile-logout-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    border: 1px solid var(--danger);
    background: linear-gradient(180deg, #ff9a9a, #ff7d7d);
    color: #230505;
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 700;
    cursor: pointer;
}

.user-profile-logout-btn:hover {
    filter: brightness(1.05);
}

.user-profile-links a:hover {
    text-decoration: underline;
}

.user-profile-site {
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.user-profile-site h4 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.user-stats-handle {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

.user-stats-handle:hover {
    text-decoration: underline;
}

.room-controls {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}

.create-room-section,
.join-room-section,
.active-blitz-section,
.config-dashboard,
.validation-section,
.problems-section,
.standings,
.vs-players,
.problem-card {
    padding: 18px;
}

.create-room-section h2,
.join-room-section h2,
.active-blitz-section h2,
.problems-section h2,
.validation-section h2 {
    font-size: 1.2rem;
    margin-bottom: 14px;
}


.room-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.room-form > button,
.room-form > .primary-btn,
.room-form > .add-problem-btn-small {
    align-self: center;
    width: auto;
    min-width: 120px;
}

.room-form input,
.room-form select,
.config-row input,
.start-battle input,
.config-display,
.password-input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.95rem;
    outline: none;
}

.room-form input:focus,
.room-form select:focus,
.config-row input:focus,
.start-battle input:focus,
.password-input:focus {
    border-color: var(--primary);
}

.config-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: var(--panel);
}

.config-group h3 {
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.config-row {
    margin-bottom: 10px;
}

.config-row label,
.config-block label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.83rem;
}

.problems-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--panel);
}

.problems-list-head {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    padding: 6px 8px;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    align-items: center;
    margin-bottom: 8px;
}

/* For Webkit browsers */
.problems-list::-webkit-scrollbar {
    width: 10px;
}
.problems-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 8px;
}
.problems-list::-webkit-scrollbar-track {
    background: var(--panel);
    border-radius: 8px;
}

.create-problem-item {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    background: #141b27;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
}

.create-problem-item input,
.create-problem-item select {
    width: 100%;
}

.remove-create-problem {
    background: transparent;
    color: var(--danger);
    border: 1px solid #4f2d33;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    padding: 0;
}

.remove-create-problem:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

 .active-blitz-section {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    max-width: 100%;
    overflow: visible !important;
    position: relative;
}

/* Keep header/search at top; center only the empty-state block itself
   so the header and search controls remain in their original positions. */
.active-blitz-empty-state {
    margin: 18px auto; /* horizontally centered, keeps header/search above */
    text-align: center;
    align-items: center;
}
.active-blitz-empty-state .empty-tips {
    display: inline-block;
    text-align: center;
    padding-left: 0;
}

.active-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

/* Keep header/search pinned at the top; center empty-state vertically
   within the section using auto margins so it stays centered on any viewport. */
.active-head {
    z-index: 2;
}
.active-blitz-empty-state {
    /* vertical centering between header and bottom of section */
    margin-top: auto;
    margin-bottom: auto;
}

.active-search-input {
    width: min(320px, 100%);
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    outline: none;
}

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

.blitz-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
    overflow-y: auto;
    max-height: calc(880px - 60px); /* Fill section minus header/search, adjust as needed */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--panel);
}

/* When the list contains only the empty-state, center it reliably across browsers */
.blitz-list.center-empty {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    /* Avoid scrollbars shifting visual center when list is empty */
    overflow-y: visible !important;
    padding-left: 16px;
    padding-right: 16px;
    padding-top: 40px; /* add space from header */
}
.blitz-list.center-empty .active-blitz-empty-state {
    margin: 0 auto;
    /* responsive width so centering is visually accurate */
    width: min(720px, 92%);
}

/* For Webkit browsers */
.blitz-list::-webkit-scrollbar {
    width: 10px;
}
.blitz-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 8px;
}
.blitz-list::-webkit-scrollbar-track {
    background: var(--panel);
    border-radius: 8px;
}

.blitz-room-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    background: var(--panel);
    min-height: 120px;
    height: auto;
    box-sizing: border-box;
    width: 100%;
    flex: 0 0 auto;
}

/* Hide action buttons by default; reveal on card hover */
.blitz-room-card .share-room-btn,
.blitz-room-card .join-this-room-btn {
    /* default hidden for pointer hover flows */
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none;
    position: absolute; /* positioned inside card */
    right: 12px;
    z-index: 2;
    border-radius: 8px;
    padding: 6px 12px;
}
.blitz-room-card .share-room-btn { top: 12px; }
.blitz-room-card .join-this-room-btn { bottom: 12px; }

.blitz-room-card:hover .share-room-btn,
.blitz-room-card:hover .join-this-room-btn {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    z-index: 12;
}

/* Show action buttons on non-pointer (touch) devices and when the card
   is actively pressed or marked active. This ensures touch users can
   access Share/Join without relying on hover. */
@media (hover: none), (pointer: coarse) {
    .blitz-room-card .share-room-btn,
    .blitz-room-card .join-this-room-btn {
        opacity: 1 !important;
        transform: translateY(0) !important;
        pointer-events: auto !important;
    }
}

.blitz-room-card:active .share-room-btn,
.blitz-room-card:active .join-this-room-btn,
.blitz-room-card.active .share-room-btn,
.blitz-room-card.active .join-this-room-btn {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    z-index: 12;
}

/* Mobile fallback: make buttons flow with content to avoid overlaying text */
@media (max-width: 420px) {
    .blitz-room-card .share-room-btn,
    .blitz-room-card .join-this-room-btn {
        position: static !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        opacity: 1 !important;
        transform: none !important;
        pointer-events: auto !important;
        display: inline-block;
        margin: 6px 6px 0 0;
    }
    .blitz-room-card .join-this-room-btn { margin-top: 12px; }
}

.blitz-room-info h4 {
    font-size: 1rem;
    margin-bottom: 4px;
    font-family: 'Orbitron', 'Russo One', 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.4px;
    text-transform: none;
    font-weight: 700;
    color: var(--text);
    text-shadow: 0 1px 6px rgba(0,0,0,0.5);
    opacity: 0.85;
}

/* Simple row layout for card info */
/* .card-row {
    display: flex;
    align-items: center;
    gap: 100px;
} */

.blitz-room-info p {
    color: var(--muted);
    font-size: 0.84rem;
}

.live-loading {
    text-align: center;
    color: var(--muted);
    padding: 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.live-dot {
    width: 10px;
    height: 10px;
    display: inline-block;
    background: #5acb8a;
    border-radius: 50%;
    box-shadow: 0 0 0 rgba(90, 203, 138, 0.5);
    animation: liveBlink 1.15s ease-in-out infinite;
}

@keyframes liveBlink {
    0% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(90, 203, 138, 0.45);
    }
    70% {
        opacity: 0.8;
        transform: scale(1.08);
        box-shadow: 0 0 0 8px rgba(90, 203, 138, 0);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(90, 203, 138, 0);
    }
}

/* Page-level live indicator (top-right) */
.page-live-indicator {
    position: fixed;
    top: 18px;
    right: 18px;
    background: rgba(17, 23, 32, 0.75);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.04);
    padding: 8px 12px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    z-index: 1200;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
/* Live badge inside active room card (top-right) */
.blitz-room-card { position: relative; }
.blitz-room-card .live-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 999px;
    background: rgba(11,17,22,0.6);
    border: 1px solid rgba(255,255,255,0.03);
    z-index: 10;
    font-size: 0.50rem;
    color: var(--muted);
}
.blitz-room-card .live-badge .live-text { color: var(--success); font-weight:700; letter-spacing:0.06em; }

.room-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding: 14px 16px;
}

/* When a battle is active, add extra top spacing so the room info bar
   stays visually separated from the sections above. Use !important to
   avoid being accidentally overridden by other responsive rules. */
body.in-battle .room-info-bar {
    padding-top: 28px !important;
    padding-bottom: 14px !important;
    margin-top: 12px !important;
}

.room-details,
.room-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.room-name {
    font-weight: 700;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Allow blitz room card titles to wrap when they are long */
.blitz-room-info h4 {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    margin-bottom: 6px;
    margin-right: 15px;
}

.spectator-panel {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--panel);
    padding: 12px;
    width: 100%;
}

.spectator-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.spectator-head h3 {
    font-size: 0.98rem;
}

.spectator-count {
    color: var(--muted);
    font-size: 0.74rem;
}

.spectator-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Keep the spectator chips contained within the panel when there are many.
   Allow vertical scrolling while preserving chip wrapping and animations. */
.spectator-list {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 6px; /* allow space for scrollbar */
    /* Never show native scrollbars across browsers */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE 10+ */
}

/* WebKit browsers: hide scrollbars (never show) */
.spectator-list::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.spectator-skeleton {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.skeleton-chip {
    width: 76px;
    height: 24px;
    border-radius: 999px;
    background: linear-gradient(90deg, #1e2637 25%, #2d3960 50%, #1e2637 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s infinite ease-in-out;
    border: 1px solid rgba(102, 116, 141, 0.35);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spectator-chip {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 9px;
    background: #141b27;
    color: #c9d7ee;
    font-size: 0.84rem;
    font-weight: 600;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.2s ease, transform 0.2s ease;
    will-change: opacity, transform;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.spectator-chip:hover {
    transform: translateY(-1px) scale(1.01);
}

.spectator-chip:focus-visible {
    outline: 2px solid #6ea8fe;
    outline-offset: 2px;
}

.spectator-chip.is-online {
    border-color: rgba(90, 203, 138, 0.45);
    background: rgba(90, 203, 138, 0.14);
    color: #9ff2c3;
}

.spectator-chip.is-left {
    border-color: rgba(104, 114, 129, 0.45);
    background: rgba(47, 54, 66, 0.62);
    color: #98a5bb;
}

.spectator-chip-handle {
    font-weight: 700;
    text-decoration: none;
    text-underline-offset: 2px;
}

.spectator-chip-status {
    font-size: 0.58rem;
    text-transform:capitalize;
    letter-spacing: 0.03em;
    opacity: 0.9;
}

.spectator-chip.is-entering {
    opacity: 0;
    transform: translateY(6px) scale(0.96);
}

.spectator-chip.is-leaving {
    opacity: 0;
    transform: translateY(-4px) scale(0.92);
    pointer-events: none;
}

.spectator-empty {
    color: var(--muted);
    font-size: 0.85rem;
}

.room-id {
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.room-players {
    color: var(--success);
    font-weight: 600;
}

.room-validation-mini,
#validationProblemLink,
.player-handle,
.player-link {
    color: #9dc4ff;
    text-decoration: none;
}

.room-validation-mini:hover,
#validationProblemLink:hover,
.player-handle:hover,
.player-link:hover {
    text-decoration: underline;
}

.config-dashboard {
        min-height: 2px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    align-items: end;
}

.config-block {
    flex: 1 1 160px;
}

.config-display {
    color: var(--text);
}

.action-buttons {
    margin-left: auto;
}

.start-battle {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.start-battle button:disabled,
.primary-btn:disabled,
button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* Make disabled form controls show restricted cursor globally (arena, create room, etc.) */
input:disabled,
textarea:disabled,
select:disabled {
    cursor: not-allowed !important;
}

.validation-problem {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#validationStatusText {
    color: var(--muted);
}

.problems-table {
    width: 100%;
    border-collapse: collapse;
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.problems-table th {
    background: #151d2b;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    padding: 10px;
    text-align: center;
}

.problems-table td {
    padding: 10px;
    text-align: center;
    border-top: 1px solid var(--border);
    background: #121925;
}

.standings h3 {
    margin-bottom: 12px;
    font-size: 1.1rem;
}

/* Standings table styles moved to css/standings-shared.css */

/* Mobile/tablet: allow standings and standings tables to overflow horizontally
   so users can side-scroll when the viewport is narrow. This follows the
   admin table behavior (table-wrap with overflow-x:auto). */
@media (max-width: 900px) {
    .standings {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Keep the table using the container width by default so columns
       expand to fill available space at intermediate widths (e.g. ~893px),
       but retain `min-width: max-content` so very wide content can still
       overflow and be side-scrolled on small devices. */
    .standings .standings-table {
        width: 100%;
        min-width: max-content;
    }

    .standings-panel .standings-table-wrap,
    .standings .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .standings-panel .standings-table,
    .standings .standings-table {
        width: 100%;
        min-width: max-content;
    }
}

.match-status-bar {
    margin-bottom: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.match-status {
    font-weight: 600;
}

.status-live {
    color: var(--success);
}

.status-ended {
    color: var(--danger);
}

.match-timer-display {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1.5rem;
    letter-spacing: 0.06em;
}

/* Centered live link area in the match status bar */
.match-live-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.match-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.match-live-anchor {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(0,0,0,0.03);
    text-decoration: none;
    color: inherit;
    font-weight: 600;
}

.match-live-anchor:hover {
    background: rgba(0,0,0,0.06);
}

.match-live-icon { font-size: 1.1rem; }
.match-live-domain { font-size: 0.95rem; color: var(--muted); }

/* Placeholder shown for providers when no link exists */
.match-live-placeholder {
    cursor: text;
    transition: opacity 150ms ease, transform 160ms ease;
    white-space: nowrap;
    color: rgba(243,245,248,0.62);
}

/* Smooth reveal of domain on hover for viewers */
.match-live-anchor .match-live-domain {
    transition: opacity 180ms ease, max-width 220ms ease, transform 180ms ease;
    opacity: 0;
    max-width: 0;
    transform: translateX(6px);
}
.match-live-anchor:hover .match-live-domain {
    opacity: 1;
    max-width: 420px;
    transform: translateX(0);
}

/* Editor layout when visible */
.match-live-editor {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}
.match-live-editor input {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
}
.match-live-editor input::placeholder {
    color: rgba(159,179,199,0.55);
}
.match-live-editor input:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(110,168,254,0.06);
    border-color: rgba(110,168,254,0.28);
}

.break-indicator {
    color: #312100;
    background: var(--warning);
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 700;
    font-size: 0.8rem;
}

.arena-panel {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 14px;
    margin-top: 14px;
    overflow: visible;
}

.player-row {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 0;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--panel);
}

.player1 { border-left: 3px solid var(--primary); }
.player2 { border-left: 3px solid var(--danger); }

.player-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Footer: reset handle-like link decorations */
.site-footer {
    margin-top: 20px;
    color: var(--muted);
    text-align: center;
}
.site-footer a {
    color: var(--text);
    background: none !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    text-decoration: none;
}
.site-footer a:hover {
    text-decoration: underline;
    color: var(--primary);
}

/* About section */
.about-hero {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 24px;
}

.about-hero h1 {
    margin: 0;
    font-size: 1.8rem;
    letter-spacing: 0.02em;
}

.about-hero p {
    margin: 0;
    max-width: 840px;
    color: var(--muted);
    line-height: 1.55;
}

.about-section {
    position: relative;
    margin: 0 0 26px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: radial-gradient(circle at 12% 20%, rgba(110, 168, 254, 0.14), rgba(110, 168, 254, 0))
        , radial-gradient(circle at 86% 6%, rgba(90, 203, 138, 0.16), rgba(90, 203, 138, 0))
        , linear-gradient(180deg, rgba(18, 23, 32, 0.94), rgba(10, 12, 18, 0.92));
    box-shadow: var(--shadow);
    overflow: hidden;
}

.about-section::before,
.about-section::after {
    content: "";
    position: absolute;
    inset: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: calc(var(--radius) - 4px);
    pointer-events: none;
}

.about-section::after {
    inset: auto 18px -32px 18px;
    height: 120px;
    background: linear-gradient(180deg, rgba(110, 168, 254, 0.12), rgba(110, 168, 254, 0));
    border: none;
    border-radius: 999px;
    filter: blur(18px);
}

.about-head {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 820px;
    margin-bottom: 18px;
    z-index: 1;
}

.about-head h2 {
    font-family: 'Orbitron', 'Inter', 'Segoe UI', system-ui, sans-serif;
    letter-spacing: 0.04em;
    font-size: 1.55rem;
    margin: 0;
}

.about-head p {
    color: var(--muted);
    line-height: 1.55;
    margin: 0;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(110, 168, 254, 0.35);
    background: rgba(110, 168, 254, 0.12);
    color: #dce9ff;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.75rem;
    width: fit-content;
}

.about-grid {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    z-index: 1;
    max-width: 900px;
}

.about-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    background: linear-gradient(165deg, rgba(22, 29, 40, 0.9), rgba(12, 16, 24, 0.92));
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.about-card::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 38%;
    height: 100%;
    background: linear-gradient(120deg, rgba(110, 168, 254, 0.08), rgba(110, 168, 254, 0));
    filter: blur(2px);
    pointer-events: none;
}

.about-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: radial-gradient(circle at 28% 24%, rgba(110, 168, 254, 0.35), rgba(110, 168, 254, 0.08));
    border: 1px solid rgba(110, 168, 254, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #dce9ff;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

.about-card h3 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.about-card p {
    margin: 0 0 10px;
    color: var(--muted);
    line-height: 1.5;
}

.about-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.about-list li {
    position: relative;
    padding-left: 18px;
    color: #e8eef8;
    font-weight: 600;
    font-size: 0.95rem;
}

.about-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 9px;
    width: 10px;
    height: 2px;
    border-radius: 10px;
    background: linear-gradient(90deg, #5acb8a, #6ea8fe);
}

.about-steps {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #e8eef8;
    font-weight: 600;
    font-size: 0.95rem;
}

.about-steps li {
    line-height: 1.4;
}

@media (max-width: 820px) {
    .about-section {
        padding: 18px;
    }
}

@media (max-width: 540px) {
    .about-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .about-card::after {
        width: 100%;
        height: 46%;
        top: auto;
        bottom: 0;
    }
}

/* Desktop/default: let the VS block keep its look but cap its width
   so it doesn't push neighboring panels. On small screens the block
   will become full-width and stack (handled in existing media queries). */
.vs-players-redesign {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

/* Allow player boxes to shrink rather than forcing wrap */
.vs-player-box {
    flex: 0 1 auto;
    min-width: 0;
}

.vs-center-vs {
    flex: 0 0 auto;
}

.player-handle {
    font-size: 1.05rem;
    font-weight: 700;
}

.player-rank {
    color: var(--muted);
    font-size: 0.82rem;
}

/* Hide CF rank/title labels site-wide (including live match and results) */
.user-profile-rank,
.standings-cf-rank,
.player-rank {
    display: none !important;
}

.player-score {
    font-size: 1.4rem;
    font-weight: 700;
    min-width: 52px;
    text-align: center;
}

.solved-badge {
    display: none;
    position: absolute;
    top: -7px;
    right: -7px;
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 999px;
    color: #04270f;
    background: var(--success);
    border: 1px solid #4abf80;
    font-weight: 700;
}

.player-row.solved .solved-badge {
    display: inline-flex;
}

.problem-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.problem-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.problem-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.problem-points {
    background: #1c2a42;
    border: 1px solid #385582;
    border-radius: 999px;
    padding: 6px 10px;
    font-weight: 700;
}

.problem-rating-badge {
    display: inline-flex;
    align-self: flex-start;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.85rem;
}

.problem-link {
    margin-top: 4px;
}

.problem-link a {
    display: inline-flex;
    border-radius: 10px;
    padding: 10px 14px;
    text-decoration: none;
}

.problem-lock-status,
.break-timer {
    border-radius: 10px;
    text-align: center;
    font-weight: 700;
    padding: 10px;
    font-size: .9em;
}

.problem-lock-status {
    background: #312024;
    border: 1px solid #5a343c;
    color: #ffb5b5;
}

.problem-lock-status.pending-loading { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.pending-spinner { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #ffd28a; box-shadow: 0 0 6px rgba(255,210,138,0.6); animation: pending-pulse 1s ease-in-out infinite; }
@keyframes pending-pulse { 0% { transform: scale(0.9); opacity: 0.4; } 50% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(0.9); opacity: 0.4; } }

.solved-flash {
    background: #123024;
    border-color: #2f7658;
    color: #90e8b7;
}

.break-timer {
    background: #171f31;
    border: 1px solid #2f3f63;
    color: #c5d5f5;
    font-size: 1.2rem;
}

/* Ensure break timer fills the problem panel cleanly on wide viewports
   and doesn't overflow its container. Use box-sizing so padding is included. */
.problem-card .break-timer {
    width: 100%;
    box-sizing: border-box;
    display: block;
}

.notification-center {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 1000;
    pointer-events: none;
}

.desktop-notification {
    pointer-events: auto;
    min-width: 280px;
    max-width: 360px;
    margin-bottom: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #121925;
    border-left: 4px solid var(--primary);
    animation: slideIn 0.25s ease;
}

.desktop-notification.winner {
    border-left-color: var(--warning);
}

@keyframes slideIn {
    from { transform: translateX(24px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Enforced responsive layout for <= 989.98px: spectator left, problem right,
   VS block spans below. This override is placed at the end to take precedence. */
@media (max-width: 989.98px) {
    body .arena-flex-layout {
        display: grid !important;
        grid-template-columns: minmax(160px, 1fr) minmax(220px, 1fr) !important;
        grid-template-rows: auto 1fr !important;
        gap: 18px !important;
        align-items: start !important;
    }
    body .arena-flex-layout > .vs-players-redesign {
        grid-column: 1 / -1 !important;
        grid-row: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        align-self: stretch !important;
    }
    body .arena-flex-layout > .spectator-panel {
        grid-column: 1 !important;
        grid-row: 2 !important;
        width: 100% !important;
        max-width: 100% !important;
        align-self: stretch !important;
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
    }
    body .arena-flex-layout > .problem-card {
        grid-column: 2 !important;
        grid-row: 2 !important;
        width: 100% !important;
        max-width: 100% !important;
        align-self: stretch !important;
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
    }
}

.password-modal,
.celebration-modal,
.match-countdown-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 7, 11, 0.74);
    padding: 16px;
}

.password-content,
.celebration-content,
.match-countdown-card {
    width: min(560px, 100%);
    padding: 22px;
    text-align: center;
}

/* Enhanced celebration visuals for winner */
.celebration-content {
    position: relative;
    overflow: visible;
    background: linear-gradient(180deg, rgba(255, 250, 230, 0.06), rgba(255, 245, 200, 0.02));
    border: 1px solid rgba(255, 230, 120, 0.12);
    box-shadow: 0 8px 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.02);
    transform-origin: center;
    animation: celebrationPop 320ms cubic-bezier(.2,.9,.24,1);
}

@keyframes celebrationPop {
    0% { transform: scale(.86); opacity: 0; }
    60% { transform: scale(1.03); opacity: 1; }
    100% { transform: scale(1); }
}

/* Tie-specific celebration styling */
.celebration-modal.is-tie .celebration-content {
    background: linear-gradient(180deg, rgba(156, 196, 255, 0.06), rgba(255, 245, 204, 0.02));
    border: 1px solid rgba(157, 196, 255, 0.16);
}
.celebration-modal.is-tie .celebration-content h2 {
    color: #9dc4ff;
}
.celebration-modal.is-tie .winner-handle {
    color: #cfe9ff;
}

/* Simple confetti pieces used by JS; positioned inside celebration content */
.celebration-content { position: relative; overflow: visible; }
.celebration-content .confetti {
    position: absolute;
    top: -10px;
    width: 8px;
    height: 14px;
    border-radius: 2px;
    opacity: 0.95;
    pointer-events: none;
    transform-origin: center;
    animation: confettiFall 3s linear forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(-8vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(120vh) rotate(720deg); opacity: 0; }
}

/* Full-page confetti pieces (placed on body) */
.global-confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 2050;
}
.global-confetti .confetti {
    position: fixed;
    top: -10vh;
    width: 10px;
    height: 16px;
    border-radius: 2px;
    opacity: 0.98;
    transform-origin: center;
    animation: confettiBurst 4s cubic-bezier(.15,.8,.35,1) forwards;
}
@keyframes confettiBurst {
    0% { transform: translateY(0) rotate(0deg) translateX(0); opacity: 1; }
    20% { transform: translateY(10vh) rotate(180deg) translateX(6vw); }
    60% { transform: translateY(70vh) rotate(540deg) translateX(-8vw); }
    100% { transform: translateY(120vh) rotate(900deg) translateX(0); opacity: 0; }
}

/* Winner typography tuning */
.celebration-content h2 { font-size: 1.6rem; letter-spacing: -0.02em; }
.winner-handle { font-size: 3.8rem; font-weight: 900; color: #ffd966; text-shadow: 0 6px 30px rgba(255,217,102,0.12); }
.celebration-content p { margin-top: 6px; color: var(--muted); font-weight: 700; }

.password-content h2,
.celebration-content h2 {
    margin-bottom: 10px;
}

.password-buttons {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.match-countdown-time,
.winner-handle {
    font-size: 3.2rem;
    font-weight: 800;
    margin: 10px 0;
}

.winner-handle {
    color: var(--warning);
}

.match-countdown-title,
.match-countdown-subtitle {
    color: var(--muted);
}

.close-btn,
.cancel-btn {
    background: #1b2232;
    border: 1px solid var(--border);
    color: var(--text);
}

.no-data,
.timestamp {
    color: var(--muted);
}

.rank-newbie { color: #8a8f99; }
.rank-pupil { color: #74ca77; }
.rank-specialist { color: #4bc7b8; }
.rank-expert { color: #6ea8fe; }
.rank-cm { color: #c67bf3; }
.rank-master,
.rank-im { color: #ffb86a; }
.rank-gm,
.rank-lgm { color: #ff7d7d; }

.site-footer {
    margin: 22px auto 0;
    max-width: 1100px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0));
    color: var(--muted);
    text-align: center;
    line-height: 1.5;
    font-size: 0.9rem;
}

.site-footer a {
    color: #9dc4ff;
    text-decoration: none;
    font-weight: 600;
}

.site-footer a:hover {
    text-decoration: underline;
}

.site-version {
    margin-top: 2px;
    font-size: 0.72rem;
    opacity: 0.78;
    letter-spacing: 0.03em;
}

@media (max-width: 1080px) {
    .room-controls {
        grid-template-columns: 1fr;
    }

    .arena-panel {
        grid-template-columns: 1fr;
    }

    .active-head {
        flex-direction: column;
        align-items: stretch;
    }

    .active-search-input {
        width: 100%;
    }
}

@media (max-width: 780px) {
    body {
        padding: 14px;
    }

    .blitz-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-panel {
        width: 100%;
        justify-content: flex-start;
    }

    .room-info-bar,
    .match-status-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .start-battle {
        width: 100%;
    }

    .start-battle input,
    .start-battle button {
        width: 100%;
    }

    .create-problem-item {
        grid-template-columns: 1fr;
    }

    .remove-create-problem {
        width: 100%;
        height: auto;
        padding: 8px;
    }
}

/* Shrink inner VS elements to avoid clipping while keeping players side-by-side.
   These rules progressively reduce avatar, circle and padding sizes so content
   stays visible instead of being clipped or overflowing. */
@media (max-width: 900px) {
    .vs-players-redesign {
        gap: 20px;
        padding: 24px 18px 18px 18px;
        align-items: center;
        overflow: visible;
    }
    .vs-player-box {
        padding: 12px 10px;
        min-width: 0;
        max-width: 340px;
        overflow: visible;
    }
    .vs-player-avatar {
        width: 48px;
        height: 48px;
        font-size: 1.6rem;
        margin-bottom: 10px;
    }
    .vs-player-handle { font-size: 1.15rem; }
    .vs-player-label { font-size: 0.98rem; }
    .vs-center-vs { min-width: auto; min-height: auto; margin: 6px 6px; }
    .vs-glow {
        width: 84px;
        height: 84px;
        padding: 0;
        font-size: 2rem;
        border-radius: 50%;
        box-shadow: 0 0 28px 8px #ffb84d77;
    }
}

@media (max-width: 640px) {
    .vs-players-redesign { gap: 14px; padding: 16px; }
    .vs-player-box { padding: 8px 8px; border-radius: 18px; }
    .vs-player-avatar { width: 40px; height: 40px; font-size: 1.2rem; }
    .vs-player-handle { font-size: 1rem; }
    .vs-player-label { font-size: 0.9rem; }
    .vs-glow { width: 60px; height: 60px; font-size: 1.6rem; padding: 0; }
    /* allow the VS center to shrink and remain centered */
    .vs-center-vs { margin: 6px 0; }
}

/* Safety: ensure inner elements are not clipped by ancestor overflow rules */
.vs-players-redesign, .vs-player-box, .vs-center-vs { overflow: visible !important; }

/* Additional aggressive shrink rules to prevent edge clipping when container
   gets tight — reduce gaps, shrink avatars and center circle, and allow boxes
   to flex and share available space while staying side-by-side. */
@media (max-width: 980px) {
    .vs-players-redesign { gap: 12px; padding: 18px 12px; }
    .vs-player-box { flex: 1 1 120px; max-width: none; padding: 10px 8px; }
    .vs-player-avatar { width: 44px; height: 44px; font-size: 1.4rem; }
    .vs-glow { width: 72px; height: 72px; font-size: 1.9rem; }
}

@media (max-width: 760px) {
    .vs-players-redesign { gap: 10px; padding: 14px 10px; }
    .vs-player-box { flex: 1 1 100px; padding: 8px 6px; }
    .vs-player-avatar { width: 38px; height: 38px; font-size: 1.1rem; }
    .vs-glow { width: 58px; height: 58px; font-size: 1.5rem; }
}

@media (max-width: 480px) {
    /* aggressive scale to keep center circle from forcing overflow */
    .vs-glow { transform-origin: center; transform: scale(0.8); }
    .vs-player-avatar { transform-origin: center; transform: scale(0.9); }
    .vs-player-box { padding-left: 6px; padding-right: 6px; }
}

/* Ensure parent containers don't clip the glow/shadow */
.arena-flex-layout, .cup-container { overflow: visible; }


/* Force three-column Arena layout when viewport is at least 700px wide:
   left = spectators, center = VS block, right = problem panel. */
@media (min-width: 700px) {
    .arena-flex-layout {
        display: flex;
        flex-direction: row;
        gap: 20px;
        align-items: stretch;
        justify-content: space-between;
        flex-wrap: nowrap;
    }

    .arena-flex-layout > .spectator-panel {
        order: 1;
        flex: 0 0 220px; /* fixed-ish left column */
        min-width: 180px;
        max-width: 260px;
        align-self: stretch;
    }

    .arena-flex-layout > .vs-players-redesign {
        order: 2;
        flex: 0 0 auto;
        /* center block keeps its look but scales via its width rule */
        width: min(480px, 42vw);
        max-width: 520px;
        align-self: center;
        margin-left: auto;
        margin-right: auto;
    }

    .arena-flex-layout > .problem-card {
        order: 3;
        flex: 0 0 300px; /* right column */
        min-width: 180px;
        max-width: 360px;
        align-self: flex-start;
    }

    /* When side-by-side in a row layout, keep spectator and problem panels
       visually equal height. Convert them to column flex containers to
       allow internal scrolling without changing overall panel height. */
    .arena-flex-layout > .spectator-panel,
    .arena-flex-layout > .problem-card {
        align-self: stretch;
        display: flex;
        flex-direction: column;
        min-height: 220px;
        height: auto;
        box-sizing: border-box;
    }

    .arena-flex-layout > .spectator-panel .spectator-list,
    .arena-flex-layout > .problem-card .problems-list {
        overflow: auto;
    }
}

/* NEVER stack the two player boxes: always keep them side-by-side.
   If space is insufficient, allow horizontal scroll rather than wrapping. */
.vs-players-redesign {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 18px !important;
}

.vs-player-box {
    /* let boxes shrink but keep a reasonable minimum to avoid collapsing */
    flex: 0 1 180px !important;
    min-width: 120px !important;
}

.vs-center-vs {
    flex: 0 0 auto !important;
    margin: 0 8px !important;
}

/* Prevent any inner element from visually escaping the VS container. */
.vs-players-redesign {
    overflow: hidden !important;
}

.vs-players-redesign * {
    box-sizing: border-box;
    max-width: 100%;
}

.vs-player-box {
    overflow: hidden;
}

.vs-glow {
    /* ensure the circular center never forces overflow */
    max-width: 100%;
    box-sizing: border-box;
}

.vs-player-avatar {
    /* Keep avatar a square circle and prevent background bleed */
    max-width: none;
    /* Specific sizes are applied in breakpoint rules elsewhere; keep square by default */
    width: var(--vs-avatar-size, 64px);
    height: var(--vs-avatar-size, 64px);
    border-radius: 50%;
    overflow: hidden;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.vs-player-handle,
.vs-player-label,
.player-score {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hide horizontal scrollbar visually while still allowing scroll (optional) */
/* Remove horizontal scroll; use zoom scaling to shrink the whole block instead. */

/* Neutralize handle coloring and remove underline on handle links
   across standings and in-battle VS elements. Use high specificity
   and !important so these rules override rank color utilities. */
.player-handle,
.player-handle a,
.player-link,
.player-handle .player-link,
.vs-player-handle,
.vs-player-handle a,
a.player-handle-link {
    color: inherit !important;
    text-decoration: none !important;
}
.player-handle:hover,
.vs-player-handle:hover,
a.player-handle-link:hover,
.player-link:hover {
    text-decoration: none !important;
}

/* Ensure rank-specific color utility classes do not color handles here */
.rank-newbie,
.rank-pupil,
.rank-specialist,
.rank-expert,
.rank-cm,
.rank-master,
.rank-im,
.rank-gm,
.rank-lgm {
    color: inherit !important;
}

/* Also neutralize any inline CF color spans that may be rendered inside
   handle HTML by forcing inherited color on descendants. */
.player-handle *,
.vs-player-handle *,
a.player-handle-link * {
    color: inherit !important;
}
