:root {
  color-scheme: dark;
  --bg: #17191d;
  --panel: #22252b;
  --panel-2: #2b3038;
  --line: #3a404b;
  --text: #f2efe8;
  --muted: #b9b2a8;
  --red: #d95f59;
  --green: #6fb36a;
  --purple: #a978d6;
  --blue: #5fa8d9;
  --gold: #d6a84f;
  --teal: #5ab7a8;
  --danger: #e36b46;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(95, 168, 217, 0.18), transparent 26rem),
    linear-gradient(135deg, #15171b 0%, #1e2025 45%, #231d1b 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-height: 76px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(34, 37, 43, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.topbar h1,
.section-title h2,
.panel h2,
.fighter h2,
.gameover-copy h2,
.hero-copy h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(26px, 4vw, 44px);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.resource-strip,
.mini-stats,
.combat-tags,
.summary-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.stat b {
  color: var(--muted);
  font-size: 11px;
}

.stat.hp {
  border-color: rgba(217, 95, 89, 0.45);
}

.stat.gold {
  border-color: rgba(214, 168, 79, 0.55);
}

.stat.ap {
  border-color: rgba(111, 179, 106, 0.48);
}

.stat.mana {
  border-color: rgba(95, 168, 217, 0.48);
}

.stat.armor,
.stat.deck {
  border-color: rgba(185, 178, 168, 0.38);
}

.stat.danger,
.stat.fire {
  border-color: rgba(227, 107, 70, 0.58);
}

.stat.poison {
  border-color: rgba(90, 183, 168, 0.58);
}

.primary-button,
.ghost-button,
.tool-button,
.end-turn-button,
.card-button,
.skill-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease;
}

.primary-button,
.end-turn-button {
  padding: 9px 14px;
  background: var(--gold);
  color: #1d1710;
  font-weight: 800;
}

.ghost-button,
.tool-button {
  padding: 9px 13px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.hero-card {
  min-height: 720px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-art {
  display: grid;
  place-items: center;
  min-height: 310px;
  border-bottom: 1px solid var(--line);
}

.hero-card.knight .hero-art {
  background:
    linear-gradient(150deg, rgba(217, 95, 89, 0.38), rgba(34, 37, 43, 0.18)),
    url("https://images.unsplash.com/photo-1519074069444-1ba4fff66d16?auto=format&fit=crop&w=900&q=80") center/cover;
}

.hero-card.ranger .hero-art {
  background:
    linear-gradient(150deg, rgba(90, 183, 168, 0.34), rgba(34, 37, 43, 0.16)),
    url("https://images.unsplash.com/photo-1448375240586-882707db888b?auto=format&fit=crop&w=900&q=80") center/cover;
}

.hero-card.witch .hero-art {
  background:
    linear-gradient(150deg, rgba(95, 168, 217, 0.36), rgba(34, 37, 43, 0.16)),
    url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?auto=format&fit=crop&w=900&q=80") center/cover;
}

.sigil {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  font-size: 48px;
  font-weight: 900;
}

.hero-copy {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.skill-list,
.blessing-list,
.equipment-list,
.deck-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-list span,
.blessing-list span,
.equipment-list span,
.deck-list span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 12px;
}

.choice-layout,
.game-layout,
.battle-layout {
  display: grid;
  gap: 16px;
}

.choice-layout {
  grid-template-columns: 340px 1fr;
  align-items: start;
}

.game-layout,
.battle-layout {
  grid-template-columns: 320px 1fr;
  align-items: start;
}

.panel,
.map-panel,
.battlefield,
.shop-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(34, 37, 43, 0.86);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.side-panel {
  display: grid;
  gap: 12px;
}

.choice-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.blessing-card {
  display: grid;
  gap: 12px;
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(43, 48, 56, 0.92);
  color: var(--text);
  text-align: left;
}

.blessing-card strong {
  font-size: 22px;
}

.blessing-card span {
  color: var(--muted);
  line-height: 1.55;
}

.map-panel,
.battlefield,
.shop-panel {
  padding: 16px;
}

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

.section-title.compact {
  margin: 18px 0 10px;
}

.node-track {
  display: grid;
  grid-template-columns: repeat(7, minmax(86px, 1fr));
  gap: 10px;
}

.map-node {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  text-align: center;
}

.map-node span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  font-weight: 800;
}

.map-node.done {
  opacity: 0.62;
}

.map-node.next {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(214, 168, 79, 0.22) inset;
}

.map-node.battle.next,
.map-node.elite.next,
.map-node.boss.next {
  background: linear-gradient(145deg, rgba(217, 95, 89, 0.18), var(--panel-2));
}

.map-node.shop.next {
  background: linear-gradient(145deg, rgba(214, 168, 79, 0.18), var(--panel-2));
}

.map-node.chest.next {
  background: linear-gradient(145deg, rgba(90, 183, 168, 0.18), var(--panel-2));
}

.map-node.rest.next {
  background: linear-gradient(145deg, rgba(95, 168, 217, 0.18), var(--panel-2));
}

.deck-preview {
  margin-top: 16px;
}

.combatants {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.fighter {
  min-height: 230px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.fighter p {
  color: var(--muted);
  line-height: 1.5;
}

.bar {
  height: 12px;
  overflow: hidden;
  margin: 14px 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.hp-bar span {
  background: var(--red);
}

.enemy-bar span {
  background: var(--danger);
}

.battle-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
}

.pile-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pile-info span {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hand,
.card-grid {
  align-items: stretch;
}

.hand {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
}

.game-card {
  display: flex;
  flex-direction: column;
  min-height: 220px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.game-card header {
  display: grid;
  gap: 6px;
}

.game-card header span {
  width: fit-content;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
}

.game-card header strong {
  min-height: 44px;
  font-size: 20px;
  line-height: 1.1;
}

.game-card header small,
.rarity {
  color: var(--muted);
  font-size: 12px;
}

.game-card p {
  flex: 1;
  margin: 12px 0;
  color: var(--text);
  line-height: 1.55;
}

.game-card.attack {
  border-color: rgba(217, 95, 89, 0.5);
}

.game-card.action {
  border-color: rgba(111, 179, 106, 0.48);
}

.game-card.spell {
  border-color: rgba(169, 120, 214, 0.5);
}

.game-card.mana {
  border-color: rgba(95, 168, 217, 0.5);
}

.game-card.equipment {
  border-color: rgba(214, 168, 79, 0.56);
}

.game-card.disabled,
.game-card.sold {
  opacity: 0.58;
}

.card-button {
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line);
  color: var(--text);
  font-weight: 700;
}

.skill-panel {
  display: grid;
  gap: 8px;
}

.skill-button {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-align: left;
}

.skill-button span {
  color: var(--muted);
}

.log-panel ol {
  display: grid;
  gap: 8px;
  max-height: 300px;
  margin: 0;
  padding-left: 18px;
  overflow: auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.shop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.gameover {
  display: grid;
  grid-template-columns: minmax(280px, 46%) 1fr;
  gap: 16px;
  min-height: calc(100vh - 130px);
}

.gameover-art {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.gameover-art.victory {
  background:
    linear-gradient(145deg, rgba(214, 168, 79, 0.28), rgba(23, 25, 29, 0.18)),
    url("https://images.unsplash.com/photo-1470252649378-9c29740c9fa8?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.gameover-art.defeat {
  background:
    linear-gradient(145deg, rgba(217, 95, 89, 0.25), rgba(23, 25, 29, 0.22)),
    url("https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=1200&q=80") center/cover;
}

.gameover-copy {
  display: grid;
  align-content: center;
  gap: 16px;
}

.intro-panel {
  position: sticky;
  top: 18px;
}

@media (max-width: 1120px) {
  .class-grid,
  .choice-grid,
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-layout,
  .battle-layout,
  .choice-layout,
  .gameover {
    grid-template-columns: 1fr;
  }

  .intro-panel {
    position: static;
  }

  .node-track {
    grid-template-columns: repeat(4, minmax(90px, 1fr));
  }

  .hand {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 10px;
  }

  .topbar,
  .section-title,
  .battle-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    display: grid;
  }

  .class-grid,
  .choice-grid,
  .card-grid,
  .combatants,
  .hand {
    grid-template-columns: 1fr;
  }

  .node-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-card {
    min-height: auto;
  }

  .hero-art {
    min-height: 220px;
  }

  .gameover-art {
    min-height: 300px;
  }
}
