/* Super Market Madness: UI styles (menu, HUD, touch controls). No external fonts or images. */

:root {
  --bg0: #0b0712;
  --bg1: #120d1d;
  --bg2: #1a1228;
  --well: #211632;
  --line: rgba(219, 203, 255, 0.12);
  --line2: rgba(219, 203, 255, 0.07);
  --line3: rgba(219, 203, 255, 0.22);
  --tx: #f7f2ff;
  --tx2: #b9abc9;
  --tx3: #7d708f;
  --acc: #8b5cf6;
  --acc-h: #a78bfa;
  --acc-hi: #c084fc;
  --gold: #f0b86b;
  --ink: #1d1006;
  --hp: #ff6b6b;
  --hunger: #f5a524;
  --thirst: #2dd4bf;
  --stam: #b8a6ff;
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #fb7185;
  --danger: #f43f5e;
  --hl: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --panel: linear-gradient(180deg, rgba(30, 21, 48, 0.8), rgba(16, 11, 27, 0.86));
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Arial Black", "Helvetica Neue", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

/* ------------------------------------------------------------------------------------------- */
/* base */

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg0); color: var(--tx);
  font-family: var(--font); font-size: 14px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  overscroll-behavior: none;
}
body {
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font-family: inherit; }
svg { display: block; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

#game {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; outline: none; background: var(--bg0);
}
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

.offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }

.lbl, .hud-lbl {
  font-size: 10.5px; font-weight: 700; line-height: 1; letter-spacing: 0.14em; text-transform: uppercase; color: var(--tx3);
}

kbd {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 6px;
  font: 700 11px/1 var(--font); letter-spacing: 0.02em; color: var(--tx);
  background: linear-gradient(180deg, #2b2040, #1c1430);
  border: 1px solid var(--line3); border-bottom-width: 2px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}
kbd.wide { padding: 0 8px; }

/* buttons */
.btn {
  appearance: none; -webkit-appearance: none; position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)), var(--bg2);
  color: var(--tx); font: 650 14px/1 var(--font); letter-spacing: 0.02em; white-space: nowrap;
  box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, 0.45);
  cursor: pointer; touch-action: manipulation;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.08s, opacity 0.15s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { border-color: var(--line3); background-color: #21172f; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--acc-h); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn-primary {
  background: var(--acc); border-color: rgba(255, 255, 255, 0.16); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), inset 0 -1px 0 rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -12px rgba(139, 92, 246, 0.85);
}
.btn-primary:hover { background: #9670f8; border-color: rgba(255, 255, 255, 0.24); }
.btn-lg { height: 52px; font-size: 16px; border-radius: 14px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; gap: 6px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--tx2); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.04); color: var(--tx); border-color: var(--line2); }
.btn-danger { color: #ffc2cb; border-color: rgba(244, 63, 94, 0.32); background: rgba(244, 63, 94, 0.08); box-shadow: none; }
.btn-danger:hover { background: rgba(244, 63, 94, 0.16); border-color: rgba(244, 63, 94, 0.5); }
.link-btn {
  appearance: none; border: 0; background: none; padding: 0; margin-left: auto;
  color: var(--acc-h); font: 600 12.5px var(--font); cursor: pointer; white-space: nowrap;
}
.link-btn:hover { color: var(--tx); text-decoration: underline; }
.icon-btn {
  appearance: none; display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(18, 13, 29, 0.72); color: var(--tx2); cursor: pointer;
  box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { color: var(--tx); border-color: var(--line3); background-color: #1d1530; }
.icon-btn:focus-visible { outline: 2px solid var(--acc-h); outline-offset: 2px; }
.icon-btn-sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn-sm svg { width: 18px; height: 18px; }

/* inputs */
input[type="text"] {
  appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 44px;
  padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--well); color: var(--tx); font: 600 16px/1 var(--font);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]::placeholder { color: var(--tx3); font-weight: 500; }
input[type="text"]:focus { border-color: rgba(167, 139, 250, 0.75); box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 0 3px rgba(139, 92, 246, 0.22); }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; margin: 0;
  background: transparent; cursor: pointer; --p: 50%;
}
input[type="range"]:focus { outline: none; }
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 6px;
  background: linear-gradient(90deg, var(--acc) 0 var(--p), rgba(219, 203, 255, 0.13) var(--p) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; border: 0;
  background: #f7f2ff; box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25), 0 2px 6px rgba(0, 0, 0, 0.5);
}
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(167, 139, 250, 0.6), 0 2px 6px rgba(0, 0, 0, 0.5); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: rgba(219, 203, 255, 0.13); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--acc); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; border: 0; background: #f7f2ff;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.25), 0 2px 6px rgba(0, 0, 0, 0.5);
}
.switch {
  -webkit-appearance: none; appearance: none; position: relative; flex: none; margin: 0;
  width: 46px; height: 28px; border-radius: 999px; cursor: pointer;
  background: rgba(219, 203, 255, 0.14); border: 1px solid var(--line);
  transition: background-color 0.15s, border-color 0.15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #f7f2ff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); transition: transform 0.16s ease;
}
.switch:checked { background: var(--acc); border-color: rgba(255, 255, 255, 0.2); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--acc-h); outline-offset: 2px; }

.card {
  background: linear-gradient(180deg, rgba(31, 22, 49, 0.9), rgba(17, 12, 28, 0.93));
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, 0.5), 0 28px 64px -24px rgba(0, 0, 0, 0.85);
}

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(11, 7, 18, 0.55); border: 1px solid var(--line2); }
.tab {
  appearance: none; flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 10px; border: 0; border-radius: 9px; background: transparent; color: var(--tx2);
  font: 750 12px/1 var(--font); letter-spacing: 0.07em; text-transform: uppercase; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, color 0.15s;
}
.tab svg { width: 16px; height: 16px; }
.tab:hover { color: var(--tx); }
.tab.active { background: var(--bg2); color: var(--tx); box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, 0.45); }
.tab:focus-visible { outline: 2px solid var(--acc-h); outline-offset: 1px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------------------------------- */
/* boot + noscript */

.boot {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 42%, #1c1330 0%, #0b0712 68%);
  transition: opacity 0.45s ease, visibility 0s linear 0.45s;
}
.boot.hidden { display: flex !important; opacity: 0; visibility: hidden; pointer-events: none; }
.boot-inner { display: grid; justify-items: center; gap: 14px; text-align: center; }
.boot-mark { width: 56px; height: 56px; color: var(--gold); animation: boot-bob 1.4s ease-in-out infinite; filter: drop-shadow(0 6px 18px rgba(240, 184, 107, 0.35)); }
.boot-title { font: 900 12px/1 var(--font); letter-spacing: 0.34em; text-transform: uppercase; color: var(--tx2); }
.boot-bar { width: 168px; height: 3px; border-radius: 3px; overflow: hidden; background: rgba(219, 203, 255, 0.1); }
.boot-bar i { display: block; width: 38%; height: 100%; border-radius: 3px; background: var(--acc-h); animation: boot-slide 1.15s ease-in-out infinite; }
.boot-text { font-size: 12.5px; color: var(--tx3); }
.boot-slow { max-width: 260px; font-size: 12.5px; color: var(--tx3); opacity: 0; animation: fade-in 0.4s ease 12s forwards; }
.boot.error {
  padding: 24px max(24px, calc(50vw - 230px)); text-align: center;
  font: 600 15px/1.55 var(--font); color: var(--tx);
}
@keyframes boot-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes boot-slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(290%); } }
.noscript {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--bg0); color: var(--tx); font: 600 16px/1.5 var(--font); text-align: center;
}

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

.menu { position: fixed; inset: 0; z-index: 60; pointer-events: auto; color: var(--tx); animation: fade-in 0.35s ease; }
.menu-bg { position: absolute; inset: 0; overflow: hidden; }
.menu-shade {
  position: absolute; inset: 0;
  background:
    radial-gradient(90% 75% at 28% 40%, rgba(11, 7, 18, 0.45) 0%, rgba(11, 7, 18, 0.8) 62%, rgba(11, 7, 18, 0.94) 100%),
    linear-gradient(180deg, rgba(20, 12, 34, 0.35), rgba(11, 7, 18, 0.75));
}
.menu-shade::before, .menu-shade::after {
  content: ""; position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; pointer-events: none; opacity: 0.55;
}
.menu-shade::before {
  left: -25vmax; top: -30vmax;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.26), rgba(139, 92, 246, 0) 62%);
}
.menu-shade::after {
  right: -30vmax; bottom: -35vmax;
  background: radial-gradient(circle, rgba(240, 184, 107, 0.16), rgba(240, 184, 107, 0) 60%);
}

/* optional CSS aisle (menu.setBackdrop('aisle')) for pages that render nothing behind the menu */
.aisle { position: absolute; inset: 0; perspective: 520px; perspective-origin: 50% 42%; display: none; opacity: 0.5; }
.menu.aisle-on .aisle { display: block; }
.aisle-plane { position: absolute; overflow: hidden; }
.aisle-plane i { position: absolute; left: 0; right: 0; top: -100%; height: 300%; will-change: transform; animation: aisle-move 2.4s linear infinite; }
.aisle-floor { left: -60%; right: -60%; top: 42%; height: 160%; transform-origin: top center; transform: rotateX(82deg); }
.aisle-floor i {
  background:
    repeating-linear-gradient(90deg, rgba(219, 203, 255, 0.12) 0 2px, transparent 2px 80px),
    repeating-linear-gradient(0deg, rgba(219, 203, 255, 0.12) 0 2px, transparent 2px 80px),
    #1a1228;
}
.aisle-ceil { left: -60%; right: -60%; bottom: 58%; height: 160%; transform-origin: bottom center; transform: rotateX(-82deg); }
.aisle-ceil i { background: repeating-linear-gradient(0deg, rgba(255, 244, 222, 0.5) 0 18px, transparent 18px 160px), #120d1d; }
.aisle-left, .aisle-right { top: -40%; bottom: -40%; width: 160%; }
.aisle-left { right: 62%; transform-origin: right center; transform: rotateY(82deg); }
.aisle-right { left: 62%; transform-origin: left center; transform: rotateY(-82deg); }
.aisle-left i, .aisle-right i {
  left: -100%; right: auto; top: 0; width: 300%; height: 100%; animation-name: aisle-side;
  background:
    repeating-linear-gradient(180deg, transparent 0 58px, rgba(0, 0, 0, 0.55) 58px 64px),
    repeating-linear-gradient(90deg, #7a2d3c 0 36px, #1e5a62 36px 70px, #8a6a2c 70px 104px, #3d2a66 104px 140px, #2a5a34 140px 170px);
}
.aisle-right i { animation-direction: reverse; }
@keyframes aisle-move { to { transform: translateY(33.333%); } }
@keyframes aisle-side { to { transform: translateX(33.333%); } }

.menu-scroll {
  position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch;
  touch-action: pan-y; overscroll-behavior: contain;
  display: flex; flex-direction: column;
  padding: calc(var(--sat) + 16px) calc(var(--sar) + 24px) calc(var(--sab) + 14px) calc(var(--sal) + 24px);
}
.menu-top, .menu-main, .menu-foot { width: 100%; max-width: 1160px; margin: 0 auto; }
.menu-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-online {
  display: inline-flex; align-items: center; gap: 9px; height: 32px; padding: 0 13px; border-radius: 999px;
  background: rgba(18, 13, 29, 0.72); border: 1px solid var(--line); color: var(--tx2);
  font: 650 12.5px/1 var(--font); box-shadow: var(--hl);
}
.menu-online .live { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.16); }
.menu-online .live::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--ok); animation: ping 2.2s ease-out infinite; }
.menu-online.off .live { background: var(--tx3); box-shadow: none; }
.menu-online.off .live::after { display: none; }
@keyframes ping { 0% { transform: scale(1); opacity: 0.6; } 70%, 100% { transform: scale(2.6); opacity: 0; } }

.menu-main {
  flex: 1 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 390px);
  align-items: center; gap: 36px; padding: 18px 0 12px;
}
.menu-hero { display: grid; justify-items: start; align-content: center; min-width: 0; }

/* logo: backlit store sign */
.logo { margin: 0 0 0 4px; display: grid; justify-items: start; position: relative; transform: rotate(-2.2deg); transform-origin: left center; font-size: 16px; }
.logo-strip {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 10px;
  margin: 0 0 -1px 22px; padding: 7px 14px 6px; border-radius: 8px 8px 0 0;
  background: var(--gold); color: var(--ink);
  font: 900 14px/1 var(--display); letter-spacing: 0.34em; text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}
.logo-strip > span:last-child { margin-right: -0.34em; }
.logo-cart { display: inline-grid; width: 22px; height: 22px; color: var(--ink); }
.logo-cart svg { width: 22px; height: 22px; }
.logo-sign {
  position: relative; display: block; padding: 12px 26px 16px;
  border-radius: 16px; border: 1px solid rgba(240, 184, 107, 0.4);
  background:
    radial-gradient(circle at 11px 11px, #6c5a82 0 2.4px, rgba(0, 0, 0, 0.5) 2.6px 3.4px, transparent 3.6px),
    radial-gradient(circle at calc(100% - 11px) 11px, #6c5a82 0 2.4px, rgba(0, 0, 0, 0.5) 2.6px 3.4px, transparent 3.6px),
    radial-gradient(circle at 11px calc(100% - 11px), #6c5a82 0 2.4px, rgba(0, 0, 0, 0.5) 2.6px 3.4px, transparent 3.6px),
    radial-gradient(circle at calc(100% - 11px) calc(100% - 11px), #6c5a82 0 2.4px, rgba(0, 0, 0, 0.5) 2.6px 3.4px, transparent 3.6px),
    linear-gradient(180deg, #241839, #140d21);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09), inset 0 0 0 5px rgba(11, 7, 18, 0.55), inset 0 0 0 6px rgba(240, 184, 107, 0.16),
    0 24px 60px -22px rgba(0, 0, 0, 0.95), 0 0 80px -30px rgba(139, 92, 246, 0.75);
}
.logo-word {
  display: block; font: 900 clamp(46px, 8.6vw, 112px)/0.98 var(--display); letter-spacing: 0.015em; text-transform: uppercase;
  color: #fff7ec;
  text-shadow: 0 0 1px #fff, 0 0 10px rgba(255, 216, 160, 0.55), 0 0 30px rgba(240, 184, 107, 0.38), 0 0 64px rgba(139, 92, 246, 0.5), 0 4px 0 #3a2856;
}
.logo-flicker { display: inline-block; will-change: opacity; animation: flicker 7s infinite; }
@keyframes flicker {
  0%, 61%, 64%, 66.5%, 100% { opacity: 1; }
  62% { opacity: 0.22; }
  65% { opacity: 0.3; }
}
.logo-tag {
  position: absolute; right: -18px; bottom: -15px; z-index: 2; transform: rotate(7deg);
  padding: 8px 13px 8px 24px; background: var(--gold); color: var(--ink);
  font: 900 10.5px/1 var(--font); letter-spacing: 0.16em; text-transform: uppercase; white-space: nowrap;
  clip-path: polygon(13px 0, 100% 0, 100% 100%, 13px 100%, 0 50%);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}
.logo-tag::before { content: ""; position: absolute; left: 10px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: #2a1d38; }

.menu-pitch { margin: 30px 0 18px; max-width: 520px; font-size: 17px; font-weight: 550; line-height: 1.45; color: var(--tx2); }

.play-card { width: 100%; max-width: 500px; padding: 18px; display: grid; gap: 16px; }
.play-id { display: flex; align-items: flex-end; gap: 12px; position: relative; }
.avatar { width: 56px; height: 56px; flex: none; border-radius: 15px; overflow: hidden; border: 1px solid var(--line); background: #231838; box-shadow: var(--hl); }
.avatar svg { width: 100%; height: 100%; }
.avatar-bg { fill: #2a1e40; }
.field { display: grid; gap: 8px; min-width: 0; }
.field-name { flex: 1; }
.saved-pill { position: absolute; right: 10px; bottom: 13px; font: 700 11px/1 var(--font); letter-spacing: 0.06em; color: var(--ok); opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.saved-pill.flash { opacity: 1; }
.saved-pill.bad { color: var(--bad); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  appearance: none; width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.on { box-shadow: 0 0 0 2px var(--bg1), 0 0 0 4px var(--tx), inset 0 2px 0 rgba(255, 255, 255, 0.28); }
.swatch:focus-visible { outline: 2px solid var(--acc-h); outline-offset: 4px; }

.play-main, .play-private { display: grid; gap: 12px; }
.invite-note {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(240, 184, 107, 0.08); border: 1px solid rgba(240, 184, 107, 0.3); color: var(--tx); font-size: 13px;
}
.invite-note svg { width: 16px; height: 16px; color: var(--gold); }
.btn-xl { height: 66px; justify-content: flex-start; gap: 14px; padding: 0 18px 0 14px; border-radius: 15px; }
.btn-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: rgba(255, 255, 255, 0.16); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22); }
.btn-ic svg { width: 18px; height: 18px; margin-left: 2px; }
.btn-stack { display: grid; gap: 5px; text-align: left; min-width: 0; }
.btn-title { font: 850 17px/1 var(--font); letter-spacing: 0.12em; text-transform: uppercase; }
.btn-sub { font: 550 12.5px/1.1 var(--font); color: rgba(255, 255, 255, 0.76); overflow: hidden; text-overflow: ellipsis; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.play-main .btn-row .btn { font-size: 12.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.play-main .btn-row .btn svg { color: var(--tx2); }

.pp-head { display: flex; align-items: center; gap: 12px; }
.pp-title { font: 850 14px/1 var(--font); letter-spacing: 0.1em; text-transform: uppercase; }
.pp-sub { margin-top: 4px; font-size: 13px; color: var(--tx2); }
.pp-created { display: grid; gap: 10px; padding: 12px; border-radius: 14px; background: rgba(11, 7, 18, 0.5); border: 1px solid var(--line); animation: rise-in 0.2s ease; }
.pp-code-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pp-code b { display: block; margin-top: 6px; font: 800 22px/1 var(--mono); letter-spacing: 0.05em; color: var(--gold); }
.pp-link {
  padding: 9px 11px; border-radius: 9px; background: rgba(11, 7, 18, 0.55); border: 1px solid var(--line2);
  font: 500 12.5px/1.2 var(--mono); color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  user-select: all; -webkit-user-select: all; cursor: text;
}
.pp-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.play-private.created .pp-sep, .play-private.created .pp-join, .play-private.created .pp-err { display: none; }
.pp-sep { display: flex; align-items: center; gap: 12px; font: 700 10.5px/1 var(--font); letter-spacing: 0.13em; text-transform: uppercase; color: var(--tx3); }
.pp-sep::before, .pp-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.pp-join { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.pp-join input { font-family: var(--mono); }
.pp-err { color: var(--bad); font-size: 13px; }
.pp-err:empty { display: none; }

.status { display: none; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 12px; font: 600 14px/1.35 var(--font); animation: rise-in 0.2s ease; }
.status.show { display: flex; }
.status.info { background: rgba(139, 92, 246, 0.12); border: 1px solid rgba(139, 92, 246, 0.34); color: var(--tx); }
.status.error { background: rgba(244, 63, 94, 0.1); border: 1px solid rgba(244, 63, 94, 0.36); color: #ffd6dc; }
.status-spin { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: var(--acc-h); animation: spin 0.8s linear infinite; }
.status.error .status-spin { animation: none; border: 0; background: var(--danger); position: relative; }
.status.error .status-spin::before { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 900 11px/16px var(--font); text-align: center; }

.side-card { display: grid; gap: 4px; padding: 8px; min-width: 0; align-self: center; }
.tab-panel { padding: 12px 8px 6px; }
.rooms { display: grid; gap: 8px; margin-bottom: 14px; }
.rooms-list { display: flex; flex-wrap: wrap; gap: 6px; }
.room-chip {
  appearance: none; display: inline-flex; align-items: center; gap: 9px; height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(11, 7, 18, 0.5); color: var(--tx); font: 650 12.5px/1 var(--font); cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.room-chip:hover:not(:disabled) { border-color: rgba(167, 139, 250, 0.6); background: rgba(139, 92, 246, 0.12); }
.room-chip:disabled { opacity: 0.45; cursor: default; }
.room-n { color: var(--tx3); font-variant-numeric: tabular-nums; }
.room-n b { color: var(--tx2); }

.lb { display: grid; }
.lb-row {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) 62px 50px 40px; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px; border-radius: 9px; font-size: 13.5px;
}
.lb-hdr { height: 26px; font: 700 10px/1 var(--font); letter-spacing: 0.13em; text-transform: uppercase; color: var(--tx3); }
.lb-body .lb-row:nth-child(odd) { background: rgba(255, 255, 255, 0.028); }
.lb-rank { color: var(--tx3); font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-row.top1 .lb-rank { color: var(--gold); }
.lb-row.top2 .lb-rank { color: #d4d7e2; }
.lb-row.top3 .lb-rank { color: #d99b6c; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.lb-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--tx2); white-space: nowrap; }
.lb-hdr .lb-n, .lb-hdr .lb-rank { color: var(--tx3); }
.lb-score { color: var(--tx); font-weight: 800; }
.lb-empty { padding: 22px 12px; text-align: center; color: var(--tx3); font-size: 13.5px; line-height: 1.5; }
.lb-skel span i { display: block; height: 8px; border-radius: 4px; background: rgba(219, 203, 255, 0.08); animation: skel 1.4s ease-in-out infinite; }
.lb-skel span:nth-child(2) i { width: 70%; }
.lb-skel span:nth-child(n+3) i { margin-left: auto; width: 70%; }
@keyframes skel { 50% { opacity: 0.4; } }

.howto-intro p { margin: 0 0 14px; font-size: 13.5px; line-height: 1.55; color: var(--tx2); }
.help { display: grid; gap: 16px; }
.help-title { margin-bottom: 8px; font: 700 10.5px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; color: var(--tx3); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.help-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 30px; font-size: 13px; color: var(--tx2); border-bottom: 1px solid var(--line2); }
.help-label { white-space: nowrap; }
.help-kbds { display: inline-flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px; }
.help-or { font-size: 11px; color: var(--tx3); }
.help-trow { display: grid; grid-template-columns: 58px 1fr; gap: 10px; padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--line2); }
.help-trow .help-label { color: var(--tx); font-weight: 650; }
.help-text { color: var(--tx2); line-height: 1.45; }

.menu-foot { display: flex; align-items: center; justify-content: center; gap: 10px; padding-top: 10px; font-size: 13px; color: var(--tx2); text-align: center; }
.tip-tag { flex: none; padding: 4px 7px; border-radius: 5px; background: var(--gold); color: var(--ink); font: 900 9.5px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; }

/* ------------------------------------------------------------------------------------------- */
/* pause + settings dialog */

.pause {
  position: fixed; inset: 0; z-index: 50; pointer-events: auto; display: grid; place-items: center;
  padding: calc(var(--sat) + 20px) calc(var(--sar) + 20px) calc(var(--sab) + 20px) calc(var(--sal) + 20px);
  background: rgba(11, 7, 18, 0.6); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px);
  animation: fade-in 0.18s ease; overflow-y: auto;
}
.pause-card { width: min(380px, 100%); padding: 24px 22px 22px; display: grid; gap: 12px; text-align: center; animation: rise-in 0.22s ease; }
.kicker { font: 800 10.5px/1 var(--font); letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold); }
.pause-note { margin: -6px 0 6px; font-size: 13px; color: var(--tx2); }
.pause-card h2 { margin: 0 0 8px; font: 900 36px/1 var(--display); letter-spacing: 0.02em; text-transform: uppercase; }
.pause-room {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 10px 10px 14px;
  border-radius: 12px; background: rgba(11, 7, 18, 0.5); border: 1px solid var(--line); text-align: left;
}
.pause-room b { display: block; margin-top: 5px; font: 800 16px/1 var(--mono); color: var(--gold); }
.pause-card .btn-danger { margin-top: 4px; }

.dialog {
  position: fixed; inset: 0; z-index: 70; pointer-events: auto; display: grid; place-items: center;
  padding: calc(var(--sat) + 16px) calc(var(--sar) + 16px) calc(var(--sab) + 16px) calc(var(--sal) + 16px);
  background: rgba(11, 7, 18, 0.55); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  animation: fade-in 0.15s ease;
}
.dialog-card {
  width: min(540px, 100%); max-height: min(680px, calc(100vh - 32px)); max-height: min(680px, calc(100dvh - 32px));
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; animation: rise-in 0.2s ease;
}
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line2); }
.dialog-head .tabs { flex: 1; }
.dialog-body { overflow-y: auto; padding: 4px 20px 16px; touch-action: pan-y; overscroll-behavior: contain; }
.dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 10px 20px; border-top: 1px solid var(--line2); }
.saved-note { font-size: 12.5px; color: var(--tx3); transition: color 0.2s; }
.saved-note.ok { color: var(--ok); font-weight: 700; }
.saved-note.bad { color: var(--bad); font-weight: 700; }
.set-group { padding: 14px 0 10px; border-bottom: 1px solid var(--line2); }
.set-group:last-child { border-bottom: 0; }
.set-title { margin-bottom: 6px; font: 700 10.5px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; color: var(--tx3); }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, 210px) 54px; align-items: center; gap: 12px; min-height: 46px; }
.set-row > label, .set-lbl { font-size: 14px; font-weight: 550; color: var(--tx); }
.set-row output { text-align: right; font: 700 13px/1 var(--font); font-variant-numeric: tabular-nums; color: var(--tx2); }
.set-row .switch { grid-column: 2 / 4; justify-self: end; }
.set-row .seg { grid-column: 2 / 4; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; border-radius: 11px; background: rgba(11, 7, 18, 0.55); border: 1px solid var(--line2); }
.seg-btn { appearance: none; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--tx2); font: 700 12.5px/1 var(--font); cursor: pointer; }
.seg-btn:hover { color: var(--tx); }
.seg-btn.on { background: var(--bg2); color: var(--tx); box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, 0.45); }
.seg-btn:focus-visible { outline: 2px solid var(--acc-h); outline-offset: 1px; }
.dialog .help { padding-top: 14px; }

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

.hud { position: fixed; inset: 0; z-index: 20; pointer-events: none; color: var(--tx); font-family: var(--font); overflow: hidden; }
.hud-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, 0.5), 0 12px 30px -14px rgba(0, 0, 0, 0.7);
}

.hud-vignette, .hud-lowhp { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.hud-vignette { background: radial-gradient(ellipse closest-side at center, rgba(255, 40, 60, 0) 70%, rgba(235, 30, 55, 0.32) 88%, rgba(190, 14, 40, 0.72) 100%), radial-gradient(ellipse farthest-corner at center, rgba(190, 14, 40, 0) 80%, rgba(170, 10, 36, 0.6) 100%); }
.hud-lowhp { background: radial-gradient(ellipse closest-side at center, rgba(150, 0, 24, 0) 72%, rgba(150, 0, 24, 0.28) 92%, rgba(130, 0, 20, 0.5) 100%); }
.hud.hp-low .hud-lowhp { animation: lowhp 1.5s ease-in-out infinite; }
.hud.hp-crit .hud-lowhp { animation-duration: 0.8s; }
@keyframes lowhp { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.85; } }

/* top left: clock */
.hud-tl { position: absolute; top: calc(var(--sat) + 16px); left: calc(var(--sal) + 16px); }
.hud-clock { display: flex; padding: 10px 2px 11px; }
.hud-clock-row { display: grid; gap: 6px; padding: 0 14px; }
.hud-clock-row + .hud-clock-row { border-left: 1px solid var(--line); }
.hud-timer { font: 850 26px/1 var(--font); font-variant-numeric: tabular-nums; letter-spacing: 0.005em; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
.hud-score { display: inline-block; font: 850 26px/1 var(--font); font-variant-numeric: tabular-nums; color: var(--gold); transform-origin: left center; }
.hud-score.pop { animation: pop 0.4s ease; }
@keyframes pop { 30% { transform: scale(1.14); } }

/* top center: PA + event */
.hud-tc {
  position: absolute; top: calc(var(--sat) + 14px); left: 50%; transform: translateX(-50%);
  width: min(500px, calc(100vw - 780px)); min-width: 380px;
  display: grid; justify-items: center; gap: 8px;
}
.hud-pa {
  display: none; align-items: stretch; max-width: 100%; border-radius: 14px; overflow: hidden;
  background: rgba(14, 10, 24, 0.92); border: 1px solid rgba(240, 184, 107, 0.4); --k: var(--gold);
  border-color: color-mix(in srgb, var(--k) 50%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 18px 40px -18px rgba(0, 0, 0, 0.95);
}
.hud-pa.show { display: flex; animation: pa-in 0.3s ease; }
.hud-pa.leaving { animation: pa-out 0.26s ease forwards; }
@keyframes pa-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes pa-out { to { opacity: 0; transform: translateY(-10px); } }
.hud-pa-tag {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; flex: none;
  padding: 8px 12px; background: var(--k); color: var(--ink);
  font: 900 9.5px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap;
}
.hud-pa-tag svg { width: 20px; height: 20px; }
.hud-pa.show .pa-wave1 { animation: pa-wave 1.1s ease-in-out infinite; }
.hud-pa.show .pa-wave2 { animation: pa-wave 1.1s ease-in-out 0.18s infinite; }
@keyframes pa-wave { 50% { opacity: 0.25; } }
.hud-pa-text { padding: 11px 15px 12px; font: 700 15px/1.35 var(--font); color: var(--tx); text-wrap: balance; }

.hud-event {
  display: none; align-items: center; gap: 9px; height: 30px; padding: 0 13px; border-radius: 999px;
  background: rgba(14, 10, 24, 0.85); --k: var(--gold); border: 1px solid color-mix(in srgb, var(--k) 50%, transparent);
  font: 850 11.5px/1 var(--font); letter-spacing: 0.11em; text-transform: uppercase; white-space: nowrap;
  box-shadow: 0 8px 22px -12px rgba(0, 0, 0, 0.9);
}
.hud-event.show { display: inline-flex; }
.hud-event-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--k); box-shadow: 0 0 10px var(--k); animation: blink 1.1s ease-in-out infinite; }
.hud-event-time { color: var(--k); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.hud-event-short { display: none; }
.hud-pa.kind-blackout, .hud-event.kind-blackout { --k: #ff7a7a; }
.hud-pa.kind-cleanup, .hud-event.kind-cleanup { --k: #facc15; }
.hud-pa.kind-bluelight, .hud-event.kind-bluelight { --k: #6aa8ff; }
.hud-pa.kind-frenzy, .hud-event.kind-frenzy { --k: #fb923c; }
.hud-pa.kind-manager, .hud-event.kind-manager { --k: #f472b6; }
.hud-pa.kind-restock, .hud-event.kind-restock { --k: #2dd4bf; }
.hud-pa.kind-info, .hud-event.kind-info { --k: var(--gold); }
.hud-event-time:empty { display: none; }
@keyframes blink { 50% { opacity: 0.3; } }

/* top right: net + feed */
.hud-tr { position: absolute; top: calc(var(--sat) + 14px); right: calc(var(--sar) + 16px); display: grid; justify-items: end; gap: 8px; }
.hud-net {
  display: inline-flex; align-items: center; gap: 11px; height: 28px; padding: 0 11px; border-radius: 9px;
  background: rgba(11, 7, 18, 0.62); border: 1px solid var(--line2);
  font: 700 12px/1 var(--font); color: var(--tx2); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.hud-net > span { display: inline-flex; align-items: center; gap: 5px; }
.hud-net svg { width: 13px; height: 13px; }
.hud-net b { color: var(--tx); font-weight: 750; }
.hud-net-solo { display: none !important; padding: 4px 7px; border-radius: 5px; background: var(--gold); color: var(--ink); font: 900 9.5px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; }
.hud-net.solo .hud-net-solo { display: inline-flex !important; }
.hud-net.solo .hud-net-players { display: none; }
.hud-net-room { font-family: var(--mono); color: var(--tx); font-weight: 600; }
.hud-net-ping i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.hud-net-ping.ok i { background: var(--warn); }
.hud-net-ping.bad i { background: var(--bad); }
.hud-fps b { color: var(--tx2); }

.hud-feed { display: grid; justify-items: end; gap: 6px; }
.feed-line {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 11px; border-radius: 10px;
  max-width: min(380px, calc(100vw - 32px)); overflow: hidden; white-space: nowrap;
  background: rgba(11, 7, 18, 0.74); border: 1px solid var(--line2);
  font: 750 13px/1 var(--font);
  opacity: 0; transform: translateX(12px); transition: opacity 0.22s ease, transform 0.22s ease;
}
.feed-line.in { opacity: 1; transform: none; }
.feed-line.out { opacity: 0; }
.feed-line.me { border-color: rgba(240, 184, 107, 0.55); background: rgba(42, 27, 18, 0.8); }
.feed-who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.feed-who span { overflow: hidden; text-overflow: ellipsis; }
.feed-who i { width: 8px; height: 8px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3); }
.feed-who.npc span { color: #b5e48c; }
.feed-weapon { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px 0 4px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); color: var(--tx2); font: 650 12px/1 var(--font); flex: none; }
.feed-weapon svg { width: 15px; height: 15px; color: var(--tx2); margin-left: 2px; }
.feed-icon { width: 20px; height: 20px; }
.feed-verb { color: var(--tx2); font-weight: 600; }

/* center */
.hud-center { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.hud-cross { position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; overflow: visible; }
.hud-cross-shadow { stroke: rgba(0, 0, 0, 0.55); stroke-width: 4; stroke-linecap: round; fill: rgba(0, 0, 0, 0.55); }
.hud-cross-lines { stroke: #fff; stroke-width: 2; stroke-linecap: round; fill: #fff; }
.hud-charge-track { fill: none; stroke: rgba(255, 255, 255, 0.2); stroke-width: 3; opacity: 0; }
.hud-charge { fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round; opacity: 0; transition: opacity 0.12s; }
.hud.charging .hud-charge, .hud.charging .hud-charge-track { opacity: 1; }
.hud.charge-full .hud-charge { stroke: #fff4e2; filter: drop-shadow(0 0 4px rgba(240, 184, 107, 0.9)); }
.hud-hitmark { stroke: #fff; stroke-width: 2.6; stroke-linecap: round; opacity: 0; filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.6)); }
.hud-hitmark.kill { stroke: #ff4d5e; stroke-width: 3.2; }
.hud-dmg { position: absolute; left: -120px; top: -120px; width: 240px; height: 240px; overflow: visible; }
.dmg-arc { opacity: 0; }
.dmg-arc-line { fill: none; stroke: #ff4d5e; stroke-width: calc(7px * var(--w, 1)); stroke-linecap: round; }
.dmg-arc-glow { fill: none; stroke: rgba(255, 50, 70, 0.3); stroke-width: calc(18px * var(--w, 1)); stroke-linecap: round; }
.hud-prompt {
  position: absolute; left: 0; top: 40px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 9px; padding: 5px 13px 5px 5px; border-radius: 11px; white-space: nowrap;
  background: rgba(11, 7, 18, 0.72); border: 1px solid var(--line);
  font: 700 14px/1 var(--font); box-shadow: 0 8px 22px -10px rgba(0, 0, 0, 0.8);
  opacity: 0; transition: opacity 0.12s;
}
.hud-prompt.show { opacity: 1; }
.hud-prompt:not(:has(kbd)) { padding-left: 13px; }
.hud-prompt kbd { height: 24px; min-width: 24px; background: var(--tx); color: var(--bg0); border-color: #fff; border-bottom-color: #cbbfe0; }
.hud-prompt kbd.wide { font-size: 10.5px; letter-spacing: 0.08em; }
.hud.dead .hud-cross, .hud.dead .hud-prompt, .hud.dead .hud-dmg, .hud.dead .hud-itemname { display: none; }
.hud.dead .hud-stats, .hud.dead .hud-bc { visibility: hidden; }

.hud-lockhint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, 84px);
  display: none; align-items: center; gap: 10px; padding: 10px 16px 10px 13px; border-radius: 999px;
  background: rgba(11, 7, 18, 0.82); border: 1px solid var(--line3); font: 700 14px/1 var(--font);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.9); animation: fade-in 0.3s ease;
}
.hud-lockhint svg { width: 18px; height: 18px; color: var(--acc-h); }
body.need-lock.hud-on:not(.hud-dead):not(.paused):not(.menu-on):not(.chat-open):not(.dialog-open) .hud-lockhint { display: inline-flex; }

/* toasts */
.hud-toasts {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 136px); transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px)); display: grid; justify-items: center; gap: 6px;
}
.toast {
  max-width: 100%; padding: 8px 15px; border-radius: 999px; text-align: center;
  background: rgba(11, 7, 18, 0.84); border: 1px solid var(--line); color: var(--tx);
  font: 650 14px/1.3 var(--font); box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.9);
  opacity: 0; transform: translateY(8px) scale(0.98); transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.in { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateY(-6px); }
.toast.bump { animation: bump 0.26s ease; }
@keyframes bump { 40% { transform: scale(1.05); } }

/* bottom left: chat + stats */
.hud-bl { position: absolute; left: calc(var(--sal) + 16px); bottom: calc(var(--sab) + 16px); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.hud-chat { width: min(420px, calc(100vw - 32px)); display: grid; gap: 6px; }
.hud-chat-lines { display: grid; justify-items: start; gap: 3px; max-height: 232px; overflow: hidden; }
.cl {
  max-width: 100%; padding: 4px 9px 5px; border-radius: 8px; background: rgba(11, 7, 18, 0.6);
  font: 500 13.5px/1.35 var(--font); color: var(--tx); overflow-wrap: anywhere; transition: opacity 0.6s ease;
  user-select: text; -webkit-user-select: text;
}
.cl-name { margin-right: 7px; font-weight: 800; }
.cl.sys { color: var(--tx2); font-style: italic; }
.cl.old { opacity: 0; }
.hud-chat:not(.open) .cl:nth-last-child(n+9) { display: none; }
.hud-chat.open { pointer-events: auto; }
.hud-chat.open .cl.old { opacity: 1; }
.hud-chat.open .hud-chat-lines { max-height: 260px; overflow-y: auto; padding: 6px; border-radius: 12px; background: rgba(11, 7, 18, 0.5); }
.hud-chat-row { display: none; align-items: center; gap: 10px; padding: 5px 5px 5px 12px; border-radius: 13px; background: rgba(14, 10, 24, 0.92); border: 1px solid rgba(167, 139, 250, 0.5); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.hud-chat.open .hud-chat-row { display: flex; }
.hud-chat-hint { flex: none; display: inline-flex; align-items: center; gap: 5px; padding-right: 6px; font-size: 11.5px; color: var(--tx3); white-space: nowrap; }
.hud-chat-hint kbd { height: 20px; font-size: 10px; }
body.touch-mode .hud-chat-hint { display: none; }
.hud-chat-say { font: 850 10.5px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.hud-chat-row input[type="text"].hud-chat-input { height: 36px; border: 0; background: transparent; box-shadow: none; padding: 0 6px; font-size: 15px; }

.hud-stats { width: 250px; padding: 11px 13px; display: grid; gap: 8px; }
.hud-effects { display: flex; flex-wrap: wrap; gap: 6px; }
.hud-effects:not(:has(.fx-chip:not([hidden]))) { display: none; }
.fx-chip {
  --c: var(--tx2); display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px;
  font: 800 10.5px/1 var(--font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--c);
  background: color-mix(in srgb, var(--c) 15%, transparent); border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.fx-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.fx-chip b { color: var(--tx); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; text-transform: none; }
.fx-chip b:empty { display: none; }
.fx-sick { --c: #a3e635; }
.fx-boost { --c: var(--gold); }
.fx-protect { --c: #7dd3fc; }
.fx-stun { --c: var(--stam); }
.stat { --c: var(--tx2); display: grid; grid-template-columns: 17px minmax(0, 1fr) 30px; align-items: center; gap: 9px; height: 17px; }
.stat svg { width: 16px; height: 16px; color: var(--c); filter: drop-shadow(0 0 6px color-mix(in srgb, var(--c) 40%, transparent)); }
.stat-bar { position: relative; height: 7px; border-radius: 7px; overflow: hidden; background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.45); }
.stat-bar i, .stat-bar b { position: absolute; inset: 0; border-radius: 7px; transform-origin: left center; }
.stat-bar i { background: var(--c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35); transition: transform 0.25s ease; }
.stat-bar b { background: rgba(255, 255, 255, 0.55); transition: transform 0.45s ease; }
.stat-num { text-align: right; font: 850 13.5px/1 var(--font); font-variant-numeric: tabular-nums; color: var(--tx); }
.stat-hp { --c: var(--hp); }
.stat-hunger { --c: var(--hunger); }
.stat-thirst { --c: var(--thirst); }
.stat-stamina { --c: var(--stam); }
.stat.low svg, .stat.low .stat-num { animation: stat-pulse 1.1s ease-in-out infinite; }
.stat.low .stat-num, .stat.crit .stat-num { color: var(--c); }
.stat.crit svg, .stat.crit .stat-num { animation: stat-pulse 0.55s ease-in-out infinite; }
.stat.crit .stat-bar { box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.45), 0 0 0 1px color-mix(in srgb, var(--c) 60%, transparent), 0 0 12px color-mix(in srgb, var(--c) 45%, transparent); }
@keyframes stat-pulse { 50% { opacity: 0.35; transform: scale(0.94); } }

/* bottom center: hotbar */
.hud-bc { position: absolute; left: 50%; bottom: calc(var(--sab) + 16px); transform: translateX(-50%); display: grid; justify-items: center; gap: 10px; }
.hud-itemname {
  display: inline-flex; align-items: center; gap: 10px; height: 30px; padding: 0 13px; border-radius: 999px; white-space: nowrap;
  background: rgba(11, 7, 18, 0.7); border: 1px solid var(--line2);
  opacity: 0; transform: translateY(6px); transition: opacity 0.2s ease, transform 0.2s ease;
}
.hud-itemname.show { opacity: 1; transform: none; }
.hud-itemname-text { font: 800 14px/1 var(--font); letter-spacing: 0.01em; }
.hud-itemname.legend .hud-itemname-text { color: var(--gold); }
.hud-itemname-hint { display: inline-flex; align-items: center; gap: 6px; font: 600 12.5px/1 var(--font); color: var(--tx2); }
.hud-itemname-hint:empty { display: none; }
.hud-itemname-hint kbd { height: 20px; min-width: 20px; font-size: 10.5px; }
.hud-hotbar {
  display: flex; gap: 8px; padding: 8px; border-radius: 19px;
  background: linear-gradient(180deg, rgba(26, 18, 41, 0.74), rgba(13, 9, 22, 0.82));
  border: 1px solid var(--line);
  box-shadow: var(--hl), 0 1px 2px rgba(0, 0, 0, 0.5), 0 14px 34px -16px rgba(0, 0, 0, 0.85);
}
.slot {
  appearance: none; position: relative; flex: none; width: 60px; height: 60px; padding: 0; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line2); pointer-events: auto; touch-action: manipulation;
  background: radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 68%), rgba(11, 7, 18, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), inset 0 -8px 16px -10px rgba(0, 0, 0, 0.6);
  transition: transform 0.14s ease, border-color 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}
.slot-icon { position: absolute; left: 4px; top: 4px; width: calc(100% - 8px); height: calc(100% - 8px); transition: opacity 0.15s, transform 0.15s; }
.slot.empty .slot-icon { opacity: 0; }
.slot-key { position: absolute; top: 5px; left: 7px; z-index: 1; font: 850 10px/1 var(--font); color: var(--tx3); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8); }
.slot:hover { border-color: var(--line3); }
.slot.sel {
  border-color: rgba(240, 184, 107, 0.9);
  background: radial-gradient(circle at 50% 32%, rgba(240, 184, 107, 0.24), rgba(240, 184, 107, 0) 70%), rgba(36, 25, 54, 0.85);
  box-shadow: 0 0 0 1px rgba(240, 184, 107, 0.35), 0 0 20px -4px rgba(240, 184, 107, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(-4px);
}
.slot.sel .slot-key { color: var(--gold); }
.slot.sel .slot-icon { transform: scale(1.06); }
.slot.legend::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 214, 120, 0.7), inset 0 0 14px rgba(255, 193, 7, 0.35);
  animation: legend 1.8s ease-in-out infinite;
}
@keyframes legend { 50% { opacity: 0.45; } }

/* scoreboard */
.hud-scoreboard { position: absolute; inset: 0; z-index: 6; display: none; place-items: center; padding: 20px; background: rgba(11, 7, 18, 0.35); }
.hud-scoreboard.show { display: grid; animation: fade-in 0.12s ease; }
.sb-card {
  width: min(740px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overflow: hidden;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; border-radius: 18px;
  background: linear-gradient(180deg, rgba(31, 22, 49, 0.94), rgba(16, 11, 27, 0.96));
  border: 1px solid var(--line); box-shadow: var(--hl), 0 28px 64px -20px rgba(0, 0, 0, 0.9);
}
.sb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px 20px 12px; }
.sb-title { font: 900 22px/1 var(--display); letter-spacing: 0.03em; text-transform: uppercase; }
.sb-room { font: 700 12.5px/1 var(--mono); color: var(--gold); }
.sb-row {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) 72px 52px 60px 66px 62px; align-items: center; gap: 8px;
  height: 38px; padding: 0 20px; font-size: 14px;
}
.sb-hdr { height: 28px; border-bottom: 1px solid var(--line2); font: 700 10px/1 var(--font); letter-spacing: 0.13em; text-transform: uppercase; color: var(--tx3); }
.sb-body { overflow-y: auto; padding: 4px 0 6px; }
.sb-body .sb-row:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }
.sb-body .sb-row.me { background: rgba(240, 184, 107, 0.11); box-shadow: inset 3px 0 0 var(--gold); }
.sb-row.out .sb-name span, .sb-row.out .sb-n { color: var(--tx3); }
.sb-rank { color: var(--tx3); font-weight: 800; font-variant-numeric: tabular-nums; }
.sb-name { display: flex; align-items: center; gap: 9px; min-width: 0; font-weight: 750; }
.sb-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-name i { flex: none; width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3); }
.sb-name em { flex: none; padding: 3px 5px; border-radius: 4px; background: var(--gold); color: var(--ink); font: 900 9px/1 var(--font); font-style: normal; letter-spacing: 0.12em; text-transform: uppercase; }
.sb-n { text-align: right; font-variant-numeric: tabular-nums; color: var(--tx2); }
.sb-hdr .sb-n { color: var(--tx3); }
.sb-score { color: var(--tx); font-weight: 850; }
.sb-st { justify-self: end; padding: 4px 7px; border-radius: 6px; font: 850 10px/1 var(--font); letter-spacing: 0.1em; text-transform: uppercase; }
.sb-st.alive { color: var(--ok); background: rgba(74, 222, 128, 0.1); }
.sb-st.dead { color: var(--tx3); background: rgba(255, 255, 255, 0.05); }
.sb-empty { padding: 26px 20px; text-align: center; color: var(--tx3); }
.sb-foot { padding: 11px 20px 13px; border-top: 1px solid var(--line2); font-size: 12px; color: var(--tx3); }

/* death */
.hud-death {
  position: absolute; inset: 0; display: none; place-items: center; pointer-events: auto; z-index: 5;
  padding: calc(var(--sat) + 24px) calc(var(--sar) + 20px) calc(var(--sab) + 24px) calc(var(--sal) + 20px);
  background: radial-gradient(ellipse at 50% 46%, rgba(70, 10, 28, 0.5), rgba(11, 7, 18, 0.9) 72%);
  overflow-y: auto;
}
.hud-death.show { display: grid; animation: fade-in 0.6s ease; }
.death-card { width: min(760px, 100%); display: grid; justify-items: center; gap: 14px; text-align: center; animation: rise-in 0.5s ease 0.1s both; }
.death-kicker { font: 850 11px/1 var(--font); letter-spacing: 0.26em; text-transform: uppercase; color: #ff8fa0; }
.death-cause { max-width: 720px; font: 900 clamp(25px, 3.6vw, 42px)/1.12 var(--display); letter-spacing: 0.005em; text-wrap: balance; text-shadow: 0 4px 26px rgba(0, 0, 0, 0.7); }
.death-who { text-shadow: 0 0 22px color-mix(in srgb, currentColor 35%, transparent), 0 4px 26px rgba(0, 0, 0, 0.7); }
.death-stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; width: 100%; max-width: 600px; margin-top: 8px;
  border-radius: 16px; overflow: hidden; background: var(--line); border: 1px solid var(--line);
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.9);
}
.death-stats > div { display: grid; gap: 8px; padding: 14px 8px 15px; background: rgba(18, 13, 29, 0.94); }
.death-stats b { font: 850 24px/1 var(--font); font-variant-numeric: tabular-nums; }
.death-newbest { padding: 6px 11px; border-radius: 999px; background: rgba(240, 184, 107, 0.12); border: 1px solid rgba(240, 184, 107, 0.45); color: var(--gold); font: 850 10.5px/1 var(--font); letter-spacing: 0.14em; text-transform: uppercase; }
.death-btn { min-width: 230px; margin-top: 6px; }
.death-btn::after { content: ""; position: absolute; inset: -6px; border-radius: 18px; border: 2px solid rgba(167, 139, 250, 0.55); opacity: 0; pointer-events: none; }
.death-btn.ready::after { animation: ring 1.8s ease-out infinite; }
@keyframes ring { 0% { opacity: 0.9; transform: scale(0.97); } 100% { opacity: 0; transform: scale(1.06); } }
.death-hint { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--tx3); opacity: 0.55; transition: opacity 0.2s; }
.death-hint.ready { opacity: 1; color: var(--tx2); }

/* ------------------------------------------------------------------------------------------- */
/* touch controls */

.touch {
  position: fixed; inset: 0; z-index: 15; display: none; pointer-events: none;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  --tb: 0px;
}
body.touch-mode.hud-on:not(.hud-dead):not(.paused):not(.menu-on):not(.chat-open):not(.dialog-open) .touch.on { display: block; }
.t-zone { position: absolute; top: calc(var(--sat) + 64px); bottom: 0; pointer-events: auto; touch-action: none; }
.t-zone-left { left: 0; width: 44%; }
.t-zone-right { right: 0; width: 56%; }
.t-stick { position: absolute; width: 0; height: 0; pointer-events: none; }
.t-stick-idle { left: calc(var(--sal) + 104px); bottom: calc(var(--sab) + var(--tb) + 104px); opacity: 0.6; }
.t-stick-live { left: 0; top: 0; display: none; }
.touch.stick-on .t-stick-live { display: block; }
.touch.stick-on .t-stick-idle { display: none; }
.t-ring {
  position: absolute; left: -66px; top: -66px; width: 132px; height: 132px; border-radius: 50%;
  border: 2px solid rgba(247, 242, 255, 0.3); background: radial-gradient(circle, rgba(11, 7, 18, 0.18), rgba(11, 7, 18, 0.42));
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.3); transition: border-color 0.12s, box-shadow 0.12s;
}
.t-knob {
  position: absolute; left: -28px; top: -28px; width: 56px; height: 56px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.75), rgba(214, 200, 240, 0.5));
  border: 1px solid rgba(255, 255, 255, 0.75); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.t-sprint {
  position: absolute; left: -50px; top: -96px; width: 100px; text-align: center; opacity: 0; transition: opacity 0.12s;
  font: 900 10px/1 var(--font); letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}
.touch.sprinting .t-ring { border-color: var(--gold); box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.3), 0 0 0 5px rgba(240, 184, 107, 0.2); }
.touch.sprinting .t-sprint { opacity: 1; }

.t-top { position: absolute; top: calc(var(--sat) + 12px); right: calc(var(--sar) + 12px); display: flex; gap: 8px; }
.t-mini {
  appearance: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 13px;
  border: 1px solid var(--line3); background: rgba(18, 13, 29, 0.66); color: var(--tx);
  box-shadow: var(--hl), 0 6px 16px -8px rgba(0, 0, 0, 0.7); pointer-events: auto; touch-action: manipulation;
}
.t-mini svg { width: 20px; height: 20px; }
.t-mini.on { background: rgba(139, 92, 246, 0.6); border-color: rgba(255, 255, 255, 0.5); }

.t-cluster { position: absolute; right: var(--sar); bottom: calc(var(--sab) + var(--tb)); width: 0; height: 0; transform-origin: 100% 100%; }
.t-btn {
  appearance: none; position: absolute; display: grid; place-items: center; align-content: center; gap: 3px; padding: 0;
  border-radius: 50%; border: 1.5px solid rgba(247, 242, 255, 0.42); background: rgba(14, 10, 24, 0.64); color: var(--tx);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 8px 18px -8px rgba(0, 0, 0, 0.7);
  pointer-events: auto; touch-action: none; transition: transform 0.06s ease, background-color 0.1s ease, border-color 0.1s ease;
}
.t-btn { --s: 60px; width: var(--s); height: var(--s); }
.t-btn svg { width: calc(var(--s) * 0.4); height: calc(var(--s) * 0.4); }
.t-btn span { font: 850 8.5px/1 var(--font); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); letter-spacing: 0.1em; text-transform: uppercase; color: rgba(247, 242, 255, 0.86); }
.t-btn.down { transform: scale(0.93); background: rgba(139, 92, 246, 0.55); border-color: rgba(255, 255, 255, 0.75); }
.t-attack { --s: 86px; right: 22px; bottom: 26px; background: rgba(150, 22, 48, 0.8); border: 2px solid rgba(255, 150, 170, 0.85); }
.t-attack.down { background: rgba(225, 45, 80, 0.8); }
.t-throw { --s: 66px; right: 120px; bottom: 16px; background: rgba(100, 62, 18, 0.8); border: 2px solid rgba(240, 184, 107, 0.9); }
.t-throw.down { background: rgba(190, 128, 48, 0.8); }
.t-jump { --s: 62px; right: 32px; bottom: 124px; }
.t-grab { --s: 58px; right: 110px; bottom: 98px; }
.t-eat { --s: 50px; right: 178px; bottom: 92px; }
.t-drop { --s: 46px; right: 106px; bottom: 168px; }
.t-crouch { --s: 50px; right: 198px; bottom: 20px; }
.t-crouch span { letter-spacing: 0.03em; }
.t-crouch.on { background: rgba(139, 92, 246, 0.62); border-color: rgba(255, 255, 255, 0.75); }
.t-grab::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid rgba(240, 184, 107, 0.7); opacity: 0; pointer-events: none; }
body.has-prompt .t-grab { border-color: var(--gold); background: rgba(100, 62, 18, 0.8); }
body.has-prompt .t-grab::after { animation: ring 1.3s ease-out infinite; }

/* ------------------------------------------------------------------------------------------- */
/* HUD layouts: touch (landscape first), then portrait / narrow */

body.touch-mode .slot-key,
body.touch-mode .sb-foot,
body.touch-mode .death-hint,
body.touch-mode .hud-itemname-hint { display: none; }
body.touch-mode .hud-tl { top: calc(var(--sat) + 12px); left: calc(var(--sal) + 12px); }
body.touch-mode .hud-clock { padding: 8px 0 9px; }
body.touch-mode .hud-clock-row { padding: 0 12px; gap: 5px; }
body.touch-mode .hud-timer, body.touch-mode .hud-score { font-size: 21px; }
body.touch-mode .hud-bl { display: contents; }
body.touch-mode .hud-stats { position: absolute; top: calc(var(--sat) + 76px); left: calc(var(--sal) + 12px); width: 190px; padding: 8px 10px; gap: 5px; }
body.touch-mode .stat { height: 12px; gap: 8px; }
body.touch-mode .stat svg { width: 13px; height: 13px; }
body.touch-mode .stat-bar { height: 6px; }
body.touch-mode .stat-num { font-size: 11.5px; }
body.touch-mode .fx-chip { height: 20px; font-size: 9.5px; padding: 0 7px; }
body.touch-mode .hud-chat { position: absolute; top: calc(var(--sat) + 110px); left: 50%; transform: translateX(-50%); width: min(420px, calc(100vw - 440px)); }
body.touch-mode .hud-chat:not(.open) .cl:nth-last-child(n+3) { display: none; }
body.touch-mode .hud-chat.open { top: calc(var(--sat) + 12px); left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 24px)); z-index: 6; }
body.touch-mode .hud-tc { top: calc(var(--sat) + 12px); width: min(420px, calc(100vw - 420px)); min-width: 0; }
body.touch-mode .hud-pa-text { font-size: 13.5px; padding: 9px 12px 10px; }
body.touch-mode .hud-pa-tag { padding: 6px 10px; }
body.touch-mode .hud-tr { top: calc(var(--sat) + 66px); right: calc(var(--sar) + 12px); }
body.touch-mode .hud-feed .feed-line:nth-last-child(n+3) { display: none; }
body.touch-mode .feed-line { height: 28px; font-size: 12px; max-width: min(360px, 42vw); }
body.touch-mode .hud-bc { bottom: calc(var(--sab) + 10px); gap: 6px; }
body.touch-mode .hud-hotbar { gap: 6px; padding: 6px; border-radius: 16px; }
body.touch-mode .slot { width: 48px; height: 48px; border-radius: 11px; }
body.touch-mode .hud-itemname { height: 26px; }
body.touch-mode .hud-itemname-text { font-size: 12.5px; }
body.touch-mode .hud-toasts { bottom: auto; top: calc(50% + 80px); }
body.touch-mode .hud-prompt { top: 34px; }
body.touch-mode .hud-scoreboard { padding: calc(var(--sat) + 12px) calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px); }
body.touch-mode .death-stats b { font-size: 20px; }
.touch.used .t-stick-idle { display: none; }

@media (orientation: portrait) {
  .touch { --tb: 100px; }
  body.touch-mode .t-cluster { transform: scale(0.9); }
  body.touch-mode .t-stick-idle { left: calc(var(--sal) + 94px); bottom: calc(var(--sab) + var(--tb) + 112px); }
  body.touch-mode .t-zone-left { width: 46%; }
  body.touch-mode .t-zone-right { width: 54%; }
  body.touch-mode .hud-tc, body.touch-mode .hud-tr { display: contents; }
  body.touch-mode .hud-net { position: absolute; top: calc(var(--sat) + 66px); right: calc(var(--sar) + 12px); gap: 8px; padding: 0 9px; }
  body.touch-mode .hud-net-room { display: none; }
  body.touch-mode .hud-event { position: absolute; top: calc(var(--sat) + 102px); right: calc(var(--sar) + 12px); height: 28px; padding: 0 10px; font-size: 10.5px; gap: 7px; }
  body.touch-mode .hud-event-name { display: none; }
  body.touch-mode .hud-event-short { display: inline; }
  body.touch-mode .hud-pa { position: absolute; top: calc(var(--sat) + 192px); left: calc(var(--sal) + 12px); right: calc(var(--sar) + 12px); z-index: 4; }
  body.touch-mode .hud-feed { position: absolute; top: calc(var(--sat) + 192px); right: calc(var(--sar) + 12px); }
  body.touch-mode .hud:has(.hud-pa.show) .hud-feed { top: calc(var(--sat) + 274px); }
  body.touch-mode .hud:has(.hud-pa.show) .feed-line:nth-last-child(n+2) { display: none; }
  body.touch-mode .feed-line { max-width: calc(100vw - 24px); }
  body.touch-mode .hud-chat { top: calc(var(--sat) + 314px); left: calc(var(--sal) + 12px); transform: none; width: calc(100vw - 24px); }
  body.touch-mode .hud-bc { bottom: calc(var(--sab) + 12px); }
  body.touch-mode .hud-hotbar { padding: 6px; gap: 6px; }
  body.touch-mode .slot { width: 50px; height: 50px; }
  body.touch-mode .hud-toasts { top: calc(50% + 84px); }
}

/* short landscape phones */
@media (orientation: landscape) and (max-height: 460px) {
  body.touch-mode .t-cluster { transform: scale(0.88); }
  body.touch-mode .t-stick-idle { left: calc(var(--sal) + 96px); bottom: calc(var(--sab) + 92px); transform: scale(0.9); }
  body.touch-mode .slot { width: 44px; height: 44px; border-radius: 10px; }
  body.touch-mode .hud-hotbar { gap: 5px; padding: 5px; border-radius: 14px; }
  body.touch-mode .t-top { top: calc(var(--sat) + 10px); }
  body.touch-mode .t-mini { width: 40px; height: 40px; border-radius: 12px; }
  body.touch-mode .hud-tr { top: calc(var(--sat) + 60px); }
}

/* narrow screens without touch controls */
@media (max-width: 760px) {
  body:not(.touch-mode) .hud-tl { top: calc(var(--sat) + 12px); left: calc(var(--sal) + 12px); }
  body:not(.touch-mode) .hud-clock { padding: 8px 0 9px; }
  body:not(.touch-mode) .hud-clock-row { padding: 0 12px; gap: 5px; }
  body:not(.touch-mode) .hud-timer, body:not(.touch-mode) .hud-score { font-size: 21px; }
  body:not(.touch-mode) .hud-tc, body:not(.touch-mode) .hud-tr, body:not(.touch-mode) .hud-bl { display: contents; }
  body:not(.touch-mode) .hud-net { position: absolute; top: calc(var(--sat) + 12px); right: calc(var(--sar) + 12px); gap: 8px; padding: 0 9px; }
  body:not(.touch-mode) .hud-net-room { display: none; }
  body:not(.touch-mode) .hud-pa { position: absolute; top: calc(var(--sat) + 76px); left: calc(var(--sal) + 12px); right: calc(var(--sar) + 12px); z-index: 4; }
  body:not(.touch-mode) .hud-pa-text { font-size: 14px; }
  body:not(.touch-mode) .hud-event { position: absolute; top: calc(var(--sat) + 76px); left: 50%; transform: translateX(-50%); }
  body:not(.touch-mode) .hud:has(.hud-pa.show) .hud-event { top: calc(var(--sat) + 160px); }
  body:not(.touch-mode) .hud-feed { position: absolute; top: calc(var(--sat) + 116px); right: calc(var(--sar) + 12px); }
  body:not(.touch-mode) .hud:not(:has(.hud-event.show)) .hud-feed { top: calc(var(--sat) + 76px); }
  body:not(.touch-mode) .hud:has(.hud-pa.show) .hud-feed { top: calc(var(--sat) + 200px); }
  body:not(.touch-mode) .hud:has(.hud-pa.show):not(:has(.hud-event.show)) .hud-feed { top: calc(var(--sat) + 160px); }
  body:not(.touch-mode) .hud:has(.hud-pa.show) .feed-line:nth-last-child(n+2) { display: none; }
  body:not(.touch-mode) .hud-feed .feed-line:nth-last-child(n+4) { display: none; }
  body:not(.touch-mode) .feed-line { height: 28px; font-size: 12px; max-width: calc(100vw - 24px); }
  body:not(.touch-mode) .hud-chat { position: absolute; top: calc(var(--sat) + 250px); left: calc(var(--sal) + 12px); width: calc(100vw - 24px); }
  body:not(.touch-mode) .hud-chat:not(.open) .cl:nth-last-child(n+3) { display: none; }
  body:not(.touch-mode) .hud-chat.open { top: calc(var(--sat) + 76px); z-index: 6; }
  body:not(.touch-mode) .hud-stats { position: absolute; left: calc(var(--sal) + 12px); bottom: calc(var(--sab) + 118px); width: 200px; padding: 9px 11px; gap: 7px; }
  body:not(.touch-mode) .stat { height: 15px; gap: 8px; }
  body:not(.touch-mode) .hud-bc { bottom: calc(var(--sab) + 12px); gap: 6px; }
  body:not(.touch-mode) .hud-hotbar { padding: 6px; gap: 6px; border-radius: 16px; }
  body:not(.touch-mode) .slot { width: 50px; height: 50px; border-radius: 11px; }
  body:not(.touch-mode) .hud-toasts { bottom: auto; top: calc(50% + 86px); }
  body:not(.touch-mode) .hud-itemname-hint { display: none; }
}

/* tiny windows (narrow and short, no touch): stats up top, chat only while typing */
@media (max-width: 760px) and (max-height: 540px) {
  body:not(.touch-mode) .hud-stats { top: calc(var(--sat) + 72px); bottom: auto; width: 180px; padding: 7px 9px; gap: 4px; }
  body:not(.touch-mode) .stat { height: 11px; }
  body:not(.touch-mode) .stat svg { width: 12px; height: 12px; }
  body:not(.touch-mode) .stat-bar { height: 5px; }
  body:not(.touch-mode) .stat-num { font-size: 11px; }
  body:not(.touch-mode) .fx-chip { height: 18px; font-size: 9px; padding: 0 6px; }
  body:not(.touch-mode) .hud-chat:not(.open) { display: none; }
  body:not(.touch-mode) .hud-chat.open { top: calc(var(--sat) + 12px); }
  body:not(.touch-mode) .hud-event { top: calc(var(--sat) + 44px); left: auto; right: calc(var(--sar) + 12px); transform: none; height: 26px; font-size: 10px; }
  body:not(.touch-mode) .hud-event-name { display: none; }
  body:not(.touch-mode) .hud-event-short { display: inline; }
  body:not(.touch-mode) .hud:has(.hud-pa.show) .hud-event { top: calc(var(--sat) + 44px); }
  body:not(.touch-mode) .hud-feed, body:not(.touch-mode) .hud:not(:has(.hud-event.show)) .hud-feed { top: calc(var(--sat) + 76px); }
  body:not(.touch-mode) .hud:has(.hud-pa.show) .hud-feed { visibility: hidden; }
  body:not(.touch-mode) .hud-feed .feed-line:nth-last-child(n+2) { display: none; }
  body:not(.touch-mode) .hud-pa { top: calc(var(--sat) + 72px); }
  body:not(.touch-mode) .hud:has(.hud-pa.show) .hud-stats { visibility: hidden; }
  body:not(.touch-mode) .hud-toasts { top: auto; bottom: calc(var(--sab) + 96px); }
  body:not(.touch-mode) .hud-itemname { display: none; }
  body:not(.touch-mode) .hud-lockhint { transform: translate(-50%, -86px); }
  body:not(.touch-mode) .hud-prompt { top: 30px; }
  body:not(.touch-mode) .slot { width: 44px; height: 44px; }
}

/* mid widths: keep the hotbar clear of the stats */
@media (max-width: 1040px) and (min-width: 761px) {
  body:not(.touch-mode) .slot { width: 52px; height: 52px; }
  body:not(.touch-mode) .hud-hotbar { gap: 6px; padding: 6px; }
  body:not(.touch-mode) .hud-stats { width: 220px; }
}
@media (max-width: 900px) and (min-width: 761px) {
  body:not(.touch-mode) .hud-bl { bottom: calc(var(--sab) + 112px); }
}
/* mid widths: the kill feed drops below the PA banner / event chip column */
@media (max-width: 1180px) and (min-width: 761px) {
  body:not(.touch-mode) .hud-feed { margin-top: max(0px, calc(var(--tc-bottom, 0px) - 42px - var(--sat))); transition: margin-top 0.2s ease; }
  body:not(.touch-mode) .hud-tc { width: min(500px, calc(100vw - 544px)); min-width: 0; }
}
@media (max-width: 960px) and (min-width: 761px) {
  body:not(.touch-mode) .hud-tc { top: calc(var(--sat) + 92px); width: min(520px, calc(100vw - 48px)); }
}

/* scoreboard + death on small screens */
@media (max-width: 640px) {
  .sb-row { grid-template-columns: 22px minmax(0, 1fr) 58px 42px 46px 52px; padding: 0 12px; gap: 6px; font-size: 13px; }
  .sb-best { display: none; }
  .hud-scoreboard { padding: 10px; }
  .sb-head { padding: 14px 14px 10px; }
  .sb-title { font-size: 18px; }
  .death-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .death-stats b { font-size: 21px; }
  .death-btn { width: 100%; }
}

/* ------------------------------------------------------------------------------------------- */
/* menu responsive */

@media (max-width: 960px) {
  .menu-main { grid-template-columns: minmax(0, 1fr); gap: 22px; align-items: start; padding-top: 22px; }
  .menu-hero { justify-items: center; text-align: center; }
  .logo { transform: rotate(-2deg); transform-origin: center; margin: 0; }
  .menu-pitch { margin: 28px auto 16px; }
  .play-card { margin: 0 auto; text-align: left; }
  .side-card { width: 100%; max-width: 500px; margin: 0 auto; }
}
@media (max-width: 520px) {
  .menu-scroll { padding: calc(var(--sat) + 12px) calc(var(--sar) + 14px) calc(var(--sab) + 12px) calc(var(--sal) + 14px); }
  .logo-strip { font-size: 11.5px; padding: 6px 11px 5px; margin-left: 16px; gap: 8px; }
  .logo-cart, .logo-cart svg { width: 18px; height: 18px; }
  .logo-sign { padding: 10px 18px 13px; border-radius: 14px; }
  .logo-word { font-size: clamp(38px, 12.4vw, 60px); }
  .logo-tag { font-size: 9.5px; right: -8px; bottom: -14px; padding: 7px 11px 7px 21px; }
  .menu-pitch { font-size: 15px; margin: 26px auto 14px; }
  .play-card { padding: 14px; gap: 14px; border-radius: 16px; }
  .swatches { gap: 7px; }
  .swatch { width: 30px; height: 30px; }
  .btn-xl { height: 62px; }
  .btn-title { font-size: 16px; }
  .play-main .btn-row .btn { padding: 0 10px; font-size: 11.5px; letter-spacing: 0.08em; }
  .help-grid { grid-template-columns: 1fr; }
  .lb-row { grid-template-columns: 22px minmax(0, 1fr) 58px 46px 34px; padding: 0 8px; gap: 6px; font-size: 13px; }
  .set-row { grid-template-columns: minmax(0, 1fr) 54px; row-gap: 2px; padding: 6px 0; }
  .set-row input[type="range"] { grid-column: 1 / 3; grid-row: 2; }
  .set-row output { grid-column: 2; grid-row: 1; }
  .set-row .switch, .set-row .seg { grid-column: 1 / 3; }
  .set-row .switch { grid-column: 2; grid-row: 1; }
  .set-row .seg { grid-row: 2; }
  .dialog { padding: calc(var(--sat) + 8px) calc(var(--sar) + 8px) calc(var(--sab) + 8px) calc(var(--sal) + 8px); }
  .dialog-body { padding: 4px 16px 14px; }
  .menu-foot { font-size: 12.5px; }
}
@media (max-width: 480px) {
  .sb-row { grid-template-columns: 20px minmax(0, 1fr) 56px 40px 50px; padding: 0 12px; }
  .sb-deaths, .sb-name em { display: none; }
}
@media (max-height: 820px) and (min-width: 961px) {
  .logo-word { font-size: clamp(46px, 7.2vw, 92px); }
  .logo-sign { padding: 10px 24px 14px; }
  .menu-pitch { margin: 24px 0 14px; }
  .play-card { gap: 14px; padding: 16px; }
  .menu-main { padding: 10px 0 6px; }
}
@media (max-height: 560px) and (min-width: 700px) {
  .menu-main { align-items: start; }
  .logo-word { font-size: clamp(40px, 7vw, 76px); }
  .menu-pitch { margin: 22px 0 12px; font-size: 15px; }
}
@media (pointer: coarse) {
  .swatch { width: 32px; height: 32px; }
  /* full screen blurs over a live WebGL canvas are costly on phones */
  .pause, .dialog { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(11, 7, 18, 0.8); }
}

@media (prefers-reduced-motion: reduce) {
  .aisle-plane i, .logo-flicker, .boot-mark,
  .menu-online .live::after, .hud-event-dot, .t-grab::after, .death-btn::after, .slot.legend::after, .stat.low svg, .stat.crit svg,
  .stat.low .stat-num, .stat.crit .stat-num { animation: none !important; }
}
