:root {
  --bg: #0d0f16;
  --bg-alt: #12151f;
  --panel: #161a26;
  --panel-border: #262c3d;
  --text: #e9ebf3;
  --text-dim: #9aa1b5;
  --text-faint: #666d84;
  --accent: #8a7bff;
  --accent-soft: rgba(138, 123, 255, 0.15);
  --good: #4ade80;
  --warn: #fbbf24;

  --ruby: #e6455c;
  --amethyst: #b565e0;
  --topaz: #f0b429;
  --emerald: #3fbf7f;
  --sapphire: #3f8cf0;
  --diamond: #cfe8f5;

  --radius: 14px;
  --radius-sm: 9px;
}

:root[data-theme="light"] {
  --bg: #f3f4f8;
  --bg-alt: #e9ebf2;
  --panel: #ffffff;
  --panel-border: #dcdfe9;
  --text: #1c1f2b;
  --text-dim: #565d73;
  --text-faint: #8890a3;
  --accent-soft: rgba(138, 123, 255, 0.12);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f4f8;
    --bg-alt: #e9ebf2;
    --panel: #ffffff;
    --panel-border: #dcdfe9;
    --text: #1c1f2b;
    --text-dim: #565d73;
    --text-faint: #8890a3;
    --accent-soft: rgba(138, 123, 255, 0.12);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, sans-serif;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(600px 400px at 15% -10%, rgba(138, 123, 255, 0.16), transparent 60%),
    radial-gradient(500px 350px at 90% 10%, rgba(63, 140, 240, 0.12), transparent 60%);
}

.site-header {
  position: relative;
  z-index: 1;
  padding: 40px 20px 24px;
  text-align: center;
}
.header-inner h1 {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  background: linear-gradient(90deg, var(--diamond), var(--accent) 60%, var(--amethyst));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.3px;
}
.subtitle { color: var(--text-dim); margin: 0; font-size: 0.95rem; }

.layout {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 60px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset;
}

.panel-head h2 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}
.hint {
  margin: 0 0 16px;
  color: var(--text-faint);
  font-size: 0.85rem;
  line-height: 1.4;
}

/* ---------- Stash grid ---------- */
.stash-grid-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}
.stash-grid {
  display: grid;
  grid-template-columns: 110px repeat(4, 96px);
  gap: 8px 10px;
  align-items: center;
  width: max-content;
  min-width: 100%;
}
.stash-grid .col-head {
  font-size: 0.75rem;
  color: var(--text-faint);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stash-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 600;
}
.stash-row-label .swatch {
  width: 10px; height: 10px; border-radius: 50%;
  box-shadow: 0 0 6px 1px var(--dot-color, transparent);
  background: var(--dot-color, #888);
  flex: none;
}
.gem-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-alt);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
}
.gem-cell img {
  width: 26px; height: 26px; object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.4));
}
.gem-cell input {
  width: 44px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.95rem;
  text-align: center;
  -moz-appearance: textfield;
}
.gem-cell input::-webkit-outer-spin-button,
.gem-cell input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.gem-cell:focus-within { border-color: var(--accent); }


/* ---------- Equipped / target slots ---------- */
.equipped-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
}
.slot-card {
  background: var(--bg-alt);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  min-height: 190px;
}
.slot-card .slot-label {
  font-size: 0.75rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pick-step-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  min-height: 1.1em;
}
.color-pick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}
.size-pick-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  width: 100%;
}
.pick-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 4px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.pick-btn img { width: 34px; height: 34px; object-fit: contain; pointer-events: none; }
.pick-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}
.pick-btn:focus-visible,
.gem-chosen:focus-visible,
.pick-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pick-size-num {
  position: absolute;
  right: 6px;
  bottom: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
}
.pick-back {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 2px 6px;
}
.pick-back:hover { color: var(--accent); }
.gem-chosen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 8px;
  background: radial-gradient(circle at 50% 35%, var(--accent-soft), transparent 75%);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.gem-chosen:hover {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(138, 123, 255, 0.25);
}
.gem-chosen img { width: 56px; height: 56px; object-fit: contain; }
.gem-caption {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 640px) {
  .equipped-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .slot-card {
    padding: 10px 8px;
    min-height: 160px;
    gap: 8px;
  }
  .pick-btn { padding: 6px 2px; }
  .pick-btn img { width: 28px; height: 28px; }
  .gem-chosen { padding: 10px 6px; }
  .gem-chosen img { width: 44px; height: 44px; }
}

/* ---------- Resources ---------- */
.resource-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.resource-col h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.resource-inputs {
  display: flex;
  gap: 10px;
}
.resource-chip {
  flex: 1;
  background: var(--bg-alt);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}
.resource-chip label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.resource-chip input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.05rem;
  text-align: center;
  font-weight: 600;
}

@media (max-width: 640px) {
  .resource-cols { grid-template-columns: 1fr; }
}

/* ---------- CTA ---------- */
.calc-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 6px 0 4px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6a5bff);
  color: white;
  border: none;
  padding: 13px 28px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(138, 123, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(138, 123, 255, 0.45); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--panel-border);
  padding: 13px 22px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }

/* ---------- Results ---------- */
.results-panel { border-color: var(--accent); }

.result-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}
.summary-card {
  flex: 1;
  min-width: 160px;
  background: var(--bg-alt);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.summary-card .big {
  font-size: 1.6rem;
  font-weight: 700;
}
.summary-card .label {
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-top: 2px;
}
.summary-card.total .big { color: var(--accent); }

/* Step numbering (shared by shopping + craft cards) */
.step-num {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
}
.step-num.big {
  width: 28px;
  height: 28px;
  font-size: 0.9rem;
}
.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 6px;
}
.step-title h3 { margin: 0; font-size: 0.95rem; color: var(--text); }
.step-sub {
  margin: 0 0 12px;
  color: var(--text-faint);
  font-size: 0.85rem;
  line-height: 1.45;
}
.craft-intro { margin-top: 20px; }

.mof-tag { color: var(--warn); font-weight: 600; }
.free-tag { color: var(--good); font-weight: 600; }

/* Step 1 — shopping list */
.shopping-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 480px;
}
.shopping-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.85rem;
}
.shopping-item b { color: var(--text); }
.shop-label { flex: 1; }
.shop-unit { color: var(--text-faint); font-size: 0.76rem; }
.shopping-item .mof-tag { font-size: 0.85rem; }
.shop-total {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.shop-total b { color: var(--warn); }
.no-purchases {
  color: var(--good);
  font-size: 0.9rem;
}

/* Resource glyphs (Aether / Godstone have no game art, use styled glyphs) */
.res-icon {
  font-style: normal;
  font-size: 1.15rem;
  line-height: 1;
}
.res-icon.aether, .res-chip.aether .res-icon { color: var(--accent); }
.res-icon.godstone, .res-chip.godstone .res-icon { color: var(--topaz); }

.target-card {
  background: var(--bg-alt);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.target-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.target-card-head img { width: 40px; height: 40px; object-fit: contain; }
.target-card-head .name { font-weight: 600; }
.target-card-head .cost {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}
.target-card-head .name-sub {
  color: var(--text-faint);
  font-weight: 400;
  font-size: 0.8rem;
}
.owned-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--good);
}

/* Numbered craft instructions inside a target card */
.craft-steps {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.step-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}
.step-line .step-num { margin-top: 1px; }
.step-text {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.45;
}

/* Ingredients ➜ result flow diagram */
.flow-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0 29px;
}
.flow-side {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.flow-plus {
  color: var(--text-faint);
  font-weight: 600;
}
.flow-arrow {
  color: var(--accent);
  font-size: 1.05rem;
}
.flow-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px 6px;
  min-width: 76px;
}
.flow-chip img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.35));
}
.flow-chip .res-icon {
  height: 30px;
  display: flex;
  align-items: center;
  font-size: 1.35rem;
}
.chip-count {
  position: absolute;
  top: -7px;
  right: -7px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
}
.chip-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
}
.chip-note {
  font-size: 0.64rem;
  color: var(--text-faint);
}

/* Final equip step */
.equip-card { border-color: var(--good); }
.equip-card .cost { color: var(--good); }
.equip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.assumptions {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 14px 20px;
}
.assumptions summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.assumptions-body { margin-top: 12px; }
.assumptions-body ul { margin: 0; padding-left: 20px; }
.assumptions-body li {
  font-size: 0.83rem;
  color: var(--text-faint);
  margin-bottom: 8px;
  line-height: 1.5;
}

.site-footer {
  text-align: center;
  padding: 20px;
  color: var(--text-faint);
  font-size: 0.78rem;
  position: relative;
  z-index: 1;
}
