        /* ------------------------------------------- event banner (flash) */
        .event-banner {
            position: fixed;
            top: 16%;
            left: 50%;
            transform: translateX(-50%);
            font-size: 28px;
            font-weight: bold;
            letter-spacing: 1px;
            text-shadow: 0 0 10px #000, 0 2px 4px #000;
            z-index: 200;
            pointer-events: none;
            animation: event-banner-fade 2.6s ease-out forwards;
        }

        /* boss entrance: bigger, blood red, holds ~4 s */
        .event-banner.boss-banner {
            font-size: 40px;
            letter-spacing: 3px;
            text-shadow: 0 0 18px rgba(255, 40, 40, 0.8), 0 2px 6px #000;
            animation: event-banner-fade 4s ease-out forwards;
        }

        /* a two-line row ("NAME\nwave title") is a head plus a context line:
           the head carries the read, so it is the bigger half. display:block
           is also what makes the author's newline a line break at all. */
        .eb-title { display: block; font-size: 1.2em; letter-spacing: 2px; }

        .eb-sub {
            display: block;
            font-size: 0.72em;
            font-weight: normal;
            letter-spacing: 1px;
            opacity: 0.85;
            margin-top: 3px;
        }

        @keyframes event-banner-fade {
            0%   { opacity: 0; transform: translateX(-50%) scale(0.9); }
            10%  { opacity: 1; transform: translateX(-50%) scale(1.05); }
            20%  { transform: translateX(-50%) scale(1); }
            75%  { opacity: 1; }
            100% { opacity: 0; transform: translateX(-50%) scale(1); }
        }

        /* ------------------------------------------- revive channel (dead) */
        .revive-bar {
            position: absolute;
            width: 74px;
            height: 9px;
            background-color: rgba(0, 0, 0, 0.8);
            border: 1px solid #7fff9f;
            border-radius: 5px;
            transform: translate(-50%, -50%);
            z-index: 11;
            display: none;
            overflow: hidden;
            pointer-events: none;
        }

        .revive-bar-inner {
            height: 100%;
            width: 0%;
            background: linear-gradient(90deg, #2ecc71, #a8ffbf);
            transition: width 0.2s linear;
        }

        .revive-label {
            position: absolute;
            transform: translate(-50%, -100%);
            font-size: 12px;
            font-weight: bold;
            color: #b6ffce;
            text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, 0.9);
            white-space: nowrap;
            z-index: 11;
            display: none;
        }

        /* ------------------------------------------- floating windows (common) */
        .window-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 10px;
            background-color: rgba(255, 255, 255, 0.08);
            padding: 8px 12px;
            cursor: grab;
            font-weight: bold;
            font-size: 13px;
            border-bottom: 1px solid #3a3a3a;
            user-select: none;
        }

        .window-header:active { cursor: grabbing; }

        .floating-window {
            position: absolute;
            background-color: rgba(12, 12, 16, 0.94);
            border: 1px solid #4a4a55;
            border-radius: 10px;
            box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
            display: none;
        }

        /* --------------------------------------------- level-up window (right) */
        #level-up-modal {
            right: 16px;
            top: 90px;
            width: 320px;
            /* two columns (weapon + passive) can hold six cards: cap the
               window to the viewport and scroll instead of overflowing */
            max-height: calc(100vh - 110px);
            overflow-y: auto;
            z-index: 160;
            flex-direction: column; /* JS shows it with display:flex */
        }

        #level-up-team {
            font-size: 11px;
            color: #aaa;
            padding: 6px 12px;
            min-height: 18px;
        }

        #level-up-options {
            display: flex;
            flex-direction: column;
            gap: 8px;
            padding: 10px 12px 12px;
        }

        /* two selection columns: one weapon upgrade AND one passive upgrade
           per level (server: game_logic/systems/level_up.py) */
        #level-up-options .lu-section-title {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 1.5px;
            color: #8fa7c9;
            font-weight: bold;
            margin-top: 4px;
        }

        #level-up-options .lu-section-title:first-child { margin-top: 0; }

        #level-up-options .lu-empty {
            font-size: 11px;
            color: #666;
            font-style: italic;
        }

        .level-up-option {
            position: relative;
            background-color: #23232b;
            border: 1px solid #3d3d4a;
            padding: 10px 12px;
            border-radius: 6px;
            cursor: pointer;
            transition: background-color 0.15s, border-color 0.15s;
        }

        .level-up-option:hover {
            background-color: #34343f;
            border-color: #7a7a95;
        }

        /* picked card: the locked choice of a column (glow + check) */
        .level-up-option.lu-picked {
            background-color: #2a3a2a;
            border-color: #7dffa8;
            box-shadow: 0 0 10px rgba(125, 255, 168, 0.25);
        }

        /* unpicked cards of a locked column: the pick is final, they fade */
        .level-up-option.lu-dimmed {
            opacity: 0.35;
            cursor: default;
            pointer-events: none;
        }

        /* 1/2/3/4/5/6 shortcut badge (top-right of each option) */
        .lu-key {
            position: absolute;
            top: 8px;
            right: 10px;
            min-width: 22px;
            height: 22px;
            line-height: 22px;
            text-align: center;
            font-size: 13px;
            font-weight: bold;
            color: #1a1a1a;
            background: #ffd54a;
            border-radius: 4px;
            padding: 0 5px;
        }

        .lu-kind {
            display: inline-block;
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 1px;
            border-radius: 3px;
            padding: 1px 7px;
            margin-bottom: 5px;
        }

        .lu-kind.kind-passive { background-color: #1d3a2a; color: #7dffa8; }

        .lu-kind.kind-weapon  { background-color: #3a2d1d; color: #ffcf7d; }

        .lu-name { font-size: 15px; font-weight: bold; margin-bottom: 3px; }

        .lu-desc { font-size: 12.5px; color: #ccc; line-height: 1.4; }

        /* the weapon row's one-line rule (data/weapons.py "effect") */
        .lu-effect { font-size: 12px; color: #a9c4e6; margin-top: 3px; line-height: 1.35; }

        /* item card art (data/weapons.py "icon"): floats right so the text
           wraps around it and the card reads like the item it is */
        .lu-icon {
            float: right;
            width: 48px;
            height: 48px;
            margin: 0 0 6px 10px;
            border-radius: 4px;
            border: 1px solid #4a4a5a;
            background-color: #141414;
            image-rendering: pixelated;
        }

        .lu-scaling { font-size: 11px; color: #8fa7c9; margin-top: 4px; }

        /* weapon rarity tag (appearance weight; tier colors below) */
        .lu-rarity { font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
                     margin-top: 4px; }

        .lu-rarity.rarity-common     { color: #9aa7b8; }

        .lu-rarity.rarity-uncommon   { color: #7dffa8; }

        .lu-rarity.rarity-rare       { color: #6db3ff; }

        .lu-rarity.rarity-epic       { color: #c58aff; }

        .lu-rarity.rarity-legendary  { color: #ffb347; }

        .lu-rarity.rarity-mythic     { color: #ff6d8a; }

        /* Roll button: re-draw this selection's offers. No timer to race -
           the window waits for the pick (public/levelup_ui.js), so the only
           cost of rolling is the offers themselves */
        #level-up-roll {
            margin: 0 12px 12px;
            padding: 7px 10px;
            font-size: 12px;
            font-weight: bold;
            letter-spacing: 1px;
            text-transform: uppercase;
            color: #1a1a1a;
            background: #ffd54a;
            border: 1px solid #b89a2e;
            border-radius: 6px;
            cursor: pointer;
            transition: background-color 0.15s;
        }

        #level-up-roll:hover { background: #ffe27d; }

        /* the SPACE keycap inside the Roll button (input.js fires the same
           roll the click does); inline so the button keeps its own line */
        #level-up-roll .lu-roll-key {
            margin-left: 7px;
            padding: 1px 5px;
            font-size: 10px;
            letter-spacing: 0;
            color: #6b5210;
            background: rgba(255, 255, 255, 0.55);
            border: 1px solid rgba(120, 92, 8, 0.5);
            border-radius: 4px;
        }

        /* locked after the first pick: picks are final, nothing left to draw */
        #level-up-roll:disabled {
            opacity: 0.4;
            cursor: default;
            background: #ffd54a;
        }

        /* "5/5" - what this selection has LEFT to re-draw with
           (game_logic/swarm.py LEVEL_UP_ROLLS; the count rides the level_up
           message, so the button can never claim a roll the server won't give) */
        #level-up-roll .lu-roll-count {
            margin-left: 7px;
            font-size: 11px;
            letter-spacing: 0;
            color: #6b5210;
        }

        /* the budget is spent: the label goes red and the count says 0/5 - the
           fighter's next roll is a new selection's problem (her pick re-arms it) */
        #level-up-roll.lu-roll-spent { background: #b9b9b9; border-color: #7c7c7c; }
        #level-up-roll.lu-roll-spent .lu-roll-count { color: #7a1f1f; }

        /* ------------------------------------------------- scoreboard (TAB) */
        #scoreboard {
            left: 50%;
            top: 18%;
            transform: translateX(-50%);
            width: 720px;
            max-width: 92vw;
            z-index: 150;
        }

        /* transform: translateX breaks px math when dragging: the drag code
           clears it (sets transform:none) on first drag */
        #scoreboard-body {
            padding: 8px 12px;
            max-height: 50vh;
            overflow-y: auto;
        }

        .sb-row {
            /* the numbers line. The loadout is NOT a column here: a fighter
               carries up to 20 weapons and a text column per loadout wrapped
               into unreadable comma soup - each player gets a second line for
               it (.sb-loadout below) */
            display: grid;
            grid-template-columns: 150px 40px 96px 96px 52px 48px;
            gap: 8px;
            align-items: center;
            font-size: 11px;
            padding: 5px 4px;
            border-bottom: 1px solid #1c1c22;
        }

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

        .sb-row.sb-head {
            color: #8a8a95;
            text-transform: uppercase;
            font-size: 9px;
            letter-spacing: 1px;
        }

        .sb-row.sb-me { background-color: rgba(76, 175, 80, 0.10); }

        /* the line under each player: what they are CARRYING (public/hud.js
           buildScoreboard) - weapon slots (the HUD's own .weapon-slot, drawn
           smaller via .sb-slot), passive chips and the stat boosts the fallback
           column hands out. It is a line of its own because the loadout is the
           part a party actually reads off TAB, and 20 of anything does not fit
           a column. */
        .sb-loadout {
            display: flex;
            flex-wrap: wrap;
            gap: 12px;
            align-items: center;
            padding: 3px 4px 8px;
            border-bottom: 1px solid #26262e;
        }

        .sb-strip { display: flex; align-items: center; gap: 6px; min-width: 0; }

        .sb-strip-label {
            color: #8a8a95;
            text-transform: uppercase;
            font-size: 9px;
            letter-spacing: 1px;
            white-space: nowrap;
        }

        .sb-strip-body { display: flex; flex-wrap: wrap; gap: 3px; min-width: 0; }

        .sb-empty { color: #5a5a63; font-size: 11px; }

        /* the HUD's weapon slot, smaller: the TAB panel lists several fighters
           at once, so the art shrinks and the ring / pip stay */
        .weapon-slot.sb-slot { width: 24px; height: 24px; }
        .weapon-slot.sb-slot .weapon-icon { width: 20px; height: 20px; }
        .weapon-slot.sb-slot .weapon-level { font-size: 9px; }

        .sb-chip {
            font-size: 10px;
            white-space: nowrap;
            padding: 1px 6px;
            border-radius: 4px;
            background-color: #2b2b2b;
            border: 1px solid #555;
            color: #e8e8e8;
        }

        .sb-chip.sb-chip-boost {
            background-color: #1d2a1d;
            border-color: #4caf50;
            color: #a8e6a0;
        }

        #scoreboard-legend {
            font-size: 10px;
            color: #8a8a95;
            padding: 6px 12px;
            border-top: 1px solid #3a3a3a;
        }

        /* quick legend (TAB): the stat types that improve each owned weapon */
        #scoreboard-weapon-legend {
            font-size: 10px;
            color: #a9b6c9;
            padding: 0 12px 6px;
            line-height: 1.5;
        }

        #scoreboard-weapon-legend:empty { display: none; }

        /* ------------------------------------- spectate / dead hint ---- */
        #spectate-hint {
            position: absolute;
            top: 64px;
            left: 50%;
            transform: translateX(-50%);
            background-color: rgba(10, 6, 24, 0.78);
            border: 1px solid var(--line);
            border-radius: 99px;
            padding: 6px 16px;
            font-size: 13px;
            font-weight: bold;
            color: #ffd7d7;
            text-shadow: 0 1px 2px #000;
            z-index: 60;
            display: none;
            text-align: center;
        }

        #spectate-hint.spectating { color: #b6d9ff; border-color: #3a4a5a; }

        /* pause button: the Esc key does not exist on a phone - the button
           opens the same room-pause menu (and the room pause is what
           pauses the sim, the banner comes from the `paused` broadcast) */
        #pause-button {
            position: absolute;
            top: 10px;
            /* right of the (in-game shifted) settings gear: toggle ~56px +
               gap + gear 44px + gap */
            right: calc(118px + env(safe-area-inset-right, 0px));
            z-index: 61;
            width: 44px;
            height: 44px;
            border-radius: 50%;
            border: 1px solid var(--line);
            background-image: linear-gradient(160deg, var(--panel-a), var(--panel-b));
            color: var(--gold);
            font-size: 17px;
            line-height: 1;
            cursor: pointer;
            touch-action: manipulation;
            user-select: none;
            -webkit-user-select: none;
            -webkit-tap-highlight-color: transparent;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
        }

        #pause-button:active { color: var(--gold-hi); border-color: var(--gold); }

        /* ------------------------------------------ settings (gear) ---- */
        /* lobby + in-game; in-game it sits left of the ability-side toggle */
        #settings-gear {
            position: fixed;
            top: 10px;
            right: 10px;
            z-index: 260;
            width: 44px;
            height: 44px;
            border-radius: 50%;
            border: 1px solid var(--line);
            background-image: linear-gradient(160deg, var(--panel-a), var(--panel-b));
            color: var(--gold);
            font-size: 20px;
            line-height: 1;
            cursor: pointer;
        }

        #settings-gear:hover { color: var(--gold-hi); border-color: var(--gold); }

        #settings-menu {
            position: fixed;
            top: 62px;
            right: 10px;
            z-index: 261;
            width: 274px;
            display: none;
            background-color: rgba(12, 14, 22, 0.97);
            border: 1px solid #4a4a58;
            border-radius: 10px;
            box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
            color: #dfe4ee;
            font-size: 13px;
        }

        .settings-header {
            padding: 10px 14px;
            font-weight: bold;
            border-bottom: 1px solid #33333f;
        }

        .settings-body { padding: 6px 14px; max-height: 62vh; overflow-y: auto; }

        .settings-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; }

        .settings-label { flex: 0 0 92px; color: #9aa3b2; }

        .settings-row select, .settings-row input[type=range] { flex: 1; min-width: 0; }

        .settings-row select { background: #1a1d29; color: #dfe4ee; border: 1px solid #44485a; border-radius: 5px; padding: 3px; }

        .settings-value { width: 46px; text-align: right; color: #9aa3b2; font-size: 12px; }

        .settings-footer { padding: 10px 14px; border-top: 1px solid #33333f; }

        .settings-footer button {
            width: 100%; padding: 7px 0; border-radius: 7px;
            border: 1px solid #5a5a66; background-color: rgba(40, 44, 60, 0.9);
            color: #fff; font-size: 12px; font-weight: bold; cursor: pointer;
        }

        .settings-footer button:hover { background-color: rgba(70, 78, 105, 0.95); }

        /* ------------------------------------------ pause menu (Esc) --- */
        #pause-menu {
            position: fixed;
            inset: 0;
            background-color: rgba(5, 6, 12, 0.78);
            z-index: 250;
            display: none;
            align-items: center;
            justify-content: center;
        }

        #pause-card {
            width: min(360px, calc(100vw - 40px));
            background-color: rgba(14, 16, 26, 0.98);
            border: 1px solid #4a4a58;
            border-radius: 12px;
            padding: 22px 26px;
            text-align: center;
            box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
            color: #fff;
        }

        #pause-title { font-size: 26px; font-weight: bold; letter-spacing: 3px; margin-bottom: 8px; }

        #pause-sub { color: #9aa3b2; font-size: 13px; margin-bottom: 18px; line-height: 1.5; }

        #pause-menu button {
            display: block; width: 100%; margin: 8px 0; padding: 10px 0;
            border-radius: 8px; border: 1px solid #5a5a66;
            background-color: rgba(40, 44, 60, 0.9); color: #fff;
            font-size: 14px; font-weight: bold; cursor: pointer;
        }

        #pause-menu button:hover { background-color: rgba(70, 78, 105, 0.95); }

        #pause-lobby-button { border-color: #7a4a4a; background-color: rgba(70, 40, 40, 0.8); }

        /* the current spectate target's name, near the crosshair */
        #spectate-target {
            position: absolute;
            top: 104px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 59;
            background-color: rgba(0, 0, 0, 0.65);
            border: 1px solid #3a4a5a;
            border-radius: 8px;
            padding: 4px 12px;
            font-size: 12px;
            font-weight: bold;
            color: #b6d9ff;
            display: none;
            white-space: nowrap;
        }

        /* wire-version guard: this cached client cannot decode the server's
           newer wire format - refuse to render the world, offer a reload */
        #wire-mismatch {
            position: fixed;
            inset: 0;
            background-color: rgba(3, 4, 8, 0.95);
            z-index: 400;
            display: none;
            align-items: center;
            justify-content: center;
            text-align: center;
            color: #fff;
        }

        #wire-mismatch-card {
            width: min(420px, calc(100vw - 40px));
            background-color: rgba(22, 18, 10, 0.98);
            border: 1px solid #8a6a2a;
            border-radius: 12px;
            padding: 26px 30px;
            line-height: 1.5;
            font-size: 14px;
        }

        #wire-mismatch-card .wm-title { font-size: 20px; font-weight: bold; margin-bottom: 10px; }

        #wire-mismatch-version { font-family: monospace; color: #ffd78a; margin-bottom: 10px; }

        #wire-mismatch-reload {
            margin-top: 16px; padding: 10px 34px;
            border-radius: 8px; border: 1px solid #8a6a2a;
            background-color: rgba(140, 100, 30, 0.9); color: #fff;
            font-size: 15px; font-weight: bold; cursor: pointer;
        }

        #wire-mismatch-reload:hover { background-color: rgba(170, 125, 40, 0.95); }

        /* ------------------------------------------- game over (end) --- */
        #game-over-screen {
            position: fixed;
            inset: 0;
            background-color: rgba(0, 0, 0, 0.72);
            z-index: 300;
            display: none;
            align-items: center;
            justify-content: center;
        }

        #game-over-card {
            background-color: rgba(14, 14, 20, 0.97);
            border: 1px solid #4a4a55;
            border-radius: 14px;
            box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
            padding: 26px 34px;
            min-width: 420px;
            max-width: 92vw;
            max-height: 90vh;
            overflow-y: auto;
            text-align: center;
        }

        #game-over-title {
            font-size: 44px;
            font-weight: bold;
            letter-spacing: 4px;
            text-shadow: 0 2px 8px #000;
        }

        #game-over-title.go-win { color: #ffd54a; }

        #game-over-title.go-lose { color: #ff6b6b; }

        #game-over-sub {
            font-size: 13px;
            color: #b9b9c5;
            margin: 6px 0 16px;
        }

        #game-over-stats {
            display: flex;
            gap: 10px;
            justify-content: center;
            margin-bottom: 16px;
            flex-wrap: wrap;
        }

        .go-stat {
            background-color: rgba(255, 255, 255, 0.06);
            border: 1px solid #3a3a44;
            border-radius: 8px;
            padding: 8px 14px;
            min-width: 90px;
        }

        .go-stat-value { font-size: 20px; font-weight: bold; color: #ffd54a; }

        .go-stat-label {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: #8a8a95;
        }

        #game-over-scoreboard { margin-bottom: 18px; }

        .go-sb-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 13px;
        }

        .go-sb-table th {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: #8a8a95;
            text-align: left;
            padding: 4px 8px;
            border-bottom: 1px solid #3a3a44;
        }

        .go-sb-table td {
            padding: 5px 8px;
            border-bottom: 1px solid #26262e;
            color: #e8e8e8;
        }

        .go-sb-table tr.go-me td { background-color: rgba(76, 175, 80, 0.12); }

        #game-over-actions {
            display: flex;
            gap: 12px;
            justify-content: center;
        }

        #game-over-actions button {
            padding: 10px 22px;
            border-radius: 8px;
            border: none;
            font-size: 15px;
            font-weight: bold;
            cursor: pointer;
        }

        #play-again-button { background-color: #4CAF50; color: white; }
