:root {
  --bg: rgba(18, 22, 30, .84);
  --panel: rgba(28, 33, 45, .9);
  --slot: #2b2f3a;
  --slot-b: #0f1219;
  --txt: #ecf3ff;
  --muted: #9eacce;
}

* {
  box-sizing: border-box
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: Tahoma, Verdana, sans-serif;
  background: radial-gradient(circle at 25% 20%, #74c3ff 0%, #8fd9ff 52%, #d5f0ff 100%);
  color: var(--txt)
}

#game {
  position: fixed;
  inset: 0
}

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

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%)
}

#crosshair:before,
#crosshair:after {
  content: "";
  position: absolute;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .7)
}

#crosshair:before {
  left: 9px;
  top: 1px;
  width: 2px;
  height: 18px
}

#crosshair:after {
  left: 1px;
  top: 9px;
  width: 18px;
  height: 2px
}

#status {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px
}

.pill {
  background: var(--bg);
  border: 2px solid rgba(255, 255, 255, .13);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 13px;
  min-width: 220px
}

#hpRow {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 8px 12px;
  background: rgba(15, 17, 23, .45);
  border-radius: 10px;
  pointer-events: none
}

#hpBars {
  display: flex;
  gap: 4px
}

.heart {
  width: 26px;
  height: 26px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23ff4d4d"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>');
  background-size: contain;
  background-repeat: no-repeat
}

.heart.empty {
  opacity: 0.2;
  filter: grayscale(1)
}

#bottomUI {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  pointer-events: none
}

#hpWrapper {
  display: flex;
  justify-content: center
}

#hotbar {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: rgba(15, 17, 23, .62);
  border: 2px solid rgba(255, 255, 255, .15);
  border-radius: 10px;
  pointer-events: auto
}

.slot {
  width: 50px;
  height: 50px;
  background: var(--slot);
  border: 3px solid var(--slot-b);
  position: relative;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .12), inset 0 -2px 0 rgba(0, 0, 0, .35);
  image-rendering: pixelated
}

.slot.sel {
  border-color: #f5f7ff;
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(255, 255, 255, .35), 0 0 13px rgba(255, 255, 255, .45)
}

.ico {
  position: absolute;
  inset: 4px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  image-rendering: pixelated
}

.cnt {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 14px;
  font-weight: 700;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000
}

.num {
  position: absolute;
  left: 3px;
  top: 1px;
  font-size: 10px;
  color: rgba(255, 255, 255, .45)
}

#inv {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .48);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto
}

#inv.show {
  display: flex
}

#invw {
  width: min(840px, 96vw);
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 12px;
  background: var(--panel);
  border: 3px solid #0a0d15;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .65)
}

#grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(40px, 1fr));
  gap: 6px
}

#craft {
  border: 2px solid rgba(255, 255, 255, .16);
  border-radius: 8px;
  background: rgba(17, 20, 29, .8);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px
}

#recipe {
  font-size: 12px;
  line-height: 1.35;
  color: #eaf2ff;
  border: 2px solid rgba(255, 255, 255, .11);
  padding: 8px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .04)
}

#craftBtn,
#invClose {
  border: 2px solid #0d1118;
  border-radius: 7px;
  padding: 8px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto
}

#craftBtn {
  background: linear-gradient(180deg, #f8edbb 0%, #eecf69 100%);
  color: #171a23
}

#craftBtn:disabled {
  background: #7f8798;
  color: #676c78;
  cursor: not-allowed
}

#invClose {
  background: rgba(255, 255, 255, .1);
  color: #eff4ff
}

#settings {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto
}

#settings.show {
  display: flex
}

#settingsPanel {
  width: min(460px, 94vw);
  background: var(--panel);
  border: 3px solid #0a0d15;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .65);
  display: flex;
  flex-direction: column;
  gap: 12px
}

#settingsTitle {
  font-size: 16px;
  letter-spacing: .6px;
  text-transform: uppercase
}

#sensWrap {
  display: flex;
  flex-direction: column;
  gap: 7px
}

#sensRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px
}

#sensSlider {
  width: 100%;
  accent-color: #7fb6ff
}

#settingsBtns {
  display: flex;
  gap: 8px
}

#settingsClose {
  border: 2px solid #0d1118;
  border-radius: 7px;
  padding: 8px 10px;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255, 255, 255, .1);
  color: #eff4ff
}

#tooltip {
  position: fixed;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12px;
  z-index: 10000;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  display: none;
  max-width: 200px;
  line-height: 1.4;
}

#tooltip b {
  color: #6edc89;
  display: block;
  margin-bottom: 2px;
}

@media (max-width:900px) {
  #invw {
    grid-template-columns: 1fr;
    max-height: 90vh;
    overflow: auto
  }

  .slot {
    width: 44px;
    height: 44px
  }

  #hotbar {
    gap: 4px;
    padding: 7px
  }
}
