:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #121712;
  color: #f5f1df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(101, 146, 92, 0.26), transparent 31%),
    linear-gradient(135deg, #101711 0%, #1a2420 50%, #18151f 100%);
}

button {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.stage {
  position: relative;
  width: min(100vw - 28px, 1280px);
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 28px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background: #17261d;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

.hud {
  position: absolute;
  z-index: 3;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: rgba(18, 24, 19, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
}

.top-left {
  left: 14px;
  top: 14px;
  width: min(360px, calc(100% - 28px));
}

.top-right {
  right: 14px;
  top: 14px;
}

.portrait {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: linear-gradient(145deg, #f0c66f, #9d6841);
  color: #1d160b;
  font-weight: 900;
  border: 2px solid #f6e4a3;
}

.bars {
  flex: 1;
  min-width: 0;
}

.name-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 14px;
}

.bar {
  height: 11px;
  margin-top: 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.38);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.bar span {
  display: block;
  height: 100%;
  width: 0%;
  transition: width 160ms ease;
}

.hp span {
  background: linear-gradient(90deg, #d5483f, #ff936c);
}

.exp span {
  background: linear-gradient(90deg, #3ca9f2, #7ee6ff);
}

.stat {
  min-width: 68px;
}

.stat span,
.quest-panel p {
  display: block;
  color: #c4d1bc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.stat strong {
  font-size: 18px;
}

#resetBtn,
.slot {
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff9df;
  background: rgba(79, 88, 63, 0.76);
  border-radius: 8px;
  min-height: 38px;
  cursor: pointer;
}

#resetBtn {
  padding: 0 14px;
}

.quest-panel {
  position: absolute;
  z-index: 3;
  left: 14px;
  top: 92px;
  width: 250px;
  padding: 11px;
  border-radius: 8px;
  background: rgba(32, 37, 27, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.quest-panel p {
  margin: 0 0 4px;
}

.quest-panel strong,
.quest-panel span {
  display: block;
}

.quest-panel span {
  margin-top: 4px;
  color: #eee6c8;
  font-size: 13px;
}

.shop-panel {
  position: absolute;
  z-index: 4;
  right: 14px;
  top: 92px;
  width: 310px;
  max-width: calc(100% - 28px);
  padding: 10px;
  border-radius: 8px;
  background: rgba(16, 20, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.32);
}

.shop-panel.collapsed .shop-list {
  display: none;
}

.shop-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.shop-head p {
  margin: 0 0 3px;
  color: #c4d1bc;
  font-size: 11px;
  text-transform: uppercase;
}

.shop-head strong {
  color: #fff6d5;
  font-size: 14px;
}

#shopToggle {
  width: 38px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(139, 101, 45, 0.78);
  color: #fff6d5;
  font-weight: 900;
  cursor: pointer;
}

.shop-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.shop-item {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 2px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(37, 45, 37, 0.82);
  color: #fff7df;
  cursor: pointer;
  text-align: left;
}

.shop-item:hover:not(:disabled),
.shop-item.equipped {
  border-color: rgba(255, 225, 138, 0.62);
  background: rgba(91, 70, 41, 0.9);
}

.shop-item:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.weapon-mark {
  grid-row: 1 / 3;
  width: 18px;
  height: 38px;
  border-radius: 999px;
  background: var(--weapon);
  box-shadow: 0 0 16px var(--weapon);
  transform: rotate(38deg);
}

.shop-item strong {
  font-size: 13px;
}

.shop-item small {
  color: #d8d1ba;
  font-size: 11px;
}

.shop-item em {
  grid-column: 3;
  grid-row: 1 / 3;
  min-width: 68px;
  padding: 6px 7px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.3);
  color: #ffe18a;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.log {
  position: absolute;
  left: 14px;
  bottom: 92px;
  z-index: 3;
  width: min(390px, calc(100% - 28px));
  max-height: 92px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  pointer-events: none;
}

.log p {
  margin: 0;
  padding: 6px 9px;
  border-radius: 7px;
  background: rgba(10, 13, 11, 0.68);
  color: #fff4cc;
  font-size: 13px;
}

.inventory {
  position: absolute;
  right: 14px;
  bottom: 92px;
  z-index: 3;
  display: flex;
  gap: 8px;
}

.item {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(23, 28, 23, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff6dc;
  font-size: 20px;
  position: relative;
}

.item small {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 11px;
  color: #fff;
}

.weapon-item {
  color: #ffe18a;
}

.action-bar {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.slot {
  width: 104px;
  padding: 7px 8px;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 6px;
  font-weight: 750;
}

.slot span {
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.38);
  color: #ffe18a;
}

.slot.active,
.slot:hover,
#resetBtn:hover {
  background: rgba(139, 101, 45, 0.88);
}

.hint {
  position: absolute;
  z-index: 3;
  right: 14px;
  bottom: 18px;
  max-width: 270px;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(9, 12, 10, 0.58);
  color: #e4dec7;
  font-size: 12px;
  text-align: right;
}

.mobile-pad {
  display: none;
}

@media (max-width: 760px) {
  .shell {
    padding: 0;
  }

  .stage {
    width: 100vw;
    height: 100vh;
    max-height: none;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
  }

  .top-right {
    top: 82px;
    left: 14px;
    right: auto;
  }

  .quest-panel,
  .hint {
    display: none;
  }

  .shop-panel {
    top: 144px;
    left: 14px;
    right: 14px;
    width: auto;
    max-height: 38vh;
    overflow: auto;
  }

  .shop-panel.collapsed {
    left: auto;
    width: 126px;
  }

  .action-bar {
    left: auto;
    right: 12px;
    bottom: 12px;
    transform: none;
    flex-direction: column;
  }

  .slot {
    width: 92px;
  }

  .inventory {
    right: 12px;
    bottom: 226px;
  }

  .log {
    bottom: 12px;
    left: 112px;
    width: calc(100% - 222px);
  }

  .mobile-pad {
    position: absolute;
    left: 12px;
    bottom: 14px;
    z-index: 4;
    width: 96px;
    height: 96px;
    display: grid;
    grid-template-columns: repeat(3, 32px);
    grid-template-rows: repeat(3, 32px);
  }

  .mobile-pad button {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(18, 23, 20, 0.72);
    color: #fff;
    border-radius: 8px;
  }

  .mobile-pad [data-dir="up"] {
    grid-column: 2;
  }

  .mobile-pad [data-dir="left"] {
    grid-column: 1;
    grid-row: 2;
  }

  .mobile-pad [data-dir="right"] {
    grid-column: 3;
    grid-row: 2;
  }

  .mobile-pad [data-dir="down"] {
    grid-column: 2;
    grid-row: 3;
  }
}
