:root {
  --void: #0b0f14;
  --deep: #121a24;
  --ink: #eef3f7;
  --muted: #8b95a3;
  --teal: #38c7d1;
  --cyan: #73e6ef;
  --ember: #ef7a38;
  --gold: #edae47;
  --gem: #59d19d;
  --relic: #f0b84a;
  --spell: #8b97f5;
  --card: rgba(255, 255, 255, 0.06);
  --stroke: rgba(56, 199, 209, 0.28);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--ink);
  background: var(--void);
  padding: calc(16px + var(--safe-top)) 16px calc(96px + var(--safe-bottom));
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at 85% 8%, rgba(56, 199, 209, 0.22), transparent 42%),
    radial-gradient(ellipse at 10% 90%, rgba(239, 122, 56, 0.12), transparent 40%),
    linear-gradient(160deg, #0b0f14 0%, #121a24 48%, #15101c 100%);
}

.top { margin-bottom: 18px; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
}
h1 {
  margin: 0;
  font-family: "Palatino Linotype", Palatino, "Book Antiqua", serif;
  font-size: clamp(2rem, 8vw, 3rem);
  letter-spacing: 0.02em;
}
.lede, .hint, .meta {
  color: var(--muted);
  line-height: 1.45;
}
.lede { margin: 8px 0 0; max-width: 38rem; }
.hint { margin: 0 0 14px; }

.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.step {
  border: 1px solid transparent;
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 0.9rem;
}
.step.active {
  border-color: var(--teal);
  background: rgba(56, 199, 209, 0.18);
}

.panel { display: none; }
.panel.active { display: block; }

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
input[type="search"], input[type="number"] {
  background: var(--card);
  border: 1px solid var(--stroke);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 0;
}
input[type="search"] { flex: 1; }
input[type="number"] { width: 4.5rem; }

button {
  cursor: pointer;
  border: none;
}
.primary, .ghost {
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
}
.primary {
  background: linear-gradient(135deg, var(--teal), #2aa8b8);
  color: #061016;
}
.ghost {
  background: var(--card);
  color: var(--ink);
  border: 1px solid rgba(255,255,255,0.08);
}

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

.card {
  text-align: left;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 12px;
  color: inherit;
  min-height: 120px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:active { transform: scale(0.98); }
.card.selected { border-color: var(--teal); box-shadow: inset 0 0 0 1px rgba(56,199,209,0.35); }
.card h3 {
  margin: 8px 0 4px;
  font-size: 1rem;
}
.card .sub { color: var(--gold); font-size: 0.75rem; }
.card .tiny { color: var(--muted); font-size: 0.72rem; margin-top: 6px; }
.check {
  float: right;
  color: var(--muted);
}
.card.selected .check { color: var(--teal); }

.thumb {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  background: linear-gradient(145deg, rgba(56,199,209,0.25), rgba(0,0,0,0.35));
}
.thumb.mage { background: linear-gradient(145deg, rgba(139,151,245,0.3), rgba(0,0,0,0.35)); }

.results { display: grid; gap: 14px; }
.option {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 14px;
}
.option h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(239,122,56,0.22);
  color: #ffd7bf;
  font-size: 0.7rem;
  font-weight: 700;
}
.rationale { color: var(--muted); font-size: 0.88rem; margin: 8px 0 12px; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  margin-bottom: 6px;
}
.row .name { font-weight: 650; }
.row .type { color: var(--muted); font-size: 0.75rem; }
.cost {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cost.Gem { color: var(--gem); background: rgba(89,209,157,0.15); }
.cost.Relic { color: var(--relic); background: rgba(240,184,74,0.15); }
.cost.Spell { color: var(--spell); background: rgba(139,151,245,0.15); }

.bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: rgba(11, 15, 20, 0.88);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,0.06);
}
.bottom .primary, .bottom .ghost { min-width: 120px; }

@media (min-width: 900px) {
  body { padding-left: 28px; padding-right: 28px; max-width: 1100px; margin: 0 auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .results { grid-template-columns: 1fr 1fr; }
}
