:root {
    /* The one UI font: change it here and all text follows (load it in index.html too).
       Sizes don't need touching: font-size-adjust below keeps letters the same height in any font. */
    --font: 'Rubik', sans-serif;
    --panel: rgba(16, 16, 20, 0.78);
    --panel-border: #000;
    --text: #ffffff;
    --muted: #b9c0c8;
    --accent: #6fbf3b;
    --accent-dark: #3f7a1f;
    --danger: #ff4141;
    --gold: #ffd23f;
    --button: #6b6b6b;
    --button-hi: #8b8b8b;
    --button-lo: #3c3c3c;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: #87b9e8;
    color: var(--text);
    font-family: var(--font);
    font-size: 20px;
    /* Lowercase letters are 0.4 of the font size tall whatever --font is (the sizes in this file
       were tuned for that), so swapping fonts never makes text too big or too small */
    font-size-adjust: 0.4;
    user-select: none;
}
/* Form controls reset font settings in the browser's own styles; make them follow the page */
button, input, select, textarea { font-size-adjust: inherit; }

#game, #game canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#ui {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

#ui > * { pointer-events: auto; }
#ui > .hud, #ui > .hud * { pointer-events: none; }

.hidden { display: none !important; }

/* ---------- Minecraft-style buttons and panels ---------- */

.btn {
    font-family: var(--font);
    font-size: 23px;
    font-weight: 600;
    color: #fff;
    text-shadow: 2px 2px 0 #3f3f3f;
    background: var(--button);
    border: 3px solid #000;
    box-shadow: inset 2px 2px 0 var(--button-hi), inset -2px -3px 0 var(--button-lo);
    padding: 14px 18px;
    cursor: pointer;
    min-width: 200px;
    image-rendering: pixelated;
}
.btn:hover:not(:disabled) { background: #7a86c4; box-shadow: inset 2px 2px 0 #a3aee8, inset -2px -3px 0 #4a548a; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { color: #a0a0a0; text-shadow: none; cursor: default; background: #4a4a4a; box-shadow: inset 2px 2px 0 #5a5a5a, inset -2px -3px 0 #2c2c2c; }
.btn.primary { background: var(--accent); box-shadow: inset 2px 2px 0 #9be06b, inset -2px -3px 0 var(--accent-dark); }
.btn.primary:hover { background: #7fd147; }
.btn.primary:disabled, .btn.primary:disabled:hover { background: #4a4a4a; box-shadow: inset 2px 2px 0 #5a5a5a, inset -2px -3px 0 #2c2c2c; }

.panel {
    background: var(--panel);
    border: 3px solid var(--panel-border);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
    padding: 20px;
}

.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.overlay.dim { background: rgba(0, 0, 0, 0.55); }
.overlay.scores { z-index: 5; }

h1, h2, h3 { font-family: var(--font); font-weight: 600; margin: 0; }

input[type=text] {
    font-family: var(--font);
    font-size: 25px;
    width: 100%;
    padding: 12px;
    color: #fff;
    background: #000;
    border: 3px solid #a0a0a0;
    outline: none;
}
input[type=text]:focus { border-color: #fff; }

input[type=range] { width: 100%; accent-color: var(--accent); }

/* Crosshair options: preview on a mid-grey patch, style buttons, colour swatches */
.crosshair-picker { display: flex; gap: 10px; align-items: stretch; }
.crosshair-preview {
    position: relative; flex: 0 0 72px; min-height: 72px;
    background: linear-gradient(135deg, #7d8a6a, #4a5560);
    border: 3px solid #000;
}
.crosshair-picks { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.crosshair-picks .menu-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.crosshair-picks .btn.menu-choice { min-width: 0; padding: 6px 4px; font-size: 16px; white-space: nowrap; }
.crosshair-colors { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crosshair-swatch { width: 28px; height: 28px; padding: 0; border: 3px solid #000; cursor: pointer; }
.crosshair-swatch.selected { border-color: #fff; outline: 2px solid #000; }
.crosshair-custom { width: 40px; height: 28px; padding: 0; border: 3px solid #000; background: #000; cursor: pointer; }

/* A slider with its exact value next to it (mouse sensitivity) */
.menu-slider-number { display: flex; align-items: center; gap: 10px; }
.menu-slider-number input[type=range] { flex: 1; min-width: 0; }
input.menu-number {
    width: 76px;
    padding: 4px 6px;
    font: inherit;
    color: #fff;
    background: #000;
    border: 3px solid #a0a0a0;
    outline: none;
}
input.menu-number:focus { border-color: #fff; }

/* ---------- Main menu: tabs (Player / Game / Options) and Play ---------- */

.menu {
    --muted: #dde2e7;   /* lighter than the HUD's, for reading on the dark panel */
    /* --dirt is the game's dirt block texture, set by MainMenu; stripes if it's missing */
    background:
        linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.65)),
        var(--dirt, repeating-linear-gradient(45deg, #5a3d24 0 16px, #604128 16px 32px)) 0 0 / 64px 64px;
    image-rendering: pixelated;
    overflow-y: auto;
    align-items: flex-start;
}
.menu.in-game { background: rgba(0, 0, 0, 0.6); }

.menu-window {
    width: min(1000px, 100%);
    margin: auto;
    display: flex;
    flex-direction: column;
}

.menu-titlebar { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 14px; }
.logo {
    text-align: center;
    font-size: clamp(54px, 12vw, 96px);
    line-height: 0.9;
    color: #e6e6e6;
    letter-spacing: 2px;
    text-shadow: 4px 4px 0 #3a3a3a, 8px 8px 0 rgba(0, 0, 0, 0.35);
}
.logo span { color: var(--danger); }
.tagline { text-align: center; color: var(--gold); font-family: var(--font); font-size: 20px; line-height: 1.6; text-shadow: 2px 2px 0 #3f2f00; }
.menu.in-game .menu-titlebar { display: none; }
.menu.in-game .menu-body { height: auto; max-height: calc(100vh - 140px); }

/* Tabs are Minecraft buttons; the open one is pressed in and joins the panel */
.menu-tabs { display: flex; gap: 6px; position: relative; top: 3px; z-index: 1; }
.btn.menu-tab { min-width: 0; padding: 12px 22px; font-size: 22px; }
.btn.menu-tab.active,
.btn.menu-tab.active:hover {
    color: var(--gold);
    background: #2a2a30;
    border-bottom-color: transparent;
    box-shadow: inset 2px 2px 0 #1a1a1e, inset -2px 0 0 #3c3c44;
    cursor: default;
}

.menu-body {
    background: var(--panel);
    border: 3px solid var(--panel-border);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
    padding: 20px;
    height: clamp(420px, calc(100vh - 320px), 560px);
    overflow-y: auto;
    scrollbar-color: #8b8b8b #000;
}

.menu-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; }
.menu-column { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
@media (max-width: 760px) {
    .menu-panel { grid-template-columns: 1fr; }
    .menu-body { height: auto; padding: 14px; }
    .btn.menu-tab { flex: 1; padding: 12px 6px; font-size: 18px; }
}

.menu-label { font-family: var(--font); font-size: 22px; color: var(--muted); margin-top: 4px; }
.menu-note { color: var(--muted); font-size: 21px; line-height: 1; }
.menu-note:empty { display: none; }

/* Fields: black with a grey frame, like the nickname box */
.menu input[type=password], .menu select {
    font-family: var(--font);
    font-size: 22px;
    width: 100%;
    min-width: 0;
    padding: 10px;
    color: #fff;
    background: #000;
    border: 3px solid #a0a0a0;
    outline: none;
}
.menu input[type=password]:focus, .menu select:focus { border-color: #fff; }
.menu input[type=range] { accent-color: var(--accent); }

/* Pick lists: characters and modes, as dark cards */
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 12px;
    text-align: left;
    background: rgba(0, 0, 0, 0.45);
    border: 3px solid #333;
    padding: 10px 12px;
    color: #fff;
    font-family: var(--font);
    cursor: pointer;
}
.menu-row:hover:not(:disabled) { border-color: #888; }
.menu-row.selected { border-color: var(--gold); background: rgba(255, 210, 63, 0.12); }
.menu-row:disabled { opacity: 0.4; cursor: default; }
.menu-row .name { font-size: 26px; font-weight: 600; line-height: 1; text-shadow: 2px 2px 0 #000; }
.menu-row.selected .name { color: var(--gold); }
.menu-row .desc { color: var(--muted); font-size: 21px; line-height: 1; }

/* One-of-several buttons (online/offline, graphics, camera...): the chosen one turns green */
.menu-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.btn.menu-choice { flex: 1 1 0; min-width: 0; padding: 8px; font-size: 23px; line-height: 1.2; }
.btn.menu-choice.selected,
.btn.menu-choice.selected:hover { background: var(--accent); box-shadow: inset 2px 2px 0 #9be06b, inset -2px -3px 0 var(--accent-dark); }

.menu-setting { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }

/* Game tab: the choices on top, then only the settings the choice uses */
.menu-steps { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; margin-bottom: 18px; }
.menu-step { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.menu-step.off { visibility: hidden; }
.menu-panel.single { grid-template-columns: 1fr; }
.menu-info {
    background: rgba(0, 0, 0, 0.45);
    border: 3px solid #333;
    padding: 12px 14px;
    font-size: 21px;
    line-height: 1.05;
    color: var(--muted);
    text-shadow: 2px 2px 0 #000;
}
@media (max-width: 760px) {
    .menu-steps { grid-template-columns: 1fr; gap: 12px; }
    .menu-step.off { display: none; }
}

.menu-footer { display: flex; align-items: center; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.menu-footer .server-status { flex: 1 1 260px; text-shadow: 2px 2px 0 #000; }
.menu-actions { display: flex; gap: 10px; margin-left: auto; }
.menu-actions .btn { min-width: 140px; }
.btn.play { font-size: 32px; padding: 18px 48px; min-width: 240px; }
@media (max-width: 760px) {
    .menu-actions { width: 100%; }
    .menu-actions .btn { flex: 1; min-width: 0; }
}

.preview {
    position: relative;
    min-height: 380px;
    background: radial-gradient(circle at 50% 40%, rgba(150, 200, 255, 0.35), rgba(0, 0, 0, 0.2));
    border: 3px solid #000;
    overflow: hidden;
}
.preview canvas { width: 100%; height: 100%; display: block; position: absolute; inset: 0; }
.preview .preview-name {
    position: absolute;
    left: 0; right: 0; bottom: 14px;
    text-align: center;
    font-family: var(--font);
    font-size: 29px;
    text-shadow: 2px 2px 0 #000;
}
@media (max-width: 760px) { .preview { min-height: 240px; } }

.label { font-family: var(--font); font-size: 22px; color: var(--muted); }

.server-status { font-size: 21px; color: var(--muted); min-height: 22px; }
.server-status.online { color: var(--accent); }

.mode-description { font-size: 21px; color: var(--muted); min-height: 42px; line-height: 1; }

.controls-help {
    font-size: 21px;
    color: var(--muted);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 14px;
    background: rgba(0, 0, 0, 0.45);
    border: 3px solid #333;
    padding: 10px 12px;
}
.controls-help b { color: #fff; font-weight: normal; }

/* Black drop shadow behind menu text, Minecraft style, so it reads on any background */
.menu .label, .menu-label, .menu-note, .mode-description, .menu-row .desc, .controls-help,
.server-status, .room-name, .room-info, .room-empty, .room-error, .room-bots { text-shadow: 2px 2px 0 #000; }

/* ---------- Pause menu ---------- */

.pause-page { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(860px, 100%); max-height: 100%; overflow-y: auto; }
.pause h2 { font-size: 40px; margin-bottom: 14px; text-shadow: 3px 3px 0 #333; }
.pause-page > .btn { width: min(402px, 100%); box-sizing: border-box; }
.pause-main > .pause-leave { margin-top: 18px; }
.pause-main > .pause-leave:hover { background: #b0463c; box-shadow: inset 2px 2px 0 #d8786e, inset -2px -3px 0 #6e2a24; }

/* Options page: sections side by side in one panel, one column on phones */
.pause-options {
    width: min(860px, 100%);
    box-sizing: border-box;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    background: var(--panel);
    border: 3px solid var(--panel-border);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
    padding: 16px 20px;
    margin-bottom: 6px;
}
.pause-column { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.pause-section { display: flex; flex-direction: column; gap: 4px; }
.pause-section h3 {
    font-size: 24px;
    color: var(--gold);
    text-shadow: 2px 2px 0 #3f2f00;
    border-bottom: 2px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 4px;
    margin-bottom: 4px;
}
.pause .menu-label { text-shadow: 2px 2px 0 #000; }
.btn.pause-toggle { min-width: 0; padding: 8px; }
@media (max-width: 760px) {
    .pause-options { grid-template-columns: 1fr; padding: 12px 14px; }
}
.pause-help .controls-groups {
    width: min(640px, 92vw);
    background: var(--panel);
    border: 3px solid var(--panel-border);
    padding: 12px 16px;
    font-size: 18px;
}

/* Grouped key lists: the in-game hint and the Esc menu's help (ui/controls.js) */
.controls-groups {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 22px;
    color: var(--text);
    text-shadow: 1px 1px 0 #000;
}
.controls-title {
    font-size: 0.8em;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 3px;
}
.controls-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.controls-group li { line-height: 1.2; }
.controls-group li::before { content: '•'; color: var(--muted); margin-right: 6px; }
.controls-group b { color: var(--gold); font-weight: 600; }

/* ---------- HUD ---------- */

.hud { position: fixed; inset: 0; pointer-events: none; }

/* Crosshair: four lines pushed out by --gap and a centre dot; the style and colour picked in the
   options set the variables (ui/crosshairs.js) */
.crosshair { position: absolute; left: 50%; top: 50%; --gap: 6px; --len: 9px; --thick: 2px; --dot: 0px; --ch: var(--ch-color, #5dff5d); }
.crosshair.hidden { display: none; }
/* Can't shoot right now (reloading, switching, bolt): grey and faint */
.crosshair.busy { --ch: #9a9a9a; opacity: 0.55; }
.ch { position: absolute; background: var(--ch); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55); }
.ch-t, .ch-b { width: var(--thick); height: var(--len); left: calc(var(--thick) / -2); }
.ch-l, .ch-r { height: var(--thick); width: var(--len); top: calc(var(--thick) / -2); }
.ch-t { bottom: var(--gap); }
.ch-b { top: var(--gap); }
.ch-l { right: var(--gap); }
.ch-r { left: var(--gap); }
.ch-dot { width: var(--dot); height: var(--dot); left: calc(var(--dot) / -2); top: calc(var(--dot) / -2); }
.crosshair.no-top .ch-t, .crosshair.no-dot .ch-dot, .crosshair.no-lines .ch:not(.ch-dot) { display: none; }
/* Reloading: a ring that fills clockwise, seconds left in the middle */
.reload-ring { display: none; }
.crosshair.reloading { opacity: 1; }
.crosshair.reloading .ch { display: none; }
.crosshair.reloading .reload-ring {
    display: block; position: absolute; left: -19px; top: -19px; width: 38px; height: 38px; --p: 0deg;
}
.reload-ring::before {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    background: conic-gradient(#5dff5d var(--p), rgba(255, 255, 255, 0.22) var(--p));
    -webkit-mask: radial-gradient(circle, transparent 13px, #000 14px);
            mask: radial-gradient(circle, transparent 13px, #000 14px);
}
.reload-ring span {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    font-family: var(--font); font-size: 13px; color: #fff; text-shadow: 1px 1px 0 #000;
}

/* Hit confirmation X; its opacity is set every frame by Hud.update, so it always fades out */
.hitmarker {
    position: absolute;
    left: 50%; top: 50%;
    width: 22px; height: 22px;
    transform: translate(-50%, -50%) rotate(45deg);
    opacity: 0;
}
.hitmarker::before, .hitmarker::after { content: ''; position: absolute; background: #fff; }
.hitmarker::before { left: 10px; top: 0; width: 2px; height: 22px; }
.hitmarker::after { left: 0; top: 10px; width: 22px; height: 2px; }

/* Sniper scope: black everywhere except a circle, with thin cross hairs */
.scope {
    position: absolute; inset: 0;
    background: radial-gradient(circle at center, transparent 0, transparent 41vmin, rgba(0, 0, 0, 0.9) 41.3vmin, #000 42vmin);
}
.scope.hidden { display: none; }
.scope-h, .scope-v { position: absolute; background: #000; }
.scope-h { left: 0; right: 0; top: 50%; height: 1px; }
.scope-v { top: 0; bottom: 0; left: 50%; width: 1px; }

/* Optic reticles while aiming down sights: square, blocky, glowing a little */
.reticle { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
.reticle.hidden { display: none; }
.reticle i { position: absolute; display: none; background: #ff2a2a; box-shadow: 0 0 3px rgba(255, 40, 40, 0.8); }
.reticle.reddot i:first-child,
.reticle.holo i:first-child { display: block; left: -2px; top: -2px; width: 4px; height: 4px; }
.reticle.holo i:nth-child(2) {
    display: block; left: -22px; top: -22px; width: 40px; height: 40px;
    background: transparent; border: 2px solid #ff2a2a; box-shadow: 0 0 3px rgba(255, 40, 40, 0.6);
}
/* Iron sights: a small bright dot on the front post tip */
.reticle.iron i:first-child {
    display: block; left: -2px; top: -2px; width: 4px; height: 4px;
    background: #7dff7a; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}
/* Reflex: a chevron, its tip on the aim point */
.reticle.reflex i { display: block; background: #ff3b1f; width: 2px; height: 11px; top: 0; transform-origin: top center; }
.reticle.reflex i:nth-child(1) { left: -1px; transform: rotate(40deg); }
.reticle.reflex i:nth-child(2) { left: -1px; transform: rotate(-40deg); }
.reticle.reflex i:nth-child(3) { display: none; }

.damage-layer { position: absolute; left: 50%; top: 50%; }
.damage-arc {
    position: absolute; left: 0; top: 0;
    width: 220px; height: 220px;
    border-radius: 50%;
    border-top: 7px solid rgba(255, 30, 20, 0.85);
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid transparent;
    opacity: 0;
    transition: opacity 0.7s;
    filter: blur(0.5px);
}
.damage-arc.show { opacity: 1; transition: none; }

/* CS-style numbers */
.cs-stat {
    display: flex; align-items: center; gap: 8px;
    font-family: var(--font);
    font-size: 44px; line-height: 1;
    color: #ffb33a;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.8), 2px 2px 0 rgba(0, 0, 0, 0.6);
}
.cs-stat .icon { font-size: 30px; opacity: 0.9; }
.hud-left { position: absolute; left: 22px; bottom: 14px; display: flex; gap: 34px; }
.cs-stat.health.low { color: #ff4a3a; animation: pulse 0.6s infinite; }
.cs-stat.armor.none { opacity: 0.45; }
@keyframes pulse { 50% { opacity: 0.55; } }

.ammo-box { position: absolute; right: 22px; bottom: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.weapon-name { font-family: var(--font); font-size: 18px; color: #ffcf7a; text-shadow: 1px 1px 0 #000; }
.cs-stat.ammo .sep { opacity: 0.5; margin: 0 2px; }
.cs-stat.ammo .reserve { font-size: 30px; opacity: 0.85; }
.cs-stat.ammo.low .value { color: #ff4a3a; }
.cs-stat.ammo.hidden { display: none; }
.ammo-box.reloading .cs-stat.ammo { animation: pulse 0.4s infinite; }
.ammo-box.reloading .weapon-name::after { content: ' · RELOADING'; color: #fff; }

/* Weapon bar: everything carried, bottom centre, always on */
.slots {
    position: absolute; left: 50%; bottom: 12px;
    transform: translateX(-50%);
    display: flex; gap: 4px;
    pointer-events: none;
}
.slot {
    position: relative;
    width: 76px; height: 64px;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 179, 58, 0.22);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.slot.selected { border-color: #ffb33a; background: rgba(40, 24, 0, 0.62); }
.slot.empty { opacity: 0.35; }
.slot canvas { width: 56px; height: 28px; opacity: 0.85; }
.slot.selected canvas { opacity: 1; filter: sepia(1) saturate(4) hue-rotate(-10deg); }
.slot .key { position: absolute; left: 4px; top: 1px; font-family: var(--font); font-size: 14px; color: #ffcf7a; }
.slot .name { font-family: var(--font); font-size: 11px; line-height: 1; color: #ddd; white-space: nowrap; }
.slot .count { font-family: var(--font); font-size: 13px; line-height: 1; color: #fff; white-space: nowrap; }
/* Not enough room between health and ammo: sit above them, smaller */
@media (max-width: 1150px) {
    .slots { bottom: 74px; }
    .slot { width: 62px; height: 54px; }
    .slot canvas { width: 44px; height: 22px; }
}

/* Inside a smoke cloud: grey, thicker towards the edges */
.smoke-screen {
    position: absolute; inset: 0; opacity: 0; pointer-events: none;
    background: radial-gradient(circle, rgba(150, 150, 146, 0.85), rgba(120, 120, 116, 1));
}

.net-stats {
    position: absolute;
    top: 12px; right: 12px;
    display: flex;
    gap: 10px;
    font-family: var(--font);
    font-size: 18px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 8px;
    color: var(--muted);
}
.net-stats .good { color: #6fe36f; }
.net-stats .ok { color: #ffd84a; }
.net-stats .bad { color: #ff5a5a; }

.killfeed {
    position: absolute;
    top: 44px; right: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}
.kill {
    background: rgba(0, 0, 0, 0.55);
    padding: 3px 10px;
    font-size: 21px;
    animation: fade-out 6s forwards;
}
.kill .killer { color: #9fd0ff; }
.kill .victim { color: #ffb0a0; }
.kill.mine { border: 2px solid #c8261d; }
.kill .weapon { color: #fff; margin: 0 8px; font-family: var(--font); font-size: 16px; }
.kill .hs { color: var(--danger); font-size: 12px; }
@keyframes fade-out { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

.toasts {
    position: absolute;
    left: 50%; top: 30%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.toast {
    font-family: var(--font);
    font-size: 22px;
    color: var(--gold);
    text-shadow: 2px 2px 0 #3f2f00;
    animation: toast 2.2s forwards;
}
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 10%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-10px); } }

.mode-badge {
    position: absolute;
    top: 12px; left: 12px;
    font-family: var(--font);
    font-size: 18px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 8px;
    color: var(--muted);
}

.protection {
    position: absolute;
    left: 50%; top: calc(50% + 46px);
    transform: translateX(-50%);
    font-family: var(--font);
    font-size: 18px;
    color: #9fd8ff;
    text-shadow: 1px 1px 0 #000;
}

.use-hint {
    position: absolute;
    left: 50%; top: calc(50% + 70px);
    transform: translateX(-50%);
    font-family: var(--font);
    font-size: 18px;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}

/* A timed action (a revive): a bar that fills over its time */
.progress-bar {
    position: absolute;
    left: 50%; top: calc(50% + 96px);
    transform: translateX(-50%);
    width: min(280px, 70vw); height: 22px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.35);
    overflow: hidden;
}
.progress-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #4cd964; }
.progress-bar span {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    font-family: var(--font); font-size: 15px; color: #fff; text-shadow: 1px 1px 0 #000;
}

.help-hint {
    position: absolute;
    left: 12px; top: 44px;
    width: min(520px, 40vw);   /* clear of the mode panel at the top centre */
    font-size: 15px;
    background: rgba(0, 0, 0, 0.72);
    border: 2px solid rgba(0, 0, 0, 0.9);
    padding: 10px 12px;
    transition: opacity 1s;
}
@media (max-width: 900px) {
    .help-hint .controls-groups { grid-template-columns: 1fr; }
}

.underwater { position: absolute; inset: 0; background: radial-gradient(circle, rgba(30, 110, 170, 0.35), rgba(5, 40, 80, 0.75)); }
.underwater.hidden { display: none; }
.vignette { position: absolute; inset: 0; opacity: 0; transition: opacity 0.5s; }
.vignette.damage { box-shadow: inset 0 0 160px 50px rgba(255, 0, 0, 0.6); }
.vignette.danger { box-shadow: inset 0 0 120px 30px rgba(255, 140, 0, 0.8); }
.vignette.heal { box-shadow: inset 0 0 140px 40px rgba(255, 80, 160, 0.5); }
.vignette.show { opacity: 1; transition: none; }
/* A blessing (the angel): a steady gold edge while it lasts */
.vignette.glow { box-shadow: inset 0 0 150px 36px rgba(255, 214, 90, 0.45); }
.vignette.glow.on { opacity: 1; animation: glow-pulse 1.6s ease-in-out infinite; }
@keyframes glow-pulse { 50% { opacity: 0.6; } }
.status-badge {
    position: absolute; left: 0; bottom: 100%;
    white-space: nowrap;
    font-family: var(--font);
    font-size: 20px;
    color: var(--gold);
    text-shadow: 2px 2px 0 #3f2f00;
    margin-bottom: 4px;
}
.status-badge.ending { color: #fff; animation: badge-blink 0.5s steps(1) infinite; }
@keyframes badge-blink { 50% { opacity: 0.35; } }

@media (max-width: 700px) {
    .cs-stat { font-size: 32px; }
    .cs-stat .icon { font-size: 22px; }
    .hud-left { gap: 18px; left: 12px; }
    .ammo-box { right: 12px; }
}

/* ---------- Scoreboard / respawn ---------- */

.scoreboard { min-width: min(520px, 92vw); background: rgba(10, 12, 18, 0.94); }
.scoreboard h3 { font-size: 25px; margin-bottom: 12px; text-align: center; }
.scoreboard table { width: 100%; border-collapse: collapse; font-size: 22px; }
.scoreboard th { font-family: var(--font); font-size: 18px; color: var(--muted); text-align: left; padding: 4px 8px; }
.scoreboard td { padding: 3px 8px; }
.scoreboard tr.me td { color: var(--gold); }
.scoreboard td.num, .scoreboard th.num { text-align: right; }
.scoreboard .dead { opacity: 0.5; }

.respawn {
    flex-direction: column;
    gap: 16px;
    background: rgba(120, 0, 0, 0.35);
    text-align: center;
}
.respawn h2 { font-size: 65px; color: #ff8a8a; text-shadow: 4px 4px 0 #3a0000; }
.respawn .reason { font-size: 26px; }
.respawn .countdown { font-family: var(--font); font-size: 25px; color: var(--muted); }
.respawn .watching { font-family: var(--font); font-size: 22px; color: var(--gold); }
.respawn .watching:empty { display: none; }
/* Watching a teammate: a strip along the top instead of the red full screen */
.respawn.spectating {
    inset: 0 0 auto 0; flex-direction: row; flex-wrap: wrap; gap: 6px 18px; padding: 10px 16px;
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
}
.respawn.spectating h2 { font-size: 26px; text-shadow: 2px 2px 0 #3a0000; }
.respawn.spectating .reason, .respawn.spectating .countdown { font-size: 18px; }
/* Tab held: the scoreboard owns the screen */
.respawn.behind { opacity: 0; }

.click-to-play {
    font-family: var(--font);
    text-align: center;
    font-size: 25px;
    text-shadow: 2px 2px 0 #000;
    background: rgba(0, 0, 0, 0.45);
    padding: 16px 20px;
    cursor: pointer;
}
.fullscreen-tip {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    margin-top: 10px;
    font-size: 17px;
    color: var(--gold);
}
.fullscreen-tip .btn { font-size: 18px; }

/* ---------- Mode panel, match end ---------- */

.mode-panel {
    position: absolute; left: 50%; top: 10px;
    transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: rgba(0, 0, 0, 0.45);
    padding: 6px 16px 7px;
    min-width: 200px;
    text-shadow: 1px 1px 0 #000;
}
.mode-panel.hidden { display: none; }
.mode-title { font-family: var(--font); font-size: 16px; color: var(--muted); }
.mode-main { font-family: var(--font); font-size: 30px; line-height: 1; color: #ffcf7a; display: flex; align-items: center; gap: 12px; }
.mode-sub { font-size: 18px; color: #ddd; }
.mode-sub:empty { display: none; }
.mode-main .gun { font-family: var(--font); font-size: 25px; color: #fff; }
.mode-main .pips { display: flex; gap: 4px; }
.mode-main .pip { width: 10px; height: 10px; border: 2px solid #ffcf7a; }
.mode-main .pip.on { background: #ffcf7a; }
.mode-main .team-t, .team-row.team-t td { color: #ff9a4a; }
.mode-main .team-ct, .team-row.team-ct td { color: #6fb6ff; }
.mode-main .clock { font-family: var(--font); font-size: 25px; color: #fff; min-width: 70px; text-align: center; }
.team-row td { font-family: var(--font); font-size: 18px; padding-top: 10px !important; }

.match-end { background: rgba(0, 0, 0, 0.6); }
.match-end .panel { display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: min(460px, 92vw); }
.match-end h2 { font-size: 36px; color: var(--gold); text-align: center; text-shadow: 3px 3px 0 #3f2f00; }
.standings { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: 4px; }
.standings li { display: grid; grid-template-columns: 30px 1fr auto 70px; gap: 10px; font-size: 22px; padding: 2px 8px; background: rgba(255, 255, 255, 0.05); }
.standings li.me { color: var(--gold); }
.standings .kd { color: var(--muted); text-align: right; }
.match-end .countdown { font-family: var(--font); font-size: 20px; color: var(--muted); }

/* ---------- Team Buy: money, banners, buy menu ---------- */

.money { font-family: var(--font); font-size: 34px; color: #7fe07f; text-shadow: 0 0 6px rgba(0, 0, 0, 0.8), 2px 2px 0 rgba(0, 0, 0, 0.6); }
.money.hidden { display: none; }
.money-delta { font-family: var(--font); font-size: 26px; color: #7fe07f; opacity: 0; transition: opacity 0.8s; text-shadow: 1px 1px 0 #000; }
.money-delta.spent { color: #ff8a6a; }
.money-delta.show { opacity: 1; transition: none; }

.round-banner {
    position: absolute; left: 50%; top: 22%;
    transform: translateX(-50%);
    font-family: var(--font); font-size: clamp(25px, 5vw, 47px);
    color: #fff; text-shadow: 3px 3px 0 #000;
    background: rgba(0, 0, 0, 0.45); padding: 12px 22px;
    white-space: nowrap;
}
.round-banner.hidden { display: none; }
.round-banner.team-t { color: #ffb06a; }
.round-banner.team-ct { color: #8ec9ff; }
.round-banner.wave { color: #b6e07a; }

.buy-menu {
    position: fixed; left: 24px; top: 50%;
    transform: translateY(-50%);
    width: min(360px, 90vw);
    background: rgba(10, 12, 8, 0.82);
    border: 2px solid rgba(255, 179, 58, 0.5);
    padding: 12px;
    display: flex; flex-direction: column; gap: 6px;
    z-index: 5;
}
.buy-menu.hidden { display: none; }
.buy-title { font-family: var(--font); font-size: 20px; color: #ffcf7a; margin-bottom: 4px; }
.buy-list { display: flex; flex-direction: column; gap: 4px; }
.buy-row {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255, 255, 255, 0.05); border: 1px solid transparent; color: #fff;
    font-family: var(--font); font-size: 22px; padding: 4px 8px; cursor: pointer; text-align: left;
}
.buy-row:hover { border-color: #ffcf7a; }
.buy-row .key { font-family: var(--font); font-size: 18px; color: #ffcf7a; width: 14px; }
.buy-row .name { flex: 1; }
.buy-row .price { color: #7fe07f; }
.buy-row.poor { opacity: 0.4; }
.buy-row.empty { opacity: 0.3; cursor: default; }
.buy-row.empty:hover { border-color: transparent; }
.buy-row.poor .price { color: #ff8a6a; }
.buy-row canvas { width: 64px; height: 32px; }
.buy-hint { font-size: 17px; color: var(--muted); }

/* ---------- Rooms (menu) ---------- */

.rooms { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.rooms.disabled .room-list, .room-create.disabled > :not(.room-empty) { opacity: 0.5; pointer-events: none; }

.room-list { display: flex; flex-direction: column; gap: 6px; max-height: 210px; overflow-y: auto; }
.room-row { background: rgba(0, 0, 0, 0.45); border: 3px solid #333; padding: 6px 8px; }
.room-row.full { opacity: 0.6; }
.room-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.room-name { font-family: var(--font); font-size: 22px; flex: 1 1 120px; overflow-wrap: anywhere; }
.room-info { color: var(--muted); font-size: 21px; }
.room-main input[type=password] { width: 140px; padding: 6px 8px; font-family: var(--font); font-size: 20px; color: #fff; background: #000; border: 3px solid #a0a0a0; outline: none; }
.btn.room-join, .btn.room-empty-create { min-width: 0; padding: 10px 14px; font-size: 22px; }
.btn.room-empty-create { align-self: flex-start; }
.room-empty { color: var(--muted); font-size: 21px; }
.room-error { color: var(--danger); font-size: 21px; min-height: 0; }
.room-error:empty { display: none; }

.room-create { display: flex; flex-direction: column; gap: 12px; }
.room-create .room-empty:empty { display: none; }
.room-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.room-create input[type=password] {
    font-family: var(--font);
    font-size: 25px;
    width: 100%;
    padding: 12px;
    color: #fff;
    background: #000;
    border: 3px solid #a0a0a0;
    outline: none;
}
.room-size, .room-select {
    font-family: var(--font);
    font-size: 22px;
    width: 100%;
    color: #fff;
    background: #000;
    border: 3px solid #a0a0a0;
    padding: 10px;
}
.room-bots { display: flex; flex-direction: column; gap: 8px; font-size: 22px; color: #fff; }
.room-bots label { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.room-bots input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
