:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151a20;
  --panel-2: #1c2229;
  --line: #303944;
  --text: #f4e7cc;
  --muted: #a9b0b8;
  --gold: #d9a441;
  --red: #9f2c24;
  --green: #4c8b5a;
  --blue: #3aa7c8;
  --violet: #8059bc;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0c1016;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.game-hidden,
.app-shell.game-hidden {
  display: none;
}

.referral-shell {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(217, 164, 65, 0.12), transparent 130px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 96px 100%,
    linear-gradient(180deg, rgba(9, 12, 16, 0.15), rgba(9, 12, 16, 0.96)),
    #10161d;
  color: var(--text);
  overflow: hidden;
}

.ref-hero {
  min-height: 500px;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 24px;
  align-items: end;
  padding: 30px clamp(22px, 5vw, 72px) 30px;
  position: relative;
}

.ref-hero::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 150px;
  background: #080b0f;
  border-top: 5px solid #bd832f;
  opacity: 0.82;
}

.ref-hero::after {
  content: "";
  position: absolute;
  inset: 20px clamp(18px, 4vw, 54px) auto;
  height: 5px;
  background: linear-gradient(90deg, transparent, #724719, #d9a441, #724719, transparent);
  opacity: 0.75;
}

.ref-copy,
.ref-showcase {
  position: relative;
  z-index: 1;
}

.ref-copy {
  display: grid;
  gap: 12px;
  align-self: center;
}

.ref-copy .brand {
  width: fit-content;
  padding: 10px 14px 10px 10px;
  background: rgba(8, 11, 15, 0.62);
  border: 1px solid #3b4651;
  border-radius: 8px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22);
}

.ref-copy h2 {
  margin: 0;
  max-width: 500px;
  font-size: clamp(30px, 3.5vw, 50px);
  line-height: 1.02;
  text-transform: uppercase;
  text-shadow: 0 5px 0 #4f1712, 0 0 28px rgba(217, 164, 65, 0.22);
}

.ref-lead {
  max-width: 620px;
  margin: 0;
  color: #c5ccd3;
  font-size: 16px;
  line-height: 1.5;
}

.ref-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ref-showcase {
  min-height: 320px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 10px;
  padding-bottom: 16px;
}

.ref-showcase img {
  width: min(22vw, 200px);
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 20px 22px rgba(0, 0, 0, 0.45));
}

.ref-showcase img:nth-child(2) {
  width: min(25vw, 245px);
  margin-bottom: 10px;
}

.ref-dashboard {
  display: grid;
  grid-template-columns: minmax(320px, 1.25fr) minmax(260px, 0.75fr);
  gap: 18px;
  padding: 0 clamp(22px, 5vw, 72px) 46px;
  position: relative;
  z-index: 1;
}

.ref-dashboard.locked {
  filter: saturate(0.65);
}

.ref-dashboard.locked .referral-link-card,
.ref-dashboard.locked .ref-score-card,
.ref-dashboard.locked .rules-card,
.ref-dashboard.locked .ref-leaderboard-card {
  opacity: 0.78;
}

.ref-card {
  background:
    linear-gradient(180deg, rgba(217, 164, 65, 0.05), transparent 48%),
    rgba(21, 26, 32, 0.94);
  border: 1px solid #3a4654;
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.referral-link-card,
.ref-leaderboard-card {
  grid-column: 1 / -1;
}

.ref-card h3 {
  margin: 4px 0 12px;
  font-size: 24px;
}

.ref-card p {
  color: var(--muted);
  line-height: 1.55;
}

.copy-row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
}

.copy-row input {
  min-width: 0;
  height: 44px;
  border: 1px solid #34404b;
  border-radius: 6px;
  background: #0c1117;
  color: var(--text);
  padding: 0 12px;
  font: inherit;
}

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

.score-grid div {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 12px;
  background: #0e1319;
  border: 1px solid #303944;
  border-radius: 6px;
}

.score-grid strong {
  font-size: 26px;
}

.score-grid span,
.rules-card li {
  color: var(--muted);
}

.rules-card ul {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.8;
}

.rules-card a {
  color: #ffd78a;
  text-decoration: none;
  font-weight: 800;
}

.rules-card a:hover {
  color: #ffffff;
}

.ref-leaderboard {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.ref-leader-row {
  display: grid;
  grid-template-columns: 64px 1fr 110px 110px 110px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  background: #10161d;
  border: 1px solid #303944;
  border-radius: 8px;
}

.ref-leader-row.top {
  border-color: var(--gold);
  background: #1b1710;
}

.ref-leader-row.self {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #121820, #0c1015);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: #20100f;
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 0 4px #6c211c;
  font-weight: 900;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-head h3,
.selected-copy h3,
.upgrade-hero h3,
.mission-console h3 {
  margin: 0;
}

.brand h1 {
  font-size: 21px;
  line-height: 1;
}

.brand p,
.eyebrow,
.label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-item,
.primary-button,
.secondary-button,
.filter {
  min-height: 42px;
  border-radius: 6px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.nav-item {
  text-align: left;
  padding: 0 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}

.nav-item:hover,
.nav-item.active {
  background: #202832;
  border-color: #3a4654;
  color: var(--text);
}

.wallet-card {
  margin-top: auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
}

.primary-button {
  padding: 0 16px;
  background: linear-gradient(180deg, #dfb04a, #9b5f1f);
  color: #160f07;
  font-weight: 800;
}

.secondary-button {
  padding: 0 16px;
  background: #212832;
  border: 1px solid #3a4654;
  color: var(--text);
}

.primary-button:hover,
.secondary-button:hover,
.filter:hover {
  transform: translateY(-1px);
}

.main {
  min-width: 0;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 76px 100%,
    radial-gradient(circle at 70% 12%, rgba(133, 45, 38, 0.22), transparent 36%),
    #0d1117;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h2 {
  font-size: 34px;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(112px, 1fr));
  border: 1px solid var(--line);
  background: rgba(21, 26, 32, 0.9);
  border-radius: 8px;
  overflow: hidden;
}

.stats-strip div {
  padding: 12px 16px;
  display: grid;
  gap: 4px;
  border-left: 1px solid var(--line);
}

.stats-strip div:first-child {
  border-left: 0;
}

.stats-strip span {
  color: var(--muted);
  font-size: 12px;
}

.stats-strip strong {
  font-size: 20px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 22px;
}

.hero-stage,
.mission-layout,
.upgrade-board {
  display: grid;
  grid-template-columns: minmax(360px, 1.2fr) minmax(260px, 0.8fr);
  gap: 18px;
}

.selected-hero,
.equipped,
.party-panel,
.mission-console,
.upgrade-hero,
.upgrade-actions,
.activity-log,
.empty-state {
  background: rgba(21, 26, 32, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.selected-hero {
  min-height: 310px;
  display: grid;
  grid-template-columns: minmax(220px, 330px) 1fr;
  align-items: center;
  gap: 22px;
  padding: 18px;
}

.selected-hero img,
.upgrade-hero img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  image-rendering: pixelated;
}

.selected-copy {
  display: grid;
  gap: 12px;
}

.selected-copy h3 {
  font-size: 30px;
}

.class-badge {
  width: fit-content;
  padding: 7px 10px;
  border: 1px solid #59452a;
  border-radius: 6px;
  background: #251914;
  color: #ffd78a;
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

.hero-bars {
  display: grid;
  gap: 10px;
}

.hero-bars div {
  display: grid;
  gap: 6px;
}

meter {
  width: 100%;
  max-width: 100%;
  height: 12px;
}

.hero-bars meter {
  display: block;
}

.equipped {
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.slot-row,
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
}

.slot,
.item-card,
.hero-card,
.mission-card,
.leader-row {
  background: #151b22;
  border: 1px solid #303944;
  border-radius: 8px;
}

.slot {
  min-height: 86px;
  padding: 10px;
  display: grid;
  align-content: center;
  gap: 5px;
}

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

.section-head h3 {
  font-size: 22px;
}

.segmented {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter {
  min-height: 34px;
  padding: 0 12px;
  background: #151b22;
  border: 1px solid var(--line);
  color: var(--muted);
}

.filter.active {
  border-color: var(--gold);
  color: var(--text);
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.hero-card {
  overflow: hidden;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.hero-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(217, 164, 65, 0.24);
}

.hero-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #0c1015;
  border-radius: 6px;
  image-rendering: pixelated;
}

.hero-card footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.rarity {
  color: var(--gold);
  font-weight: 800;
}

.mission-layout {
  grid-template-columns: 1fr 360px;
}

.party-panel {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.party-panel h3 {
  margin: 4px 0 0;
}

.party-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.party-selector {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
}

.party-chip {
  min-height: 64px;
  padding: 8px;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  align-items: center;
  background: #11171e;
  border: 1px solid #303944;
  border-radius: 8px;
  text-align: left;
}

.party-chip.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(217, 164, 65, 0.25);
}

.party-chip img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
}

.party-chip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.mission-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.mission-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.mission-card.locked {
  border-color: #4b3434;
  background: #171416;
}

.mission-card h3 {
  margin: 0;
  font-size: 20px;
}

.mission-card p {
  margin: 0;
  color: var(--muted);
}

.mission-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.drop-table {
  display: grid;
  gap: 6px;
  padding: 10px;
  background: #0e1319;
  border: 1px solid #2b333d;
  border-radius: 6px;
}

.drop-table span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.drop-table strong {
  color: var(--text);
  font-weight: 700;
}

.mission-meta span {
  padding: 8px;
  background: #0e1319;
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.mission-console {
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
}

.inventory-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.item-card {
  padding: 14px;
  min-height: 178px;
  display: grid;
  align-content: start;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.item-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(217, 164, 65, 0.08), transparent 45%, rgba(58, 167, 200, 0.08));
  pointer-events: none;
}

.item-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  background: #0e1319;
  border: 1px solid #3a4654;
  border-radius: 6px;
  color: var(--gold);
  font-weight: 900;
  image-rendering: pixelated;
  position: relative;
  z-index: 1;
}

.item-icon svg {
  width: 58px;
  height: 58px;
  shape-rendering: crispEdges;
}

.item-card strong,
.item-card span,
.item-card small,
.item-card button {
  position: relative;
  z-index: 1;
}

.item-card[data-rarity="Rare"] {
  border-color: #3a7ca5;
}

.item-card[data-rarity="Epic"] {
  border-color: #7b55b3;
}

.item-card[data-rarity="Legendary"] {
  border-color: #d9a441;
  box-shadow: 0 0 0 1px rgba(217, 164, 65, 0.28), var(--shadow);
}

.item-rarity {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 5px;
  background: #0e1319;
  border: 1px solid #303944;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.inventory-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.upgrade-board {
  grid-template-columns: 300px 1fr;
}

.upgrade-hero,
.upgrade-actions,
.activity-log {
  padding: 18px;
}

.upgrade-actions {
  display: grid;
  gap: 12px;
  align-content: start;
}

.activity-log {
  grid-column: 1 / -1;
  min-height: 180px;
  color: var(--muted);
}

.leaderboard {
  display: grid;
  gap: 10px;
}

.leader-row {
  display: grid;
  grid-template-columns: 54px 1fr 120px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
}

@media (max-width: 980px) {
  .ref-hero,
  .ref-dashboard {
    grid-template-columns: 1fr;
  }

  .ref-hero {
    min-height: auto;
    padding-top: 34px;
  }

  .ref-copy h2 {
    font-size: 42px;
  }

  .ref-showcase {
    min-height: 240px;
  }

  .ref-showcase img,
  .ref-showcase img:nth-child(2) {
    width: min(32vw, 190px);
  }

  .score-grid,
  .ref-leader-row {
    grid-template-columns: 1fr 1fr;
  }

  .copy-row {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-stage,
  .mission-layout,
  .upgrade-board,
  .selected-hero {
    grid-template-columns: 1fr;
  }

  .stats-strip {
    grid-template-columns: 1fr;
  }
}
