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

body {
  background: #0b0b10;
  color: #cfc9bf;
  font: 14px/1.4 "Iowan Old Style", Georgia, serif;
  overflow: hidden;
}

#game { display: block; cursor: crosshair; }

/* --- run status (the descent scoreboard) --- */
#run-status {
  position: fixed;
  left: 50%; top: 14px;
  transform: translateX(-50%);
  font-size: 13px; color: #c9b76a;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

/* --- minimap --- */
#minimap {
  position: fixed;
  left: 16px; top: 16px;
  border: 1px solid #3a3a45;
  border-radius: 4px;
  background: #0b0b10ee;
  image-rendering: pixelated;
  pointer-events: none;
}

/* --- HUD: life/mana globes flanking the skill bar, PoE2-style --- */
#hud {
  position: fixed;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 14px;
  pointer-events: none; /* the canvas stays clickable between elements */
}
#hud .globe, #hud .skill-slot { pointer-events: auto; }

.globe {
  position: relative;
  width: 104px; height: 104px;
  border-radius: 50%;
  background: #101018;
  border: 2px solid #4a4a58;
  box-shadow: inset 0 0 18px #000, 0 2px 8px #000a;
  overflow: hidden;
}
.globe-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 100%;
  transition: height 120ms linear;
}
.globe.life .globe-fill {
  background: radial-gradient(circle at 35% 30%, #d14a4a, #7a1818 65%, #4e0e0e);
}
.globe.mana .globe-fill {
  background: radial-gradient(circle at 35% 30%, #4a7ad1, #1c3d8a 65%, #10245e);
}
/* glassy highlight over the liquid */
.globe::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background:
    radial-gradient(ellipse 55% 30% at 50% 16%, #ffffff2e, transparent 70%),
    radial-gradient(circle at 50% 120%, transparent 55%, #00000066);
  pointer-events: none;
}
.globe span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #efe9dc; text-shadow: 0 1px 3px #000;
}

#hud-center { display: flex; flex-direction: column; gap: 6px; width: 300px; }

#skill-bar { display: flex; justify-content: center; gap: 6px; }
/* .skill-slot, not .slot — the inventory grid owns that class */
.skill-slot {
  position: relative;
  width: 52px; height: 52px;
  border-radius: 6px;
  border: 1px solid #3a3a4e;
  background: #14141d;
  box-shadow: inset 0 0 10px #000;
  cursor: pointer;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  padding-bottom: 12px;
  color: #cfc9bf;
  font-family: inherit;
}
.skill-slot:hover { border-color: #b8a44a; }
.skill-slot .glyph {
  width: 22px; height: 22px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}
.skill-slot .slot-name { font-size: 8px; letter-spacing: 0.03em; color: #8d8678; }
.skill-slot .key {
  position: absolute;
  right: 3px; bottom: 2px;
  font-size: 10px; color: #b8a44a;
}
.skill-slot.drained { opacity: 0.35; filter: grayscale(0.7); }
.skill-slot.cast-flash { border-color: #efe9dc; box-shadow: 0 0 10px #b8a44a; }

.bar {
  position: relative;
  height: 22px;
  background: #1a1a22;
  border: 1px solid #3a3a45;
  border-radius: 3px;
  overflow: hidden;
}
.bar .fill { height: 100%; width: 100%; transition: width 120ms linear; }
#xp-row { display: flex; align-items: center; gap: 8px; pointer-events: none; }
#level-badge { font-size: 12px; color: #c9b76a; min-width: 42px; text-align: right; text-shadow: 0 1px 2px #000; }
#xp-row .bar.xp { flex: 1; height: 7px; }
.bar.xp .fill { background: linear-gradient(#c9b76a, #8a7a36); transition: width 200ms linear; }

/* --- inventory panel --- */
#panel {
  position: fixed;
  user-select: none;
  -webkit-user-select: none;
  right: 16px; top: 16px;
  width: 280px; max-height: 75vh;
  overflow-y: auto;
  background: rgba(16, 16, 22, 0.95);
  border: 1px solid #3a3a45;
  border-radius: 4px;
  padding: 12px;
}
#panel h2 { font-size: 13px; color: #8d8678; text-transform: uppercase; letter-spacing: 1px; margin: 8px 0 6px; }
#panel .hint { font-size: 11px; color: #55504a; margin-top: 10px; }

.inv-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.slot {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  background: #14141c;
  border: 1px solid #2a2a33;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slot .slot-label {
  position: absolute;
  bottom: 1px; left: 0; right: 0;
  text-align: center;
  font-size: 8px; color: #55504a;
  text-transform: uppercase; letter-spacing: 0.5px;
  pointer-events: none;
}
.slot.filled { cursor: grab; }
.slot.filled:active { cursor: grabbing; }
.slot.filled:hover { background: #1c1c26; }
.slot svg { width: 70%; height: 70%; pointer-events: none; }

/* rarity tints the icon (currentColor) and the slot border */
.slot.rarity-normal { color: #cfc9bf; }
.slot.rarity-magic { color: #8888ff; border-color: #50509a; }
.slot.rarity-rare { color: #ffff77; border-color: #8a8a3a; }
.rarity-normal { color: #cfc9bf; }
.rarity-magic { color: #8888ff; }
.rarity-rare { color: #ffff77; }

/* drag feedback: legal targets glow while a drag is in flight */
.slot.drop-ok { border-color: #b8a44a; background: #221f14; }
.slot.dragging { opacity: 0.35; }

/* --- tooltip --- */
#tooltip {
  position: fixed;
  z-index: 10;
  max-width: 240px;
  background: rgba(12, 12, 18, 0.97);
  border: 1px solid #3a3a45;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 13px;
  pointer-events: none;
}
#tooltip .tt-name { display: block; }
#tooltip .tt-kind { display: block; font-size: 11px; color: #8d8678; }
#tooltip .tt-implicit {
  display: block; font-size: 12px; color: #a89968; font-style: italic;
  border-bottom: 1px solid #3a362e; padding-bottom: 3px; margin-bottom: 3px;
}
#tooltip .tt-affix { display: block; font-size: 12px; color: #7d8fb0; }
#tooltip .tt-plain { display: block; font-size: 11px; color: #55504a; font-style: italic; }

/* --- event log --- */
#log {
  position: fixed;
  left: 16px; bottom: 16px;
  width: 340px; max-height: 180px;
  overflow: hidden;
  font-size: 12px; color: #8d8678;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
#log .ev-death { color: #c0392b; }
#log .ev-drop, #log .ev-pickup, #log .ev-equip { color: #b8a44a; }
#log .ev-ignite { color: #e67e22; }
#log .ev-chill { color: #7fd4ff; }
#log .ev-shock { color: #f5e25f; }
#log .ev-level_up { color: #c9b76a; font-weight: bold; }
#log .ev-descend { color: #c9b76a; font-weight: bold; }
#log .ev-portal { color: #7fd4ff; }
#log .ev-death_eject { color: #c0392b; font-weight: bold; }
#log .ev-run_over { color: #c0392b; font-weight: bold; }

/* --- overlays --- */
#overlay {
  position: fixed; inset: 0;
  background: rgba(10, 0, 0, 0.82);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 24px;
}
#overlay-text { font-size: 64px; letter-spacing: 6px; color: #a32626; }
#overlay button {
  font: inherit; font-size: 16px;
  background: #1a1a22; color: #cfc9bf;
  border: 1px solid #3a3a45; border-radius: 3px;
  padding: 8px 24px; cursor: pointer;
}
#overlay button:hover { border-color: #6a6455; }

#help {
  position: fixed;
  right: 16px; bottom: 16px;
  font-size: 12px; color: #55504a;
}

.hidden { display: none !important; }

/* Passive chooser: the milestone-choice card, bottom center above the HUD. */
#passive-chooser {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: #14141dee;
  border: 1px solid #3a3a4e;
  border-radius: 6px;
  padding: 10px 14px;
  text-align: center;
  z-index: 5;
}
#passive-chooser h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #b8a44a;
  font-weight: normal;
  letter-spacing: 0.06em;
}
.passive-option {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 4px;
  padding: 8px 12px;
  background: #1c1c28;
  border: 1px solid #3a3a4e;
  border-radius: 4px;
  color: #cfc9bf;
  font-family: Georgia, serif;
  font-size: 12px;
  cursor: pointer;
}
.passive-option:hover {
  border-color: #b8a44a;
  background: #232331;
}
.passive-option span {
  color: #8d8678;
  font-size: 11px;
}

/* Flask rack: two vials tucked against the life globe. */
#flask-rack { display: flex; gap: 5px; align-items: flex-end; pointer-events: auto; }
.flask {
  position: relative;
  width: 24px; height: 58px;
  border: 1px solid #3a3a4e;
  border-radius: 5px 5px 8px 8px;
  background: #101018;
  box-shadow: inset 0 0 8px #000;
  overflow: hidden;
  cursor: pointer;
  padding: 0;
}
.flask:hover { border-color: #b8a44a; }
.flask .flask-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  transition: height 150ms linear;
}
.flask.life .flask-fill { background: linear-gradient(#d14a4a, #6e1414); }
.flask.mana .flask-fill { background: linear-gradient(#4a7ad1, #16306e); }
.flask .key {
  position: absolute; left: 0; right: 0; bottom: 1px;
  text-align: center;
  font-size: 10px; color: #b8a44a; text-shadow: 0 1px 2px #000;
}
.flask.drained { opacity: 0.45; filter: grayscale(0.6); }

/* Currency strip in the panel; an armed orb highlights bag cells. */
#orb-strip { display: flex; gap: 6px; margin-bottom: 4px; }
.orb {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px;
  background: #14141c;
  border: 1px solid #2a2a33;
  border-radius: 3px;
  color: #cfc9bf; font: inherit; font-size: 12px;
  cursor: pointer;
}
.orb:hover { border-color: #b8a44a; }
.orb.armed { border-color: #b8a44a; background: #221f14; }
.orb.drained { opacity: 0.45; }
.orb-dot { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
#panel.orb-armed .inv-grid .slot.filled { border-color: #b8a44a66; cursor: cell; }
#log .ev-orb { color: #d97b4a; }

#tooltip .tt-compare {
  display: block;
  margin-top: 6px; padding-top: 4px;
  border-top: 1px solid #3a362e;
  font-size: 10px; color: #6a6455;
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* Join screen: name claim or guest, shown before the socket opens. */
#join {
  position: fixed; inset: 0;
  background: rgba(10, 0, 0, 0.88);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
}
#join-title { font-size: 48px; letter-spacing: 8px; color: #cfc9bf; margin-bottom: 10px; }
#join input {
  font: inherit; font-size: 18px; text-align: center;
  background: #1a1a22; color: #cfc9bf;
  border: 1px solid #3a3a45; border-radius: 3px;
  padding: 8px 16px; width: 240px; outline: none;
}
#join input:focus { border-color: #6a6455; }
#join button {
  font: inherit; font-size: 16px;
  background: #1a1a22; color: #cfc9bf;
  border: 1px solid #3a3a45; border-radius: 3px;
  padding: 8px 24px; cursor: pointer; width: 274px;
}
#join button:hover { border-color: #6a6455; }
#join button.ghost { background: none; border-color: transparent; color: #55504a; }
#join button.ghost:hover { color: #8d8678; }
#join-error { font-size: 13px; color: #a32626; min-height: 16px; }
