:root {
  color-scheme: dark;
  --ink: #f4f0df;
  --muted: #aca68f;
  --panel: #171916;
  --panel-2: #20231e;
  --line: #383d32;
  --gold: #e7b84f;
  --blood: #d6504d;
  --leaf: #56a870;
  --aqua: #58b4b8;
  --void: #0f100e;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(99, 126, 83, 0.18), transparent 32rem),
    linear-gradient(135deg, #10120f 0%, #191a16 52%, #121512 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  height: 100%;
  min-height: 0;
}

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid rgba(244, 240, 223, 0.1);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #10120f;
}

.hud-top {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.hud-top > div {
  min-width: 92px;
  padding: 10px 12px;
  border: 1px solid rgba(244, 240, 223, 0.13);
  border-radius: 8px;
  background: rgba(18, 20, 17, 0.78);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(12px);
}

.label,
.eyebrow,
.stat-grid span,
.equipment-slot span,
.bag-slot span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hud-top strong {
  display: block;
  margin-top: 3px;
  font-size: 0.95rem;
}

.dpad {
  position: absolute;
  right: 22px;
  bottom: 22px;
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  gap: 8px;
  touch-action: none;
}

.camp-menu {
  position: absolute;
  top: 96px;
  right: 22px;
  z-index: 6;
  display: none;
  width: min(440px, calc(100% - 44px));
  max-height: min(620px, calc(100% - 138px));
  padding: 14px;
  border: 1px solid rgba(244, 240, 223, 0.16);
  border-radius: 8px;
  background: rgba(20, 22, 19, 0.94);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(14px);
}

.camp-menu.is-open {
  display: flex;
  flex-direction: column;
}

.camp-menu .camp-panel {
  flex: 1 1 auto;
  height: auto;
  min-height: 180px;
}

.camp-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.camp-menu-head h2 {
  margin-top: 2px;
  font-size: 1.15rem;
}

.icon-button {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(244, 240, 223, 0.14);
  border-radius: 8px;
  background: #272b23;
  cursor: pointer;
}

.icon-button::before,
.icon-button::after {
  position: absolute;
  top: 15px;
  left: 9px;
  width: 14px;
  height: 2px;
  content: "";
  border-radius: 999px;
  background: var(--ink);
}

.icon-button::before {
  transform: rotate(45deg);
}

.icon-button::after {
  transform: rotate(-45deg);
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.dir {
  position: relative;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(244, 240, 223, 0.16);
  border-radius: 8px;
  background: rgba(22, 24, 20, 0.82);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.dir::before {
  position: absolute;
  inset: 19px 17px 17px 17px;
  content: "";
  border-top: 3px solid var(--ink);
  border-left: 3px solid var(--ink);
}

.dir:hover,
.dir:focus-visible {
  border-color: rgba(231, 184, 79, 0.75);
  outline: none;
}

.dir:active {
  transform: translateY(1px);
}

.up {
  grid-column: 2;
  grid-row: 1;
}

.up::before {
  transform: rotate(45deg);
}

.left {
  grid-column: 1;
  grid-row: 2;
}

.left::before {
  transform: rotate(-45deg);
}

.right {
  grid-column: 3;
  grid-row: 2;
}

.right::before {
  transform: rotate(135deg);
}

.down {
  grid-column: 2;
  grid-row: 3;
}

.down::before {
  transform: rotate(225deg);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: 0;
  padding: 22px;
  background: rgba(20, 22, 19, 0.98);
}

.side-panel header {
  flex: 0 0 auto;
}

.character-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
}

.character-chip span {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(244, 240, 223, 0.7);
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.24);
}

.character-chip strong {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.75rem;
  line-height: 1;
}

h2 {
  font-size: 0.95rem;
}

.panel-section {
  flex: 0 0 auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.vitals {
  display: grid;
  gap: 13px;
}

.meter-row {
  display: grid;
  grid-template-columns: 28px 1fr 58px;
  gap: 9px;
  align-items: center;
  font-size: 0.85rem;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #3c2725;
}

.meter div {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blood), #f08d5d);
  transition: width 160ms ease;
}

.meter.xp {
  background: #24343b;
}

.meter.xp div {
  background: linear-gradient(90deg, var(--aqua), #9ee2c1);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.stat-grid div {
  min-width: 0;
  padding: 9px 8px;
  border-radius: 8px;
  background: var(--panel-2);
}

.stat-grid strong {
  display: block;
  margin-top: 3px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.small-button {
  display: inline-grid;
  place-items: center;
  min-width: 62px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(244, 240, 223, 0.14);
  border-radius: 8px;
  background: #272b23;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.sort-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.sort-select {
  min-width: 86px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(244, 240, 223, 0.14);
  border-radius: 8px;
  background: #272b23;
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}

.sort-select:hover,
.sort-select:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.small-button:hover,
.small-button:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.danger {
  color: #ffb0a4;
}

.equipment-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.equipment-slot,
.bag-slot {
  position: relative;
  border: 1px solid rgba(244, 240, 223, 0.11);
  border-radius: 8px;
  background: var(--panel-2);
}

.equipment-slot {
  display: grid;
  grid-template-rows: 16px 1fr;
  min-height: 72px;
  padding: 8px;
  cursor: grab;
}

.equipment-slot.is-empty {
  border-style: dashed;
  color: var(--muted);
}

.equipment-slot.is-occupied {
  border-color: rgba(231, 184, 79, 0.38);
}

.equipment-slot.is-blocked {
  border-style: dashed;
  background: #1a1d19;
}

.equipment-slot.drag-over,
.bag-slot.drag-over {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(231, 184, 79, 0.5);
}

.inventory-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  max-height: 100%;
  overflow: auto;
  padding-right: 3px;
}

.bag-slot {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  padding: 5px;
  cursor: pointer;
}

.bag-slot:hover,
.bag-slot:focus-visible,
.equipment-slot:hover,
.equipment-slot:focus-visible {
  border-color: rgba(231, 184, 79, 0.8);
  outline: none;
}

.bag-slot.is-empty {
  border-style: dashed;
  cursor: default;
}

.item-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.14);
  color: #d9d4c4;
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
}

.item-icon i,
.item-icon i::before,
.item-icon i::after {
  position: absolute;
  display: block;
  content: "";
}

.item-icon i {
  inset: 0;
  margin: auto;
}

.type-oneHand i {
  width: 6px;
  height: 29px;
  border-radius: 6px 6px 2px 2px;
  background: currentColor;
  transform: rotate(42deg);
}

.type-oneHand i::before {
  left: -7px;
  bottom: 5px;
  width: 20px;
  height: 4px;
  border-radius: 999px;
  background: #8b6c3f;
}

.type-twoHand i {
  width: 8px;
  height: 36px;
  border-radius: 7px 7px 2px 2px;
  background: currentColor;
  transform: rotate(42deg);
}

.type-twoHand i::before {
  left: -8px;
  bottom: 7px;
  width: 24px;
  height: 4px;
  border-radius: 999px;
  background: #8b6c3f;
}

.type-twoHand i::after {
  left: 2px;
  bottom: -8px;
  width: 4px;
  height: 13px;
  border-radius: 999px;
  background: #6f5130;
}

.type-ranged i {
  width: 28px;
  height: 31px;
  border-left: 4px solid currentColor;
  border-radius: 50%;
  transform: rotate(-12deg);
}

.type-ranged i::before {
  left: 9px;
  top: 2px;
  width: 2px;
  height: 28px;
  background: rgba(244, 240, 223, 0.7);
  transform: rotate(12deg);
}

.type-ranged i::after {
  left: 12px;
  top: 13px;
  width: 17px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
}

.type-shield i {
  width: 28px;
  height: 33px;
  background: currentColor;
  clip-path: polygon(50% 0, 88% 13%, 80% 70%, 50% 100%, 20% 70%, 12% 13%);
}

.type-shield i::before {
  left: 12px;
  top: 5px;
  width: 3px;
  height: 23px;
  background: rgba(15, 16, 14, 0.35);
}

.type-head i {
  width: 30px;
  height: 23px;
  border-radius: 18px 18px 8px 8px;
  background: currentColor;
}

.type-head i::before {
  left: 5px;
  bottom: 5px;
  width: 20px;
  height: 5px;
  border-radius: 999px;
  background: rgba(15, 16, 14, 0.55);
}

.type-chest i {
  width: 31px;
  height: 33px;
  background: currentColor;
  clip-path: polygon(25% 0, 75% 0, 96% 30%, 80% 100%, 20% 100%, 4% 30%);
}

.type-chest i::before {
  left: 8px;
  top: 6px;
  width: 15px;
  height: 21px;
  border-left: 2px solid rgba(15, 16, 14, 0.35);
  border-right: 2px solid rgba(15, 16, 14, 0.35);
}

.type-legs i {
  width: 27px;
  height: 33px;
}

.type-legs i::before,
.type-legs i::after {
  top: 0;
  width: 10px;
  height: 33px;
  border-radius: 4px 4px 8px 8px;
  background: currentColor;
}

.type-legs i::before {
  left: 3px;
}

.type-legs i::after {
  right: 3px;
}

.type-boots i {
  width: 35px;
  height: 24px;
}

.type-boots i::before,
.type-boots i::after {
  bottom: 2px;
  width: 15px;
  height: 22px;
  border-radius: 5px 5px 9px 3px;
  background: currentColor;
}

.type-boots i::before {
  left: 1px;
  transform: skewX(-7deg);
}

.type-boots i::after {
  right: 1px;
  transform: scaleX(-1) skewX(-7deg);
}

.type-ring i {
  width: 29px;
  height: 29px;
  border: 5px solid currentColor;
  border-radius: 50%;
}

.type-ring i::before {
  left: 8px;
  top: -9px;
  width: 8px;
  height: 8px;
  background: currentColor;
  transform: rotate(45deg);
}

.type-charm i {
  width: 27px;
  height: 27px;
  background: currentColor;
  transform: rotate(45deg);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.type-charm i::before {
  left: 9px;
  top: 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(15, 16, 14, 0.45);
}

.type-consumable i {
  width: 20px;
  height: 31px;
  border: 3px solid currentColor;
  border-radius: 5px 5px 9px 9px;
}

.type-consumable i::before {
  left: 3px;
  top: -8px;
  width: 8px;
  height: 6px;
  border-radius: 2px 2px 0 0;
  background: currentColor;
}

.type-consumable i::after {
  left: 5px;
  top: 10px;
  width: 10px;
  height: 10px;
  background:
    linear-gradient(currentColor, currentColor) center / 10px 3px no-repeat,
    linear-gradient(currentColor, currentColor) center / 3px 10px no-repeat;
}

.item-level {
  position: absolute;
  right: 4px;
  bottom: 3px;
  min-width: 18px;
  height: 18px;
  padding: 2px 4px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  color: var(--ink);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
}

.item-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-stats {
  color: var(--muted);
  font-size: 0.78rem;
}

.rarity-common {
  color: #d9d4c4;
}

.rarity-sturdy {
  color: #73c68b;
}

.rarity-keen {
  color: #76c7e8;
}

.rarity-relic {
  color: #d994ff;
}

.inventory-section {
  flex: 1 1 auto;
  min-height: 210px;
  overflow: hidden;
}

.empty-state {
  padding: 13px 10px;
  border: 1px dashed rgba(244, 240, 223, 0.15);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.tooltip {
  position: fixed;
  z-index: 20;
  display: none;
  max-width: 260px;
  padding: 10px 11px;
  border: 1px solid rgba(244, 240, 223, 0.17);
  border-radius: 8px;
  background: rgba(15, 16, 14, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.4);
  color: var(--ink);
  pointer-events: none;
}

.tooltip.is-visible {
  display: block;
}

.tooltip-title {
  margin-bottom: 2px;
  font-weight: 900;
}

.tooltip-meta,
.tooltip-stats,
.tooltip-help {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.tooltip-help {
  margin-top: 6px;
  color: #d9d4c4;
}

.log-section {
  flex: 0 0 142px;
  min-height: 0;
}

.log-list {
  display: flex;
  flex-direction: column-reverse;
  gap: 7px;
  height: 82px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  color: var(--muted);
  font-size: 0.82rem;
}

.mini-status {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.camp-action {
  min-width: 0;
  height: 30px;
  padding: 0 7px;
  border: 1px solid rgba(244, 240, 223, 0.12);
  border-radius: 8px;
  background: #252921;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 800;
}

.camp-action:hover,
.camp-action:focus-visible {
  border-color: var(--gold);
  color: var(--ink);
  outline: none;
}

.camp-action:disabled {
  opacity: 0.45;
  cursor: default;
}

.camp-panel {
  height: calc(100% - 40px);
  min-height: 174px;
  overflow: auto;
  padding-right: 2px;
}

.compact-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}

.camp-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.camp-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 9px;
}

.camp-toolbar .sort-select {
  width: 100%;
}

.camp-card,
.skill-card,
.stat-card {
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(244, 240, 223, 0.11);
  border-radius: 8px;
  background: var(--panel-2);
}

.camp-card strong,
.skill-card strong,
.stat-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.camp-card span,
.skill-card span,
.stat-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
}

.skill-card em {
  color: #9ee2c1;
  font-style: normal;
}

.camp-card.is-locked,
.skill-card.is-locked {
  opacity: 0.48;
}

.shop-list,
.skill-list,
.stat-list,
.portal-list {
  display: grid;
  gap: 7px;
}

.skill-branches {
  display: grid;
  gap: 9px;
}

.branch-title {
  margin: 5px 0 6px;
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.resource-line {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.78rem;
}

.resource-line strong {
  color: var(--ink);
}

.log-list li {
  padding: 7px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.character-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(8, 9, 8, 0.72);
  backdrop-filter: blur(8px);
}

.character-overlay.is-open {
  display: grid;
}

.character-modal {
  width: min(520px, 100%);
  max-height: min(680px, calc(100vh - 36px));
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(244, 240, 223, 0.16);
  border-radius: 8px;
  background: rgba(20, 22, 19, 0.98);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
}

.character-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.character-card {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 50px;
  padding: 9px 10px;
  border: 1px solid rgba(244, 240, 223, 0.12);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
  text-align: left;
}

.character-card:hover,
.character-card:focus-visible,
.character-card.is-active {
  border-color: var(--gold);
  outline: none;
}

.character-card-swatch {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(244, 240, 223, 0.65);
  border-radius: 50%;
}

.character-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-card small {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.character-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px auto;
  gap: 8px;
}

.character-form input {
  min-width: 0;
  height: 34px;
  border: 1px solid rgba(244, 240, 223, 0.14);
  border-radius: 8px;
  background: #272b23;
  color: var(--ink);
  font: inherit;
}

.character-form input[type="text"],
.character-form input:not([type]) {
  padding: 0 10px;
}

.character-form input[type="color"] {
  padding: 4px;
}

.character-form input:hover,
.character-form input:focus-visible {
  border-color: var(--gold);
  outline: none;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .game-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 62vh) auto;
    height: auto;
    min-height: 100%;
  }

  .stage {
    border-right: 0;
    border-bottom: 1px solid rgba(244, 240, 223, 0.1);
  }

  .side-panel {
    height: auto;
  }

  .equipment-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .inventory-list {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .hud-top {
    right: 12px;
    left: 12px;
    gap: 7px;
  }

  .hud-top > div {
    min-width: 0;
    flex: 1;
    padding: 9px;
  }

  .dpad {
    right: 14px;
    bottom: 14px;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
  }

  .dir {
    width: 50px;
    height: 50px;
  }

  .camp-menu {
    top: 86px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(62vh - 110px);
  }
}

@media (max-width: 460px) {
  .side-panel {
    padding: 16px;
  }

  .stat-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  .inventory-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
