/* ============================================================
   Boomer Shooter Roguelike - HUD and overlay styling
   ============================================================ */

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

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  color: #ddd;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  overflow: hidden;
  user-select: none;
}

#game-container {
  position: absolute;
  inset: 0;
}

#game-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: 14px;
  text-shadow: 1px 1px 2px #000;
}

#hud-topleft { position: absolute; top: 12px; left: 12px; width: 240px; }
#hud-topcenter { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); text-align: center; }
#hud-topright { position: absolute; top: 140px; right: 12px; text-align: right; }

#minimap-container { border: 1px solid rgba(255,255,255,0.2); border-radius: 4px; overflow: hidden; }
#minimap-canvas { display: block; }
#hud-bottomleft { position: absolute; bottom: 12px; left: 12px; width: min(520px, calc(100vw - 24px)); }
#hud-bottomcenter { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); text-align: center; }
#hud-bottomright { position: absolute; bottom: 12px; right: 12px; text-align: right; }

#location-text { font-size: 18px; font-weight: bold; color: #f2c14e; }
#objective-text { font-size: 13px; color: #9fd8e6; }

.bar-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.bar-label { width: 28px; color: #aaa; font-size: 11px; }
.bar { flex: 1; height: 12px; background: #1a1a1a; border: 1px solid #444; border-radius: 3px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; transition: width 0.1s linear; }
.bar-fill.hp { background: linear-gradient(90deg, #b3202b, #e34a4a); }
.bar-fill.sta { background: linear-gradient(90deg, #2f7d32, #5fc265); }
.bar-fill.hp-preview { position: absolute; top: 0; background: rgba(255, 110, 80, 0.55); display: none; transition: none; }
#health-text, #stamina-text { width: 34px; text-align: right; font-size: 11px; }
#armor-row { font-size: 12px; color: #b9c6e6; margin-top: 4px; }

#weapon-name { font-weight: bold; color: #f2c14e; }
#weapon-resource { font-size: 12px; color: #9fd8e6; }
#weapon-mods { font-size: 11px; color: #c79fdd; max-width: 240px; }
#extract-hint { color: #ff8a4a; font-weight: bold; }

#hud-loadout {
  display: grid;
  grid-template-columns: 1.1fr 0.92fr 0.92fr 0.92fr;
  gap: 6px;
  margin-bottom: 8px;
  align-items: stretch;
}
.hud-slot {
  position: relative;
  overflow: hidden;
  min-height: 74px;
  padding: 7px 8px 6px;
  border: 1px solid rgba(226, 157, 52, 0.75);
  background:
    linear-gradient(180deg, rgba(20, 14, 10, 0.92), rgba(10, 8, 6, 0.88)),
    radial-gradient(circle at top, rgba(255, 214, 120, 0.12), transparent 55%);
  box-shadow: inset 0 0 18px rgba(0,0,0,0.35);
  border-radius: 6px;
}
.hud-slot.weapon-slot { border-color: rgba(159, 216, 230, 0.9); }
.hud-slot.weapon-slot::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(var(--reload-fill, 0) * 100%);
  background: linear-gradient(90deg, rgba(159, 216, 230, 0.36), rgba(88, 150, 170, 0.16));
  opacity: 0;
  transition: width 0.08s linear, opacity 0.16s ease;
}
.hud-slot.weapon-slot.reloading::before {
  opacity: 1;
}
.hud-slot.quick-slot { border-color: rgba(226, 157, 52, 0.7); }
.hud-slot > * {
  position: relative;
  z-index: 1;
}
.hud-slot-key {
  font-size: 9px;
  color: #9fd8e6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.hud-slot-icon {
  margin-top: 3px;
  font-weight: bold;
  font-size: 15px;
  color: #ffe08a;
}
.hud-slot-name {
  margin-top: 3px;
  color: #fff0c6;
  font-size: 11px;
  font-weight: bold;
  line-height: 1.15;
}
.hud-slot-stats {
  margin-top: 5px;
  min-height: 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  color: #9fd8e6;
  font-size: 10px;
}
.hud-slot-stat-left,
.hud-slot-stat-right {
  min-width: 0;
}
.hud-slot-stat-right {
  text-align: right;
}
.hud-slot-meta {
  margin-top: 5px;
  min-height: 14px;
  color: #9fd8e6;
  font-size: 10px;
}
.weapon-slot.empty .hud-slot-stats { color: rgba(159, 216, 230, 0.5); }
.hud-slot.empty .hud-slot-name { color: rgba(255, 240, 198, 0.58); }
.hud-slot.empty .hud-slot-icon,
.hud-slot.empty .hud-slot-meta { color: rgba(159, 216, 230, 0.5); }

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 4;
  font-size: 0;
}
#interact-prompt {
  margin-top: 6px;
  background: rgba(0,0,0,0.55);
  border: 1px solid #6a5acd;
  padding: 4px 10px;
  border-radius: 4px;
  color: #ffe9a8;
  display: inline-block;
}

/* ---------- Floating layer (damage numbers / prompts) ---------- */
#float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.float-text {
  position: absolute;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 1px 1px 2px #000;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

/* ---------- Overlay menus ---------- */
#overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 10, 16, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: auto;
}
#overlay.inventory-open {
  background: rgba(8, 10, 16, 0.34);
  align-items: center;
  justify-content: center;
}
.panel {
  background: linear-gradient(180deg, #1c1f2a, #11131c);
  border: 2px solid #3a3f5a;
  border-radius: 10px;
  padding: 28px 34px;
  max-width: 820px;
  width: 90%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}
.panel h1 { color: #f2c14e; margin-bottom: 6px; font-size: 30px; }
.panel h2 { color: #f2c14e; margin: 10px 0 8px; font-size: 20px; }
.panel h3 { color: #c79fdd; margin: 10px 0 4px; font-size: 15px; }
.panel p { margin: 6px 0; line-height: 1.45; color: #c9ccd6; }
.panel .muted { color: #8a8fa3; font-size: 12px; }
.panel .row { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0; align-items: center; }
.panel .col { flex: 1; min-width: 200px; }

button, .btn {
  background: #2a2f48;
  color: #fff;
  border: 1px solid #4a5078;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  pointer-events: auto;
}
button:hover, .btn:hover { background: #3a4170; border-color: #6a72a8; }
button.primary { background: #5a3a8a; border-color: #8a6acf; }
button.primary:hover { background: #6e4aa8; }
button.danger { background: #6a2030; border-color: #a8384a; }
button.danger:hover { background: #8a2840; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible {
  outline: 2px solid #ffe08a;
  outline-offset: 2px;
  border-color: #ffe08a;
}

.item-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.item-card {
  background: #161924;
  border: 1px solid #2e3247;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
}
.item-card:hover { border-color: #6a72a8; background: #1d2130; }
.item-card .iname { color: #f2c14e; font-weight: bold; }
.item-card .idesc { color: #8a8fa3; font-size: 11px; margin-top: 2px; }
.item-card .istack { color: #9fd8e6; font-size: 11px; }

.kvs { font-size: 13px; color: #c9ccd6; }
.kvs .k { color: #8a8fa3; display: inline-block; width: 130px; }
.kvs .v { color: #f2c14e; }

.controls-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 4px 12px;
  font-size: 13px;
  color: #c9ccd6;
}
.controls-grid .key { color: #f2c14e; font-weight: bold; }

/* ---------- Debug overlays ---------- */
.debug-overlay {
  position: absolute;
  background: rgba(0,0,0,0.7);
  border: 1px solid #2f7d32;
  color: #9be29b;
  font-family: "Consolas", monospace;
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 4px;
  z-index: 15;
  pointer-events: none;
  white-space: pre;
  max-width: 60%;
  max-height: 70%;
  overflow: auto;
}
#debug-f1 { top: 50px; left: 12px; }
#debug-f2 { top: 50px; right: 12px; }
#debug-f3 { bottom: 60px; left: 50%; transform: translateX(-50%); }

#click-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.7);
  border: 1px solid #6a5acd;
  padding: 14px 22px;
  border-radius: 8px;
  font-size: 18px;
  color: #ffe9a8;
  z-index: 25;
  pointer-events: none;
}

.status-line { color: #9fd8e6; font-size: 13px; margin: 4px 0; }
.tag { display: inline-block; background: #2a2f48; border: 1px solid #4a5078; border-radius: 4px; padding: 1px 6px; font-size: 11px; margin: 2px; color: #c9ccd6; }
.tag.fire { color: #ff8a4a; border-color: #a8384a; }
.tag.poison { color: #6acf6a; border-color: #2f7d32; }
.tag.holy { color: #ffe9a8; border-color: #b9a14a; }
.tag.frost { color: #9fd8e6; border-color: #3a6a8a; }

/* ---------- Sulfur-style inventory ---------- */
.inventory-overlay {
  --cell: clamp(40px, 4.85vh, 60px);
  width: min(98vw, 1760px);
  max-height: 94vh;
  display: grid;
  grid-template-columns: minmax(500px, 560px) max-content;
  gap: 24px;
  align-items: start;
  justify-content: center;
  padding: 24px 26px 28px;
  color: #f4e3b5;
  text-shadow: 1px 1px 2px #000;
  overflow: auto;
}
.inventory-overlay.with-stash {
  grid-template-columns: minmax(500px, 560px) max-content max-content;
}
.equip-panel,
.inv-grid-panel {
  background:
    linear-gradient(180deg, rgba(31, 20, 11, 0.72), rgba(16, 10, 6, 0.52)),
    radial-gradient(circle at top, rgba(255, 214, 120, 0.06), transparent 58%);
  border: 1px solid rgba(226, 157, 52, 0.72);
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35), inset 0 0 38px rgba(0,0,0,0.22), 0 14px 36px rgba(0,0,0,0.16);
  backdrop-filter: blur(2px);
}
.equip-panel {
  padding: 22px 22px 20px;
  min-height: 700px;
}
.quick-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.paper-doll {
  display: grid;
  grid-template-columns: 96px 104px 104px 96px;
  grid-template-rows: 76px 124px 76px 84px;
  gap: 10px;
  justify-content: center;
  align-items: stretch;
}
.equip-slot {
  position: relative;
  border: 2px solid rgba(226, 157, 52, 0.72);
  background: linear-gradient(180deg, rgba(42, 31, 22, 0.56), rgba(27, 20, 15, 0.4));
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 226, 169, 0.58);
  font-size: 12px;
  text-align: center;
  overflow: hidden;
  border-radius: 8px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.equip-slot.selected {
  outline: 2px solid #ffe08a;
  outline-offset: 2px;
}
.equip-slot:hover {
  border-color: rgba(255, 214, 120, 0.96);
  box-shadow: inset 0 0 24px rgba(255, 214, 120, 0.08);
}
.slot-quick1, .slot-quick2, .slot-quick3 { min-height: 58px; }
.slot-helmet { grid-column: 2; grid-row: 1; }
.slot-chest { grid-column: 2; grid-row: 2; }
.slot-boots { grid-column: 2; grid-row: 3; }
.slot-amulet { grid-column: 3; grid-row: 1; }
.slot-gloves { grid-column: 1; grid-row: 2; }
.slot-primary {
  grid-column: 1 / span 2;
  grid-row: 4;
  min-height: 84px;
}
.slot-secondary {
  grid-column: 3 / span 2;
  grid-row: 4;
  min-height: 84px;
}
.equip-item {
  width: 100%;
  height: 100%;
  padding: 7px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: #fff0c6;
  background: rgba(92, 64, 35, 0.72);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}
.equip-item:hover,
.inv-item:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: inset 0 0 12px rgba(255,255,255,0.06), 0 0 0 1px rgba(255, 224, 138, 0.18);
}
.equip-empty { pointer-events: none; }
.inv-resources {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 14px;
  margin-top: 20px;
  font-size: 13px;
  color: #f3d784;
}
.inv-grid-panel {
  padding: 12px;
}
.inv-grid-title {
  height: 24px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: bold;
  color: #f2c14e;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.inv-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
  width: calc(var(--cols) * var(--cell));
  height: calc(var(--rows) * var(--cell));
}
.inv-cell {
  border: 1px solid rgba(226, 157, 52, 0.78);
  background: rgba(12, 8, 4, 0.22);
  transition: background 0.08s linear, box-shadow 0.08s linear, border-color 0.08s linear;
}
.inv-drag-footprint {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-template-rows: repeat(var(--rows), var(--cell));
  pointer-events: none;
  z-index: 1;
}
.inv-drag-footprint-cell {
  border: 1px solid rgba(109, 219, 126, 0.96);
  background: rgba(32, 84, 39, 0.36);
  box-shadow: inset 0 0 14px rgba(109, 219, 126, 0.22);
}
.inv-drag-footprint.invalid .inv-drag-footprint-cell {
  border-color: rgba(238, 102, 102, 0.96);
  background: rgba(112, 28, 28, 0.34);
  box-shadow: inset 0 0 14px rgba(238, 102, 102, 0.22);
}
.inv-drag-footprint-cell.anchor {
  box-shadow: inset 0 0 0 2px rgba(255, 240, 198, 0.92), inset 0 0 16px rgba(255, 240, 198, 0.12);
}
.inv-item {
  z-index: 2;
  margin: 2px;
  border: 1px solid rgba(255, 223, 141, 0.88);
  background: rgba(91, 58, 28, 0.88);
  color: #fff4d6;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  cursor: grab;
  overflow: hidden;
  padding: 4px;
  font-size: 11px;
  line-height: 1.1;
  border-radius: 6px;
  box-shadow: inset 0 0 12px rgba(255,255,255,0.04);
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.inv-item.selected {
  outline: 2px solid #ffe08a;
  outline-offset: 1px;
}
.equip-slot.drag-preview-valid {
  border-color: rgba(109, 219, 126, 0.96);
  background: rgba(32, 84, 39, 0.36);
  box-shadow: inset 0 0 14px rgba(109, 219, 126, 0.22);
}
.equip-slot.drag-preview-invalid {
  border-color: rgba(238, 102, 102, 0.96);
  background: rgba(112, 28, 28, 0.34);
  box-shadow: inset 0 0 14px rgba(238, 102, 102, 0.22);
}
.inv-item.weapon, .equip-item.weapon { background: rgba(47, 87, 97, 0.9); }
.inv-item.consumable, .equip-item.consumable { background: rgba(92, 84, 35, 0.9); }
.inv-item.ingredient, .equip-item.ingredient { background: rgba(65, 88, 55, 0.9); }
.inv-icon {
  font-weight: bold;
  font-size: 12px;
  color: #ffe08a;
}
.inv-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inv-stack {
  position: absolute;
  right: 5px;
  bottom: 3px;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}
.inv-detail-panel {
  grid-column: 1 / -1;
  height: 126px;
  padding: 14px 16px;
  margin-top: 2px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background:
    linear-gradient(180deg, rgba(29, 18, 10, 0.72), rgba(18, 11, 7, 0.58)),
    radial-gradient(circle at top left, rgba(159, 216, 230, 0.06), transparent 52%);
  border: 1px solid rgba(226, 157, 52, 0.72);
  border-radius: 10px;
  box-shadow: inset 0 0 24px rgba(0,0,0,0.22);
  overflow: hidden;
}
.inv-detail-title {
  color: #f2c14e;
  font-size: 15px;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inv-detail-subtitle {
  margin-top: 3px;
  color: #9fd8e6;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inv-detail-body {
  margin-top: 8px;
  color: #fff0c6;
  font-size: 12px;
  line-height: 1.45;
  min-height: 0;
  overflow: hidden;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.inv-detail-hint {
  color: #8a8f9e;
}

@media (max-width: 900px) {
  #hud-bottomleft { width: min(440px, calc(100vw - 24px)); }
  #hud-loadout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .hud-slot { min-height: 70px; }
  .inventory-overlay,
  .inventory-overlay.with-stash {
    grid-template-columns: 1fr;
    justify-content: stretch;
    width: min(98vw, 980px);
    padding: 18px;
  }
  .paper-doll {
    grid-template-columns: repeat(4, minmax(72px, 1fr));
  }
}

/* ============================================================================
 * Co-op lobby (mp-lab) — shown before the run; replaces single-player START/ROOM
 * ==========================================================================*/
#lobby-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a1410 0%, rgba(42,20,16,0) 60%),
    linear-gradient(160deg, #0c0a0e 0%, #140d10 50%, #0a0708 100%);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #f3e7d8;
}
#lobby-screen.hidden { display: none; }
.lobby-panel {
  width: min(560px, 92vw);
  background: rgba(20, 14, 14, 0.92);
  border: 1px solid #4a2f23;
  border-radius: 14px;
  padding: 26px 28px 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 0 60px rgba(255, 120, 40, 0.04);
}
.lobby-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.lobby-title {
  margin: 0; font-size: 40px; letter-spacing: 6px; font-weight: 900;
  background: linear-gradient(180deg, #ffd27a, #ff7a33 70%, #c43a1e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 24px rgba(255, 120, 40, 0.25);
}
.lobby-sub { margin: 4px 0 0; color: #b39a86; font-size: 13px; }
.lobby-room-pill {
  flex: none; align-self: center;
  background: #1c1310; border: 1px solid #5a3a2a; border-radius: 999px;
  padding: 7px 14px; font-size: 13px; color: #d8c2ad; white-space: nowrap;
}
.lobby-room-pill span { color: #ffcf8a; font-weight: 700; letter-spacing: 2px; }
.lobby-slots {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  margin: 22px 0 18px;
}
.lobby-slot {
  --pc: #4aa3ff;
  background: #15100e; border: 1px solid #382722; border-radius: 10px;
  padding: 12px 10px; min-height: 76px; opacity: 0.55;
  transition: opacity .15s, border-color .15s, box-shadow .15s;
}
.lobby-slot.filled { opacity: 1; border-color: var(--pc); box-shadow: 0 0 0 1px var(--pc) inset, 0 8px 22px rgba(0,0,0,0.35); }
.lobby-slot.me { box-shadow: 0 0 0 2px var(--pc) inset, 0 0 22px -4px var(--pc); }
.lobby-slot-top { display: flex; align-items: center; justify-content: space-between; }
.lobby-slot-id { font-weight: 800; color: var(--pc); font-size: 15px; }
.lobby-slot-status { font-size: 10px; letter-spacing: 1px; color: #9a8472; }
.lobby-slot.filled .lobby-slot-status { color: #d8c2ad; }
.lobby-slot-name { margin-top: 14px; font-size: 13px; color: #cdbaa6; }
.lobby-actions { display: flex; gap: 12px; }
.lobby-ready, .lobby-copy {
  font-family: inherit; font-size: 15px; font-weight: 700;
  border-radius: 10px; padding: 13px 18px; cursor: pointer; border: 1px solid transparent;
  transition: filter .15s, background .15s, transform .05s;
}
.lobby-ready {
  flex: 1; color: #1a0f08;
  background: linear-gradient(180deg, #ffd27a, #ff8a3a);
  border-color: #ffb066;
}
.lobby-ready:disabled { filter: grayscale(0.6) brightness(0.7); cursor: default; }
.lobby-ready.is-ready { background: linear-gradient(180deg, #8fe08f, #4fb04f); border-color: #6fd06f; }
.lobby-ready:not(:disabled):active { transform: translateY(1px); }
.lobby-copy { background: #241813; color: #e6d4c2; border-color: #5a3a2a; }
.lobby-copy:hover { background: #2e1f18; }
.lobby-status { margin-top: 14px; text-align: center; font-size: 13px; color: #c9b39e; min-height: 18px; }
.lobby-hint { margin: 8px 0 0; text-align: center; font-size: 11px; color: #8a7665; }
