/* ============================================================
   Prey or Perish — dark neon UI
   IDs/classes referenced by app.js are preserved:
   #startMenuWrapper (max-height toggle), #settings (max-height toggle),
   #playerNameInput, #startButton, #spectateButton, #settingsButton,
   .input-error, #gameAreaWrapper, #status, .chatbox
   ============================================================ */

:root {
    --bg-0: #05060a;
    --bg-1: #0c0f16;
    --panel: rgba(16, 20, 28, 0.72);
    --panel-border: rgba(120, 255, 200, 0.18);
    --text: #e6edf3;
    --text-dim: #93a1b0;
    --green: #4a64ff;
    --green-2: #2740ff;
    --green-rgb: 74, 100, 255;
    --cyan: #8529fd;
    --red: #ff693c;
    --red-2: #e0511f;
    --red-rgb: 255, 105, 60;

    /* Start-menu accent palette (neon blue / violet / orange).
       Used ONLY by the registration/start screen, not the in-game HUD. */
    --m-blue: #2740ff;
    --m-blue-2: #1a2fd0;
    --m-blue-rgb: 39, 64, 255;
    --m-violet: #8529fd;
    --m-orange: #ff693c;
    --m-orange-2: #e0511f;
    --m-orange-rgb: 255, 105, 60;
}

* {
    font-family: 'Rubik', system-ui, -apple-system, Segoe UI, sans-serif;
    font-size: 14px;
    box-sizing: border-box;
}

html {
    height: 100%;
    background: var(--bg-0);
}
html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    color: var(--text);
}

body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: transparent;
}

/* When the soft keyboard is open (touch), lift the form to the top so the name
   field stays visible above the keyboard. */
body.kb {
    align-items: flex-start;
}
body.kb #brandLogo { display: none; }
body.kb #startMenuWrapper { margin-top: 10px; }

/* Full-screen fixed background layer (gradients + dot grid). Fixed so it always
   covers the visible viewport on mobile, regardless of content height. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(1000px 700px at 16% 10%, rgba(var(--m-blue-rgb), 0.30), transparent 58%),
        radial-gradient(900px 700px at 86% 90%, rgba(var(--m-orange-rgb), 0.26), transparent 58%),
        radial-gradient(800px 600px at 82% 12%, rgba(155, 107, 255, 0.22), transparent 58%),
        radial-gradient(800px 600px at 12% 88%, rgba(var(--m-orange-rgb), 0.16), transparent 58%),
        radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: auto, auto, auto, auto, 26px 26px;
    pointer-events: none;
    z-index: 0;
}

canvas {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

div {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ---------- Start menu ---------- */

#startMenuWrapper {
    position: relative;
    z-index: 2;
    transition: max-height 1s;
    overflow: hidden;
}

/* decorative floating blobs */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(6px);
    opacity: 0.8;
    pointer-events: none;
    z-index: 0;
    animation: float 14s ease-in-out infinite;
}
.blob--green { width: 150px; height: 150px; left: 12%; top: 22%;
    background: radial-gradient(circle at 35% 32%, #c2c9ff, var(--m-blue));
    box-shadow: 0 0 90px 30px rgba(var(--m-blue-rgb), 0.45); }
.blob--red   { width: 200px; height: 200px; right: 10%; bottom: 16%;
    background: radial-gradient(circle at 35% 32%, #ffd0a8, var(--m-orange));
    box-shadow: 0 0 110px 40px rgba(var(--m-orange-rgb), 0.45);
    animation-delay: -4s; animation-duration: 18s; }
.blob--cyan  { width: 110px; height: 110px; right: 22%; top: 18%;
    background: radial-gradient(circle at 35% 32%, #d6c4ff, var(--m-violet));
    box-shadow: 0 0 80px 26px rgba(155, 107, 255, 0.4);
    animation-delay: -8s; animation-duration: 16s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(20px, -26px) scale(1.08); }
    66%      { transform: translate(-18px, 16px) scale(0.94); }
}

/* Side banner on the auth screen — orange pitch on a translucent panel. */
#sideBanner {
    position: fixed;
    right: 24px;
    top: 16%;
    width: 250px;
    z-index: 2;
    padding: 18px 20px;
    border-radius: 16px;
    background: rgba(10, 13, 18, 0.55);
    border: 1px solid rgba(var(--m-orange-rgb), 0.4);
    box-shadow: 0 12px 44px rgba(0, 0, 0, 0.5), 0 0 40px rgba(var(--m-orange-rgb), 0.12);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: var(--m-orange);
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 13px;
    line-height: 1.55;
}
/* Not on the small-screen (<768) "use a bigger screen" block, nor once in-game. */
@media (max-width: 767px) { #sideBanner { display: none; } }

/* Hide all menu decoration once the game is running */
body.in-game .blob,
body.in-game #sideBanner { display: none; }
body.in-game::before { display: none; }
body.in-game { background: #05060a; height: var(--app-h, 100dvh); }

@property --angle {
    syntax: "<angle>";
    initial-value: 0deg;
    inherits: false;
}

#startMenu {
    position: relative;
    z-index: 1;
    margin: auto;
    width: 410px;
    max-width: calc(100vw - 32px);
    padding: 32px 28px 26px;
    border-radius: 20px;
    background: var(--panel);
    border: 1px solid transparent;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow:
        0 40px 100px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 0 90px rgba(var(--m-blue-rgb), 0.10) inset;
}

/* rotating neon gradient border */
#startMenu::before {
    content: "";
    position: absolute;
    inset: -1.5px;
    border-radius: inherit;
    padding: 1.5px;
    background: conic-gradient(from var(--angle),
        var(--m-blue), var(--m-violet), var(--m-orange), var(--m-blue));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask-composite: exclude;
    animation: rotateBorder 7s linear infinite;
    pointer-events: none;
    z-index: 2;
    opacity: 0.9;
}
/* soft outer halo of the same gradient */
#startMenu::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: conic-gradient(from var(--angle),
        var(--m-blue), var(--m-violet), var(--m-orange), var(--m-blue));
    filter: blur(18px);
    opacity: 0.35;
    z-index: -1;
    animation: rotateBorder 7s linear infinite;
    pointer-events: none;
}
@keyframes rotateBorder {
    to { --angle: 360deg; }
}

/* ---------- Brand logo (above the card, on the background) ---------- */

#brandLogo {
    display: block;
    margin: 0 auto -6px;
    width: 300px;
    max-width: 78%;
    height: auto;
    pointer-events: none;
    filter: drop-shadow(0 6px 26px rgba(var(--m-blue-rgb), 0.45));
    position: relative;
    z-index: 1;
}

/* ---------- Brand title ---------- */

.brand {
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 46px;
    line-height: 1;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 12px;
}
.brand .prey {
    background: linear-gradient(180deg, #dfe3ff 0%, var(--m-blue) 55%, var(--m-blue-2) 100%);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--m-blue);
    filter: drop-shadow(0 0 10px rgba(var(--m-blue-rgb), 0.75));
    animation: pulseGreen 2.8s ease-in-out infinite;
}
.brand .perish {
    background: linear-gradient(180deg, #ffe6d0 0%, var(--m-orange) 55%, var(--m-orange-2) 100%);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--m-orange);
    filter: drop-shadow(0 0 10px rgba(var(--m-orange-rgb), 0.75));
    animation: pulseRed 2.8s ease-in-out infinite;
}
.brand .orr {
    font-family: 'Rubik', sans-serif;
    font-weight: 500;
    font-style: italic;
    font-size: 17px;
    color: var(--text-dim);
    filter: none;
}
@keyframes pulseGreen {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(var(--m-blue-rgb), 0.6)); }
    50%      { filter: drop-shadow(0 0 18px rgba(var(--m-blue-rgb), 1)) drop-shadow(0 0 36px rgba(var(--m-blue-rgb), 0.5)); }
}
@keyframes pulseRed {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(var(--m-orange-rgb), 0.6)); }
    50%      { filter: drop-shadow(0 0 18px rgba(var(--m-orange-rgb), 1)) drop-shadow(0 0 36px rgba(var(--m-orange-rgb), 0.5)); }
}

.tagline {
    text-align: center;
    margin: 0 0 22px;
    font-family: 'Rubik', sans-serif;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.35;
    letter-spacing: 0.3px;
    color: #ffd9a8;
    background: linear-gradient(90deg, var(--m-blue) 0%, #ffb877 50%, var(--m-orange) 100%);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(var(--m-orange-rgb), 0.45));
}

/* ---------- Live reward pool (start screen, under the tagline) ----------
   Sits directly beneath the rewards promise, so the claim and the number are
   read as one sentence. Hidden by an inline style until the server sends a
   figure; the display value below is what it un-hides to. */
.menu-pool {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: -12px 0 20px;
    padding: 10px 14px;
    border-radius: 13px;
    background: rgba(8, 11, 16, 0.6);
    border: 1px solid rgba(var(--m-orange-rgb), 0.35);
    box-shadow: 0 0 26px rgba(var(--m-orange-rgb), 0.12) inset;
}
.menu-pool .mp-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--text-dim);
}
.menu-pool .mp-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 0.5px;
    color: #ffd9a8;
    text-shadow: 0 0 16px rgba(var(--m-orange-rgb), 0.55);
}
.menu-pool .mp-unit { font-size: 13px; font-weight: 700; color: var(--m-orange); }
/* Token leg of the creator fees — its own line, deliberately not added into
   the ETH figure (that would need a price nobody here has). */
.menu-pool .mp-alt {
    flex-basis: 100%;
    text-align: center;
    font-family: 'Rubik', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--m-violet);
}

/* ---------- Leaderboard link (start screen) ----------
   Tertiary next to Play and Rules: same shape and rhythm as the buttons, but
   violet and quieter, so it reads as "somewhere else to go" rather than a
   third thing to press before playing. */
#leaderboardLink.menu-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px auto 0;
    width: 100%;
    height: 48px;
    font-family: 'Orbitron', sans-serif;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--m-violet);
    background: rgba(133, 41, 253, 0.08);
    border-radius: 13px;
    box-shadow: 0 0 0 1px rgba(133, 41, 253, 0.45) inset;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.25s ease, background 0.25s ease;
}
#leaderboardLink.menu-link:hover {
    transform: translateY(-2px);
    background: rgba(133, 41, 253, 0.18);
    box-shadow: 0 8px 22px rgba(133, 41, 253, 0.28), 0 0 0 1px rgba(133, 41, 253, 0.7) inset;
}
#leaderboardLink.menu-link:active { transform: translateY(0); }
#leaderboardLink .ml-ico { font-size: 15px; line-height: 1; }

/* ---------- Name input ---------- */

#playerNameInput {
    width: 100%;
    text-align: center;
    padding: 13px;
    color: var(--text);
    background: rgba(8, 11, 16, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    transition: box-shadow 0.25s, border 0.25s;
    margin-bottom: 6px;
    outline: none;
    font-size: 15px;
}
#playerNameInput::placeholder { color: #5e6b78; }
#playerNameInput:focus, #playerNameInput.focus {
    border-color: rgba(var(--m-blue-rgb), 0.7);
    box-shadow: 0 0 0 3px rgba(var(--m-blue-rgb), 0.16), 0 0 18px rgba(var(--m-blue-rgb), 0.25);
}

/* Name field + cell-colour swatch */
.name-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 6px;
}
.name-row #playerNameInput {
    flex: 1;
    width: auto;
    margin-bottom: 0;
}
/* The colour input is the visible swatch (works on desktop + touch). */
#colorPicker.swatch {
    flex: 0 0 52px;
    width: 52px;
    height: auto;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(8, 11, 16, 0.85);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.2s ease;
}
#colorPicker.swatch:hover { transform: translateY(-1px); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22); }
#colorPicker.swatch::-webkit-color-swatch-wrapper { padding: 0; }
#colorPicker.swatch::-webkit-color-swatch { border: none; border-radius: 8px; }
#colorPicker.swatch::-moz-color-swatch { border: none; border-radius: 8px; }

/* ---------- Buttons ---------- */

#startButton, #spectateButton, #settingsButton {
    position: relative;
    display: block;
    overflow: hidden;
    margin: 12px auto 0;
    width: 100%;
    height: 54px;
    font-family: 'Orbitron', sans-serif;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
    color: #ffffff;
    border: 0;
    border-radius: 13px;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.25s ease, filter 0.25s ease;
}

/* Play — neon blue-violet with idle glow pulse + running sheen */
#startButton {
    background: linear-gradient(135deg, #8a97ff, var(--m-blue) 45%, var(--m-blue-2));
    box-shadow: 0 10px 28px rgba(var(--m-blue-rgb), 0.45), 0 0 0 1px rgba(var(--m-blue-rgb), 0.6) inset;
    will-change: box-shadow;
    animation: playGlow 3.4s ease-in-out infinite;
}
#startButton::after {
    content: "";
    position: absolute;
    top: -20%;
    left: 0;
    width: 45%;
    height: 140%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    transform: translateX(-260%) skewX(-22deg);
    will-change: transform;
    animation: sheen 4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
#startButton:hover { transform: translateY(-3px) scale(1.015); filter: brightness(1.1);
    box-shadow: 0 16px 38px rgba(var(--m-blue-rgb), 0.6), 0 0 30px rgba(var(--m-blue-rgb), 0.55); }
#startButton:active { transform: translateY(0) scale(1); }
@keyframes playGlow {
    0%, 100% { box-shadow: 0 10px 28px rgba(var(--m-blue-rgb), 0.42), 0 0 0 1px rgba(var(--m-blue-rgb), 0.6) inset; }
    50%      { box-shadow: 0 13px 34px rgba(var(--m-blue-rgb), 0.6), 0 0 22px rgba(var(--m-blue-rgb), 0.45), 0 0 0 1px rgba(var(--m-blue-rgb), 0.75) inset; }
}
@keyframes sheen {
    0%   { transform: translateX(-260%) skewX(-22deg); }
    45%  { transform: translateX(460%) skewX(-22deg); }
    100% { transform: translateX(460%) skewX(-22deg); }
}

/* Spectate — orange outline / ghost */
#spectateButton {
    color: var(--m-orange);
    background: rgba(var(--m-orange-rgb), 0.07);
    box-shadow: 0 0 0 1px rgba(var(--m-orange-rgb), 0.45) inset;
}
#spectateButton:hover { transform: translateY(-2px);
    background: rgba(var(--m-orange-rgb), 0.16);
    box-shadow: 0 8px 22px rgba(var(--m-orange-rgb), 0.25), 0 0 0 1px rgba(var(--m-orange-rgb), 0.7) inset; }
#spectateButton:active { transform: translateY(0); }

/* How to hunt — orange outline */
#settingsButton {
    color: var(--m-orange);
    background: rgba(var(--m-orange-rgb), 0.07);
    box-shadow: 0 0 0 1px rgba(var(--m-orange-rgb), 0.45) inset;
}
#settingsButton:hover { transform: translateY(-2px);
    background: rgba(var(--m-orange-rgb), 0.16);
    box-shadow: 0 8px 22px rgba(var(--m-orange-rgb), 0.25), 0 0 0 1px rgba(var(--m-orange-rgb), 0.7) inset; }
#settingsButton:active { transform: translateY(0); }

/* ---------- Settings + instructions panels ---------- */

#settings, #startMenuWrapper {
    -webkit-transition: max-height 1s;
    -moz-transition: max-height 1s;
    -o-transition: max-height 1s;
    transition: max-height 1s;
    overflow: hidden;
}
#settings { max-height: 0; }

#startMenu h3 {
    margin: 18px 0 6px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--m-blue);
    font-family: 'Orbitron', sans-serif;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

#startMenu ul {
    margin: 8px 0 0;
    padding-left: 18px;
    color: var(--text-dim);
}
#startMenu #instructions li { margin-bottom: 6px; line-height: 1.45; }
#startMenu .hl-perish { color: var(--m-orange); font-weight: 600; }

#settings ul { list-style: none; padding-left: 0; }
#settings label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 6px 10px 6px 0;
    color: var(--text-dim);
    cursor: pointer;
}
#settings input[type="checkbox"] { accent-color: var(--m-blue); width: 15px; height: 15px; }

#startMenu .input-error {
    display: block;
    color: var(--m-orange);
    opacity: 0;
    font-size: 12px;
    text-align: center;
    margin-top: 4px;
    transition: opacity 0.2s;
}

/* ---------- Modal (How to hunt / buy abilities) ---------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3, 5, 10, 0.7);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
    position: relative;
    width: 460px;
    max-width: calc(100vw - 32px);
    padding: 28px 26px 24px;
    border-radius: 18px;
    background: rgba(16, 20, 28, 0.97);
    border: 1px solid rgba(var(--m-blue-rgb), 0.35);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), 0 0 60px rgba(var(--m-blue-rgb), 0.12);
    color: var(--text);
    animation: modalIn 0.18s ease;
}
@keyframes modalIn {
    from { transform: translateY(10px) scale(0.98); opacity: 0; }
    to   { transform: none; opacity: 1; }
}
.modal h3 {
    margin: 0 0 14px;
    font-family: 'Orbitron', sans-serif;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--m-blue);
}
.modal ul { margin: 0; padding-left: 20px; color: var(--text-dim); }
.modal li { margin-bottom: 10px; line-height: 1.5; }
.modal p { margin: 0 0 12px; color: var(--text-dim); line-height: 1.55; }
.modal .modal-soon { color: var(--m-orange); font-weight: 500; }
.modal .hl-perish { color: inherit; font-weight: 600; }

/* Wide 3-column variant (How to play / Rules / Extra features). */
.modal-wide { width: 880px; }
.modal-cols {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 26px;
}
.modal-col h3 { margin: 0 0 12px; font-size: 18px; }
.modal-col.col-rules h3 { color: var(--green); }
.modal-col.col-extra h3 { color: var(--m-orange); }
.modal-col.col-extra li b { color: var(--m-orange); }
.modal-col.col-extra .extra-note {
    margin: 14px 0 0;
    color: var(--m-orange);
    font-size: 13px;
    line-height: 1.5;
    font-weight: 700;
}
.modal-col-sub { margin: 0 0 12px; color: var(--text); font-weight: 600; font-size: 13px; }
@media (max-width: 820px) {
    .modal-cols { grid-template-columns: 1fr; gap: 18px; }
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9px;
    color: var(--text-dim);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); }

/* ---------- In-game HUD ---------- */

#gameAreaWrapper {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--app-h, 100dvh);
    opacity: 0;
    z-index: 1;
}

#hudLeft {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 2;
    width: 260px;            /* exit (52) + gap (8) + weight (200) */
    display: flex;
    flex-direction: column;
    gap: 8px;
}
#hudTopRow {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

#weight {
    width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 2px;
    padding: 10px 16px;
    background: rgba(10, 13, 18, 0.72);
    border: 1px solid rgba(var(--green-rgb), 0.4);
    border-radius: 12px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 22px rgba(var(--green-rgb), 0.18);
}
#weight .w-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--text-dim);
}
#weight .w-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    color: var(--green);
    text-shadow: 0 0 12px rgba(var(--green-rgb), 0.7);
}
#weight .w-place {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--red);
    text-shadow: 0 0 10px rgba(var(--red-rgb), 0.5);
    margin-top: 3px;
}
#weight .w-coords {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

/* Narrow exit button — same height/style as the MASS box, just an icon */
#exitBtn {
    flex: 0 0 52px;
    width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 13, 18, 0.72);
    border: 1px solid rgba(var(--green-rgb), 0.4);
    border-radius: 12px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: var(--green);
    cursor: pointer;
    box-shadow: 0 0 22px rgba(var(--green-rgb), 0.12);
    transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.2s, transform 0.12s;
}
#exitBtn:hover {
    transform: translateY(-1px);
    color: var(--red);
    border-color: rgba(var(--red-rgb), 0.65);
    box-shadow: 0 0 24px rgba(var(--red-rgb), 0.28);
}
#exitBtn:active { transform: translateY(0); }

#status {
    position: absolute;
    min-width: 230px;
    width: 230px;
    padding: 12px 14px;
    background: rgba(10, 13, 18, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: var(--text);
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    top: 14px;
    right: 14px;
    z-index: 2;
}
#status .title {
    display: block;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: var(--green);
    letter-spacing: 1px;
    text-shadow: 0 0 12px rgba(var(--green-rgb), 0.6);
    margin-bottom: 2px;
}
#status .lb-note {
    display: block;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
}
#status .lb-row, #status .lb-head {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
}
#status .lb-row {
    border-radius: 6px;
    font-weight: 600;
}
/* Column header (# | Name | Room | Amount) — small bold, aligned to the row grid. */
#status .lb-head {
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-dim);
}
/* The global `* { font-family: Rubik; font-size: 14px }` rule sets the font
   DIRECTLY on these label spans, which beats inheriting from .lb-head — so the
   font must be declared on the spans themselves to take effect. */
#status .lb-head > span {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
}
#status .lb-h-room { text-align: center; }
#status .lb-h-mass { text-align: right; }
#status .lb-name {
    display: flex;
    min-width: 0;
    align-items: baseline;
    gap: 7px;
    overflow: hidden;
}
/* Name truncates with an ellipsis so the rank, room badge and mass stay fully
   visible no matter how long the name is. */
#status .lb-pname {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
#status .lb-rank {
    color: var(--text-dim);
    font-size: 12px;
    min-width: 16px;
}
#status .lb-room {
    text-align: center;
    line-height: 1;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--text-dim);
}
#status .lb-mass {
    text-align: right;
    color: var(--green);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
#status .lb-row.me {
    background: rgba(var(--red-rgb), 0.14);
}
#status .lb-row.me .lb-name,
#status .lb-row.me .lb-rank { color: var(--red); }
#status .lb-row.me .lb-mass { color: var(--red); }

/* Top 3 = reward winners: gold / silver / bronze backing on the row. */
#status .lb-win-1 { background: rgba(255, 210, 74, 0.18); box-shadow: inset 2px 0 0 #ffd24a; }
#status .lb-win-2 { background: rgba(207, 216, 230, 0.15); box-shadow: inset 2px 0 0 #cfd8e6; }
#status .lb-win-3 { background: rgba(224, 152, 90, 0.16); box-shadow: inset 2px 0 0 #e0985a; }
#status .lb-win-1 .lb-rank { color: #ffd24a; }
#status .lb-win-2 .lb-rank { color: #cfd8e6; }
#status .lb-win-3 .lb-rank { color: #e0985a; }

.chatbox {
    position: static;
    width: 100%;
    height: 240px;
    display: flex;
    flex-direction: column;
    background: rgba(10, 13, 18, 0.72);
    border: 1px solid rgba(var(--green-rgb), 0.4);
    border-radius: 12px;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 22px rgba(var(--green-rgb), 0.12);
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
    transition: height 0.25s ease;
    font-family: 'Orbitron', sans-serif;
}
.chatbox .chat-header {
    pointer-events: all;
    cursor: pointer;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--green);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    user-select: none;
}
.chatbox .chat-toggle { color: var(--text-dim); font-size: 12px; }
.chatbox.collapsed { height: 34px; }
.chatbox.collapsed .chat-list,
.chatbox.collapsed .chat-input { display: none; }
.chatbox.collapsed .chat-header { border-bottom: none; }
.chatbox .chat-list {
    flex: 1 1 auto;
    min-height: 0;
    padding: 8px;
    margin: 0;
    list-style: none;
    overflow: hidden;
    color: var(--text);
}
.chatbox .chat-list,
.chatbox .chat-list li,
.chatbox .chat-list li b,
.chatbox .chat-input {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    letter-spacing: 0.3px;
}
.chatbox .chat-list li { padding: 2px; margin: 3px; }
.chatbox .chat-list li.me b { color: var(--red); }
.chatbox .chat-list li.friend b { color: var(--green); }
.chatbox .chat-list li.system { color: #b07cff; font-style: italic; }
.chatbox .chat-list li.system:before { content: "» "; }
.chatbox .chat-input {
    pointer-events: all;
    width: 100%;
    padding: 9px;
    color: var(--text);
    background: transparent;
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    outline: none;
}
.chatbox .chat-input::placeholder { color: #5e6b78; }

/* ---------- Reward drop timer + coin firework ---------- */

/* Top-centre HUD stack: narrow room badge above the reward timer.
   The badge stretches to the timer's (content-driven) width. */
#topCenterHud {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
}
#centerStack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
#rewardPool {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 22px;
    border-radius: 14px;
    background: rgba(10, 13, 18, 0.78);
    border: 1px solid rgba(255, 210, 74, 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 26px rgba(255, 200, 60, 0.16);
    text-align: center;
}
#rewardPool .rp-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-dim);
}
#rewardPool .rp-value {
    font-family: 'Orbitron', sans-serif;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.05;
    color: #ffd24a;
    text-shadow: 0 0 12px rgba(255, 200, 60, 0.6);
    font-variant-numeric: tabular-nums;
}
#rewardPool .rp-unit { font-size: 14px; opacity: 0.9; }
/* Second fee leg (paid in the game token, not ETH). Deliberately quieter than
   the headline so the two are never read as one total. */
#rewardPool .rp-alt {
    font-family: 'Orbitron', sans-serif;
    font-size: 10px;
    letter-spacing: 1px;
    margin-top: 2px;
    color: var(--text-dim);
}
#roomBadge {
    align-self: stretch;
    padding: 3px 24px;
    border-radius: 10px;
    background: rgba(10, 13, 18, 0.78);
    border: 1px solid rgba(var(--m-blue-rgb), 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 22px rgba(var(--m-blue-rgb), 0.16);
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 2px;
    line-height: 1.1;
    color: var(--m-blue);
    text-shadow: 0 0 10px rgba(var(--m-blue-rgb), 0.5);
}
#roomBadge .rb-cap {
    color: var(--text-dim);
    text-shadow: none;
}

#rewardTimer {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 8px 24px;
    border-radius: 14px;
    background: rgba(10, 13, 18, 0.78);
    border: 1px solid rgba(var(--green-rgb), 0.4);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 26px rgba(var(--green-rgb), 0.18);
    text-align: center;
}
#rewardTimer .rt-label {
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-dim);
}
#rewardTimer .rt-time {
    font-family: 'Orbitron', sans-serif;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.05;
    color: var(--green);
    text-shadow: 0 0 12px rgba(var(--green-rgb), 0.6);
    font-variant-numeric: tabular-nums;
}
#fireworkLayer {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    z-index: 6;
    pointer-events: none;
}
/* CSS-drawn gold coin (no emoji — renders the same on every device) */
.coin {
    position: absolute;
    left: 0;
    top: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff3b0, #ffd54a 45%, #f0a51e 100%);
    border: 1px solid rgba(255, 240, 180, 0.9);
    box-shadow: 0 0 12px rgba(255, 200, 60, 0.8);
    transform: translate(-50%, -50%);
    animation: coinFly 2s ease-out forwards;
    will-change: transform, opacity;
}
@keyframes coinFly {
    0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
    12%  { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.85) rotate(320deg); opacity: 0; }
}
/* ---------- Action buttons (holo gradient, bottom-right) ---------- */

#actionBtns {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 2;
    display: flex;
    align-items: flex-end;
    gap: 14px;
}
/* Touch version stacks the 4 buttons vertically (desktop keeps its 2 in a row). */
@media (pointer: coarse) {
    #actionBtns { flex-direction: column; align-items: center; }
}
.ab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
}
/* Hover tooltip for Shield / Vampire (desktop only — touch has no hover).
   Anchored to the button's right edge so the wide text never runs off-screen. */
.ab .tip {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    width: 244px;
    padding: 10px 13px;
    border-radius: 10px;
    background: rgba(10, 13, 18, 0.96);
    border: 1px solid rgba(127, 119, 221, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 18px rgba(127, 119, 221, 0.25);
    color: #eef1fb;
    font-family: 'Rubik', sans-serif;
    font-size: 13px;
    line-height: 1.45;
    text-align: left;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 5;
}
.ab:hover .tip { opacity: 1; transform: translateY(0); }
/* Shield countdown pill, shown above the button while the shield is active. */
.ab-timer {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(10, 13, 18, 0.92);
    border: 1px solid rgba(150, 240, 255, 0.6);
    color: #b6f4ff;
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    box-shadow: 0 0 14px rgba(150, 240, 255, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 6;
}
.ab-timer.on { opacity: 1; }
/* Vampire timer is red to match its red pulse. */
.ab-timer.vamp {
    border-color: rgba(255, 80, 80, 0.7);
    color: #ff8a8a;
    box-shadow: 0 0 14px rgba(255, 60, 60, 0.3);
}
.ab .cap {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    letter-spacing: 0.5px;
    color: #fff;
}
/* Split + Eject are touch-only; on keyboard they're Space/W. */
.ab-touch { display: none; }
@media (pointer: coarse) {
    .ab-touch { display: flex; }
}
/* Holo-gradient round button: conic ring with a dark inset face. */
.gbtn {
    width: 64px;
    height: 64px;
    padding: 0;
    border: none;
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: conic-gradient(from 210deg, #378add, #7f77dd, #ff693c, #ffb05a, #378add);
    box-shadow: 0 0 18px rgba(127, 119, 221, 0.4);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation; /* instant taps, even as a 2nd finger mid-steer */
    transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.gbtn::before {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 35%, #10162a, #0a0e1a);
}
.gbtn svg { width: 34px; height: 34px; display: block; position: relative; z-index: 1; }
.gbtn:hover { transform: translateY(-2px); }
.gbtn:active { transform: scale(0.92); box-shadow: 0 0 26px rgba(127, 119, 221, 0.6); }

/* Per-button badges. Shield/Vampire: red circle with the free-uses count.
   Split/Eject (touch): red rounded "FREE" tag. */
.gbtn-wrap { position: relative; display: inline-flex; }
.ability-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 21px;
    height: 21px;
    padding: 0 4px;
    border-radius: 999px;
    background: #e2402f;
    border: 2px solid #0a0d15;
    color: #fff;
    /* Match the leaderboard number font (Rubik, bold, tabular). */
    font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.free-badge {
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 8px;
    border-radius: 7px;
    background: #e2402f;
    border: 1.5px solid #0a0d15;
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 10px;
    letter-spacing: 0.5px;
}

/* Buy-more modal: a compact card pinned near the top, NOT a full-screen overlay,
   so the game underneath stays steerable while it's open. */
#buyModal {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: none;
}
#buyModal.show { display: block; }
.buy-card {
    width: 280px;
    max-width: calc(100vw - 32px);
    padding: 18px 20px;
    border-radius: 16px;
    background: rgba(12, 16, 26, 0.97);
    border: 1px solid rgba(var(--red-rgb), 0.5);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7), 0 0 50px rgba(var(--red-rgb), 0.18);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    text-align: center;
    font-family: 'Rubik', sans-serif;
}
.buy-line {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
}
.buy-line #buyTotal, .buy-line #buyQty { color: var(--m-orange); }
.buy-balance {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 8px;
    color: var(--text-dim);
    font-size: 13px;
}
.buy-balance .wallet-ic { width: 18px; height: 18px; color: var(--m-orange); }
.buy-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 16px 0;
}
.buy-stepper button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.buy-stepper button:disabled { opacity: 0.3; cursor: default; }
.buy-stepper #buyQtyNum {
    min-width: 28px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 22px;
    color: #fff;
}
.buy-actions { display: flex; gap: 10px; }
.buy-actions button {
    flex: 1;
    height: 40px;
    border-radius: 10px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
}
#buyCancel { background: transparent; border: 1px solid rgba(255, 255, 255, 0.25); color: var(--text-dim); }
#buyConfirm {
    background: var(--m-orange);
    border: 1px solid var(--m-orange);
    color: #1a0c06;
}
#buyConfirm:disabled { opacity: 0.4; cursor: default; }

/* ---------- Mobile steer pad / joystick (bottom-left) ---------- */
#joystick {
    position: absolute;
    left: 72px;
    bottom: 72px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(10, 13, 18, 0.5);
    border: 1px solid rgba(var(--green-rgb), 0.4);
    box-shadow: 0 0 22px rgba(var(--green-rgb), 0.16), inset 0 0 30px rgba(var(--green-rgb), 0.06);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 2;
    touch-action: none;       /* never let the pad scroll/zoom the page */
}
/* The knob marks the live touch point + heading; it's moved via inline transform
   from JS. Hidden (faded) while the open-area drag has steering instead. */
#joystickKnob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 62px;
    height: 62px;
    margin: -31px 0 0 -31px;
    border-radius: 50%;
    background: rgba(var(--green-rgb), 0.30);
    border: 1.5px solid rgba(var(--green-rgb), 0.7);
    box-shadow: 0 0 16px rgba(var(--green-rgb), 0.35);
    transition: transform 0.05s linear, opacity 0.15s ease;
    will-change: transform;
}
#joystick.joy-hidden #joystickKnob { opacity: 0; }

/* ---------- In-game controls hint ---------- */

#controlsHint {
    position: absolute;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    z-index: 3;
    padding: 11px 22px;
    border-radius: 999px;
    background: rgba(10, 13, 18, 0.8);
    border: 1px solid rgba(var(--green-rgb), 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: var(--text-dim);
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    box-shadow: 0 0 26px rgba(var(--green-rgb), 0.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease, transform 0.6s ease;
}
#controlsHint b { color: var(--green); font-weight: 800; }
#controlsHint.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Pointer-based controls:
   - fine pointer (mouse/trackpad → laptop/PC, incl. touchscreen laptops):
     text hint only, no on-screen buttons.
   - coarse pointer (finger → phone/tablet without trackpad):
     on-screen buttons only, no text hint, no chat. */
#mobile { display: none; }
@media (pointer: coarse) {
    #mobile { display: block; }
    #controlsHint { display: none !important; }
}

/* ---------- "You lose" overlay ---------- */

#loseOverlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3, 5, 10, 0.82);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
#loseOverlay.show { display: flex; }
.lose-card {
    text-align: center;
    padding: 38px 44px;
    border-radius: 20px;
    background: rgba(16, 20, 28, 0.96);
    border: 1px solid rgba(var(--red-rgb), 0.45);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7), 0 0 70px rgba(var(--red-rgb), 0.18);
    animation: modalIn 0.2s ease;
}
.lose-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 50px;
    letter-spacing: 3px;
    background: linear-gradient(180deg, #ffd9c8 0%, var(--red) 60%, var(--red-2) 100%);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 16px rgba(var(--red-rgb), 0.7));
    margin-bottom: 8px;
}
.lose-sub { margin: 0 0 22px; color: var(--text-dim); font-size: 14px; }
.lose-sub b { color: var(--text); font-variant-numeric: tabular-nums; }
#loseBackBtn {
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
    padding: 13px 30px;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--green), var(--cyan));
    box-shadow: 0 8px 24px rgba(var(--green-rgb), 0.4);
    transition: transform 0.12s ease, filter 0.2s ease;
}
#loseBackBtn:hover { transform: translateY(-2px); filter: brightness(1.08); }

/* ---------- Round-over winners screen ---------- */
#roundEndOverlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(3, 5, 10, 0.88);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
#roundEndOverlay.show { display: flex; }
#reFireworkLayer {
    position: absolute;
    top: 42%;
    left: 50%;
    width: 0;
    height: 0;
    z-index: 0;
    pointer-events: none;
}
.re-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 580px;
    text-align: center;
    padding: 34px 38px;
    border-radius: 22px;
    background: rgba(16, 20, 28, 0.97);
    border: 1px solid rgba(255, 210, 74, 0.5);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7), 0 0 80px rgba(255, 200, 60, 0.18);
    animation: modalIn 0.2s ease;
}
.re-title {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 40px;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(180deg, #fff3b0 0%, #ffd24a 55%, #f0a51e 100%);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 16px rgba(255, 200, 60, 0.6));
    margin-bottom: 6px;
}
.re-sub { margin: 0 0 20px; color: var(--text); font-size: 15px; font-weight: 600; }
.re-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
    max-height: 46vh;
    overflow-y: auto;
}
.re-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.re-rank {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 24px;
    min-width: 34px;
    text-align: center;
    color: var(--text-dim);
}
.re-name {
    text-align: left;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 20px;
    color: #fff;
    overflow-wrap: anywhere;
}
.re-room {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
}
.re-mass {
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    font-size: 24px;
    color: var(--green);
    font-variant-numeric: tabular-nums;
}
.re-place-1 { border-color: rgba(255, 210, 74, 0.6); box-shadow: inset 3px 0 0 #ffd24a; }
.re-place-1 .re-rank { color: #ffd24a; }
.re-place-2 { border-color: rgba(207, 216, 230, 0.55); box-shadow: inset 3px 0 0 #cfd8e6; }
.re-place-2 .re-rank { color: #cfd8e6; }
.re-place-3 { border-color: rgba(224, 152, 90, 0.55); box-shadow: inset 3px 0 0 #e0985a; }
.re-place-3 .re-rank { color: #e0985a; }
.re-newround { margin: 0 0 22px; color: #ffd24a; font-weight: 700; font-size: 16px; line-height: 1.5; }
#roundContinueBtn {
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #14250a;
    padding: 14px 40px;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    background: linear-gradient(135deg, #ffd24a, #f0a51e);
    box-shadow: 0 8px 24px rgba(255, 200, 60, 0.4);
    transition: transform 0.12s ease, filter 0.2s ease;
}
#roundContinueBtn:hover { transform: translateY(-2px); filter: brightness(1.08); }

/* ---------- Room selection screen ---------- */

#roomSelectWrapper {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#roomSelectWrapper.show { display: flex; }

#roomSelect {
    position: relative;
    z-index: 1;
    width: 460px;
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 40px);
    display: flex;
    flex-direction: column;
    padding: 30px 26px 24px;
    border-radius: 20px;
    background: var(--panel);
    border: 1px solid transparent;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow:
        0 40px 100px rgba(0, 0, 0, 0.7),
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 0 90px rgba(var(--m-blue-rgb), 0.10) inset;
}
#roomSelect::before {
    content: "";
    position: absolute;
    inset: -1.5px;
    border-radius: inherit;
    padding: 1.5px;
    background: conic-gradient(from var(--angle),
        var(--m-blue), var(--m-violet), var(--m-orange), var(--m-blue));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask-composite: exclude;
    animation: rotateBorder 7s linear infinite;
    pointer-events: none;
    z-index: 2;
    opacity: 0.9;
}

.rs-title {
    margin: 0 0 4px;
    text-align: center;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 1px;
    color: #fff;
    text-transform: uppercase;
}
.rs-note {
    margin: 0 0 18px;
    text-align: center;
    font-family: 'Rubik', sans-serif;
    font-size: 13px;
    color: var(--text-dim);
}

.room-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* Show up to ~5 rooms; beyond that the list scrolls internally.
       (row ~52px + 10px gap) * 5 - last gap = ~300px */
    max-height: 300px;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 4px;
}

.room-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 15px 18px;
    border: 0;
    border-radius: 13px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    color: #fff;
    background: linear-gradient(135deg, #8a97ff, var(--m-blue) 45%, var(--m-blue-2));
    box-shadow: 0 8px 22px rgba(var(--m-blue-rgb), 0.35), 0 0 0 1px rgba(var(--m-blue-rgb), 0.5) inset;
    transition: transform 0.14s ease, box-shadow 0.25s ease, filter 0.25s ease;
}
.room-btn:hover {
    transform: translateY(-2px) scale(1.01);
    filter: brightness(1.08);
    box-shadow: 0 14px 32px rgba(var(--m-blue-rgb), 0.55), 0 0 24px rgba(var(--m-blue-rgb), 0.4);
}
.room-btn:active { transform: translateY(0) scale(1); }
.room-btn .rb-num { font-size: 17px; font-weight: 800; letter-spacing: 0.5px; white-space: nowrap; }
.room-btn .rb-count {
    font-size: 14px;
    font-weight: 600;
    font-family: 'Rubik', sans-serif;
    opacity: 0.95;
    white-space: nowrap;
}

.room-btn.full {
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    filter: none;
    transform: none;
}
.room-btn.full .rb-count { color: var(--m-orange); font-weight: 800; }

.rs-back {
    margin: 18px auto 0;
    padding: 10px 26px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--m-orange);
    background: rgba(var(--m-orange-rgb), 0.07);
    box-shadow: 0 0 0 1px rgba(var(--m-orange-rgb), 0.45) inset;
    transition: transform 0.14s ease, background 0.25s ease;
}
.rs-back:hover { transform: translateY(-2px); background: rgba(var(--m-orange-rgb), 0.16); }
.rs-back:active { transform: translateY(0); }

input[type="image"]:focus { border: none; outline: 1px solid transparent; border-style: none; }
*:focus { outline: 1px solid transparent; border-style: none; }

/* ============================================================
   Wallet header (React island) — fixed top-right, over
   both the start menu and the in-game view.
   ============================================================ */
/* Top-right header bar: X link + wallet widget, in one row. */
#topRightBar {
    position: fixed;
    top: 10px;
    right: 12px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 10px;
}
body.ca-open #topRightBar { top: 46px; }
#wallet-root { display: contents; }
#xLink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: #e6edf3;
    background: rgba(10, 13, 18, 0.82);
    border: 1px solid rgba(var(--m-blue-rgb), 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 22px rgba(var(--m-blue-rgb), 0.18);
    transition: transform .12s ease, background .12s ease, color .12s ease;
}
#xLink:hover { transform: translateY(-1px); background: rgba(var(--m-blue-rgb), 0.20); color: #fff; }
/* Hide the wallet block during gameplay — only on menu / room picker. X stays. */
body.in-game #wallet-root,
body.in-game .wallet-widget { display: none !important; }
.wallet-widget {
    position: relative;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 12px;
    background: rgba(10, 13, 18, 0.82);
    border: 1px solid rgba(var(--m-blue-rgb), 0.45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: 0 0 22px rgba(var(--m-blue-rgb), 0.18);
    font-family: 'Orbitron', sans-serif;
}
.wallet-widget button { font-family: 'Orbitron', sans-serif; cursor: pointer; }
.ww-addr {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 9px;
    border: 1px solid rgba(var(--m-blue-rgb), 0.4);
    background: rgba(var(--m-blue-rgb), 0.10);
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.ww-addr:hover { background: rgba(var(--m-blue-rgb), 0.20); }
.ww-chain-ic {
    width: 12px; height: 12px; border-radius: 50%;
    background: linear-gradient(135deg, #8098ee 0%, #454a75 100%);
    box-shadow: 0 0 8px rgba(128, 152, 238, 0.55);
}
.ww-bal {
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    padding: 0 2px;
    white-space: nowrap;
}
.ww-bal i { color: var(--text-dim); font-style: normal; font-size: 10px; }
.ww-network {
    padding: 5px 12px;
    border-radius: 9px;
    border: none;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--m-blue), var(--m-blue-2));
    box-shadow: 0 4px 16px rgba(var(--m-blue-rgb), 0.45);
}
.ww-network:hover { filter: brightness(1.1); transform: translateY(-1px); }
.ww-network:active { transform: translateY(0); }
.ww-caret { font-size: 9px; color: var(--text-dim); margin-left: 2px; }
/* Deposit — green, opens the wallet panel (address + QR). */
.ww-deposit {
    padding: 5px 12px;
    border-radius: 9px;
    border: none;
    color: #14250a;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #c6ff5a, #8ed600);
    box-shadow: 0 4px 16px rgba(170, 255, 0, 0.35);
}
.ww-deposit:hover { filter: brightness(1.1); transform: translateY(-1px); }
.ww-deposit:active { transform: translateY(0); }
/* Logout — small icon button. */
.ww-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 9px;
    border: 1px solid rgba(255, 95, 174, 0.45);
    background: rgba(255, 45, 149, 0.12);
    color: #ff5fae;
}
.ww-logout:hover { background: rgba(255, 45, 149, 0.22); transform: translateY(-1px); }
.ww-logout:active { transform: translateY(0); }

/* Wallet dropdown panel: balances + deposit address + QR. */
.ww-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 250px;
    padding: 14px;
    border-radius: 14px;
    background: rgba(10, 13, 18, 0.97);
    border: 1px solid rgba(var(--m-blue-rgb), 0.5);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(var(--m-blue-rgb), 0.18);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    z-index: 70;
    text-align: left;
}
.ww-panel-head {
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
}
/* Network warning under the deposit QR — sending an asset from the wrong
   chain to this address loses it, so the network is named explicitly. */
.ww-net-note {
    margin-top: 8px;
    font-size: 10px;
    line-height: 1.4;
    color: var(--text-dim);
    text-align: center;
}
.ww-bal-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.ww-bal-row b { font-variant-numeric: tabular-nums; }
.ww-dep-label {
    margin: 12px 0 6px;
    font-size: 11px;
    color: var(--text-dim);
    font-family: 'Rubik', sans-serif;
}
.ww-dep-addr {
    width: 100%;
    word-break: break-all;
    padding: 8px 10px;
    border-radius: 9px;
    border: 1px dashed rgba(var(--m-blue-rgb), 0.5);
    background: rgba(var(--m-blue-rgb), 0.08);
    color: var(--text);
    font-family: 'Rubik', monospace;
    font-size: 11px;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
}
.ww-dep-addr:hover { background: rgba(var(--m-blue-rgb), 0.16); }
.ww-qr {
    display: block;
    width: 150px;
    height: 150px;
    margin: 12px auto 2px;
    border-radius: 10px;
    background: #fff;
    padding: 6px;
}
@media (pointer: coarse) {
    #topRightBar { top: 8px; right: 8px; gap: 6px; }
    body.ca-open #topRightBar { top: 42px; }
    #xLink { width: 34px; height: 34px; }
    .wallet-widget { padding: 5px 6px; gap: 5px; }
    .ww-addr, .ww-bal, .ww-network { font-size: 11px; }
}

/* ============================================================
   Token contract address banner (top strip, closeable)
   ============================================================ */
#caBar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 70;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 44px;
    background: linear-gradient(90deg, var(--m-blue), var(--m-violet), var(--m-orange));
    color: #fff;
    font-family: 'Orbitron', sans-serif;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
}
#caBar .ca-inner { display: inline-flex; align-items: center; gap: 8px; max-width: 92%; overflow: hidden; }
#caBar .ca-label {
    font-weight: 800; letter-spacing: 1px; font-size: 10px;
    background: rgba(0, 0, 0, 0.28); padding: 2px 7px; border-radius: 6px; flex: none;
}
#caBar .ca-value {
    font-weight: 700; font-size: 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
}
#caClose {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 24px; border: none; border-radius: 6px;
    background: rgba(0, 0, 0, 0.22); color: #fff; font-size: 18px; line-height: 1;
    cursor: pointer;
}
#caClose:hover { background: rgba(0, 0, 0, 0.4); }
/* When the banner is open, push the top HUD below it so nothing overlaps. */
body.ca-open #hudLeft,
body.ca-open #topCenterHud { top: 48px; }
@media (pointer: coarse) {
    body.ca-open #hudLeft,
    body.ca-open #topCenterHud { top: 44px; }
}

/* ============================================================
   Small screens (<768px): the game isn't playable on phones.
   On the start menu keep only the rewards tagline and replace the
   play controls (name field, colour swatch, both buttons) with a
   notice telling the player to use a bigger screen.
   ============================================================ */
.mobile-block-msg { display: none; }
@media (max-width: 767px) {
    #startMenu .name-row,
    #startMenu .input-error,
    #startMenu > a,
    #startMenu #startButton,
    #startMenu #settingsButton { display: none !important; }

    /* ...except the leaderboard link. `#startMenu > a` above is aimed at the
       wrapper around Play; this link is also a direct <a> child and would be
       swept up with it. The board is a normal responsive page, so a phone
       visitor who can't play still has somewhere to go. */
    #startMenu > a#leaderboardLink.menu-link { display: flex !important; }

    .mobile-block-msg {
        display: block;
        margin: 18px 0 4px;
        padding: 0 6px;
        text-align: center;
        font-family: 'Rubik', sans-serif;
        font-weight: 600;
        font-size: 16px;
        line-height: 1.5;
        color: #ffd9a8;
    }
}
