:root {
  --bg: #0b0f1a;
  --panel: rgba(12, 16, 28, .82);
  --card: #1a2033;
  --line: rgba(255, 255, 255, .12);
  --text: #eef1ff;
  --muted: #9aa4c4;
  --a: #ff4d5e;
  --b: #3d8bff;
  --bot: #2fd36b;
  --gold: #ffd166;
  --bad: #ff5d73;
  --hud: #f2e3a8;
  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.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; user-select: none; }
canvas#cv { 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 #2c3550; border-radius: 10px; padding: 9px 11px; outline: none; user-select: text; }
input:focus, select:focus { border-color: var(--b); }
.btn { padding: 11px 16px; border-radius: 12px; border: 1px solid #2c3550; background: var(--card); font-weight: 600; }
.btn.primary { border: 0; background: linear-gradient(135deg, var(--a), var(--b)); box-shadow: 0 8px 26px rgba(61, 139, 255, .3); font-size: 18px; padding: 14px; }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.danger { border-color: #6b2333; color: #ffb3bf; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 17px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 13px; }

/* ---------- вход ---------- */
.join { display: none; position: fixed; inset: 0; z-index: 30; background: radial-gradient(1000px 640px at 50% 0%, #1d2a52, var(--bg) 70%); align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.join.on { display: flex; }
.join-box { width: 100%; max-width: 440px; 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; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.help summary { cursor: pointer; color: var(--text); font-weight: 600; }
.help table { width: 100%; margin-top: 6px; border-collapse: collapse; }
.help td { padding: 3px 4px; }
.help td:first-child { color: var(--text); white-space: nowrap; width: 40%; }
.join-note { text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- HUD ---------- */
.hud { display: none; position: fixed; inset: 0; z-index: 10; pointer-events: none; font-variant-numeric: tabular-nums; }
.hud.on { display: block; }
.hud button, .hud .touch > div { pointer-events: auto; }

.crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; --gap: 6px; }
.crosshair i { position: absolute; background: #6dff8a; box-shadow: 0 0 2px #000; }
.crosshair i:nth-child(1) { width: 2px; height: 8px; left: -1px; bottom: var(--gap); }
.crosshair i:nth-child(2) { width: 2px; height: 8px; left: -1px; top: var(--gap); }
.crosshair i:nth-child(3) { width: 8px; height: 2px; right: var(--gap); top: -1px; }
.crosshair i:nth-child(4) { width: 8px; height: 2px; left: var(--gap); top: -1px; }
.scope { display: none; position: absolute; inset: 0; }
.scope.on { display: block; }
.scope-ring { position: absolute; left: 50%; top: 50%; width: min(92vh, 92vw); height: min(92vh, 92vw); transform: translate(-50%, -50%); border-radius: 50%; box-shadow: 0 0 0 200vmax #000; background:
  linear-gradient(#000, #000) center / 1px 100% no-repeat, linear-gradient(#000, #000) center / 100% 1px no-repeat; }
.hitmark { position: absolute; left: 50%; top: 50%; width: 0; height: 0; opacity: 0; }
.hitmark i { position: absolute; width: 2px; height: 9px; background: #fff; box-shadow: 0 0 2px #000; }
.hitmark i:nth-child(1) { transform: translate(-9px, -12px) rotate(-45deg); }
.hitmark i:nth-child(2) { transform: translate(7px, -12px) rotate(45deg); }
.hitmark i:nth-child(3) { transform: translate(-9px, 3px) rotate(45deg); }
.hitmark i:nth-child(4) { transform: translate(7px, 3px) rotate(-45deg); }
.hitmark.on { animation: hit .25s ease-out; }
.hitmark.head i { background: var(--bad); }
@keyframes hit { 0% { opacity: 1; } 100% { opacity: 0; } }
.hurt { position: absolute; inset: 0; box-shadow: inset 0 0 180px rgba(255, 20, 40, .8); opacity: 0; transition: opacity .4s; }
.hurt.on { opacity: 1; transition: none; }
.flashbang { position: absolute; inset: 0; background: #fff; opacity: 0; }

.topbar { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; align-items: stretch; }
.score { display: flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.score b { font-size: 24px; }
.score span { font-weight: 900; font-size: 15px; }
.score small { color: var(--gold); font-size: 13px; }
.score.a span, .score.a b { color: var(--a); }
.score.b span, .score.b b { color: var(--b); }
.clock { text-align: center; padding: 3px 14px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); min-width: 92px; }
#timer { font-size: 22px; font-weight: 800; color: var(--hud); }
#timer.warn { color: var(--bad); }
#phase { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.bots-left { position: absolute; top: 62px; left: 50%; transform: translateX(-50%); font-size: 13px; color: var(--bot); text-shadow: 0 1px 2px #000; }

.minimap { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 8px; width: 180px; height: 180px; border-radius: 12px; background: rgba(10, 14, 24, .7); border: 1px solid var(--line); }
.killfeed { position: absolute; top: 56px; right: 10px; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; max-width: 46vw; }
.killfeed li { background: rgba(10, 12, 20, .7); padding: 3px 10px; border-radius: 6px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.killfeed li.mine { border: 1px solid var(--bad); }
.killfeed li.info { color: var(--gold); }
.killfeed li.admin { color: #c9b8ff; }
.killfeed .ta { color: var(--a); } .killfeed .tb { color: var(--b); } .killfeed .tbot { color: var(--bot); }

.chat { position: absolute; left: 10px; bottom: 120px; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-width: min(520px, 60vw); }
.chat li { font-size: 14px; text-shadow: 0 1px 2px #000, 0 0 4px #000; transition: opacity 1s; }
.chat li.old { opacity: 0; }
.hud.chatting .chat li.old { opacity: .85; }
.chat .n { font-weight: 700; }
.chat .team { color: var(--gold); }
.chat-input { display: none; position: absolute; left: 10px; bottom: 86px; align-items: center; gap: 6px; pointer-events: auto; }
.chat-input.on { display: flex; }
.chat-input span { font-size: 13px; color: var(--gold); text-shadow: 0 1px 2px #000; }
.chat-input input { width: min(420px, 70vw); padding: 6px 10px; background: rgba(10, 14, 24, .85); }

.vitals { position: absolute; left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 12px; }
.vital { display: flex; align-items: baseline; gap: 6px; padding: 4px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--hud); }
.vital .ico { font-size: 20px; }
.vital b { font-size: 30px; }
.vital small { color: var(--muted); }
.vital.low b { color: var(--bad); }
.money { position: absolute; right: 12px; bottom: 112px; display: flex; align-items: baseline; gap: 4px; padding: 4px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: #7dff9d; }
.money span { font-size: 20px; font-weight: 800; }
.money b { font-size: 26px; }
.money small { color: var(--gold); margin-left: 8px; font-size: 12px; }
.money.flash { animation: money .5s; }
@keyframes money { 50% { transform: scale(1.12); } }
.ammo { position: absolute; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); text-align: right; padding: 4px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); color: var(--hud); min-width: 170px; }
.slots { display: flex; gap: 4px; justify-content: flex-end; margin: 2px 0; flex-wrap: wrap; }
.slots span { font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); }
.slots span.on { color: var(--text); border-color: var(--gold); }
.ammo-row b { font-size: 32px; }
.ammo-row b.low { color: var(--bad); }
.ammo-row span { color: var(--muted); margin-left: 4px; }
.weapon-name { color: var(--muted); font-size: 13px; }

.banner { display: none; position: absolute; left: 50%; top: 24%; transform: translate(-50%, -50%); text-align: center; padding: 14px 28px; border-radius: 16px; background: rgba(10, 12, 22, .78); border: 1px solid var(--line); min-width: min(440px, 90vw); }
.banner.on { display: block; }
.banner-title { font-size: 30px; font-weight: 800; }
.banner-sub { color: var(--muted); margin-top: 4px; }
.spec { display: none; position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 16px; text-align: center; }
.spec.on { display: block; }
.spec small { display: block; color: var(--muted); font-size: 12px; }
.lock { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; pointer-events: auto; cursor: pointer; background: rgba(5, 7, 14, .3); }
.lock.on { display: flex; }
.lock-box { display: flex; flex-direction: column; gap: 6px; align-items: center; background: var(--panel); border: 1px solid var(--line); padding: 18px 26px; border-radius: 16px; }
.lock-box b { font-size: 20px; }
.lock-box span { color: var(--muted); font-size: 13px; }
.top-buttons { position: absolute; top: 196px; left: 8px; display: flex; gap: 6px; }
.perf { position: fixed; right: 8px; top: 8px; z-index: 50; font: 12px ui-monospace, monospace; color: #9f9; text-shadow: 0 1px 2px #000; pointer-events: none; display: none; }
.perf.on { display: block; }

/* ---------- панели ---------- */
.panel { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(5, 6, 12, .55); align-items: flex-start; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 12px 16px; overflow-y: auto; }
.panel.on { display: flex; }
.panel-box { width: 100%; max-width: 640px; background: rgba(14, 18, 30, .95); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px 18px; }
.panel-box.wide { max-width: 900px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel h2 { margin: 0; font-size: 22px; }
.panel h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); font-weight: 600; }

.buy-money { margin-left: auto; color: #7dff9d; font-size: 20px; font-weight: 800; }
.buy-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.buy-cats button { padding: 8px 12px; border-radius: 10px; border: 1px solid #2c3550; background: var(--card); }
.buy-cats button.on { border-color: var(--gold); color: var(--gold); }
.buy-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; margin-top: 10px; }
.buy-items button { text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid #2c3550; background: var(--card); display: flex; flex-direction: column; gap: 3px; }
.buy-items button:hover:not(:disabled) { border-color: var(--gold); }
.buy-items b { font-size: 15px; }
.buy-items small { color: var(--muted); font-size: 12px; }
.buy-items .price { color: #7dff9d; font-weight: 700; }
.buy-items button:disabled .price { color: var(--bad); }
.buy-items kbd { float: right; color: var(--muted); font: 12px ui-monospace, monospace; }

.board { display: none; position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 35; background: rgba(12, 16, 28, .92); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; width: min(860px, calc(100vw - 24px)); max-height: calc(100vh - 100px); overflow: auto; pointer-events: none; }
.board.on { display: block; }
.board .head { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.board .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.board h4 { margin: 0 0 6px; font-size: 16px; display: flex; justify-content: space-between; }
.board h4.a { color: var(--a); } .board h4.b { color: var(--b); }
.board table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.board td, .board th { padding: 4px 5px; text-align: right; }
.board th { color: var(--muted); font-weight: 500; }
.board td:first-child, .board th:first-child { text-align: left; }
.board tr.me td { color: var(--gold); }
.board tr.dead td { opacity: .5; }
.board tr.off td:first-child::after { content: " (нет связи)"; color: var(--muted); font-size: 12px; }
.board .bots-line { margin-top: 10px; color: var(--bot); font-size: 14px; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.settings-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.settings-grid label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.settings-grid output { color: var(--text); font-size: 13px; }
.adm-rules input { width: 100%; }
#btn-leave { margin-top: 10px; }
#btn-rules { margin-top: 10px; }
.admin-locked { display: none; margin-top: 10px; }
.admin.locked .admin-locked { display: block; }
.admin.locked #admin-body { display: none; }
.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: 5px 6px; border-top: 1px solid var(--line); white-space: nowrap; }
.ptable select { padding: 5px 7px; font-size: 13px; }
.ptable .acts { display: flex; gap: 4px; }
.ptable .acts button { min-width: 32px; height: 30px; border-radius: 8px; border: 1px solid #2c3550; background: var(--card); font-size: 13px; padding: 0 6px; }
.ptable tr.off { opacity: .45; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ---------- сенсорное управление ---------- */
.touch { display: none; }
body.touchdev .touch { display: block; }
.joy { position: absolute; left: 0; bottom: 0; width: 42%; height: 60%; }
.look { position: absolute; right: 0; top: 15%; width: 58%; height: 85%; }
.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)); }
.t-btn { position: absolute; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .3); background: rgba(20, 24, 40, .55); font-size: 20px; font-weight: 800; width: 54px; height: 54px; }
.t-btn.fire { right: 22px; bottom: 150px; width: 88px; height: 88px; background: rgba(255, 77, 94, .55); font-size: 28px; }
.t-btn.jump { right: 124px; bottom: 120px; }
.t-btn.crouch { right: 124px; bottom: 56px; }
.t-btn.reload { right: 120px; bottom: 196px; }
.t-btn.weapon { right: 32px; bottom: 250px; }
.t-btn.scopebtn { right: 186px; bottom: 160px; }
body.touchdev .vitals { bottom: auto; top: 50px; left: auto; right: 10px; transform: scale(.75); transform-origin: top right; }
body.touchdev .money { bottom: auto; top: 96px; right: 10px; transform: scale(.75); transform-origin: top right; }
body.touchdev .ammo { bottom: auto; top: 136px; right: 10px; transform: scale(.75); transform-origin: top right; }
body.touchdev .killfeed { top: 230px; }
body.touchdev .minimap { top: 52px; width: 104px; height: 104px; }
body.touchdev .top-buttons { top: 162px; gap: 4px; }
body.touchdev .icon-btn { width: 34px; height: 34px; font-size: 15px; }
body.touchdev .bots-left { display: none; }
.rotate { display: none; }
@media (orientation: portrait) {
  body.touchdev .rotate { display: block; position: absolute; left: 50%; top: 40%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 13px; color: var(--muted); white-space: nowrap; }
}
body.touchdev .chat { bottom: auto; top: 190px; }

.toast { position: fixed; left: 50%; top: 90px; transform: translateX(-50%) translateY(-260px); 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; }
.nogl { display: none; position: fixed; inset: 0; z-index: 80; background: var(--bg); align-items: center; justify-content: center; font-size: 18px; padding: 24px; text-align: center; }
.nogl.on { display: flex; }

@media (max-width: 700px) {
  .score { padding: 3px 8px; gap: 5px; }
  .score b { font-size: 18px; }
  #timer { font-size: 17px; }
  .clock { min-width: 70px; padding: 2px 8px; }
  .board .cols { grid-template-columns: 1fr; }
}
