/* ══════════════════════════════════════════════════════
   PASTOR — Vampire-Survivors-style tile-based survival
   Styles
   ══════════════════════════════════════════════════════ */

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

:root {
  --bg: #0a0a12;
  --panel: #111118;
  --border: #1e1e2e;
  --gold: #ff6;
  --cyan: #6ff;
  --pink: #f6f;
  --red: #f44;
  --green: #0f0;
  --hp-color: #e33;
  --xp-color: #48f;
  --font-ui: 'Silkscreen', monospace;
  --font-mono: 'Courier New', monospace;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #ccc;
  font-family: var(--font-ui);
  font-size: 12px;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  font-family: var(--font-ui);
  font-size: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 8px 18px;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
  transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.3); }
.btn:active { filter: brightness(0.9); }
.btn-primary { background: #2a1e00; color: var(--gold); border-color: #3a2800; }
.btn-secondary { background: #001a1a; color: var(--cyan); border-color: #002a2a; }
.btn-danger { background: #1a0000; color: var(--red); border-color: #2a0000; }

/* ── Game layout ─────────────────────────────────────── */
#game {
  display: flex;
  flex-direction: column;
  width: 100%; height: 100%;
  position: relative;
}

#gameHeader {
  background: var(--panel);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 12px;
  font-size: 11px;
  min-height: 32px;
  z-index: 10;
}

#gameHeader span { white-space: nowrap; }
#btnLeave {
  background: none; border: 1px solid var(--border); color: #aaa;
  font-size: 16px; line-height: 1; width: 28px; height: 28px;
  border-radius: 4px; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; -webkit-tap-highlight-color: transparent;
}
#btnLeave:hover, #btnLeave:active { color: #fff; border-color: var(--red); background: rgba(255,60,60,0.15); }
#roomLabel { color: var(--gold); font-weight: 700; }
#timerLabel { color: #fff; font-size: 14px; font-weight: 700; letter-spacing: 1px; }
#playerCount { color: var(--cyan); }
#killCount { color: var(--red); margin-left: auto; }

#gameArea {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050510;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── HUD (bars + weapon slots) ─────────────────────── */
#hud {
  position: absolute;
  top: 38px; left: 8px;
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#hudBars {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(0,0,0,0.6);
  padding: 6px 8px;
  border-radius: 4px;
  min-width: 180px;
}

.hud-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 14px;
}

.bar-label {
  font-size: 9px;
  width: 18px;
  text-align: right;
  color: #888;
}

.bar-track {
  flex: 1;
  height: 8px;
  background: #1a1a2a;
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.15s;
}

.hp-fill { background: var(--hp-color); }
.xp-fill { background: var(--xp-color); }

.bar-val {
  font-size: 9px;
  width: 48px;
  color: #aaa;
}

#weaponSlots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  pointer-events: none;
}

.weapon-slot {
  width: 32px; height: 32px;
  background: rgba(0,0,0,0.6);
  border: 1px solid #333;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  position: relative;
}

.weapon-slot .weapon-cd {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: #555;
}

.weapon-slot .weapon-lvl {
  position: absolute;
  top: -1px; right: 1px;
  font-size: 7px;
  color: var(--gold);
}

/* ── Level-up Panel ──────────────────────────────────── */
#levelUpPanel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.levelup-box {
  text-align: center;
  max-width: 500px;
  width: 90%;
}

.levelup-title {
  font-size: 24px;
  color: var(--gold);
  margin-bottom: 4px;
  text-shadow: 0 0 15px #fc0;
}

.levelup-sub {
  font-size: 11px;
  color: #888;
  margin-bottom: 16px;
}

.levelup-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.levelup-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color 0.15s, background 0.15s;
  clip-path: polygon(4px 0, calc(100% - 4px) 0, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 0 calc(100% - 4px), 0 4px);
}
.levelup-card:hover { border-color: var(--gold); background: #1a1a10; }

.levelup-icon {
  font-size: 22px;
  width: 36px;
  text-align: center;
}

.levelup-info { text-align: left; flex: 1; }
.levelup-name { font-size: 13px; font-weight: 700; }
.levelup-desc { font-size: 10px; color: #888; margin-top: 2px; }
.levelup-lvl { font-size: 9px; color: var(--gold); }

/* ── Death / Victory / Leave Overlays ────────────────── */
#deathOverlay, #victoryOverlay, #leaveOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.death-box, .victory-box, .leave-box {
  text-align: center;
  max-width: 400px;
  width: 85%;
}

.leave-box {
  background: #111;
  border: 2px solid var(--border);
  padding: 24px 20px;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  box-shadow: 6px 6px 0 rgba(0,0,0,0.5);
}

.leave-title {
  font-size: 20px;
  color: var(--gold);
  margin-bottom: 8px;
}

.leave-msg {
  font-size: 11px;
  color: #888;
  margin-bottom: 20px;
}

.leave-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.leave-buttons .btn {
  min-width: 100px;
  padding: 10px 20px;
}

.death-title {
  font-size: 32px;
  color: var(--red);
  text-shadow: 0 0 20px #f00;
  margin-bottom: 10px;
}

.death-stats, .victory-stats {
  font-size: 11px;
  color: #aaa;
  margin: 12px 0;
  line-height: 1.8;
}

.death-msg {
  font-size: 11px;
  color: #666;
  margin-bottom: 16px;
}

.victory-title {
  font-size: 32px;
  color: var(--gold);
  text-shadow: 0 0 20px #fc0;
  margin-bottom: 10px;
}

.victory-subtitle {
  font-size: 14px;
  color: var(--gold);
  margin-bottom: 12px;
}

/* ── Message Log (floating) ──────────────────────────── */
#messageLog {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  max-width: 400px;
}

.msg-line {
  font-size: 10px;
  background: rgba(0,0,0,0.6);
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
  animation: msgFadeIn 0.25s ease;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Damage Flash ────────────────────────────────────── */
.damage-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.1s;
}
.damage-flash.active {
  opacity: 1;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(255,0,0,0.25) 100%);
}

/* ── Event Banner ────────────────────────────────────── */
.event-banner {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  font-size: 16px;
  font-weight: 700;
  padding: 8px 24px;
  background: rgba(0,0,0,0.8);
  border: 1px solid var(--border);
  text-align: center;
  animation: bannerPulse 0.5s ease infinite alternate;
  white-space: nowrap;
}

@keyframes bannerPulse {
  from { text-shadow: 0 0 6px currentColor; }
  to { text-shadow: 0 0 16px currentColor; }
}

/* ── Responsive / Mobile ─────────────────────────────── */
@media (max-width: 768px), (pointer: coarse) {
  #hud { top: 36px; left: 4px; }
  #hudBars { min-width: 140px; padding: 4px 6px; }
  .bar-label { font-size: 8px; }
  .bar-val { font-size: 8px; width: 36px; }
  .weapon-slot { width: 26px; height: 26px; font-size: 13px; }
  .levelup-card { padding: 10px 12px; }
  #messageLog { bottom: 170px; }
}
