:root {
  --bg-top: #281e30;
  --bg-bottom: #100b14;
  --panel: #201b24;
  --panel-border: #4a454e;
  --panel-inner: #312b36;

  --accent: #e76f22;
  --accent-bright: #ffb759;

  --emerald: #36d17d;
  --text: #ffffff;
  --muted: #a8a4ac;
  --shadow: rgba(0, 0, 0, 0.6);

  --common: #c8c8c8;
  --rare: #2bd887;
  --unique: #f26f21;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top, rgba(100, 50, 150, 0.15), transparent 40%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  font-family: 'VT323', monospace;
  font-size: 1.2rem;
  letter-spacing: 0.02em;
}

/* Typography globals */
h1,
h2,
h3,
strong,
.label,
.eyebrow,
button,
.slot-label,
.inventory-count,
.overlay-eyebrow,
.metric-label,
.detail-power {
  font-family: 'Silkscreen', cursive;
  font-weight: normal;
}

h1,
h2,
h3 {
  margin: 0;
  text-transform: uppercase;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero {
  text-align: center;
  margin-bottom: 24px;
}

.eyebrow,
.overlay-eyebrow {
  margin: 0;
  text-transform: uppercase;
  color: var(--rare);
  font-size: 0.9rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  line-height: 1;
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.8);
  margin: 10px 0;
}

.subtitle {
  max-width: 760px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1.3rem;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.controls span,
.stat-card {
  background: var(--panel);
  border: 4px solid var(--panel-border);
  padding: 12px 16px;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.6);
  border-radius: 2px;
}

kbd {
  display: inline-block;
  min-width: 32px;
  text-align: center;
  padding: 4px 8px;
  margin-right: 4px;
  background: #3e3845;
  border: 2px solid #6b6375;
  color: var(--accent-bright);
  font-family: 'Silkscreen', cursive;
}

.game-panel {
  display: grid;
  gap: 18px;
}

.chapter-panel,
.hero-select {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.hero-select {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.chapter-button,
.hero-button {
  border: 4px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
  border-radius: 2px;
  padding: 12px 16px;
  font-size: 0.9rem;
  transition: transform 0.1s;
}

.hero-button {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hero-button span {
  font-family: 'VT323', monospace;
  color: var(--muted);
  font-size: 1.1rem;
}

.chapter-button:hover,
.hero-button:hover {
  transform: translate(-2px, -2px);
  border-color: #6d6775;
}

.chapter-button.active,
.hero-button.active {
  background: #3c3445;
  border-color: var(--rare);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
  transform: translate(2px, 2px);
}

.hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-card strong {
  font-size: 1.6rem;
  margin-top: 4px;
  color: var(--common);
}

.canvas-frame {
  position: relative;
  padding: 6px;
  background: #18141b;
  border: 4px solid var(--panel-border);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.7);
  border-radius: 2px;
}

canvas {
  width: 100%;
  display: block;
  image-rendering: pixelated;
  background: #110d14;
}

.overlay {
  position: absolute;
  inset: 6px;
  display: grid;
  place-items: center;
  background: rgba(10, 8, 12, 0.7);
  transition: opacity 220ms ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  width: min(440px, calc(100% - 32px));
  padding: 28px;
  background: var(--panel);
  border: 6px solid var(--panel-border);
  text-align: center;
  box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.8);
}

.overlay-card p {
  color: var(--muted);
  font-size: 1.2rem;
}

button {
  margin-top: 12px;
  padding: 12px 22px;
  border: 4px solid #1c1721;
  background: #393342;
  color: var(--text);
  font-family: 'Silkscreen', cursive;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
  transition: transform 0.1s;
}

button:hover {
  transform: translate(-2px, -2px);
  background: #474052;
}

button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.6);
}

.secondary-button {
  background: #25202b;
}

.loadout-panel {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 300px;
  gap: 14px;
}

.loadout-sidebar,
.inventory-section,
.detail-panel {
  background: var(--panel);
  border: 4px solid var(--panel-border);
  padding: 16px;
  box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.6);
}

.loadout-label,
.metric-label,
.inventory-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.loadout-hero-card h3,
.inventory-header h3,
.detail-panel h3 {
  margin: 8px 0 6px;
  font-size: 1.45rem;
  color: var(--common);
}

.loadout-copy,
.detail-description {
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.loadout-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.loadout-metrics div {
  background: var(--panel-inner);
  border: 4px solid var(--panel-border);
  padding: 10px;
  text-align: center;
}

.loadout-metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 1.4rem;
}

.equipped-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.equip-slot,
.inventory-item {
  margin-top: 0;
  border: 4px solid var(--panel-border);
  background: var(--panel-inner);
  color: var(--text);
  padding: 12px;
  box-shadow: inset 4px 4px 0 rgba(0, 0, 0, 0.3);
  text-align: left;
}

.slot-label,
.slot-type,
.item-rarity,
.item-power {
  display: block;
}

.slot-icon,
.item-icon {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  background: #110d14;
  border: 4px solid #4d4952;
  font-size: 1.5rem;
  color: var(--common);
}

.slot-label,
.item-name {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.slot-type,
.item-rarity,
.item-power {
  font-family: 'VT323', monospace;
  color: var(--muted);
  font-size: 1.1rem;
}

.inventory-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.inventory-item {
  min-height: 118px;
}

/* Rarity colors */
.rarity-common {
  color: #cccccc;
}

.rarity-rare {
  color: var(--rare);
}

.rarity-unique {
  color: var(--unique);
}

/* Selected and Equipped */
.inventory-item.selected,
.equip-slot.selected {
  border-color: #ffffff;
  background: #4b4552;
}

.inventory-item.equipped {
  background: #2a3530;
  border-color: var(--emerald);
}

.detail-panel {
  display: flex;
  flex-direction: column;
}

/* Base rarity badge style */
.detail-rarity {
  margin: 0 0 12px;
  display: inline-block;
  padding: 4px 8px;
  background: #393342;
  color: var(--common);
  border: 2px solid var(--panel-border);
  font-family: 'Silkscreen', cursive;
  font-size: 0.8rem;
  align-self: flex-start;
  text-transform: uppercase;
}

/* Badge colors matching exact rarity */
.detail-rarity.rarity-common {
  background: #5c5c5c;
  color: #fff;
  border-color: #333;
}

.detail-rarity.rarity-rare {
  background: var(--rare);
  color: #000;
  border-color: #0b5936;
}

.detail-rarity.rarity-unique {
  background: var(--unique);
  color: #fff;
  border-color: #632601;
}

.detail-power {
  margin: 12px 0;
  font-size: 1.8rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Power Icon (Rhombus shape) */
.detail-power::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  background: #a49da8;
  border: 3px solid #6d6775;
  transform: rotate(45deg);
}

.detail-stats {
  margin: 0 0 16px;
  padding-left: 18px;
  color: var(--text);
  min-height: 116px;
}

.detail-stats li {
  margin-bottom: 6px;
  position: relative;
  list-style-type: none;
}

/* Bullet diamond for stats */
.detail-stats li::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 6px;
  width: 6px;
  height: 6px;
  background: var(--muted);
  transform: rotate(45deg);
}

.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

@media (max-width: 900px) {
  .loadout-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .hero-select {
    grid-template-columns: 1fr;
  }

  .inventory-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}