:root {
  --hud: #f2b33d; --hud-dim: rgba(242, 179, 61, .55); --t: #e0a050; --ct: #7fb2ff;
  --bg: #14170f; --panel: rgba(18, 22, 14, .92); --line: #4b5236; --txt: #e8e4cf; --muted: #a39f88; --accent: #c9a227; --danger: #c0473a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--txt); font: 14px/1.45 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif; user-select: none; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: var(--txt); background: #2b3122; border: 1px solid var(--line); padding: 7px 14px; cursor: pointer; border-radius: 2px; }
button:hover { background: #3a4230; border-color: var(--accent); }
button.primary { background: #5c6a26; border-color: #94a33e; }
button.primary:hover { background: #6f7f2e; }
button.danger { background: #5a2420; border-color: #8a3a32; }
button.big { padding: 11px 22px; font-size: 16px; font-weight: 600; }
button.mini { padding: 2px 8px; font-size: 12px; float: right; }
input, select { font: inherit; color: var(--txt); background: #0f120b; border: 1px solid var(--line); padding: 5px 8px; border-radius: 2px; }
input[type=range] { padding: 0; vertical-align: middle; }
label { display: block; margin: 8px 0; color: var(--muted); }
label input:not([type=range]):not([type=checkbox]), label select { margin-left: 6px; }
label.chk input { margin-right: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tip { color: var(--muted); font-size: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); padding: 16px 18px; border-radius: 3px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .45); z-index: 20; }
#menu { background: radial-gradient(ellipse at 30% 20%, #3b3a22 0%, #171a10 55%, #0b0d08 100%); overflow: auto; align-items: flex-start; }
.menuwrap { width: min(1080px, 100%); padding: 28px 16px 40px; }
header h1 { margin: 0; font-size: 44px; letter-spacing: 4px; color: #f0d27a; text-shadow: 0 3px 0 #5a4410, 0 0 30px rgba(240, 190, 80, .25); }
header h1 span { font-size: 20px; letter-spacing: 6px; color: #b9a76b; margin-left: 8px; }
header p { color: var(--muted); margin: 4px 0 18px; }
.cols { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } header h1 { font-size: 32px; } }
h2, h3 { margin: 0 0 10px; color: #f0d27a; font-weight: 600; }
h3 { font-size: 15px; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-top: 6px; }
.maps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.map { border: 2px solid var(--line); padding: 6px; cursor: pointer; background: #10130c; border-radius: 3px; }
.map canvas { width: 100%; aspect-ratio: 1; display: block; image-rendering: pixelated; background: #000; }
.map b { display: block; margin-top: 4px; }
.map small { color: var(--muted); font-size: 11px; display: block; min-height: 30px; }
.map.sel { border-color: var(--accent); background: #232913; }
#rooms { max-height: 190px; overflow: auto; margin-bottom: 10px; }
.roomrow { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-bottom: 1px solid #262b1c; cursor: pointer; }
.roomrow:hover { background: #262c1b; }
.roomrow small { color: var(--muted); }
table.keys { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
table.keys td { padding: 3px 4px; border-bottom: 1px solid #262b1c; }
table.keys td:nth-child(odd) { color: var(--accent); white-space: nowrap; font-family: Consolas, monospace; }
footer { margin-top: 14px; color: var(--muted); }

/* ---------- 阵营选择 ---------- */
#teamsel .panel { width: min(620px, 94vw); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.teambtn { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 18px; text-align: left; min-height: 150px; }
.teambtn span { font-size: 26px; font-weight: 700; }
.teambtn.ct span { color: var(--ct); }
.teambtn.t span { color: var(--t); }
.teambtn small { color: var(--muted); }
#teamsel b, #buy b.k { display: inline-block; min-width: 20px; color: var(--accent); }
.panel.small { width: 340px; display: flex; flex-direction: column; gap: 8px; }
#roomlink { width: 100%; margin-top: 4px; font-size: 12px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-family: "Arial Black", "Segoe UI", "Microsoft YaHei", sans-serif; }
#hud input { pointer-events: auto; }
#cross { position: absolute; left: 50%; top: 50%; --g: 6px; }
#cross i { position: absolute; background: #5f5; box-shadow: 0 0 1px #000; }
#cross .l, #cross .r { width: 8px; height: 2px; top: -1px; }
#cross .t, #cross .b { width: 2px; height: 8px; left: -1px; }
#cross .l { right: var(--g); } #cross .r { left: var(--g); }
#cross .t { bottom: var(--g); } #cross .b { top: var(--g); }
#hitmark { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px; opacity: 0; transition: opacity .15s;
  background: linear-gradient(45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%), linear-gradient(-45deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%);
  -webkit-mask: radial-gradient(circle, transparent 5px, #000 6px); mask: radial-gradient(circle, transparent 5px, #000 6px); }
#hitmark.on { opacity: 1; transition: none; }
#hitmark.hs { filter: drop-shadow(0 0 2px red) sepia(1) saturate(8) hue-rotate(-40deg); }
#scope { position: absolute; inset: 0; background: radial-gradient(circle at center, transparent 0, transparent min(38vh, 38vw), #000 calc(min(38vh, 38vw) + 1px)); }
#scope::before, #scope::after { content: ""; position: absolute; background: #000; }
#scope::before { left: 0; right: 0; top: 50%; height: 1px; }
#scope::after { top: 0; bottom: 0; left: 50%; width: 1px; }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; }
#dmgdir { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
#dmgdir i { position: absolute; width: 60px; height: 14px; margin: -7px -30px; background: radial-gradient(ellipse, rgba(255, 30, 20, .85), transparent 70%); transition: opacity .8s; }
#radar { position: absolute; left: 14px; top: 14px; width: 190px; height: 190px; border-radius: 50%; background: rgba(0, 0, 0, .35); border: 2px solid rgba(242, 179, 61, .4); }
#topbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 16px; align-items: center; font-size: 22px; color: var(--hud); text-shadow: 0 0 4px #000; }
#topbar .t { color: var(--t); } #topbar .ct { color: var(--ct); }
#timer { min-width: 76px; text-align: center; background: rgba(0, 0, 0, .35); padding: 2px 10px; border-radius: 3px; }
#timer.warn { color: #ff5a4a; }
#bombico { position: absolute; top: 46px; left: 50%; transform: translateX(-50%); font-size: 26px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
#killfeed { position: absolute; right: 14px; top: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-weight: 600; font-size: 13px; }
#killfeed div { background: rgba(0, 0, 0, .55); padding: 3px 9px; border-radius: 2px; }
#killfeed div.me { border: 1px solid #c33; }
#killfeed .w { color: #ddd; margin: 0 7px; font-size: 12px; }
.tc { color: var(--t); } .ctc { color: var(--ct); }
#center { position: absolute; top: 27%; left: 0; right: 0; text-align: center; font-size: 30px; color: #fff; text-shadow: 0 2px 6px #000; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-weight: 700; }
#center small { display: block; font-size: 16px; color: #ddd; font-weight: 400; }
#hint { position: absolute; bottom: 120px; left: 0; right: 0; text-align: center; color: #fff; font-size: 15px; text-shadow: 0 1px 3px #000; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; }
#progress { position: absolute; top: 62%; left: 50%; transform: translateX(-50%); width: 300px; text-align: center; color: #fff; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; text-shadow: 0 1px 2px #000; }
#progress .bar { height: 10px; border: 1px solid var(--hud); background: rgba(0, 0, 0, .5); margin-top: 4px; }
#progbar { height: 100%; width: 0; background: var(--hud); }
#bl { position: absolute; left: 18px; bottom: 14px; font-size: 34px; color: var(--hud); text-shadow: 0 0 6px rgba(0, 0, 0, .8); display: flex; gap: 34px; opacity: .9; }
#bl b { font-weight: 900; }
#bl .low { color: #ff3b30; }
#money { position: absolute; right: 20px; bottom: 74px; font-size: 30px; color: #4fe066; text-shadow: 0 0 6px rgba(0, 0, 0, .8); display: flex; gap: 8px; align-items: center; }
#money span { font-size: 20px; }
#money #c4ico { color: #ff5b4a; font-size: 18px; border: 2px solid #ff5b4a; padding: 0 4px; animation: blink 1.2s infinite; }
#cashdelta { color: #8f8; font-size: 18px !important; }
#cashdelta.neg { color: #f66; }
#ammo { position: absolute; right: 20px; bottom: 14px; font-size: 34px; color: var(--hud); text-shadow: 0 0 6px rgba(0, 0, 0, .8); }
#ammo b { font-weight: 900; }
#ammo span { font-size: 24px; opacity: .85; margin-left: 10px; }
#weapons { position: absolute; right: 20px; bottom: 120px; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 13px; color: var(--hud-dim); text-shadow: 0 0 3px #000; }
#weapons .on { color: var(--hud); font-weight: 700; font-size: 15px; }
#chatlog { position: absolute; left: 14px; bottom: 80px; width: min(520px, 60vw); font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; text-shadow: 0 1px 2px #000; }
#chatlog div { transition: opacity 1s; }
#chatlog .sys { color: #ffd76a; }
#chatin { position: absolute; left: 14px; bottom: 50px; width: min(520px, 70vw); background: rgba(0, 0, 0, .7); }
#spec { position: absolute; bottom: 0; left: 0; right: 0; height: 64px; background: rgba(0, 0, 0, .6); display: flex; align-items: center; justify-content: center; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 18px; color: #fff; flex-direction: column; }
#spec small { color: #bbb; font-size: 12px; }
#netinfo { position: absolute; right: 14px; bottom: 170px; font: 11px Consolas, monospace; color: rgba(255, 255, 255, .45); }

/* ---------- 购买菜单 / 计分板 ---------- */
#buy { position: fixed; left: 40px; top: 50%; transform: translateY(-50%); width: 420px; z-index: 15; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; }
#buy .it { display: flex; justify-content: space-between; padding: 6px 8px; cursor: pointer; border-bottom: 1px solid #262b1c; }
#buy .it:hover { background: #2c3320; }
#buy .it.no { opacity: .4; }
#buy .it .p { color: #4fe066; }
#buy .it .p.x { color: #e55; }
#buy .foot { margin-top: 10px; color: var(--muted); font-size: 12px; }
#board { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(760px, 94vw); z-index: 15; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; }
#board table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
#board th { text-align: left; font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); }
#board td { padding: 3px 6px; }
#board tr.dead td { opacity: .45; }
#board tr.me td { background: rgba(255, 255, 255, .07); }
#board .hdr { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); }

/* ---------- 触屏 / 手机横屏 ---------- */
#touch { position: fixed; inset: 0; z-index: 8; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#joyzone { position: absolute; left: 0; top: 18%; bottom: 0; width: 42%; touch-action: none; }
#lookzone { position: absolute; right: 0; top: 0; bottom: 0; width: 58%; touch-action: none; }
#joy { position: absolute; width: 130px; height: 130px; margin: -65px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(0, 0, 0, .18); pointer-events: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255, 255, 255, .35); }
.tb { position: absolute; display: flex; align-items: center; justify-content: center; width: 58px; height: 58px; border-radius: 50%; background: rgba(0, 0, 0, .32); border: 2px solid rgba(255, 255, 255, .35); color: #fff; font: 600 13px "Segoe UI", "Microsoft YaHei", sans-serif; text-shadow: 0 1px 2px #000; touch-action: none; text-align: center; line-height: 1.1; }
.tb.on { background: rgba(242, 179, 61, .45); border-color: var(--hud); }
.tb.big { width: 92px; height: 92px; font-size: 16px; background: rgba(160, 30, 20, .35); border-color: rgba(255, 120, 100, .6); }
#tFire { right: calc(26px + env(safe-area-inset-right)); bottom: 70px; }
#tFire2 { left: calc(18px + env(safe-area-inset-left)); top: 40%; width: 54px; height: 54px; background: rgba(160, 30, 20, .3); }
#tJump { right: calc(130px + env(safe-area-inset-right)); bottom: 28px; }
#tCrouch { right: calc(130px + env(safe-area-inset-right)); bottom: 100px; }
#tReload { right: calc(30px + env(safe-area-inset-right)); bottom: 178px; }
#tScope { right: calc(104px + env(safe-area-inset-right)); bottom: 172px; }
#tNext { right: calc(30px + env(safe-area-inset-right)); bottom: 250px; }
#tNade { right: calc(104px + env(safe-area-inset-right)); bottom: 244px; }
#tUse { right: calc(200px + env(safe-area-inset-right)); bottom: 28px; font-size: 11px; }
#tDrop { right: calc(178px + env(safe-area-inset-right)); bottom: 210px; width: 44px; height: 44px; }
.tbar { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; margin-top: 40px; }
.tbar .tb { position: static; width: auto; height: 30px; padding: 0 12px; border-radius: 15px; font-size: 12px; }
#rotate { display: none; position: fixed; inset: 0; z-index: 100; background: #14170f; color: #f0d27a; align-items: center; justify-content: center; text-align: center; font-size: 22px; }
@media (orientation: portrait) and (pointer: coarse) { body.ingame #rotate { display: flex; } }

body.touch #radar { width: 112px; height: 112px; left: calc(8px + env(safe-area-inset-left)); top: 8px; }
body.touch #weapons, body.touch #netinfo { display: none; }
body.touch #bl { font-size: 24px; gap: 18px; left: calc(14px + env(safe-area-inset-left)); bottom: 8px; }
body.touch #ammo { right: auto; left: 50%; transform: translateX(-50%); bottom: 6px; font-size: 26px; }
body.touch #ammo span { font-size: 18px; }
body.touch #money { right: calc(14px + env(safe-area-inset-right)); bottom: auto; top: 128px; font-size: 22px; }
body.touch #killfeed { font-size: 11px; }
body.touch #chatlog { bottom: 44px; font-size: 12px; width: 40vw; }
body.touch #hint { bottom: 46px; font-size: 13px; }
body.touch #center { font-size: 22px; top: 22%; }
body.touch #topbar { font-size: 17px; top: 6px; }
body.touch #spec { height: 40px; font-size: 14px; pointer-events: none; }
body.touch #buy { left: 50%; transform: translate(-50%, -50%); width: min(460px, 92vw); max-height: 92vh; overflow: auto; }
body.touch #buy .it { padding: 9px 8px; }
body.touch #board { max-height: 92vh; overflow: auto; font-size: 12px; }
@media (max-height: 520px) {
  .teambtn { min-height: 0; padding: 10px; } .teambtn span { font-size: 20px; }
  #teamsel .panel, .panel.small { max-height: 94vh; overflow: auto; }
}
