:root {
  --bg: #070912;
  --panel: rgba(12, 16, 32, 0.78);
  --line: rgba(127, 233, 255, 0.28);
  --cyan: #7fe9ff;
  --amber: #ffb347;
  --red: #ff5a5a;
  --green: #5dff9a;
  --text: #e8eeff;
  --muted: #8f9ac0;
  --font: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-user-select: none; user-select: none; touch-action: none; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }

.back-btn { position: fixed; top: max(12px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); z-index: 40; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; font-size: 13px; font-weight: 600; color: var(--text); text-decoration: none; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); }
.back-btn:hover { border-color: var(--cyan); }
body.playing .back-btn { display: none; }

/* 조준선 */
.crosshair, .hitmark { position: fixed; left: 50%; top: 50%; width: 0; height: 0; z-index: 10; pointer-events: none; }
.crosshair i, .hitmark i { position: absolute; background: var(--cyan); box-shadow: 0 0 3px #000; }
.crosshair i { width: 2px; height: 8px; }
.crosshair i:nth-child(1) { left: -1px; top: -14px; }
.crosshair i:nth-child(2) { left: -1px; top: 6px; }
.crosshair i:nth-child(3) { width: 8px; height: 2px; left: -14px; top: -1px; }
.crosshair i:nth-child(4) { width: 8px; height: 2px; left: 6px; top: -1px; }
.hitmark { opacity: 0; transition: opacity .08s; }
.hitmark.show { opacity: 1; }
.hitmark i { width: 2px; height: 9px; background: #fff; }
.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.head i { background: #ffe066; }
.hitmark.kill i { background: var(--red); height: 13px; }

.dmg-dir { position: fixed; left: 50%; top: 50%; width: 220px; height: 220px; z-index: 9; pointer-events: none; opacity: 0; border-radius: 50%; border-top: 6px solid rgba(255, 70, 70, .85); filter: blur(1px); }
.dmg-dir.show { animation: dmg .7s ease-out; }
@keyframes dmg { 0% { opacity: 1; } 100% { opacity: 0; } }
.vignette { position: fixed; inset: 0; z-index: 8; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 0, 20, .65) 100%); }
.heal-flash { position: fixed; inset: 0; z-index: 8; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 50%, rgba(60, 255, 140, .4) 100%); }
.heal-flash.show { animation: dmg .6s ease-out; }

/* 조준·스코프 */
body.aiming .crosshair { transform: scale(.6); }
.crosshair { transition: transform .12s; }
.scope { position: fixed; inset: 0; z-index: 9; pointer-events: none; display: none; background: radial-gradient(circle at center, transparent 0, transparent min(34vw, 34vh), rgba(0,0,0,.92) calc(min(34vw, 34vh) + 2px)); }
.scope i { position: absolute; left: 50%; top: 50%; width: min(68vw, 68vh); height: min(68vw, 68vh); transform: translate(-50%, -50%); border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0,0,0,.8), inset 0 0 40px rgba(0,0,0,.6); background: linear-gradient(rgba(10,10,10,.9), rgba(10,10,10,.9)) center / 100% 1px no-repeat, linear-gradient(rgba(10,10,10,.9), rgba(10,10,10,.9)) center / 1px 100% no-repeat; }
body.scoped .scope { display: block; }
body.scoped .crosshair { display: none; }
.slot.locked { opacity: .45; }
.slot em { font-style: normal; }
@media (max-width: 600px) {
  .slots { gap: 3px; }
  .slot { padding: 2px 5px; }
  .slot:not(.on) em { display: none; }
}
.tbtn.aim { right: max(30px, env(safe-area-inset-right)); bottom: max(290px, calc(env(safe-area-inset-bottom) + 280px)); width: 54px; height: 54px; }
.tbtn.aim.on { background: rgba(127, 233, 255, .4); border-color: var(--cyan); }

/* 헤드샷·피해 숫자 */
.head-tag { position: fixed; left: 50%; top: calc(50% + 26px); z-index: 11; transform: translateX(-50%); font-size: 14px; font-weight: 800; letter-spacing: .08em; color: #ffe066; text-shadow: 0 0 8px rgba(255, 200, 0, .7), 0 1px 2px #000; opacity: 0; pointer-events: none; white-space: nowrap; }
.head-tag.show { animation: head-pop .6s ease-out forwards; }
@keyframes head-pop { 0% { opacity: 0; transform: translateX(-50%) scale(1.6); } 15% { opacity: 1; transform: translateX(-50%) scale(1); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-6px); } }
.popups { position: fixed; inset: 0; z-index: 11; pointer-events: none; overflow: hidden; }
.dmg-num { position: absolute; left: 0; top: 0; font-size: 15px; font-weight: 800; color: #dff6ff; text-shadow: 0 1px 2px #000, 0 0 4px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; will-change: transform; }
.dmg-num.head { font-size: 21px; color: #ffe066; }
.dmg-num.kill { color: #ff7a6a; }
.dmg-num.head.kill { color: #ffb02e; }
.tip { margin: 0 0 12px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 224, 102, .08); border: 1px solid rgba(255, 224, 102, .25); font-size: 12.5px; line-height: 1.5; color: #f3e6b0; }

/* 미니맵 */
.minimap { position: fixed; left: auto; bottom: auto; inset-inline-start: auto; top: calc(max(12px, env(safe-area-inset-top)) + 46px); right: max(12px, env(safe-area-inset-right)); z-index: 20; width: 168px; height: 168px; border-radius: 50%; pointer-events: none; }
body.touch .minimap { width: 118px; height: 118px; }
@media (max-width: 600px) { .minimap { width: 118px; height: 118px; } }

/* 상단 */
.hud-top { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.wave-box { display: flex; align-items: baseline; gap: 8px; padding: 5px 16px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.wave-box span { font-size: 12px; color: var(--muted); }
.wave-box b { font-size: 22px; color: var(--cyan); font-variant-numeric: tabular-nums; }
.left-info { margin: 0; padding: 2px 12px; font-size: 12px; border-radius: 999px; background: var(--panel); }
.hud-score { position: fixed; top: max(12px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); z-index: 20; display: flex; flex-direction: column; pointer-events: none; }
.hud-score span { font-size: 11px; color: var(--muted); }
.hud-score b { font-size: 20px; font-variant-numeric: tabular-nums; }
.hud-tools { position: fixed; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 30; display: flex; gap: 6px; }
.mini { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 16px; }

/* 하단: 체력·탄약 */
.hud-hp { position: fixed; left: max(18px, env(safe-area-inset-left)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 20; width: min(260px, 40vw); padding: 10px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); pointer-events: none; }
.hp-top { display: flex; justify-content: space-between; align-items: baseline; }
.hp-top span { font-size: 12px; color: var(--muted); }
.hp-top b { font-size: 26px; font-variant-numeric: tabular-nums; }
.hp-track { height: 8px; margin-top: 4px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; }
.hp-bar { height: 100%; width: 100%; background: linear-gradient(90deg, #3fd47e, var(--green)); transition: width .15s; }
.hp-bar.low { background: linear-gradient(90deg, #c22, var(--red)); }
.hud-ammo { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 20; padding: 10px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); text-align: right; pointer-events: none; }
.slots { display: flex; gap: 6px; justify-content: flex-end; }
.slot { font-size: 11px; padding: 2px 7px; border-radius: 6px; color: var(--muted); border: 1px solid transparent; }
.slot.on { color: var(--amber); border-color: rgba(255, 179, 71, .5); }
.ammo-row b { font-size: 34px; font-variant-numeric: tabular-nums; }
.ammo-row span { font-size: 15px; color: var(--muted); margin-left: 4px; }
.gun-name { font-size: 12px; color: var(--cyan); }

.banner { position: fixed; top: 24%; left: 50%; transform: translate(-50%, -10px); z-index: 25; display: flex; flex-direction: column; align-items: center; gap: 4px; opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; text-align: center; }
.banner.show { opacity: 1; transform: translate(-50%, 0); }
.banner b { font-size: clamp(28px, 6vw, 46px); letter-spacing: .04em; color: #fff; text-shadow: 0 0 18px rgba(127, 233, 255, .8); }
.banner span { font-size: 15px; color: var(--amber); text-shadow: 0 1px 4px #000; }

/* 화면 */
.screen { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(ellipse at center, rgba(7, 9, 18, .55), rgba(7, 9, 18, .9)); overflow-y: auto; }
#title { background: linear-gradient(180deg, rgba(7,9,18,.2), rgba(7,9,18,.75)); }
.card { width: min(480px, 100%); padding: 26px 26px 20px; border-radius: 18px; background: rgba(12, 16, 32, .9); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.5); text-align: center; margin: auto; }
.card.small { width: min(360px, 100%); }
.kicker { margin: 0; font-size: 12px; letter-spacing: .2em; color: var(--cyan); }
h1 { margin: 6px 0 8px; font-size: clamp(30px, 8vw, 40px); letter-spacing: .02em; }
h2 { margin: 6px 0 14px; font-size: 26px; }
.lead { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.foes { list-style: none; padding: 0; margin: 0 0 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 12.5px; text-align: left; }
.foes i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; margin: 0 0 14px; font-size: 12px; color: var(--muted); }
kbd { display: inline-block; padding: 1px 6px; margin-right: 3px; border-radius: 4px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--text); font: 600 11px var(--font); }
.touch-only { display: none; }
body.touch .touch-only { display: block; }
body.touch .pc-only { display: none; }
.sens { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.sens input { width: 160px; accent-color: var(--cyan); }
.big-btn { display: block; width: 100%; padding: 14px; border: 0; border-radius: 12px; background: linear-gradient(180deg, #8ff0ff, #3ab8e0); color: #04121c; font-size: 18px; font-weight: 800; letter-spacing: .1em; }
.big-btn:hover { filter: brightness(1.08); }
.ghost-btn { display: block; width: 100%; margin-top: 8px; padding: 11px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--text); }
.best { min-height: 1em; margin: 10px 0 0; font-size: 13px; color: var(--amber); }
.credit { margin: 10px 0 0; font-size: 11px; color: var(--muted); opacity: .8; }
.stats { display: grid; gap: 6px; margin-bottom: 8px; }
.stats div { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 8px; background: rgba(255,255,255,.05); }
.stats span { color: var(--muted); }
.load-track { height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); overflow: hidden; }
.load-bar { height: 100%; width: 0; background: var(--cyan); transition: width .2s; }
.err { font-size: 12px; color: var(--red); word-break: break-all; }

/* 모바일 조작 */
.touch-ui { position: fixed; inset: 0; z-index: 15; }
.move-zone { position: absolute; left: 0; top: 0; bottom: 0; width: 45%; }
.look-zone { position: absolute; right: 0; top: 0; bottom: 0; width: 55%; }
.stick-base { position: fixed; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); opacity: 0; pointer-events: none; }
.stick-base.on { opacity: 1; }
.stick-knob { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: rgba(127, 233, 255, .45); }
.tbtn { position: fixed; z-index: 16; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); background: rgba(12, 16, 32, .55); color: var(--text); font-size: 13px; font-weight: 700; }
.tbtn.fire { right: max(26px, env(safe-area-inset-right)); bottom: max(120px, calc(env(safe-area-inset-bottom) + 110px)); width: 84px; height: 84px; background: rgba(255, 90, 90, .35); font-size: 15px; }
.tbtn.jump { right: max(122px, calc(env(safe-area-inset-right) + 110px)); bottom: max(108px, calc(env(safe-area-inset-bottom) + 100px)); width: 58px; height: 58px; }
.tbtn.reload { right: max(30px, env(safe-area-inset-right)); bottom: max(222px, calc(env(safe-area-inset-bottom) + 212px)); width: 54px; height: 54px; }
.tbtn.swap { right: max(96px, calc(env(safe-area-inset-right) + 86px)); bottom: max(190px, calc(env(safe-area-inset-bottom) + 182px)); width: 54px; height: 54px; }
body.touch .hud-hp { width: min(200px, 33vw); padding: 7px 10px; }
body.touch .hp-top b { font-size: 20px; }
body.touch .ammo-row b { font-size: 26px; }

@media (max-width: 600px) {
  .card { padding: 20px 18px 16px; }
  .foes { grid-template-columns: 1fr; }
  .hud-score { top: max(56px, calc(env(safe-area-inset-top) + 46px)); }
}

/* 맵 선택 */
.map-label { margin: 4px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .12em; color: var(--muted); text-align: left; }
.maps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.map-card { display: grid; gap: 3px; align-content: start; text-align: left; padding: 10px; border-radius: 12px; border: 1px solid rgba(127, 233, 255, .18); background: rgba(10, 16, 32, .7); color: inherit; font: inherit; cursor: pointer; transition: border-color .15s, background .15s; }
.map-card:hover { border-color: rgba(127, 233, 255, .5); }
.map-card[aria-pressed="true"] { border-color: var(--cyan); background: rgba(58, 184, 224, .16); box-shadow: 0 0 14px rgba(127, 233, 255, .25); }
.map-ico { font-size: 22px; }
.map-card b { font-size: 14px; }
.map-desc { font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.map-meta { font-size: 11px; color: var(--amber); margin-top: 2px; }
@media (max-width: 640px) { .maps { grid-template-columns: 1fr; } .map-card { grid-template-columns: 30px 1fr; column-gap: 8px; } .map-ico { grid-row: span 3; } }
