:root {
  --bg: #0d0f17;
  --panel: rgba(20, 24, 38, .92);
  --card: #1a2033;
  --line: #2c3550;
  --text: #eef1ff;
  --muted: #98a2c3;
  --accent: #5fa8ff;
  --glow: #4df3ff;
  --ok: #34e39b;
  --bad: #ff5d73;
  --warn: #ffd166;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
input, select {
  font: inherit; color: var(--text); background: #11152a; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.btn { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; }
.btn.primary { border: 0; background: linear-gradient(135deg, #ff5d73, #a855f7); box-shadow: 0 8px 26px rgba(255, 93, 115, .3); font-size: 18px; padding: 14px; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.danger { border-color: #6b2333; color: #ffb3bf; }
.btn:active { transform: translateY(1px); }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

/* ---------- вход ---------- */
.join { display: none; position: fixed; inset: 0; z-index: 30; background: radial-gradient(900px 600px at 50% 0%, #2a1840, var(--bg) 70%); align-items: center; justify-content: center; padding: 16px; }
.join.on { display: flex; }
.join-box { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 12px; }
.logo { font-size: 60px; text-align: center; }
h1 { margin: 0; text-align: center; font-size: 42px; letter-spacing: 1px; }
.tagline { text-align: center; color: var(--muted); margin: 0 0 6px; }
.join input { padding: 14px 16px; font-size: 18px; }
.help { color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }

/* ---------- HUD ---------- */
.hud { display: none; position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud.on { display: block; }
.hud button, .hud .joy { pointer-events: auto; }
.feed { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-width: min(60vw, 420px); }
.feed li { background: rgba(10, 12, 20, .6); padding: 4px 10px; border-radius: 8px; font-size: 13px; animation: in .25s; }
.feed li.kill { color: #ffd0d6; }
.feed li.admin { color: #c9b8ff; }
.feed li.join, .feed li.leave { color: var(--muted); }
@keyframes in { from { opacity: 0; transform: translateX(-10px); } }
.top-buttons { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; display: flex; gap: 8px; }
.board { display: none; position: absolute; top: 62px; right: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; min-width: 230px; font-size: 14px; }
.board.on { display: block; }
.board table { border-collapse: collapse; width: 100%; }
.board td, .board th { padding: 4px 6px; text-align: right; }
.board th { color: var(--muted); font-weight: 500; }
.board td:first-child, .board th:first-child { text-align: left; }
.board .me-row-hl td { color: var(--warn); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

.me { position: absolute; left: 12px; bottom: max(14px, env(safe-area-inset-bottom)); width: min(320px, 44vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.me-row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.me-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-kd { color: var(--muted); font-variant-numeric: tabular-nums; }
.hpbar { position: relative; height: 18px; border-radius: 999px; background: #2a0f17; overflow: hidden; }
.hpfill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff3b5c, #ff8a5c); transition: width .15s; }
.hpbar span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 18px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.me-weapon { margin-top: 6px; font-size: 13px; color: var(--muted); }
.me-weapon.glow { color: var(--glow); text-shadow: 0 0 8px var(--glow); }

.dead { display: none; position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%); text-align: center; background: rgba(40, 6, 14, .75); border: 1px solid #6b2333; padding: 16px 26px; border-radius: 16px; }
.dead.on { display: block; }
.dead-title { font-size: 26px; font-weight: 800; color: #ffb3bf; }

.joy { display: none; position: absolute; left: 0; bottom: 0; width: 50%; height: 60%; }
.joy-knob { display: none; position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .06); }
.joy-knob::after { content: ""; position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(255, 255, 255, .35); transform: translate(var(--kx, 0), var(--ky, 0)); }
.attack { display: none; position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); width: 96px; height: 96px; border-radius: 50%; border: 0; font-size: 38px; background: radial-gradient(circle at 50% 35%, #ff8a9a, #d9264a); box-shadow: 0 6px 0 #7d0f22, 0 0 30px rgba(255, 60, 90, .4); }
.attack:active { transform: translateY(4px); box-shadow: 0 2px 0 #7d0f22; }
body.touch .joy, body.touch .attack { display: block; }
body.touch .me { bottom: auto; top: 60px; left: 12px; width: min(260px, 60vw); }
body.touch .feed { top: auto; bottom: 140px; left: 50%; transform: translateX(-50%); align-items: center; max-width: 64vw; }
body.touch .feed li { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 64vw; }

/* ---------- админка ---------- */
.admin { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(5, 6, 12, .6); align-items: flex-start; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 12px 16px; overflow-y: auto; }
.admin.on { display: flex; }
.admin-box { width: 100%; max-width: 760px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px 18px; backdrop-filter: blur(6px); }
.admin-head { display: flex; justify-content: space-between; align-items: center; }
.admin h2 { margin: 0; font-size: 22px; }
.admin h3 { margin: 18px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); font-weight: 600; }
.admin-locked { display: none; }
.admin.locked .admin-locked { display: block; }
.admin.locked #admin-body { display: none; }
.weapon-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.wcard { text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.wcard.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(95, 168, 255, .2); }
.wcard.glow.on { border-color: var(--glow); box-shadow: 0 0 18px rgba(77, 243, 255, .45); }
.wcard canvas { position: static; width: 100%; height: 56px; }
.wcard b { font-size: 16px; }
.wcard small { color: var(--muted); }
.table-wrap { overflow-x: auto; }
.ptable { width: 100%; border-collapse: collapse; font-size: 14px; }
.ptable th { color: var(--muted); font-weight: 500; text-align: left; padding: 6px; white-space: nowrap; }
.ptable td { padding: 6px; border-top: 1px solid var(--line); white-space: nowrap; }
.ptable select, .ptable input { padding: 6px 8px; font-size: 13px; }
.ptable input { width: 76px; }
.ptable .acts { display: flex; gap: 4px; }
.ptable .acts button { width: 34px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }
.ptable .off { opacity: .45; }
.settings { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.settings label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.settings input { width: 110px; }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%) translateY(-200px); background: #2a1730; border: 1px solid var(--bad); color: #ffd6dd; padding: 10px 16px; border-radius: 12px; z-index: 60; transition: transform .25s; max-width: calc(100vw - 32px); }
.toast.on { transform: translateX(-50%) translateY(0); }
.conn { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: var(--bad); color: #fff; text-align: center; padding: 6px; font-size: 14px; }
.conn.on { display: block; }

@media (max-width: 560px) {
  .ptable th:nth-child(5), .ptable td:nth-child(5) { display: none; }
}
