/* ============================================================
   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); }
}

/* Hide all menu decoration once the game is running */
body.in-game .blob { 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));
}

/* ---------- 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 / Deposit SOL) ---------- */

.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: var(--m-orange); font-weight: 600; }
.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;
    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 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 3px 6px;
    border-radius: 6px;
    font-weight: 600;
}
#status .lb-name {
    display: flex;
    align-items: baseline;
    gap: 7px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
#status .lb-rank {
    color: var(--text-dim);
    font-size: 12px;
    min-width: 16px;
}
#status .lb-room {
    flex: none;
    align-self: center;
    line-height: 1;
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    background: rgba(var(--m-blue-rgb), 0.16);
    border: 1px solid rgba(var(--m-blue-rgb), 0.35);
    border-radius: 6px;
    padding: 1px 5px;
}
#status .lb-mass {
    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); }

.chatbox {
    position: absolute;
    width: 300px;
    height: 320px;
    display: flex;
    flex-direction: column;
    background: rgba(10, 13, 18, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.06);
    bottom: 8px;
    left: 8px;
    border-radius: 12px;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    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: column;
    align-items: center;
    gap: 6px;
}
#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;
}
#rewardTimer .rt-msg {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--red);
    text-shadow: 0 0 12px rgba(var(--red-rgb), 0.6);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: opacity 0.4s ease, max-height 0.4s ease, margin-top 0.4s ease;
}
#rewardTimer .rt-msg.show { max-height: 22px; opacity: 1; margin-top: 4px; }

#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; }
}
/* Small inline gold coin for the "Check your wallet" message (no emoji). */
.coin-ic {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff3b0, #ffd54a 45%, #f0a51e 100%);
    border: 1px solid rgba(255, 240, 180, 0.9);
    vertical-align: -2px;
}

/* ---------- Mobile control buttons (blue) ---------- */

.ctrl-btn {
    position: absolute;
    bottom: 12px;
    width: 92px;
    height: 92px;
    padding: 18px;
    border-radius: 50%;
    background: rgba(10, 13, 18, 0.78);
    border: 1px solid rgba(var(--green-rgb), 0.45);
    color: var(--green);
    cursor: pointer;
    z-index: 2;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    box-shadow: 0 0 22px rgba(var(--green-rgb), 0.2);
    transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.ctrl-btn svg { width: 100%; height: 100%; display: block; }
.ctrl-btn:active { transform: scale(0.92); box-shadow: 0 0 28px rgba(var(--green-rgb), 0.4); }
/* Both control buttons stacked on the right. */
#feed { right: 12px; bottom: 12px; }
#split { right: 12px; bottom: 116px; }

/* ---------- 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); }

/* ---------- 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; }

/* ============================================================
   Privy wallet header (React island) — fixed top-right, over
   both the start menu and the in-game view.
   ============================================================ */
#privy-root { position: fixed; top: 0; right: 0; z-index: 60; }
/* Hide the wallet widget during gameplay — only show it on the menu / room picker. */
body.in-game #privy-root,
body.in-game .wallet-widget { display: none !important; }
.wallet-widget {
    position: fixed;
    top: 12px;
    right: 12px;
    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-sol-ic {
    width: 12px; height: 12px; border-radius: 50%;
    background: linear-gradient(135deg, #9945FF 0%, #14F195 100%);
    box-shadow: 0 0 8px rgba(20, 241, 149, 0.5);
}
.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-export {
    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-export:hover { filter: brightness(1.1); transform: translateY(-1px); }
.ww-export:active { transform: translateY(0); }
@media (pointer: coarse) {
    .wallet-widget { top: 8px; right: 8px; padding: 5px 6px; gap: 5px; }
    .ww-addr, .ww-bal, .ww-export { font-size: 11px; }
}
