:root { --ink: #dfe8f2; --dim: #8796a8; --cyan: #39e6ff; --red: #ff3355; --panel: rgba(8,12,20,0.88); --line: rgba(57,230,255,0.25); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #04060a; color: var(--ink); font-family: 'Noto Sans KR', system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
body:not(.touch) .touch-only { display: none; }
body.touch .mouse-only { display: none; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#xhair { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; margin: -30px 0 0 -30px; }
#xhair svg { width: 100%; height: 100%; }
#xring { fill: none; stroke: var(--cyan); stroke-width: 2.5; stroke-dasharray: 138.2; stroke-dashoffset: 0; transform: rotate(-90deg); transform-origin: 30px 30px; opacity: 0.85; }
#xhair .dot { fill: #fff; }
#xhair .tick { stroke: rgba(255,255,255,0.75); stroke-width: 2; }
#xhair.cool #xring { stroke: #ff7a5a; opacity: 0.5; }
#hud-tl { position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top)); font-size: 13px; }
#h-ship { font-family: 'Black Ops One', monospace; color: var(--cyan); letter-spacing: 0.08em; margin-bottom: 6px; }
#h-list div { display: flex; gap: 8px; align-items: center; padding: 2px 0; text-shadow: 0 1px 2px #000; }
#h-list i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
#h-list b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
#h-list .me { color: #fff; font-weight: 700; }
#h-list .bot { color: var(--dim); }
#hud-tr { position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 14px; }
#h-kills { text-align: center; }
#h-kills b { display: block; font-family: 'Black Ops One', monospace; font-size: 34px; line-height: 1; color: #fff; text-shadow: 0 0 12px rgba(57,230,255,0.6); }
#h-kills span { font-size: 11px; color: var(--dim); }
#h-time { font-family: 'Black Ops One', monospace; font-size: 18px; color: var(--dim); font-variant-numeric: tabular-nums; }
#b-mute { pointer-events: auto; background: rgba(0,0,0,0.4); border: 1px solid var(--line); color: var(--ink); border-radius: 6px; width: 36px; height: 32px; cursor: pointer; }
#feed { position: absolute; right: max(14px, env(safe-area-inset-right)); top: calc(max(12px, env(safe-area-inset-top)) + 64px); display: grid; gap: 4px; justify-items: end; font-size: 13px; }
#feed div { background: rgba(0,0,0,0.5); padding: 3px 9px; border-radius: 4px; border-left: 2px solid var(--red); animation: feedIn 0.2s; }
#feed .mine { border-left-color: var(--cyan); background: rgba(57,230,255,0.15); }
@keyframes feedIn { from { transform: translateX(20px); opacity: 0; } }
#h-dash { position: absolute; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); }
#h-dash i { width: 140px; height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; display: block; }
#h-dash u { display: block; height: 100%; width: 100%; background: var(--cyan); }
#h-prot { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); color: #ffd23f; font-size: 14px; text-shadow: 0 1px 3px #000; }
#center-msg { position: absolute; left: 0; right: 0; top: 34%; text-align: center; font-family: 'Black Ops One', monospace; font-size: 30px; color: #fff; text-shadow: 0 0 16px rgba(57,230,255,0.8); opacity: 0; transition: opacity 0.3s; }
#center-msg.on { opacity: 1; transition: none; }
#lock-hint { position: absolute; left: 50%; top: 70%; transform: translateX(-50%); background: rgba(0,0,0,0.6); padding: 8px 14px; border-radius: 6px; font-size: 14px; }

/* 오버레이 */
.ov { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; overflow-y: auto; padding: 16px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 30%, rgba(20,60,90,0.35), rgba(2,4,8,0.94) 70%); }
.panel { width: 100%; max-width: 560px; margin: auto; text-align: center; }
h1 { font-family: 'Black Ops One', 'Noto Sans KR', sans-serif; font-weight: 400; font-size: clamp(44px, 9vw, 76px); margin: 0; letter-spacing: 0.06em; color: #fff; text-shadow: 0 0 24px rgba(57,230,255,0.55), 0 0 2px #fff; }
.sub { font-family: 'Black Ops One', monospace; color: var(--cyan); letter-spacing: 0.4em; font-size: 13px; margin: 2px 0 16px; }
.lead { color: #b8c4d2; line-height: 1.7; font-size: 15px; margin: 0 0 18px; }
.lead b { color: var(--red); }
.join { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.join input { font: inherit; font-size: 17px; width: 200px; max-width: 100%; padding: 11px 14px; background: rgba(0,0,0,0.5); color: #fff; border: 1px solid var(--line); border-radius: 6px; outline: none; }
.join input:focus { border-color: var(--cyan); }
.btn { font-family: 'Black Ops One', 'Noto Sans KR', sans-serif; font-size: 19px; letter-spacing: 0.1em; padding: 11px 30px; background: linear-gradient(#1aa6c4, #0b6a82); color: #fff; border: 1px solid #6ff0ff; border-radius: 6px; cursor: pointer; box-shadow: 0 0 18px rgba(57,230,255,0.35); }
.btn:hover { filter: brightness(1.15); }
.btn:focus-visible, .join input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.msg { min-height: 20px; margin: 10px 0; color: #ffd23f; font-size: 14px; }
.online { color: var(--dim); font-size: 13px; margin-bottom: 10px; }
.online b { color: #7dff6a; }
.keys { color: var(--dim); font-size: 13px; margin: 6px 0 16px; line-height: 1.8; }
kbd { font-family: 'Black Ops One', monospace; color: var(--cyan); border: 1px solid var(--line); padding: 0 5px; border-radius: 3px; font-size: 12px; }
.board-wrap { border: 1px solid var(--line); border-radius: 8px; background: var(--panel); text-align: left; overflow: hidden; }
.board-h { font-family: 'Black Ops One', 'Noto Sans KR', sans-serif; padding: 9px 12px; color: #ffd23f; letter-spacing: 0.1em; border-bottom: 1px solid var(--line); }
.board-body { max-height: 240px; overflow: auto; }
.board { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.board th { color: var(--dim); font-weight: 400; text-align: left; padding: 6px 10px; position: sticky; top: 0; background: #0a101a; }
.board td { padding: 6px 10px; border-top: 1px solid rgba(255,255,255,0.05); white-space: nowrap; }
.board td:nth-child(2) { max-width: 10em; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.board tr.live td { background: rgba(125,255,106,0.06); }
.board .tag { font-size: 10px; color: #04060a; background: #7dff6a; border-radius: 3px; padding: 0 4px; margin-left: 6px; font-weight: 700; }
.board tr:nth-child(2) td:first-child { color: #ffd23f; font-weight: 900; }
.board-empty { padding: 18px 12px; color: var(--dim); font-size: 13px; }
.dead-h { font-family: 'Black Ops One', 'Noto Sans KR', sans-serif; font-size: clamp(44px, 9vw, 72px); color: var(--red); text-shadow: 0 0 24px rgba(255,51,85,0.6); margin-bottom: 6px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 6px 0 8px; }
.stats div { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--panel); }
.stats b { display: block; font-family: 'Black Ops One', monospace; font-size: 28px; color: #fff; }
.stats span { font-size: 12px; color: var(--dim); }
#ov-dead .btn { margin: 6px 0 16px; }

/* 터치 */
#touch { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
#joy { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 2px solid rgba(57,230,255,0.3); background: rgba(57,230,255,0.05); opacity: 0.6; }
#joy.on { opacity: 1; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(57,230,255,0.25); border: 1px solid rgba(57,230,255,0.6); }
.tb { position: absolute; pointer-events: auto; border-radius: 50%; border: 2px solid rgba(57,230,255,0.5); background: rgba(8,20,30,0.55); color: #fff; font: 700 15px 'Noto Sans KR', sans-serif; touch-action: none; -webkit-tap-highlight-color: transparent; }
.tb.fire { width: 92px; height: 92px; right: calc(max(18px, env(safe-area-inset-right)) + 16px); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 40px); border-color: rgba(255,51,85,0.8); background: rgba(80,10,20,0.5); }
.tb.fire.cool { opacity: 0.45; }
#t-dash { width: 64px; height: 64px; right: calc(max(18px, env(safe-area-inset-right)) + 124px); bottom: calc(max(16px, env(safe-area-inset-bottom)) + 24px); }
.tb.down { filter: brightness(1.6); }
body.touch #h-dash { bottom: auto; top: calc(max(12px, env(safe-area-inset-top)) + 4px); }
@media (max-height: 520px) { .lead { margin-bottom: 10px; font-size: 14px; } .board-body { max-height: 150px; } h1 { font-size: 44px; } }
.lead small { color: var(--dim); font-size: 12px; }

/* 플레이어 / 봇 구분 */
#h-kills { display: flex; gap: 12px; align-items: flex-end; }
.kc { text-align: center; }
.kc b { display: block; font-family: 'Black Ops One', monospace; line-height: 1; }
.kc.p b { font-size: 36px; color: #fff; text-shadow: 0 0 12px rgba(255,51,85,0.7); }
.kc.b b { font-size: 22px; color: var(--dim); }
.kc span { font-size: 10px; color: var(--dim); white-space: nowrap; }
.kc.p span { color: #ff8095; }
#h-ship { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#h-ship .cnt { font-family: 'Noto Sans KR', sans-serif; font-size: 12px; letter-spacing: 0; padding: 2px 8px; border-radius: 10px; font-weight: 700; }
#h-ship .cnt.p { background: rgba(255,51,85,0.2); color: #ff9aab; border: 1px solid rgba(255,51,85,0.5); }
#h-ship .cnt.b { background: rgba(140,155,175,0.15); color: #b8c2cf; border: 1px solid rgba(140,155,175,0.4); }
#h-list em { font-style: normal; font-size: 9px; font-weight: 700; padding: 0 4px; border-radius: 3px; color: #fff; background: #ff3355; }
#h-list .bot em { background: #5d6878; }
#h-list .me em { background: var(--cyan); color: #04060a; }
#feed .fp { color: #ff9aab; font-weight: 700; }
#feed .fb { color: #9aa6b6; }
#feed i { font-style: normal; color: var(--dim); }
#feed .vplayer { border-left-color: var(--red); }
#feed .vbot { border-left-color: #5d6878; opacity: 0.85; }
#feed .mine.vplayer { background: rgba(255,51,85,0.25); }
#feed .mine.vbot { background: rgba(140,155,175,0.18); }
#feed .info { border-left-color: #7dff6a; }
#center-msg.player { color: #fff; font-size: 34px; text-shadow: 0 0 18px rgba(255,51,85,0.9); }
#center-msg.bot { color: #b8c2cf; font-size: 22px; text-shadow: 0 0 10px rgba(0,0,0,0.9); }
body.dragging, body.dragging canvas#game { cursor: grabbing; }
canvas#game { cursor: crosshair; }
#lock-hint { top: auto; bottom: calc(max(22px, env(safe-area-inset-bottom)) + 26px); font-size: 12px; opacity: 0.75; }

/* 플레이어 입장 알림 */
#join-banner { position: absolute; left: 50%; top: 64%; transform: translate(-50%, -10px); text-align: center; padding: 10px 26px; border-radius: 10px;
  background: linear-gradient(90deg, rgba(255,51,85,0), rgba(255,51,85,0.35), rgba(255,51,85,0)); opacity: 0; pointer-events: none; white-space: nowrap; }
#join-banner small { display: block; font-size: 12px; letter-spacing: 0.3em; color: #ffb3c0; }
#join-banner b { font-size: 26px; font-weight: 900; text-shadow: 0 0 14px rgba(0,0,0,0.9); }
#join-banner.on { animation: joinIn 3.2s ease-out forwards; }
@keyframes joinIn { 0% { opacity: 0; transform: translate(-50%, -24px) scale(1.2); } 8% { opacity: 1; transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, 0); } }
#join-ind { position: absolute; left: 50%; top: 50%; width: 0; height: 0; pointer-events: none; }
#join-ind i { position: absolute; left: -11px; top: -122px; width: 0; height: 0; border-left: 11px solid transparent; border-right: 11px solid transparent; border-bottom: 20px solid #ff3355; filter: drop-shadow(0 0 6px rgba(0,0,0,0.9)); animation: indPulse 0.6s ease-in-out infinite alternate; }
#join-ind span { position: absolute; left: -80px; top: -150px; width: 160px; text-align: center; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px #000; transform-origin: 80px 150px; }
@keyframes indPulse { to { transform: translateY(-6px); } }
#h-ship.pulse .cnt.p { animation: pillPulse 0.5s ease-in-out 4 alternate; }
@keyframes pillPulse { to { background: rgba(255,51,85,0.75); color: #fff; box-shadow: 0 0 14px rgba(255,51,85,0.8); } }
@media (prefers-reduced-motion: reduce) { #join-banner.on, #join-ind i, #h-ship.pulse .cnt.p { animation-duration: 0.01s; } #join-banner.on { opacity: 1; } }
