/* ================= LOBBY (setup screen) ==========================
           ONE decision trail: I name · II fighter · III realm · IV ordeal · GO.
           Every question is a full screen of its own; #lobby[data-step] (the
           ONLY state lobby.js writes for layout) shows one and hides three, and
           the same attribute lights the phase pills. Below the screens sits the
           trail: who is in the room, what the room will play, the button.

           The markup is public/ui/lobby.html (static frame) and every tile,
           card and slot inside it is built by public/lobby.js from the
           generated endpoints (/players_types.js, /maps.js, /stages.js), so new
           content appears with no CSS change: the grids are auto-fill.

           The look is one token: --lb-hue. lobby.js moves it to the colour of
           the ARENA the room will play (MAPS sky_tint, the same int the renderer
           tints that sky with) and every glow, pill and gradient follows it.
           A fighter's own colour rides on her monogram only (--lb-mono-hue).

           public/styles/responsive.css (linked LAST) is the ONLY sheet allowed
           to re-lay this out - only sizes, never the slide machinery. */

        #lobby {
            --lb-hue: 265;
            --lb-a: hsl(var(--lb-hue), 75%, 70%);
            --lb-gold: #f3d98b;
            --lb-ink: #f7efe0;
            --lb-mut: #bfb0d8;
            --lb-head: "Cinzel", "Trajan Pro", Georgia, serif;
            --lb-body: "Segoe UI", "Cormorant Garamond", Georgia, serif;
            position: fixed;
            inset: 0;
            z-index: 100;
            display: flex;              /* showLobby() flips it to flex */
            color: var(--lb-ink);
            font-family: var(--lb-body);
            font-size: 19px;
            font-weight: 600;
            letter-spacing: 0.02em;
            user-select: none;
        }

        /* --- the ambient sky: two drifting mote fields over a hue wash ------ */
        .lb-bg {
            position: absolute;
            inset: 0;
            z-index: 0;
            pointer-events: none;
            background:
                radial-gradient(circle at 78% 14%, #fff6d8 0 2.2%, rgba(243, 217, 139, 0.33) 4%, transparent 18%),
                radial-gradient(ellipse at 20% 0%, hsl(var(--lb-hue), 60%, 30%), transparent 60%),
                radial-gradient(ellipse at 50% 110%, hsl(calc(var(--lb-hue) + 40), 55%, 24%), transparent 60%),
                linear-gradient(#0d0a24, #1a1038 60%, #2a1546);
            transition: background 1s;
        }

        .lb-bg::before,
        .lb-bg-stars {
            content: "";
            position: absolute;
            inset: -300px 0 0 0;
            background-image:
                radial-gradient(3px 3px at 40px 60px, #ffe9a0, transparent),
                radial-gradient(2px 2px at 140px 160px, rgba(255, 233, 160, 0.67), transparent),
                radial-gradient(2.5px 2.5px at 210px 40px, #fff, transparent);
            background-size: 260px 260px;
            animation: lbDrift 50s linear infinite reverse;
        }

        .lb-bg-stars {
            background-position: 130px 90px;
            opacity: 0.6;
            animation-duration: 80s;
        }

        @keyframes lbDrift {
            to { transform: translateY(260px); }
        }

        .lb-bg::after {
            content: "";
            position: absolute;
            inset: 0;
            background: radial-gradient(ellipse at center, transparent 50%, rgba(5, 3, 15, 0.6));
        }

        .lb-shell {
            position: relative;
            z-index: 1;
            display: flex;
            flex-direction: column;
            flex: 1 1 auto;
            min-height: 0;
        }

        /* every control in here is tapped, not hovered: kill the grey flash */
        #lobby button {
            -webkit-tap-highlight-color: transparent;
            touch-action: manipulation;
            font-family: inherit;
            color: #000;
            font-size: 1em;
        }

        #lobby button:focus-visible,
        #lobby input:focus-visible {
            outline: 2px solid var(--lb-gold);
            outline-offset: 2px;
        }

        /* --- header: brand, the four phases, sound + bests ----------------- */
        .lb-top {
            flex: 0 0 auto;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: calc(12px + env(safe-area-inset-top, 0px)) calc(58px + env(safe-area-inset-right, 0px)) 10px calc(16px + env(safe-area-inset-left, 0px));
        }

        .lb-brand {
            font-family: var(--lb-head);
            font-size: 22px;
            font-weight: 900;
            letter-spacing: 0.14em;
            background: linear-gradient(90deg, var(--lb-a), var(--lb-gold));
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }

        .lb-rail {
            display: flex;
            gap: 6px;
        }

        .lb-rail-btn {
            font-family: var(--lb-head);
            font-size: 11px;
            font-weight: 800;
            letter-spacing: 0.14em;
            padding: 8px 16px;
            color: var(--lb-mut);
            border-radius: 99px;
            border: 1px solid rgba(243, 217, 139, 0.2);
            background-color: rgba(255, 255, 255, 0.04);
            cursor: pointer;
            transition: color 0.2s, background-color 0.2s, border-color 0.2s;
        }

        .lb-rail-btn:hover { color: var(--lb-ink); }

        /* a question already answered stays readable, just quieter than the one
           on screen (the trail is a trail: you can walk back along it) */
        .lb-rail-btn.done { color: var(--lb-gold); border-color: rgba(243, 217, 139, 0.45); }

        .lb-rail-btn.selected {
            background-image: linear-gradient(90deg, var(--lb-a), var(--lb-gold));
            color: #2a1546;
            border-color: transparent;
        }

        .lb-who { display: flex; align-items: center; gap: 8px; }

        .lb-icon-btn {
            border: 0;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.08);
            color: var(--lb-ink);
            font-size: 16px;
            line-height: 1;
            cursor: pointer;
        }

        .lb-icon-btn:hover { background-color: rgba(255, 255, 255, 0.18); }

        .lb-icon-btn.off { color: #6d7789; }

        /* --- the screens: one visible, three parked ----------------------- */
        .lb-main {
            position: relative;
            flex: 1 1 auto;
            min-height: 0;
        }

        .lb-scr {
            position: absolute;
            inset: 0;
            display: flex;
            min-height: 0;
            opacity: 0;
            visibility: hidden;
            pointer-events: none;
            transform: scale(1.04);
            transition: opacity 0.35s, transform 0.35s, visibility 0.35s;
        }

        #lobby[data-step="name"] .lb-name,
        #lobby[data-step="fighter"] .lb-fighter,
        #lobby[data-step="arena"] .lb-arena,
        #lobby[data-step="difficulty"] .lb-diff {
            opacity: 1;
            visibility: visible;
            pointer-events: auto;
            transform: none;
        }

        /* --- shared type ------------------------------------------------- */
        .lb-lbl {
            font-family: var(--lb-head);
            font-size: 11px;
            font-weight: 800;
            letter-spacing: 0.3em;
            color: var(--lb-gold);
        }

        .lb-ttl {
            font-family: var(--lb-head);
            font-size: clamp(22px, 4vw, 34px);
            font-weight: 900;
            letter-spacing: 0.12em;
            text-align: center;
        }

        .lb-caption {
            margin: 0;
            max-width: 62ch;
            align-self: center;
            text-align: center;
            font-size: 14px;
            font-weight: 500;
            color: var(--lb-mut);
        }

        .lb-cta {
            border: 2px solid #fff3c4;
            cursor: pointer;
            font-family: var(--lb-head);
            font-size: 15px;
            font-weight: 800;
            letter-spacing: 0.2em;
            padding: 14px 40px;
            color: #000;
            background-image: linear-gradient(180deg, #fff0b8, var(--lb-gold) 50%, #d9a441);
            border-radius: 99px;
            box-shadow: 0 0 28px rgba(243, 217, 139, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.53);
            transition: transform 0.2s, filter 0.2s;
        }

        .lb-cta:hover:not(:disabled) { transform: scale(1.05); filter: brightness(1.15); }

        .lb-cta:disabled { filter: grayscale(1) brightness(0.6); cursor: not-allowed; }

        .lb-blink { animation: lbGlow 2.4s ease-in-out infinite; }

        @keyframes lbGlow {
            50% { box-shadow: 0 0 54px rgba(243, 217, 139, 0.8), inset 0 2px 0 rgba(255, 255, 255, 0.53); }
        }

        /* --- I · name --------------------------------------------------- */
        .lb-name {
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 10px;
            padding: 20px;
            text-align: center;
        }

        .lb-logo {
            font-family: var(--lb-head);
            font-size: clamp(44px, 10vw, 112px);
            font-weight: 800;
            line-height: 1;
            letter-spacing: 0.08em;
            background-image: linear-gradient(180deg, #fff7e0, var(--lb-gold) 60%, #c9902f);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            filter: drop-shadow(0 0 30px rgba(160, 90, 255, 0.6));
            animation: lbPulse 3s ease-in-out infinite;
        }

        @keyframes lbPulse {
            50% { filter: drop-shadow(0 0 55px rgba(180, 120, 255, 0.9)); }
        }

        .lb-tag {
            color: var(--lb-mut);
            letter-spacing: 0.3em;
            font-size: 16px;
            font-style: italic;
            margin-bottom: 20px;
        }

        .lb-nickbox {
            display: flex;
            align-items: center;
            gap: 8px;
            border-bottom: 2px solid var(--lb-gold);
            padding: 4px 6px;
            margin: 8px 0 6px;
        }

        #nickname-input {
            background-color: transparent;
            border: 0;
            outline: none;
            text-align: center;
            font-family: var(--lb-head);
            font-size: clamp(24px, 5vw, 38px);
            font-weight: 900;
            width: min(80vw, 460px);
            color: #fff;
            user-select: text;
        }

        #nickname-input::placeholder { color: rgba(191, 176, 216, 0.45); }

        .lb-dice {
            background: none;
            border: 0;
            font-size: 24px;
            cursor: pointer;
            transition: transform 0.3s;
        }

        .lb-dice:hover { transform: rotate(180deg); }

        .lb-err {
            height: 20px;
            color: #ff6b8e;
            font-size: 14px;
        }

        /* --- II · fighter ---------------------------------------------- */
        .lb-fighter { gap: 18px; padding: 0 20px 8px; }

        .lb-roster {
            flex: 1.25 1 0;
            display: flex;
            flex-direction: column;
            min-width: 0;
            min-height: 0;
        }

        .lb-search {
            flex: 0 0 auto;
            -webkit-appearance: none;
            background-color: rgba(255, 255, 255, 0.07);
            border: 1px solid rgba(243, 217, 139, 0.33);
            border-radius: 99px;
            padding: 11px 22px;
            outline: none;
            font-family: var(--lb-body);
            font-size: 18px;
            font-weight: 700;
            color: var(--lb-ink);
            user-select: text;
            margin-bottom: 8px;
        }

        .lb-search:focus { border-color: var(--lb-a); background-color: rgba(255, 255, 255, 0.11); }

        .lb-search::-webkit-search-decoration,
        .lb-search::-webkit-search-cancel-button { -webkit-appearance: none; }

        .lb-chips {
            flex: 0 0 auto;
            display: none; /*flex*/
            gap: 6px;
            overflow-x: auto;
            margin-bottom: 8px;
            padding-bottom: 2px;
            scrollbar-width: none;
        }

        .lb-chip {
            border: 1px solid rgba(243, 217, 139, 0.2);
            background-color: rgba(255, 255, 255, 0.07);
            padding: 5px 14px;
            cursor: pointer;
            white-space: nowrap;
            color: var(--lb-mut);
            font-weight: 700;
            border-radius: 99px;
            font-size: 14px;
        }

        .lb-chip.selected { background-color: var(--lb-gold); color: #2a1546; }

        .lb-cnt { color: var(--lb-mut); font-size: 13px; margin-bottom: 4px; flex: 0 0 auto; }

        .lb-grid {
            flex: 1 1 auto;
            overflow-y: auto;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
            gap: 8px;
            padding: 15px;
            align-content: start;
            scrollbar-width: thin;
            scrollbar-color: var(--lb-a) transparent;
        }

        .lb-tile {
            position: relative;
            aspect-ratio: 1;
            border: 0;
            padding: 0;
            cursor: pointer;
            overflow: hidden;
            background-color: rgba(255, 255, 255, 0.06);
            border-radius: 14px;
            box-shadow: 0 0 0 1px rgba(243, 217, 139, 0.27);
            transition: transform 0.15s, box-shadow 0.15s;
            width: 100%;
            height: 100%;
        }

        .lb-tile:hover { transform: scale(1.20); z-index: 2; }

        .lb-tile.selected {
            outline: 3px solid var(--lb-gold);
            outline-offset: -3px;
            box-shadow: 0 0 18px rgba(243, 217, 139, 0.6);
        }

        .lb-tile img {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        /* no splash on disk (the four starter fighters): the monogram is the art */
        .lb-tile-mono {
            position: absolute;
            inset: 0;
            display: grid;
            place-items: center;
            font-family: var(--lb-head);
            font-size: 30px;
            font-weight: 800;
            color: rgba(255, 255, 255, 0.85);
            background-image: linear-gradient(150deg, hsl(var(--lb-tile-hue, 265), 55%, 34%), hsl(var(--lb-tile-hue, 265), 60%, 16%));
        }

        .lb-fighter-name {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 1;
            font-size: 87%;
            padding: 12px 2px 3px;
            background-image: linear-gradient(transparent, #9c9c9cd6);
            text-align: center;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: #1a161a;
            font-weight: bold;
        }

        .lb-off { display: none; }

        .lb-grid-empty {
            grid-column: 1 / -1;
            text-align: center;
            color: var(--lb-mut);
            padding: 50px 0;
            font-size: 20px;
        }

        .lb-podium {
            flex: 1 1 0;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            min-width: 0;
            min-height: 0;
            overflow-y: auto;
            scrollbar-width: none;
            text-align: center;
            position: relative;
        }

        .lb-podium > * { position: relative; z-index: 1; }

        /* two flexible spacers instead of justify-content: center - a centered
           flex column clips what it cannot fit, spacers collapse to nothing and
           the podium simply starts scrolling */
        .lb-podium::before,
        .lb-podium::after {
            content: "";
            flex: 1 1 0;
        }

        /* the art is bounded by the HEIGHT as well as the column: on a short
           laptop the name, the stat bars and the CTA under it must all stay on
           screen (38vh of width keeps the 5/6 frame at 46vh of height) */
        .lb-art {
            width: min(100%, 320px, 38vh);
            aspect-ratio: 5 / 6;
            position: relative;
            overflow: hidden;
            border-radius: 20px;
            box-shadow: 0 0 0 1px rgba(243, 217, 139, 0.35), 0 20px 40px hsla(var(--lb-hue), 90%, 20%, 0.55);
            animation: lbFloat 4s ease-in-out infinite;
            background-color: #0b0716;
        }

        @keyframes lbFloat {
            50% { transform: translateY(-10px); }
        }

        .lb-art img {
            position: absolute;
            inset: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            display: block;
        }

        .lb-art-mono {
            position: absolute;
            inset: 0;
            display: grid;
            place-items: center;
            font-family: var(--lb-head);
            font-size: 96px;
            font-weight: 800;
            color: rgba(255, 255, 255, 0.82);
            background-image: linear-gradient(150deg, hsl(var(--lb-mono-hue, 265), 55%, 34%), hsl(var(--lb-mono-hue, 265), 60%, 14%));
        }

        .lb-hn {
            font-family: var(--lb-head);
            font-size: clamp(26px, 4vw, 42px);
            font-weight: 900;
            letter-spacing: 0.08em;
            text-shadow: 0 0 24px var(--lb-a);
        }

        .lb-hr {
            color: var(--lb-gold);
            letter-spacing: 0.3em;
            font-weight: 700;
            font-size: 14px;
            margin: 2px 0 10px;
        }

        .lb-stats { width: min(100%, 300px); margin-bottom: 14px; }

        .lb-bar-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 4px 0; }

        .lb-bar-key { width: 48px; text-align: left; color: var(--lb-mut); }

        .lb-bar-val { text-align: right; font-variant-numeric: tabular-nums; }

        .lb-bar-track { display: flex; gap: 3px; flex: 1; }

        .lb-bar-cell { flex: 1; height: 8px; background-color: rgba(255, 255, 255, 0.11); border-radius: 99px; }

        .lb-bar-cell.on {
            background-image: linear-gradient(90deg, var(--lb-a), var(--lb-gold));
            box-shadow: 0 0 8px var(--lb-gold);
        }

        .lb-stat-trait .lb-bar-val { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

        /* --- III · realm ------------------------------------------------ */
        .lb-arena {
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 12px;
            padding: 0 12px;
            min-height: 0;
        }

        .lb-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

        .lb-tab {
            border: 1px solid rgba(243, 217, 139, 0.2);
            background-color: rgba(255, 255, 255, 0.07);
            color: var(--lb-mut);
            border-radius: 99px;
            padding: 7px 18px;
            font-size: 14px;
            font-weight: 700;
            cursor: pointer;
        }

        .lb-tab.selected { background-color: var(--lb-gold); color: #2a1546; }

        .lb-car {
            display: flex;
            gap: 18px;
            overflow-x: auto;
            scroll-snap-type: x mandatory;
            width: 100%;
            padding: 26px calc(50% - 120px);
            scrollbar-width: none;
        }

        .lb-map {
            flex: none;
            width: 230px;
            height: 320px;
            scroll-snap-align: center;
            position: relative;
            border: 0;
            padding: 0;
            cursor: pointer;
            overflow: hidden;
            opacity: 0.55;
            transform: scale(0.88);
            transition: opacity 0.3s, transform 0.3s, box-shadow 0.3s;
            border-radius: 120px 120px 18px 18px;
            box-shadow: 0 0 0 2px rgba(243, 217, 139, 0.33);
        }

        .lb-map:hover { opacity: 0.85; transform: scale(0.95); }

        .lb-map.selected {
            opacity: 1;
            transform: scale(1.04);
            box-shadow: 0 0 0 3px var(--lb-gold), 0 0 24px rgba(243, 217, 139, 0.55);
        }

        /* the arena's own palette is its thumbnail (MAPS ground / sky_tint) */
        .lb-map-art { position: absolute; inset: 0; z-index: 0; }

        /* a skyline per category, painted from the card's own colours: the
           cosmic arenas get the Cathedral's nave, the rest get their own shape */
        .lb-map-sky {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            height: 46%;
            background-color: rgba(0, 0, 0, 0.4);
        }

        .lb-map.cat-Cosmic .lb-map-sky {
            background-color: rgba(0, 0, 0, 0.45);
            clip-path: polygon(0 100%, 0 62%, 6% 62%, 6% 34%, 12% 12%, 18% 34%, 18% 62%, 27% 62%, 27% 26%, 34% 4%, 41% 26%, 41% 62%, 56% 62%, 56% 30%, 63% 10%, 70% 30%, 70% 62%, 82% 62%, 82% 40%, 88% 20%, 94% 40%, 94% 62%, 100% 62%, 100% 100%);
        }

        .lb-map.cat-Arena .lb-map-sky {
            clip-path: polygon(0 100%, 0 60%, 18% 28%, 34% 56%, 52% 16%, 70% 50%, 86% 30%, 100% 56%, 100% 100%);
        }

        .lb-map.cat-Biomes .lb-map-sky {
            clip-path: polygon(0 100%, 0 55%, 22% 15%, 38% 50%, 58% 0, 80% 45%, 100% 25%, 100% 100%);
        }

        .lb-map.cat-Structures .lb-map-sky {
            clip-path: polygon(0 100%, 0 40%, 10% 40%, 10% 18%, 22% 18%, 22% 44%, 36% 44%, 36% 8%, 50% 8%, 50% 40%, 66% 40%, 66% 22%, 80% 22%, 80% 50%, 100% 50%, 100% 100%);
        }

        .lb-map.cat-Custom .lb-map-sky {
            clip-path: polygon(0 100%, 0 48%, 14% 30%, 30% 46%, 46% 22%, 62% 44%, 78% 26%, 100% 46%, 100% 100%);
        }

        .lb-map-sky2 {
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            height: 30%;
            background-color: rgba(0, 0, 0, 0.62);
            clip-path: polygon(0 100%, 0 40%, 30% 70%, 55% 20%, 78% 60%, 100% 30%, 100% 100%);
        }

        .lb-map-gate {
            position: absolute;
            left: 50%;
            bottom: 26%;
            width: 54px;
            height: 88px;
            translate: -50% 0;
            border-radius: 27px 27px 0 0;
            background-color: rgba(243, 217, 139, 0.16);
            box-shadow: inset 0 0 22px rgba(243, 217, 139, 0.3);
        }

        .lb-map-roll {
            position: absolute;
            top: 14px;
            left: 14px;
            z-index: 2;
            font-family: var(--lb-head);
            font-size: 9px;
            font-weight: 800;
            letter-spacing: 0.16em;
            padding: 4px 9px;
            border-radius: 99px;
            background-color: rgba(5, 3, 15, 0.72);
            border: 1px solid rgba(243, 217, 139, 0.45);
            color: var(--lb-gold);
        }

        /* the label plate is the card's own ::after - the name stays the
           tile's FIRST child (scripts/lobby_check.mjs reads an arena's label
           through it), so the plate is paint, not markup order */
        .lb-map::after {
            content: "";
            position: absolute;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 2;
            height: 45%;
            background-image: linear-gradient(transparent, rgba(0, 0, 0, 0.87));
        }

        .lb-map-name {
            position: absolute;
            left: 14px;
            right: 14px;
            bottom: 32px;
            z-index: 3;
            font-family: var(--lb-head);
            font-size: 17px;
            font-weight: 900;
            letter-spacing: 0.06em;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .lb-map-fixed {
            position: absolute;
            left: 14px;
            right: 14px;
            bottom: 14px;
            z-index: 3;
            color: var(--lb-mut);
            font-size: 14px;
        }

        .lb-lines { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }

        .lb-line {
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 0;
        }

        .lb-line-label {
            font-family: var(--lb-head);
            font-size: 10px;
            font-weight: 800;
            letter-spacing: 0.2em;
            color: var(--lb-mut);
            white-space: nowrap;
        }

        .lb-seg { display: flex; gap: 6px; }

        .lb-seg-btn {
            border: 1px solid rgba(243, 217, 139, 0.24);
            background-color: rgba(255, 255, 255, 0.07);
            color: var(--lb-mut);
            border-radius: 99px;
            padding: 9px 18px;
            font-size: 15px;
            font-weight: 700;
            cursor: pointer;
        }

        .lb-seg-btn:hover:not(:disabled) { color: var(--lb-ink); }

        .lb-seg-btn.selected { background-image: linear-gradient(90deg, var(--lb-a), var(--lb-gold)); color: #2a1546; border-color: transparent; }

        .lb-seg-btn:disabled { opacity: 0.35; cursor: not-allowed; }

        /* --- IV · ordeal ------------------------------------------------ */
        .lb-diff {
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 16px;
            padding: 0 16px;
        }

        .lb-stages {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
            gap: 10px;
            width: min(100%, 900px);
        }

        .lb-stage {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 6px;
            padding: 14px 16px;
            text-align: left;
            border: 1px solid rgba(243, 217, 139, 0.24);
            border-radius: 16px;
            background-color: rgba(255, 255, 255, 0.05);
            color: inherit;
            cursor: pointer;
            transition: border-color 0.2s, background-color 0.2s, transform 0.15s;
        }

        .lb-stage:hover { transform: translateY(-2px); border-color: rgba(243, 217, 139, 0.6); }

        .lb-stage.selected {
            border-color: transparent;
            background-image: linear-gradient(150deg, hsl(var(--lb-hue), 55%, 30%), rgba(243, 217, 139, 0.16));
            box-shadow: 0 0 0 1px var(--lb-gold), 0 8px 24px rgba(0, 0, 0, 0.4);
        }

        .lb-stage > span:first-child {
            font-family: var(--lb-head);
            font-size: 18px;
            font-weight: 800;
            letter-spacing: 0.06em;
        }

        .lb-stage-meta { font-size: 12px; color: var(--lb-mut); font-variant-numeric: tabular-nums; }

        .lb-stage.selected .lb-stage-meta { color: var(--lb-gold); }

        /* --- the trail: the room's slots + the one button ---------------- */
        .lb-bar {
            flex: 0 0 auto;
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 10px 20px calc(12px + env(safe-area-inset-bottom, 0px));
            background-image: linear-gradient(transparent, rgba(0, 0, 0, 0.66));
        }

        .lb-slots { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1 1 auto; }

        .lb-party { display: flex; align-items: center; gap: 8px; min-width: 0; }

        .lb-slot {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 6px 10px 6px 6px;
            background-color: rgba(255, 255, 255, 0.06);
            border: 1px solid rgba(243, 217, 139, 0.2);
            border-radius: 14px;
            min-width: 0;
        }

        .lb-slot.me { border-color: var(--lb-gold); background-color: rgba(255, 255, 255, 0.1); }

        .lb-slot.ready { border-color: #9dffc4; box-shadow: 0 0 16px rgba(157, 255, 196, 0.33); }

        .lb-slot-art {
            position: relative;
            width: 44px;
            height: 44px;
            flex: none;
            background-color: rgba(0, 0, 0, 0.4);
            border-radius: 10px;
            overflow: hidden;
            display: grid;
            place-items: center;
            color: var(--lb-mut);
            font-family: var(--lb-head);
            font-weight: 800;
        }

        .lb-slot-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

        .lb-slot-who { min-width: 0; }

        .lb-slot-nm {
            font-weight: 700;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 15ch;
        }

        .lb-slot-sx {
            font-family: var(--lb-head);
            font-size: 10px;
            font-weight: 800;
            letter-spacing: 0.14em;
            color: var(--lb-mut);
            white-space: nowrap;
        }

        .lb-slot.ready .lb-slot-sx { color: #9dffc4; }

        .lb-foot { display: flex; align-items: center; gap: 12px; min-width: 0; }

        .lb-picked {
            font-size: 14px;
            color: var(--lb-mut);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 46ch;
        }

        .lb-picked b { color: var(--lb-ink); font-weight: 700; }

        .lb-note {
            font-size: 13px;
            color: #ffd98a;
            max-width: 40ch;
        }

        .lb-note.room-warn { color: #ff6b8e; }

        .lb-load {
            display: flex;
            align-items: center;
            gap: 8px;
            min-width: 210px;
            font-family: var(--lb-head);
            font-size: 10px;
            font-weight: 800;
            letter-spacing: 0.14em;
            color: var(--lb-mut);
        }

        .lb-load-track {
            position: relative;
            flex: 1 1 auto;
            height: 6px;
            border-radius: 99px;
            background-color: rgba(255, 255, 255, 0.12);
            overflow: hidden;
        }

        .lb-load-fill {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            width: 0%;
            border-radius: inherit;
            background-image: linear-gradient(90deg, #d9a441, var(--lb-gold), #fff0b8);
            transition: width 0.2s;
        }

        .lb-load-pct { color: var(--lb-ink); }

        .lb-buttons { display: flex; gap: 8px; }

        .lb-btn {
            font-family: var(--lb-head);
            font-size: 15px;
            font-weight: 800;
            letter-spacing: 0.14em;
            padding: 14px 30px;
            border-radius: 99px;
            border: 2px solid rgba(243, 217, 139, 0.55);
            background-color: rgba(255, 255, 255, 0.07);
            color: var(--lb-ink);
            cursor: pointer;
            transition: transform 0.15s, filter 0.2s;
        }

        .lb-btn:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.2); }

        .lb-btn:disabled { opacity: 0.45; cursor: not-allowed; }

        .lb-play {
            background-image: linear-gradient(180deg, #fff0b8, var(--lb-gold) 50%, #d9a441);
            box-shadow: 0 0 28px rgba(243, 217, 139, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.53);
        }

        /* --- best runs (★) --------------------------------------------- */
        .lb-bests {
            position: absolute;
            top: 74px;
            right: calc(16px + env(safe-area-inset-right, 0px));
            z-index: 5;
            width: 320px;
            max-height: min(60vh, 460px);
            overflow-y: auto;
            border: 1px solid rgba(243, 217, 139, 0.35);
            border-radius: 16px;
            background-color: rgba(10, 7, 26, 0.95);
            box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
        }

        .lb-bests-head {
            font-family: var(--lb-head);
            font-size: 13px;
            font-weight: 800;
            letter-spacing: 0.2em;
            padding: 12px 14px;
            color: var(--lb-gold);
            border-bottom: 1px solid rgba(243, 217, 139, 0.2);
        }

        .lb-bests-body { padding: 6px 8px 10px; }

        .lb-run-row {
            display: grid;
            grid-template-columns: 1fr auto auto;
            gap: 10px;
            padding: 7px 6px;
            font-size: 14px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        }

        .lb-run-row span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

        .lb-run-wave { color: var(--lb-gold); font-variant-numeric: tabular-nums; }

        .lb-run-kills { color: var(--lb-mut); font-variant-numeric: tabular-nums; }

        .lb-empty { color: var(--lb-mut); padding: 12px 6px; text-align: center; }

        /* --- the gate: the beat between Play and the first tick --------- */
        .lb-gate {
            position: fixed;
            inset: 0;
            z-index: 300;
            display: none;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 18px;
            text-align: center;
            background-color: rgba(5, 4, 26, 0.95);
            color: var(--lb-ink);
            font-family: var(--lb-body);
        }

        .lb-gate.on { display: flex; animation: lbGate 1.5s ease forwards; }

        @keyframes lbGate {
            0% { opacity: 1; }
            70% { opacity: 1; }
            100% { opacity: 0; }
        }

        .lb-gate-title {
            font-family: var(--lb-head);
            font-size: clamp(30px, 7vw, 68px);
            font-weight: 900;
            letter-spacing: 0.1em;
            background-image: linear-gradient(90deg, hsl(265, 75%, 70%), #f3d98b);
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            animation: lbPop 0.5s;
        }

        @keyframes lbPop {
            from { transform: scale(2.5); opacity: 0; }
        }

        .lb-gate-vs { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

        .lb-gate-vs > div {
            width: clamp(54px, 12vw, 96px);
            aspect-ratio: 1;
            border-radius: 50%;
            overflow: hidden;
            position: relative;
            background-color: rgba(255, 255, 255, 0.06);
            animation: lbPop 0.6s backwards;
            box-shadow: 0 0 0 3px #f3d98b;
        }

        .lb-gate-vs img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
