@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Share+Tech+Mono&display=swap');

:root {
  --col-bg: #0a0c10;
  --col-hud: #00ffe0;
  --col-hud-dim: rgba(0,255,224,0.15);
  --col-danger: #ff3c3c;
  --col-warn: #ffcc00;
  --col-ui-bg: rgba(0,0,0,0.6);
  --col-border: rgba(0,255,224,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--col-bg);
  color: var(--col-hud);
  font-family: 'Share Tech Mono', monospace;
  overflow: hidden;
  user-select: none;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    linear-gradient(90deg, rgba(0,255,224,0.04), transparent 18%, transparent 82%, rgba(255,204,0,0.035)),
    radial-gradient(circle at 50% 18%, rgba(0,255,224,0.06), transparent 34%);
  opacity: .75;
  animation: hudBreath 5s ease-in-out infinite;
}

#canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  outline: none;
  cursor: crosshair;
}

/* ── HUD ── */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* 크로스헤어 */
#crosshair {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 26px; height: 26px;
  animation: crosshairIdle 1.8s ease-in-out infinite;
}
#crosshair::before, #crosshair::after {
  content: '';
  position: absolute;
  background: rgba(255,255,255,0.85);
}
#crosshair::before { width: 2px; height: 72%; left: 50%; top: 14%; transform: translateX(-50%); }
#crosshair::after  { height: 2px; width: 72%; left: 14%; top: 50%; transform: translateY(-50%); }
#crosshair .dot {
  position: absolute;
  width: 5px; height: 5px;
  background: #00ffe0;
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  box-shadow: 0 0 10px rgba(0,255,224,.65);
}
@keyframes crosshairIdle {
  0%, 100% { opacity: .82; filter: drop-shadow(0 0 2px rgba(255,255,255,.25)); }
  50% { opacity: 1; filter: drop-shadow(0 0 6px rgba(0,255,224,.28)); }
}

/* 체력바 */
#health-bar {
  position: absolute;
  bottom: 48px; left: 32px;
  width: 220px;
  animation: panelInLeft .55s cubic-bezier(.16,1,.3,1) both;
}
#health-label {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--col-hud);
  margin-bottom: 5px;
  opacity: 0.7;
}
#health-track {
  width: 100%;
  height: 6px;
  background: rgba(0,255,224,0.1);
  border: 1px solid var(--col-border);
  border-radius: 2px;
  overflow: hidden;
}
#health-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00ffe0, #00c8b4);
  transition: width 0.3s, background 0.3s;
  border-radius: 2px;
  box-shadow: 0 0 18px rgba(0,255,224,.22);
}
#health-fill.warn  { background: linear-gradient(90deg, #ffcc00, #ff8800); }
#health-fill.crit  { background: linear-gradient(90deg, #ff3c3c, #ff0000); animation: pulse 0.5s ease infinite alternate; }
#health-num {
  font-size: 28px;
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  letter-spacing: 2px;
  margin-top: 4px;
  transition: color 0.3s;
}

@keyframes pulse { from { opacity: 1; } to { opacity: 0.5; } }

/* 탄약 */
#ammo-display {
  position: absolute;
  bottom: 40px; right: 32px;
  text-align: right;
  animation: panelInRight .55s .08s cubic-bezier(.16,1,.3,1) both;
}
#ammo-current {
  font-family: 'Orbitron', monospace;
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(0,255,224,.22);
  transition: color .18s, text-shadow .18s, transform .18s;
}
#ammo-current.sniper-ammo { color: #ffcc00; text-shadow: 0 0 18px rgba(255,204,0,0.45); }
#ammo-max {
  font-size: 14px;
  opacity: 0.4;
  margin-top: 2px;
  letter-spacing: 2px;
}
#ammo-mode {
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--col-warn);
  margin-top: 4px;
}

/* 리로딩 */
#reload-bar {
  position: absolute;
  bottom: 130px; left: 50%;
  transform: translateX(-50%);
  width: 200px;
  display: none;
}
#reload-bar.visible { display: block; animation: reloadPop .22s cubic-bezier(.16,1,.3,1) both; }
#reload-bar.blocked #reload-label { color: #ff6666; }
#reload-label {
  text-align: center;
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--col-warn);
  margin-bottom: 6px;
  animation: blink 0.6s ease infinite alternate;
}
#reload-track {
  width: 100%;
  height: 3px;
  background: rgba(255,204,0,0.15);
  border: 1px solid rgba(255,204,0,0.4);
}
#reload-fill {
  height: 100%;
  width: 0%;
  background: var(--col-warn);
  transition: width 0.05s linear;
}
@keyframes blink { from { opacity: 1; } to { opacity: 0.3; } }

/* 대시 쿨다운 */
#dash-cd {
  position: absolute;
  bottom: 100px; left: 32px;
  font-size: 10px;
  letter-spacing: 3px;
  color: rgba(0,255,224,0.5);
  display: none;
}
#dash-cd.visible { display: block; }

/* 데미지 플래시 */
#damage-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(255,0,0,0.35) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
#damage-flash.active { opacity: 1; }

/* 킬 피드 */
#killfeed {
  position: absolute;
  top: 82px; right: 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}
.killfeed-entry {
  background: var(--col-ui-bg);
  border-left: 2px solid var(--col-danger);
  padding: 4px 10px;
  font-size: 11px;
  letter-spacing: 2px;
  box-shadow: 0 0 18px rgba(255,60,60,.08);
  animation: slideIn 0.22s cubic-bezier(.16,1,.3,1), feedPulse .55s ease, fadeOut 0.5s ease 2.5s forwards;
}
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: none; } }
@keyframes fadeOut { to { opacity:0; } }
@keyframes feedPulse {
  0% { filter: brightness(1.9); }
  100% { filter: brightness(1); }
}

/* 플레이어 수 */
#player-count {
  position: absolute;
  top: 32px; left: 32px;
  font-size: 11px;
  letter-spacing: 3px;
  opacity: 0.5;
}
#combat-navbar #player-count {
  position: static;
  opacity: .62;
  white-space: nowrap;
  animation: textScan 2.8s linear infinite;
}

/* 히트마커 */
#hitmarker {
  --hm-color: #ffffff;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 28px; height: 28px;
  opacity: 0;
  transition: opacity 0.05s;
  pointer-events: none;
}
#hitmarker.active { opacity: 1; animation: hitmarkerSnap .18s cubic-bezier(.16,1,.3,1) both; }
#hitmarker::before, #hitmarker::after {
  content: '';
  position: absolute;
  background: var(--hm-color);
  transition: background 0.05s;
}
#hitmarker::before { width: 2px; height: 100%; left: 50%; transform: translateX(-50%) rotate(45deg); }
#hitmarker::after  { height: 2px; width: 100%; top: 50%; transform: translateY(-50%) rotate(45deg); }

/* 잠금 화면 / 오버레이 */
#lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(8px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 80px 16px 32px;
  box-sizing: border-box;
}
#lock-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, transparent 0 42%, rgba(0,255,224,.08) 48%, transparent 54%),
    repeating-linear-gradient(90deg, transparent 0 90px, rgba(0,255,224,.025) 91px, transparent 92px);
  transform: translateX(-18%);
  animation: overlaySweep 8s linear infinite;
}
#lock-overlay::after {
  content: '';
  position: absolute;
  left: 8vw;
  right: 8vw;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,255,224,.34), transparent);
  opacity: .5;
  animation: lineDrift 3.8s ease-in-out infinite;
}
#lock-overlay h1 {
  font-family: 'Orbitron', monospace;
  font-size: 36px;
  font-weight: 900;
  letter-spacing: 6px;
  margin-bottom: 16px;
  text-shadow: 0 0 30px var(--col-hud);
}
#lock-overlay p {
  font-size: 13px;
  letter-spacing: 4px;
  opacity: 0.5;
  margin-bottom: 40px;
}
#lock-overlay button {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--col-hud);
  background: transparent;
  border: 1px solid var(--col-border);
  padding: 14px 40px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
#lock-overlay button:hover {
  background: var(--col-hud-dim);
  box-shadow: 0 0 20px rgba(0,255,224,0.2);
  transform: translateY(-1px);
}

/* 사망 화면 */
#death-screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(200,0,0,0.15);
  backdrop-filter: blur(4px);
}
#death-screen.active { display: flex; animation: deathIn 0.3s ease; }
@keyframes deathIn { from { opacity:0; } to { opacity:1; } }
#death-screen h2 {
  font-family: 'Orbitron', monospace;
  font-size: 52px;
  font-weight: 900;
  color: var(--col-danger);
  letter-spacing: 8px;
  text-shadow: 0 0 40px #ff0000;
  margin-bottom: 12px;
}
#death-screen p { font-size: 12px; letter-spacing: 4px; opacity: 0.4; }

/* ADS 비네트 */
#ads-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.6) 100%);
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 5;
}

/* 스캔라인 오버레이 */
#scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
  animation: scanMove 2.2s linear infinite;
}

#speed-lines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  background:
    radial-gradient(ellipse at center, transparent 30%, rgba(255,255,255,.08) 31%, transparent 33%),
    repeating-conic-gradient(from 0deg at 50% 50%, transparent 0deg 8deg, rgba(0,255,224,.12) 9deg 10deg, transparent 11deg 18deg);
  transform: scale(1.08);
  transition: opacity .14s;
  mix-blend-mode: screen;
}
body.speeding #speed-lines {
  opacity: .28;
  animation: speedRush .36s linear infinite;
}
@keyframes speedRush {
  from { transform: scale(1.02) rotate(0deg); filter: blur(1px); }
  to { transform: scale(1.18) rotate(1deg); filter: blur(0); }
}

body.hit-kick #canvas {
  animation: hitKick 0.12s ease-out;
}
body.headshot-kick #canvas {
  animation: headshotKick 0.18s ease-out;
}
@keyframes hitKick {
  0% { filter: saturate(1.45) contrast(1.08); }
  100% { filter: none; }
}
@keyframes headshotKick {
  0% { filter: saturate(1.8) contrast(1.2) brightness(1.15); }
  100% { filter: none; }
}

.weapon-slot {
  transform-origin: right center;
  animation: slotIdle 3.4s ease-in-out infinite;
}
.weapon-slot.active {
  animation: slotActive .28s cubic-bezier(.16,1,.3,1) both, slotGlow 1.8s ease-in-out infinite .28s;
}

@keyframes hudBreath {
  0%, 100% { opacity: .58; }
  50% { opacity: .86; }
}
@keyframes panelInLeft {
  from { opacity: 0; transform: translateX(-18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes panelInRight {
  from { opacity: 0; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes reloadPop {
  from { opacity: 0; transform: translateX(-50%) translateY(8px) scale(.96); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes hitmarkerSnap {
  from { transform: translate(-50%,-50%) scale(1.45) rotate(8deg); }
  to { transform: translate(-50%,-50%) scale(1) rotate(0); }
}
@keyframes overlaySweep {
  from { transform: translateX(-28%); }
  to { transform: translateX(28%); }
}
@keyframes lineDrift {
  0%, 100% { transform: translateY(-48px); opacity: .22; }
  50% { transform: translateY(48px); opacity: .6; }
}
@keyframes scanMove {
  from { background-position-y: 0; }
  to { background-position-y: 8px; }
}
@keyframes slotIdle {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}
@keyframes slotActive {
  from { transform: translateX(8px) scale(.98); }
  to { transform: translateX(0) scale(1); }
}
@keyframes slotGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(0,255,224,0.1); }
  50% { box-shadow: 0 0 20px rgba(0,255,224,0.22); }
}
@keyframes textScan {
  0%, 92%, 100% { opacity: .58; }
  94% { opacity: .94; }
  96% { opacity: .38; }
}

#bandage-bar {
  position: absolute;
  bottom: 160px; left: 50%;
  transform: translateX(-50%);
  width: 200px;
  display: none;
}
#bandage-bar.visible { display: block; }
#bandage-label {
  text-align: center;
  font-size: 10px;
  letter-spacing: 4px;
  color: #00ee88;
  margin-bottom: 6px;
  animation: blink 0.6s ease infinite alternate;
}
#bandage-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00aa55, #00ee88);
  transition: width 0.05s linear;
}

/* ── 채팅 ── */
#chat-wrap {
  position: fixed;
  bottom: 80px;
  left: 24px;
  width: 320px;
  z-index: 50;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* 메시지 목록 */
#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 200px;
  overflow: hidden;
  justify-content: flex-end;
  margin-bottom: 6px;
}
.chat-msg {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 4px 9px;
  background: rgba(0,0,0,0.55);
  border-left: 2px solid rgba(0,255,224,0.3);
  color: rgba(255,255,255,0.88);
  backdrop-filter: blur(4px);
  animation: chatIn 0.18s cubic-bezier(.16,1,.3,1), chatFade 0.4s ease 7s forwards;
  max-width: 100%;
  word-break: break-all;
  pointer-events: none;
}
.chat-msg .chat-nick {
  color: #00ffe0;
  margin-right: 6px;
}
.chat-msg.chat-mine .chat-nick { color: #ffcc00; }
.chat-msg.chat-system {
  border-left-color: rgba(255,200,0,0.4);
  color: rgba(255,200,100,0.75);
  font-size: 10px;
}
@keyframes chatIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes chatFade { to { opacity: 0; } }

/* 입력창 */
#chat-input-wrap {
  display: none;
  pointer-events: all;
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(0,255,224,0.4);
  backdrop-filter: blur(8px);
  padding: 6px 10px;
  gap: 6px;
  align-items: center;
}
#chat-input-wrap.active { display: flex; }
#chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #fff;
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  letter-spacing: 1px;
  caret-color: #00ffe0;
}
#chat-input::placeholder { color: rgba(255,255,255,0.3); }
#chat-hint {
  position: fixed;
  bottom: 52px;
  left: 24px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.2);
  pointer-events: none;
}

/* ── 온라인 플레이어 자기 자신 태그 ── */
.online-self-tag {
  font-size: 8px;
  letter-spacing: 2px;
  color: rgba(0,255,224,0.5);
  border: 1px solid rgba(0,255,224,0.3);
  padding: 1px 5px;
  opacity: 0.7;
}

/* ── 반응형: 작은 화면 대응 ── */
@media (max-width: 600px) {
  #lock-overlay h1 {
    font-size: clamp(18px, 6vw, 36px);
    letter-spacing: clamp(2px, 2vw, 6px);
  }
  #lock-overlay p {
    font-size: clamp(9px, 2.5vw, 13px);
    letter-spacing: clamp(1px, 1vw, 4px);
  }
  #lock-overlay button {
    font-size: clamp(10px, 3vw, 13px);
    padding: clamp(8px, 3vw, 14px) clamp(18px, 8vw, 40px);
    letter-spacing: clamp(2px, 1.5vw, 4px);
  }
  #lock-overlay {
    justify-content: flex-start;
    padding: 70px 16px 40px;
  }
}

@media (max-height: 700px) {
  #lock-overlay {
    justify-content: flex-start;
    padding-top: 60px;
  }
  #lock-overlay h1 { font-size: clamp(16px, 4vh, 36px); margin-bottom: 8px; }
  #lock-overlay p { margin-bottom: 16px; }
  #lock-overlay button { padding: 8px 24px; }
}

/* 반응형: 데스로 화면 버튼도 */
@media (max-width: 480px) {
  #death-screen h2 {
    font-size: clamp(28px, 10vw, 52px);
    letter-spacing: clamp(3px, 2vw, 8px);
  }
  .room-action {
    font-size: clamp(8px, 2.5vw, 10px);
    padding: 0 clamp(6px, 2vw, 12px);
    letter-spacing: clamp(1px, 0.5vw, 2px);
  }
  #room-input {
    font-size: clamp(9px, 2.5vw, 12px);
  }
}

/* 아주 작은 화면: 룸 패널 레이아웃 세로로 */
@media (max-width: 400px) {
  /* inline style 우선순위 때문에 important 사용 */
  #room-panel {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  #room-info {
    grid-column: 1 / -1;
    flex-direction: column;
    gap: 4px;
  }
  #room-input {
    grid-column: 1 / -1;
  }
  #room-join-btn, #room-create-btn, #room-quick-btn {
    font-size: 9px;
  }
}
