:root {
  --hud-bg: rgba(22, 31, 38, 0.56);
  --hud-border: rgba(210, 231, 245, 0.45);
  --hud-selected: rgba(77, 190, 255, 0.45);
  --text-main: #f0f8ff;
  --text-subtle: #d8e9f8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  color: var(--text-main);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #d6efff 0%, #9fc5db 50%, #7fa7be 100%);
}

canvas {
  display: block;
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(5, 20, 31, 0.52), rgba(24, 41, 54, 0.52));
  backdrop-filter: blur(2px);
  cursor: pointer;
}

#overlay.hidden {
  display: none;
}

.panel {
  width: min(92vw, 700px);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid rgba(223, 241, 255, 0.35);
  background: rgba(8, 19, 27, 0.58);
  box-shadow: 0 14px 44px rgba(3, 10, 17, 0.35);
  text-align: center;
}

.panel h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0.04em;
}

.panel p {
  margin: 6px 0;
  font-size: clamp(16px, 2.1vw, 20px);
}

.hint {
  color: var(--text-subtle);
  font-size: clamp(13px, 1.7vw, 15px);
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  line-height: 1;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
}

#crosshair-left,
#crosshair-right {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  line-height: 1;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
  display: none;
}

#crosshair-left {
  left: 25%;
}

#crosshair-right {
  left: 75%;
}

body.split-screen #crosshair {
  display: none;
}

body.split-screen #crosshair-left,
body.split-screen #crosshair-right {
  display: block;
}

#objective {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(231, 244, 255, 0.38);
  background: rgba(10, 26, 36, 0.52);
  text-align: center;
  font-size: clamp(13px, 1.8vw, 16px);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
}

#event-message {
  position: absolute;
  left: 50%;
  top: 58px;
  transform: translateX(-50%);
  min-height: 24px;
  text-align: center;
  font-size: clamp(12px, 1.7vw, 15px);
  color: #fff3b4;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.85);
}

#boss-health-bar,
#luc-health-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  width: min(68vw, 420px);
  padding: 7px 10px;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
}

#boss-health-bar {
  top: 90px;
  border: 1px solid rgba(255, 163, 163, 0.45);
  background: rgba(28, 7, 11, 0.72);
}

#luc-health-bar {
  top: 136px;
  border: 1px solid rgba(134, 188, 255, 0.45);
  background: rgba(10, 18, 36, 0.72);
}

#boss-health-bar.active,
#luc-health-bar.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#boss-health-name,
#boss-health-value,
#luc-health-name,
#luc-health-value {
  text-align: center;
  font-size: 12px;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.85);
}

#boss-health-name {
  font-weight: 700;
  color: #ffd3d3;
  margin-bottom: 4px;
}

#luc-health-name {
  font-weight: 700;
  color: #d7ebff;
  margin-bottom: 4px;
}

#boss-health-track,
#luc-health-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
}

#boss-health-track {
  border: 1px solid rgba(255, 196, 196, 0.35);
  background: rgba(19, 4, 7, 0.7);
}

#luc-health-track {
  border: 1px solid rgba(177, 215, 255, 0.35);
  background: rgba(8, 12, 30, 0.7);
}

#boss-health-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff3d3d 0%, #ff8b4a 100%);
  box-shadow: 0 0 12px rgba(255, 74, 74, 0.5);
  transition: width 140ms ease;
}

#luc-health-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3f8dff 0%, #69ccff 100%);
  box-shadow: 0 0 12px rgba(94, 169, 255, 0.5);
  transition: width 140ms ease;
}

#boss-health-value {
  margin-top: 4px;
  color: #ffe5cf;
}

#luc-health-value {
  margin-top: 4px;
  color: #d8eeff;
}

body.split-screen #boss-health-bar,
body.split-screen #luc-health-bar {
  width: min(76vw, 500px);
}

body.boss-bars-compact #boss-health-bar,
body.boss-bars-compact #luc-health-bar {
  width: min(58vw, 350px);
  padding: 5px 8px;
  border-radius: 8px;
}

body.boss-bars-compact #boss-health-bar {
  top: 84px;
}

body.boss-bars-compact #luc-health-bar {
  top: 116px;
}

body.boss-bars-compact #boss-health-name,
body.boss-bars-compact #boss-health-value,
body.boss-bars-compact #luc-health-name,
body.boss-bars-compact #luc-health-value {
  font-size: 11px;
}

body.boss-bars-compact #boss-health-track,
body.boss-bars-compact #luc-health-track {
  height: 8px;
}

body.split-screen.boss-bars-compact #boss-health-bar,
body.split-screen.boss-bars-compact #luc-health-bar {
  width: min(70vw, 420px);
}

#hotbar,
#hotbar-p2 {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  gap: 0;
  max-width: min(92vw, 240px);
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}

#hotbar-p2 {
  display: none;
}

body.split-screen #hotbar {
  left: 25%;
}

body.split-screen #hotbar-p2 {
  display: flex;
  left: 75%;
}

#inventory-panel,
#inventory-panel-p2 {
  position: absolute;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%) translateY(8px);
  width: min(94vw, 980px);
  max-height: min(62vh, 560px);
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(231, 244, 255, 0.38);
  background: rgba(10, 24, 34, 0.78);
  box-shadow: 0 14px 40px rgba(2, 9, 15, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

#inventory-panel-p2 {
  display: none;
}

#inventory-panel.open,
#inventory-panel-p2.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

body.split-screen #inventory-panel,
body.split-screen #inventory-panel-p2 {
  width: min(44vw, 520px);
  max-height: min(62vh, 560px);
}

body.split-screen #inventory-panel {
  left: 25%;
}

body.split-screen #inventory-panel-p2 {
  display: block;
  left: 75%;
}

#inventory-title,
#inventory-title-p2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 8px;
}

#inventory-tabs,
#inventory-tabs-p2 {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.inventory-tab {
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid rgba(198, 223, 243, 0.45);
  background: rgba(20, 33, 44, 0.65);
  font-size: 12px;
  color: var(--text-subtle);
}

.inventory-tab.active {
  border-color: rgba(255, 228, 127, 0.95);
  color: #fff3c4;
  box-shadow: 0 0 0 1px rgba(255, 228, 127, 0.22) inset;
}

#inventory-grid,
#inventory-grid-p2 {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  max-height: min(45vh, 380px);
  overflow-y: auto;
  padding-right: 2px;
}

.inventory-cell {
  min-height: 66px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(210, 231, 245, 0.42);
  background: rgba(22, 31, 38, 0.62);
  display: grid;
  align-content: start;
  gap: 2px;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
}

.inventory-cell.focused {
  border-color: rgba(255, 231, 131, 0.95);
  box-shadow: 0 0 0 2px rgba(255, 223, 109, 0.24) inset;
}

.inventory-cell.selected {
  border-color: rgba(130, 224, 255, 0.95);
  background: rgba(77, 190, 255, 0.24);
}

.inventory-cell-name {
  font-size: 12px;
  font-weight: 700;
}

.inventory-cell-count {
  font-size: 12px;
  opacity: 0.94;
}

#inventory-help,
#inventory-help-p2 {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-subtle);
}

.slot {
  display: none;
  min-width: 112px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg);
  gap: 2px;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
}

.slot.selected {
  display: grid;
  border-color: rgba(130, 224, 255, 0.9);
  background: var(--hud-selected);
  box-shadow: 0 0 0 2px rgba(121, 205, 255, 0.22) inset;
}

.slot-key {
  font-size: 12px;
  opacity: 0.86;
}

.slot-name {
  font-size: 14px;
  font-weight: 700;
}

.slot-count {
  font-size: 14px;
}

@media (max-width: 640px) {
  #hotbar,
  #hotbar-p2 {
    bottom: 12px;
    max-width: min(92vw, 220px);
  }

  #inventory-panel,
  #inventory-panel-p2 {
    bottom: 72px;
    padding: 10px;
  }

  #inventory-grid,
  #inventory-grid-p2 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  body.split-screen #inventory-panel,
  body.split-screen #inventory-panel-p2 {
    width: min(47vw, 420px);
  }

  .inventory-cell {
    min-height: 58px;
    padding: 5px 6px;
  }

  .slot {
    min-width: 100px;
    padding: 8px 10px;
  }

  .slot-name {
    font-size: 13px;
  }

  #boss-health-bar,
  #luc-health-bar {
    width: min(88vw, 360px);
  }

  #boss-health-bar {
    top: 96px;
  }

  #luc-health-bar {
    top: 142px;
  }

  body.boss-bars-compact #boss-health-bar,
  body.boss-bars-compact #luc-health-bar {
    width: min(84vw, 320px);
  }

  body.boss-bars-compact #boss-health-bar {
    top: 92px;
  }

  body.boss-bars-compact #luc-health-bar {
    top: 120px;
  }
}
