* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #10130f;
  color: #eef4e8;
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  user-select: none;
}

#game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  background: #1f3024;
  cursor: crosshair;
}

#hud {
  position: absolute;
  top: 16px;
  left: 16px;
  width: min(390px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid rgba(236, 214, 155, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(35, 42, 29, 0.92), rgba(8, 12, 9, 0.84)),
    radial-gradient(circle at 12% 0%, rgba(236, 214, 155, 0.12), transparent 42%);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
}

.hud-row {
  display: grid;
  grid-template-columns: 42px 1fr 82px;
  gap: 10px;
  align-items: center;
  min-height: 24px;
  font-size: 14px;
  text-shadow: 0 1px 2px #000;
}

.hud-row + .hud-row {
  margin-top: 8px;
}

.bar {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.4);
  background: #1f251f;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.55);
}

.bar-fill {
  width: 0%;
  height: 100%;
  transition: width 120ms linear;
}

.hp {
  background: linear-gradient(90deg, #a9272e, #f05a4f);
}

.xp {
  background: linear-gradient(90deg, #2e76c7, #72c9ff);
}

#stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
  color: #cfdbc8;
}

#stats span {
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(236, 214, 155, 0.08);
  background: rgba(255, 255, 255, 0.07);
}

#inventory {
  position: absolute;
  top: 152px;
  right: 16px;
  width: min(390px, calc(100vw - 32px));
  max-height: calc(100vh - 250px);
  overflow: auto;
  overflow-x: hidden;
  padding: 12px;
  border: 1px solid rgba(236, 214, 155, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(30, 36, 25, 0.95), rgba(7, 11, 8, 0.9)),
    radial-gradient(circle at 90% 0%, rgba(236, 214, 155, 0.1), transparent 42%);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
}

#npc-panel {
  position: absolute;
  top: 152px;
  right: 16px;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 230px);
  overflow: auto;
  padding: 12px;
  border: 1px solid rgba(236, 214, 155, 0.22);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(25, 30, 21, 0.94), rgba(9, 13, 10, 0.9));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(5px);
}

#npc-panel.hidden {
  display: none;
}

#npc-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

#npc-close,
.npc-action {
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: linear-gradient(180deg, #397044, #254f2d);
  color: #eef4e8;
  cursor: pointer;
}

.npc-action:disabled {
  cursor: default;
  opacity: 0.42;
}

.npc-list {
  display: grid;
  gap: 8px;
}

.npc-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(236, 214, 155, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.npc-row small {
  display: block;
  margin-top: 3px;
  color: #aebba8;
}

.npc-note {
  margin: 0 0 10px;
  color: #cfdbc8;
  font-size: 13px;
}

#inventory.hidden {
  display: none;
}

#inventory header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

#points-text {
  color: #cfdbc8;
  font-size: 12px;
}

#character-panel {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 10px;
}

#paperdoll {
  width: 116px;
  height: 132px;
  border: 1px solid rgba(236, 214, 155, 0.16);
  border-radius: 8px;
  background: radial-gradient(circle at 50% 42%, rgba(69, 98, 62, 0.9), rgba(18, 24, 18, 0.84));
}

#equipment-slots {
  display: grid;
  gap: 8px;
}

.equip-slot {
  display: grid;
  grid-template-columns: 1fr 52px;
  align-items: center;
  gap: 4px;
  min-height: 58px;
  padding: 8px;
  border: 1px solid rgba(236, 214, 155, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.035));
}

.equip-slot span {
  color: #aebba8;
  font-size: 12px;
}

.equip-slot strong {
  color: #eef4e8;
  font-size: 13px;
}

.equip-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  justify-self: end;
  border: 1px solid rgba(236, 214, 155, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: #aebba8;
  font-size: 10px;
  text-align: center;
}

#stat-panel {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border: 1px solid rgba(236, 214, 155, 0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  font-size: 13px;
}

.stat-row button {
  width: 28px;
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: linear-gradient(180deg, #397044, #254f2d);
  color: #eef4e8;
  cursor: pointer;
}

.stat-row button:disabled {
  cursor: default;
  opacity: 0.35;
}

#inventory h2 {
  margin: 0 0 8px;
  color: #cfdbc8;
  font-size: 13px;
  font-weight: 700;
}

#inventory-list {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.inventory-item {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 48px;
  padding: 6px;
  border: 1px solid rgba(236, 214, 155, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.032));
  cursor: pointer;
  transition: transform 90ms ease, filter 90ms ease, border-color 90ms ease;
}

.inventory-item:hover,
.equip-icon:hover,
.quick-slot:hover:not(.locked) {
  transform: translateY(-1px);
  filter: brightness(1.12);
}

.inventory-item.locked {
  opacity: 0.72;
}

.level-lock {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 3px;
  border-radius: 4px;
  background: rgba(70, 0, 0, 0.5);
  color: rgba(255, 82, 82, 0.82);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.rarity-normal {
  border-color: rgba(236, 214, 155, 0.14);
}

.rarity-rare {
  border-color: rgba(76, 154, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(76, 154, 255, 0.18);
}

.rarity-epic {
  border-color: rgba(177, 91, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(177, 91, 255, 0.2);
}

.rarity-legendary {
  border-color: rgba(245, 190, 70, 0.9);
  box-shadow: inset 0 0 0 1px rgba(245, 190, 70, 0.24), 0 0 14px rgba(245, 190, 70, 0.12);
}

.inventory-item span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #eef4e8;
}

.item-icon {
  position: relative;
  width: 28px;
  height: 28px;
}

.item-icon.consumable {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd2df, #d94b7a 58%, #7e1d3d);
}

.item-icon.weapon {
  transform: rotate(-35deg);
}

.item-icon.weapon::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 0;
  width: 5px;
  height: 24px;
  border-radius: 3px 3px 1px 1px;
  background: var(--item-color, #d8dde0);
}

.item-icon.weapon::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 18px;
  width: 17px;
  height: 5px;
  border-radius: 2px;
  background: #5b3925;
}

.item-icon.armor {
  border-radius: 7px 7px 10px 10px;
  background: var(--item-color, #9a5f35);
  box-shadow: inset 7px 0 rgba(255, 255, 255, 0.16), inset -7px 0 rgba(0, 0, 0, 0.18);
}

.item-icon.armor::after {
  content: "";
  position: absolute;
  left: 5px;
  right: 5px;
  top: 13px;
  height: 4px;
  background: rgba(0, 0, 0, 0.25);
}

.item-icon.atlas-icon {
  background-repeat: no-repeat;
  background-color: transparent;
  background-size: cover;
  border-radius: 0;
  box-shadow: none;
}

.item-icon.atlas-icon::before,
.item-icon.atlas-icon::after {
  display: none;
}

.inventory-item small {
  position: absolute;
  right: 4px;
  bottom: 3px;
  color: #eef4e8;
  font-size: 11px;
  text-shadow: 0 1px 2px #000;
}

.inventory-item button {
  display: none;
}

.inventory-item button:hover {
  background: none;
}

.inventory-empty {
  grid-column: 1 / -1;
  color: #aebba8;
  font-size: 13px;
}

#item-tooltip {
  position: fixed;
  z-index: 50;
  width: 240px;
  padding: 10px;
  border: 1px solid rgba(236, 214, 155, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(22, 27, 20, 0.98), rgba(7, 10, 8, 0.98)),
    radial-gradient(circle at 12% 0%, rgba(236, 214, 155, 0.16), transparent 45%);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.52);
  color: #eef4e8;
  font-size: 13px;
  pointer-events: none;
}

#item-tooltip.hidden {
  display: none;
}

#item-tooltip strong {
  display: block;
  margin-bottom: 4px;
}

#item-tooltip small {
  display: block;
  color: #aebba8;
  line-height: 1.35;
}

#help {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(620px, calc(100vw - 32px));
  color: #d9e4d2;
  font-size: 13px;
}

#help span {
  padding: 7px 9px;
  border: 1px solid rgba(236, 214, 155, 0.16);
  border-radius: 8px;
  background: rgba(12, 16, 13, 0.76);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
}

#quickbar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  display: grid;
  grid-template-columns: repeat(5, 74px);
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: auto;
}

.quick-slot {
  position: relative;
  height: 58px;
  padding: 7px 5px 5px;
  border: 1px solid rgba(236, 214, 155, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(32, 38, 28, 0.94), rgba(8, 12, 9, 0.9)),
    radial-gradient(circle at 50% 0%, rgba(236, 214, 155, 0.12), transparent 55%);
  color: #eef4e8;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 90ms ease, filter 90ms ease;
}

.quick-slot kbd {
  position: absolute;
  top: 4px;
  left: 5px;
  min-width: 17px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  font: 700 11px Arial;
}

.quick-slot span {
  display: grid;
  place-items: center;
  height: 100%;
  padding-top: 8px;
}

.quick-slot.locked {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 640px) {
  #hud {
    top: 10px;
    left: 10px;
    width: calc(100vw - 20px);
  }

  #inventory {
    top: 146px;
    right: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 250px);
  }

  #npc-panel {
    top: 146px;
    right: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 250px);
  }

  #help {
    right: 10px;
    bottom: 10px;
    justify-content: flex-start;
  }

  #quickbar {
    bottom: 80px;
    grid-template-columns: repeat(5, minmax(48px, 1fr));
    width: calc(100vw - 20px);
  }
}
