:root {
  --bg: #0b1220;
  --panel: rgba(10, 16, 30, 0.72);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --me: #3b82f6;
  --enemy: #ef4444;
  --accent: #facc15;
  --good: #22c55e;
  --display: 'Black Han Sans', 'Noto Sans KR', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: 'Noto Sans KR', system-ui, sans-serif;
  user-select: none; -webkit-user-select: none;
}
#view { position: fixed; inset: 0; }
#view canvas { display: block; }
.hidden { display: none !important; }

/* ---------- 메뉴 화면 ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(8, 12, 24, 0.25), rgba(8, 12, 24, 0.82));
  overflow-y: auto;
}
.menu-inner {
  width: min(580px, 100%);
  display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center;
}
.logo {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(72px, 13vw, 132px); line-height: 1; letter-spacing: 0.04em;
  color: #fff; transform: rotate(-3deg);
  text-shadow: 0 6px 0 #1d4ed8, 0 12px 0 #0f172a, 0 18px 40px rgba(0, 0, 0, 0.55);
}
.tag { color: #cbd5e1; font-weight: 700; letter-spacing: 0.02em; margin-top: 4px; }
h2 { font-family: var(--display); font-weight: 400; font-size: 56px; letter-spacing: 0.03em; }
.panel {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 18px; display: flex; flex-direction: column; gap: 12px;
  backdrop-filter: blur(6px);
}
.row { display: flex; align-items: center; gap: 12px; }
.row .lbl { width: 96px; text-align: left; color: #cbd5e1; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.row input[type=range] { flex: 1; accent-color: var(--me); min-width: 0; }
.row .val { width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
.seg { display: flex; flex: 1; background: rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; color: #cbd5e1; font: inherit; font-weight: 700;
  padding: 8px 0; border-radius: 8px; cursor: pointer;
}
.seg button.on { background: var(--me); color: #fff; }
.seg button:not(.on):hover { background: rgba(255, 255, 255, 0.08); }
.btn {
  border: 0; cursor: pointer; font: inherit; font-weight: 900; color: #fff;
  border-radius: 12px; padding: 12px 22px; transition: transform 0.08s, filter 0.15s;
}
.btn:active { transform: translateY(2px); }
.btn.big {
  font-family: var(--display); font-weight: 400; font-size: 30px; letter-spacing: 0.04em;
  width: 100%; padding: 14px 0;
  background: linear-gradient(180deg, #4f8ff7, #2563eb); box-shadow: 0 6px 0 #1e3a8a;
}
.btn.big:hover { filter: brightness(1.08); }
.btn.ghost { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); width: 100%; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.14); }
.keys {
  font-size: 13px; color: #cbd5e1; line-height: 1.9;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; width: 100%;
}
kbd {
  display: inline-block; font: inherit; font-weight: 700; font-size: 12px; color: #fff;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.2); border-bottom-width: 2px;
  border-radius: 6px; padding: 0 6px; line-height: 20px;
}
.hint { color: var(--muted); font-size: 13px; min-height: 18px; }
.error { color: #fecaca; background: rgba(127, 29, 29, 0.6); border-radius: 10px; padding: 10px 14px; font-weight: 700; }

#resultTitle.win { color: #86efac; text-shadow: 0 5px 0 #166534; }
#resultTitle.lose { color: #fca5a5; text-shadow: 0 5px 0 #7f1d1d; }
#resultScore { font-family: var(--display); font-size: 44px; letter-spacing: 0.08em; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 6px; }
.stats b { display: block; font-family: var(--display); font-weight: 400; font-size: 28px; }
.stats span { font-size: 12px; color: var(--muted); font-weight: 700; }

/* ---------- 게임 화면 표시 ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#scorebar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 0; border-radius: 12px; overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
#scorebar .side { display: flex; align-items: center; gap: 10px; padding: 0 16px; min-width: 104px; }
#scorebar .side.me { background: var(--me); justify-content: flex-start; }
#scorebar .side.enemy { background: var(--enemy); justify-content: flex-end; }
#scorebar .who { font-weight: 900; font-size: 14px; opacity: 0.9; }
#scorebar b { font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1; }
#scorebar .mid { background: rgba(10, 16, 30, 0.86); padding: 6px 18px; text-align: center; min-width: 110px; }
#roundLabel { font-size: 12px; font-weight: 700; color: var(--muted); }
#timer { font-family: var(--display); font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
#timer.urgent { color: #fca5a5; }

#pips { position: absolute; top: 76px; left: 50%; transform: translateX(-50%); display: flex; gap: 120px; }
.pips { display: flex; gap: 5px; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.25); display: block; }
.pips.me i.on { background: var(--me); box-shadow: 0 0 8px var(--me); }
.pips.enemy i.on { background: var(--enemy); box-shadow: 0 0 8px var(--enemy); }

#killfeed { position: absolute; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.kf {
  background: rgba(10, 16, 30, 0.78); border-radius: 8px; padding: 6px 12px; font-weight: 700; font-size: 14px;
  display: flex; gap: 8px; align-items: center; animation: kfIn 0.18s ease-out;
}
.kf .blue { color: #93c5fd; }
.kf .red { color: #fca5a5; }
.kf .wpn { color: #e2e8f0; font-size: 12px; background: rgba(255, 255, 255, 0.1); padding: 1px 7px; border-radius: 5px; }
.kf .hs { color: var(--accent); font-size: 12px; }
.kf.fade { opacity: 0; transition: opacity 0.4s; }
@keyframes kfIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 조준점 */
#crosshair { position: absolute; left: 50%; top: 50%; --gap: 8px; }
#crosshair i { position: absolute; background: #fff; box-shadow: 0 0 2px rgba(0, 0, 0, 0.9); display: block; }
#crosshair .c-t, #crosshair .c-b { width: 2px; height: 9px; left: -1px; }
#crosshair .c-l, #crosshair .c-r { width: 9px; height: 2px; top: -1px; }
#crosshair .c-t { top: calc(-1 * var(--gap) - 9px); }
#crosshair .c-b { top: var(--gap); }
#crosshair .c-l { left: calc(-1 * var(--gap) - 9px); }
#crosshair .c-r { left: var(--gap); }
#crosshair .c-dot { width: 3px; height: 3px; left: -1.5px; top: -1.5px; border-radius: 50%; }
#crosshair.dotonly .c-t, #crosshair.dotonly .c-b, #crosshair.dotonly .c-l, #crosshair.dotonly .c-r { display: none; }
#crosshair.hide { display: none; }

#hitmarker { position: absolute; left: 50%; top: 50%; opacity: 0; }
#hitmarker i { position: absolute; width: 2px; height: 10px; background: #fff; left: -1px; top: -5px; box-shadow: 0 0 2px #000; }
#hitmarker i:nth-child(1) { transform: rotate(45deg) translateY(-12px); }
#hitmarker i:nth-child(2) { transform: rotate(135deg) translateY(-12px); }
#hitmarker i:nth-child(3) { transform: rotate(225deg) translateY(-12px); }
#hitmarker i:nth-child(4) { transform: rotate(315deg) translateY(-12px); }
#hitmarker.head i { background: var(--accent); }
#hitmarker.kill i { background: #ef4444; height: 14px; top: -7px; }

#floaters { position: absolute; inset: 0; }
.floater {
  position: absolute; left: 0; top: 0; font-family: var(--display); font-size: 22px; color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7), 0 0 6px rgba(0, 0, 0, 0.5); will-change: transform, opacity;
}
.floater.head { color: var(--accent); font-size: 26px; }

#nametag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); text-align: center; display: none; }
#nametag span { font-weight: 900; font-size: 13px; color: #fff; text-shadow: 0 1px 2px #000; }
.ntbar { width: 64px; height: 5px; background: rgba(0, 0, 0, 0.55); border-radius: 3px; overflow: hidden; margin-top: 2px; }
#ntHp { height: 100%; width: 100%; background: var(--enemy); transition: width 0.15s; }

#dmgDir {
  position: absolute; left: 50%; top: 50%; width: 220px; height: 220px; margin: -110px 0 0 -110px;
  border-radius: 50%; border-top: 6px solid rgba(239, 68, 68, 0.9); opacity: 0;
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.8));
}
#vignette {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 45%, rgba(220, 20, 20, 0.6) 100%);
}
#lowhp {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(120, 0, 0, 0.55) 100%);
}

#healthBox {
  position: absolute; left: 20px; bottom: 20px; width: 280px;
  background: rgba(10, 16, 30, 0.72); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
.hpnum { display: flex; align-items: baseline; gap: 6px; }
.hpnum b { font-family: var(--display); font-weight: 400; font-size: 36px; line-height: 1; }
.hpnum span { color: var(--muted); font-weight: 900; font-size: 13px; }
.hpbar { position: relative; height: 10px; background: rgba(255, 255, 255, 0.1); border-radius: 5px; overflow: hidden; margin-top: 6px; }
#hpFill, #hpGhost { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 5px; }
#hpFill { background: linear-gradient(90deg, #22c55e, #4ade80); }
#hpFill.mid { background: linear-gradient(90deg, #eab308, #facc15); }
#hpFill.low { background: linear-gradient(90deg, #dc2626, #f87171); }
#hpGhost { background: rgba(255, 255, 255, 0.45); transition: width 0.5s ease-out 0.15s; }

#weaponBox {
  position: absolute; right: 20px; bottom: 20px; width: 300px; text-align: right;
  background: rgba(10, 16, 30, 0.72); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
}
#ammoText b { font-family: var(--display); font-weight: 400; font-size: 40px; line-height: 1; }
#ammoText b.empty { color: #f87171; }
#ammoText span { color: var(--muted); font-weight: 900; font-size: 16px; margin-left: 4px; }
#weaponName { font-weight: 900; font-size: 14px; color: #e2e8f0; margin: 2px 0 8px; }
#slots { display: flex; gap: 6px; justify-content: flex-end; }
.slot {
  position: relative; flex: 1; background: rgba(255, 255, 255, 0.07); border: 1px solid transparent;
  border-radius: 8px; padding: 5px 4px 4px; font-size: 11px; font-weight: 700; color: #cbd5e1; text-align: center;
}
.slot .k { position: absolute; left: 5px; top: 2px; font-size: 10px; color: var(--muted); }
.slot .n { display: block; margin-top: 8px; white-space: nowrap; }
.slot .c { position: absolute; right: 5px; top: 2px; font-size: 10px; color: var(--accent); }
.slot.on { background: rgba(59, 130, 246, 0.35); border-color: var(--me); color: #fff; }
.slot.dim { opacity: 0.45; }

#reloadHint { position: absolute; left: 50%; top: calc(50% + 46px); transform: translateX(-50%); text-align: center; display: none; }
.rl-label { font-weight: 900; font-size: 13px; text-shadow: 0 1px 3px #000; }
.rl-bar { width: 110px; height: 4px; background: rgba(0, 0, 0, 0.5); border-radius: 2px; margin-top: 4px; overflow: hidden; }
#reloadFill { height: 100%; width: 0; background: #fff; }

#banner { position: absolute; left: 0; right: 0; top: 24%; text-align: center; opacity: 0; transition: opacity 0.2s; }
#banner.show { opacity: 1; }
#bannerMain {
  font-family: var(--display); font-size: clamp(44px, 7vw, 76px); letter-spacing: 0.04em; line-height: 1.05;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.45), 0 10px 30px rgba(0, 0, 0, 0.4);
}
#bannerSub { font-family: var(--display); font-size: clamp(22px, 3.2vw, 34px); margin-top: 6px; color: #e2e8f0; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45); }
#banner.win #bannerMain { color: #86efac; }
#banner.lose #bannerMain { color: #fca5a5; }
#banner.go #bannerMain { color: var(--accent); }

@media (max-width: 720px) {
  #healthBox { width: 180px; left: 10px; bottom: 10px; }
  #weaponBox { width: 210px; right: 10px; bottom: 10px; }
  .slot .n { font-size: 10px; }
  #pips { gap: 60px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* 팀 점수판 (Tab) */
#board { position: fixed; top: 14%; left: 50%; transform: translateX(-50%); width: min(920px, 94vw); display: flex; gap: 14px; z-index: 12; }
#board .bcol { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; backdrop-filter: blur(4px); }
#board h3 { font-family: var(--display); font-weight: 400; font-size: 18px; margin-bottom: 6px; }
#board .blue h3 { color: var(--me); }
#board .red h3 { color: var(--enemy); }
#board table { width: 100%; border-collapse: collapse; font-size: 13px; }
#board th { color: var(--muted); font-weight: 400; text-align: right; padding: 2px 4px; }
#board th:first-child, #board td:first-child { text-align: left; }
#board td { text-align: right; padding: 2px 4px; border-top: 1px solid rgba(255,255,255,0.06); }
#board tr.dead td { opacity: 0.45; }
#board tr.me td { color: var(--accent); font-weight: 700; }
#board td .tag { color: var(--muted); font-size: 11px; margin-left: 4px; }

/* 킬 알림 / 경기 결과 / 로비 */
#killpop { position: fixed; left: 50%; top: 62%; transform: translateX(-50%); font-size: 22px; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.7); opacity: 0; white-space: nowrap; pointer-events: none; }
#killpop b { color: var(--enemy); font-family: var(--display); font-weight: 400; font-size: 26px; }
#killpop i { font-style: normal; font-size: 13px; color: var(--accent); margin-left: 8px; border: 1px solid var(--accent); border-radius: 4px; padding: 1px 5px; }
#killpop.show { animation: killpop 1.8s ease-out forwards; }
@keyframes killpop { 0% { opacity: 0; transform: translateX(-50%) scale(1.5); } 12% { opacity: 1; transform: translateX(-50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-14px); } }
#matchResult { position: fixed; top: 10%; left: 50%; transform: translateX(-50%); width: min(980px, 95vw); z-index: 14; text-align: center; background: rgba(8,12,24,.88); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px 14px; }
#matchResult h2 { font-family: var(--display); font-weight: 400; font-size: 40px; }
#matchResult h2.win { color: var(--good); }
#matchResult h2.lose { color: var(--enemy); }
#matchScore { font-size: 28px; font-weight: 900; margin-bottom: 10px; }
#matchResult .cols { display: flex; gap: 14px; text-align: left; }
#matchResult .bcol { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
#matchResult h3 { font-family: var(--display); font-weight: 400; font-size: 18px; margin-bottom: 6px; }
#matchResult .blue h3 { color: var(--me); }
#matchResult .red h3 { color: var(--enemy); }
#matchResult table { width: 100%; border-collapse: collapse; font-size: 13px; }
#matchResult th { color: var(--muted); font-weight: 400; text-align: right; padding: 2px 4px; }
#matchResult th:first-child, #matchResult td:first-child { text-align: left; }
#matchResult td { text-align: right; padding: 3px 4px; border-top: 1px solid rgba(255,255,255,0.06); }
#matchResult tr.me td { color: var(--accent); font-weight: 700; }
#matchResult td .tag { color: var(--muted); font-size: 11px; margin-left: 4px; }
.mrhint { color: var(--muted); font-size: 13px; margin-top: 10px; }
.menu-inner.wide { width: min(760px, 94vw); }
.muted { color: var(--muted); font-size: 13px; }
.txt { flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid #556; background: #0003; color: inherit; font: inherit; }
.roomhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.roomlist { display: flex; flex-direction: column; gap: 6px; min-height: 60px; }
.roomlist .empty { color: var(--muted); text-align: center; padding: 16px 0; }
.roomrow { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; background: rgba(255,255,255,.04); }
.roomrow:hover { background: rgba(255,255,255,.1); }
.roomrow .nm { flex: 1; font-weight: 700; }
.roomrow .st { font-size: 12px; color: var(--muted); }
.roomrow .st.live { color: var(--good); }
.teams { display: flex; gap: 14px; margin: 10px 0 14px; }
.tcol { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 170px; text-align: left; }
.tcol h3 { font-family: var(--display); font-weight: 400; font-size: 20px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tcol.blue h3 { color: var(--me); }
.tcol.red h3 { color: var(--enemy); }
.tcol ul { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.tcol li { padding: 5px 8px; border-radius: 6px; background: rgba(255,255,255,.06); font-size: 14px; }
.tcol li.me { outline: 1px solid var(--accent); color: var(--accent); font-weight: 700; }
.tcol li .tag { color: var(--muted); font-size: 11px; margin-left: 6px; }
.tcol li.botfill { color: var(--muted); font-style: italic; }
.mini { font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 6px; border: 1px solid var(--line); background: rgba(255,255,255,.08); color: var(--text); cursor: pointer; }
.mini:hover { background: rgba(255,255,255,.18); }
.mini:disabled { opacity: .35; cursor: default; }
