:root {
  color-scheme: dark;
  --bg: #070b0b;
  --surface: #0d1313;
  --surface-2: #121a19;
  --line: rgba(213, 187, 128, 0.24);
  --line-strong: rgba(236, 199, 111, 0.55);
  --gold: #dfb85d;
  --gold-pale: #f0d89a;
  --gold-dark: #9b7330;
  --text: #f3eee3;
  --muted: #aeb7b2;
  --green: #6ec99d;
  --red: #e77a6d;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
  --radius: 4px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 72% 14%, rgba(67, 104, 87, 0.11), transparent 30rem),
    linear-gradient(180deg, #080c0c 0%, #050808 100%);
  font-family: "Manrope", sans-serif;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .21;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
  z-index: 20;
  mix-blend-mode: soft-light;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.ambient {
  position: fixed;
  border: 1px solid rgba(223, 184, 93, .08);
  width: 38rem;
  height: 38rem;
  transform: rotate(45deg);
  pointer-events: none;
  z-index: -1;
}
.ambient::before, .ambient::after {
  content: "";
  position: absolute;
  border: inherit;
  inset: 4rem;
}
.ambient::after { inset: 9rem; }
.ambient-one { top: -24rem; left: -22rem; }
.ambient-two { right: -28rem; top: 34rem; }

.site-header {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #0b0e0d;
  background: linear-gradient(135deg, var(--gold-pale), var(--gold-dark));
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 23px;
  clip-path: polygon(50% 0, 94% 24%, 94% 76%, 50% 100%, 6% 76%, 6% 24%);
}
.brand strong, .brand small { display: block; letter-spacing: .12em; }
.brand strong { font-family: "Cinzel", serif; font-size: 16px; }
.brand small { color: var(--gold); font-size: 9px; margin-top: 3px; }

.market-state {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .04em;
}
.state-dot {
  width: 7px;
  height: 7px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(223, 184, 93, .1), 0 0 15px rgba(223, 184, 93, .5);
  animation: pulse 2s infinite;
}
.market-state.online .state-dot { background: var(--green); box-shadow: 0 0 0 5px rgba(110, 201, 157, .1), 0 0 15px rgba(110, 201, 157, .5); }
.market-state.error .state-dot { background: var(--red); box-shadow: 0 0 0 5px rgba(231, 122, 109, .1); animation: none; }

main {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto 80px;
}

.hero {
  position: relative;
  padding: 78px 0 58px;
  max-width: 980px;
  animation: reveal .7s ease both;
}
.hero::after {
  content: "";
  position: absolute;
  width: 1px;
  height: 130px;
  left: calc(100% + 7vw);
  top: 70px;
  background: linear-gradient(var(--gold), transparent);
  opacity: .5;
  transform: rotate(32deg);
  box-shadow: 42px 10px 0 rgba(223, 184, 93, .18), 84px 20px 0 rgba(223, 184, 93, .08);
}
.eyebrow {
  color: var(--gold);
  font-size: 10px;
  letter-spacing: .28em;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}
.eyebrow span { width: 28px; height: 1px; background: var(--gold); }
.hero h1 {
  margin: 18px 0 18px;
  max-width: 900px;
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(44px, 6.1vw, 86px);
  line-height: .98;
  letter-spacing: -.045em;
}
.hero h1 em { color: var(--gold-pale); font-style: normal; }
.hero > p {
  max-width: 640px;
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
  font-size: 15px;
}
.hero-meta {
  position: absolute;
  left: calc(100% + 6vw);
  bottom: 58px;
  display: flex;
  gap: 42px;
}
.hero-meta div { min-width: 92px; }
.hero-meta strong {
  display: block;
  color: var(--gold-pale);
  font-family: "Cinzel", serif;
  font-size: 22px;
}
.hero-meta span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.calculator-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  border: 1px solid var(--line-strong);
  background: rgba(9, 14, 14, .88);
  box-shadow: var(--shadow);
  animation: reveal .8s .12s ease both;
}
.calculator-shell::before {
  content: "";
  position: absolute;
  width: 88px;
  height: 3px;
  background: var(--gold);
}

.control-panel {
  padding: 34px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(223, 184, 93, .035), transparent 35%),
    var(--surface);
}
.panel-heading, .results-topbar > div {
  display: flex;
  align-items: center;
  gap: 13px;
}
.step-number {
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: .08em;
}
.panel-heading p, .results-topbar p {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: .18em;
}
.panel-heading h2, .results-topbar h2 {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 20px;
  font-weight: 600;
}

.chest-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 25px 0 22px;
}
.chest-selector button {
  height: 42px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .015);
  color: var(--muted);
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-size: 13px;
  transition: .2s ease;
}
.chest-selector button:hover { color: var(--text); border-color: rgba(223, 184, 93, .38); transform: translateY(-1px); }
.chest-selector button.active {
  color: #111;
  background: linear-gradient(135deg, var(--gold-pale), #bd8d37);
  border-color: var(--gold-pale);
  box-shadow: 0 7px 24px rgba(181, 132, 45, .17);
}
.chest-selector button.special {
  grid-column: 1 / -1;
  letter-spacing: .08em;
}

.selected-chest {
  min-height: 112px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 17px;
  padding: 18px;
  border: 1px solid var(--line);
  background: #090e0e;
}
.selected-chest img { width: 72px; height: 72px; object-fit: contain; image-rendering: auto; position: relative; z-index: 1; }
.chest-aura {
  position: absolute;
  width: 95px;
  height: 95px;
  left: 7px;
  background: radial-gradient(circle, rgba(223, 184, 93, .18), transparent 68%);
  filter: blur(2px);
}
.selected-chest span { display: block; color: var(--muted); font-size: 8px; letter-spacing: .15em; }
.selected-chest strong { display: block; margin: 5px 0 6px; font-family: "Cinzel", serif; font-size: 14px; }
.selected-chest a { color: var(--gold); text-decoration: none; font-size: 10px; }

.input-block { margin-top: 24px; }
.input-block > label, .cost-settings label {
  display: flex;
  justify-content: space-between;
  color: var(--text);
  font-size: 11px;
  margin-bottom: 9px;
}
.input-block label small { color: var(--muted); }
.number-control {
  height: 54px;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  border: 1px solid var(--line-strong);
  background: #080c0c;
}
.number-control button {
  border: 0;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  font-size: 22px;
}
.number-control input {
  min-width: 0;
  border: 0;
  border-inline: 1px solid var(--line);
  outline: none;
  background: transparent;
  color: var(--text);
  text-align: center;
  font-family: "Cinzel", serif;
  font-size: 18px;
  -moz-appearance: textfield;
}
.number-control input::-webkit-inner-spin-button { display: none; }
.quick-values { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 7px; }
.quick-values button {
  padding: 6px 2px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 9px;
}
.quick-values button.active { color: var(--gold-pale); border-color: var(--gold-dark); background: rgba(223, 184, 93, .06); }

.mode-block { margin-top: 23px; }
.mode-block > span { font-size: 11px; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  margin-top: 9px;
  background: #080c0c;
  border: 1px solid var(--line);
}
.segmented button {
  border: 0;
  padding: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
}
.segmented button.active { color: var(--gold-pale); background: rgba(223, 184, 93, .1); }
.mode-block p { min-height: 28px; margin: 8px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }

.cost-settings {
  margin-top: 16px;
  padding-block: 11px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.cost-settings summary { cursor: pointer; color: var(--muted); font-size: 10px; list-style: none; }
.cost-settings summary::before { content: "+"; color: var(--gold); margin-right: 8px; }
.cost-settings[open] summary::before { content: "−"; }
.cost-settings label { margin-top: 13px; }
.cost-settings input {
  width: 100%;
  border: 1px solid var(--line);
  background: #080c0c;
  color: var(--text);
  padding: 10px;
  outline: none;
}
.cost-settings small { display: block; color: var(--muted); font-size: 8px; line-height: 1.5; margin-top: 6px; }

.calculate-button {
  width: 100%;
  height: 57px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border: 1px solid var(--gold-pale);
  background: linear-gradient(115deg, #e1bc64, #aa792b);
  color: #10120f;
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: .08em;
  transition: transform .2s ease, box-shadow .2s ease;
}
.calculate-button:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(201, 151, 55, .17); }
.calculate-button:disabled { opacity: .55; cursor: wait; transform: none; }
.calculate-button i { font-style: normal; font-size: 18px; }

.results-panel { min-width: 0; padding: 34px 38px 32px; background: rgba(6, 10, 10, .6); }
.results-topbar { display: flex; align-items: center; justify-content: space-between; }
.refresh-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  cursor: pointer;
  font-size: 9px;
  letter-spacing: .05em;
}
.refresh-button span { color: var(--gold); margin-right: 5px; }
.refresh-button:hover { color: var(--text); border-color: var(--line-strong); }
.refresh-button:disabled {
  cursor: not-allowed;
  color: #76807b;
  border-color: rgba(196, 166, 100, .12);
  background: rgba(255, 255, 255, .015);
}
.refresh-button:disabled .refresh-icon { color: #8f7948; animation: none; }
.refresh-button:not(:disabled) .refresh-icon { display: inline-block; animation: refresh-ready 1.8s ease-in-out infinite; }

.summary-grid { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 10px; margin-top: 26px; }
.summary-card {
  position: relative;
  overflow: hidden;
  min-height: 120px;
  padding: 21px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.summary-card.primary { border-color: var(--line-strong); background: linear-gradient(120deg, rgba(223, 184, 93, .1), rgba(13, 19, 19, .75)); }
.summary-card > span { color: #c3cbc6; font-size: 9px; letter-spacing: .14em; }
.summary-card strong { display: block; margin: 13px 0 5px; font-family: "Cinzel", serif; color: var(--gold-pale); font-size: clamp(19px, 2vw, 28px); line-height: 1.18; overflow-wrap: anywhere; }
.summary-card:not(.primary) strong { color: var(--text); font-size: clamp(17px, 1.8vw, 24px); }
.summary-card small { color: #c1c9c4; font-size: 10px; line-height: 1.5; }
.card-glow {
  position: absolute;
  width: 140px;
  height: 140px;
  right: -60px;
  bottom: -80px;
  border-radius: 50%;
  background: var(--gold);
  opacity: .07;
  filter: blur(24px);
}
.summary-card.positive strong { color: var(--green); }
.summary-card.negative strong { color: var(--red); }

.coverage-row {
  display: grid;
  grid-template-columns: 190px minmax(100px, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin: 18px 0 31px;
  color: var(--muted);
  font-size: 9px;
}
.coverage-row > div:first-child { display: flex; justify-content: space-between; gap: 8px; }
.coverage-row strong { color: var(--text); }
.coverage-track { height: 3px; background: rgba(255, 255, 255, .06); }
.coverage-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--gold-dark), var(--gold-pale)); transition: width .5s ease; }
.coverage-row p { margin: 0; }

.drop-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 13px; }
.drop-heading h3 { margin: 0 0 4px; font-family: "Cinzel", serif; font-size: 16px; }
.drop-heading > div > span { color: var(--muted); font-size: 9px; }
.legend { display: flex; gap: 12px; color: var(--muted); font-size: 8px; }
.dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; margin-right: 4px; }
.dot.market { background: var(--green); }
.dot.missing { background: #555; }

.items-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.item-card {
  min-width: 0;
  min-height: 104px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(196, 166, 100, .13);
  background: linear-gradient(115deg, rgba(21, 29, 27, .96), rgba(12, 18, 17, .98));
  transition: border-color .2s ease, transform .2s ease;
}
.item-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.item-icon-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle, rgba(223, 184, 93, .1), transparent 70%);
  border: 1px solid var(--line);
}
.item-icon-wrap img { max-width: 42px; max-height: 42px; object-fit: contain; }
.item-icon-wrap::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  right: 4px;
  top: 4px;
  border-radius: 50%;
  background: #555;
}
.item-card.has-price .item-icon-wrap::after { background: var(--green); box-shadow: 0 0 8px var(--green); }
.item-body { min-width: 0; }
.item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-family: "Cinzel", serif;
  font-size: 12px;
  color: #fffaf0;
}
.item-stats { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; color: #b8c1bc; font-size: 9px; }
.item-stats b { color: var(--gold-pale); font-weight: 600; }
.item-value-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 10px -5px -4px;
  padding: 9px 6px 5px;
  border-top: 1px solid rgba(223, 184, 93, .13);
  background: rgba(223, 184, 93, .025);
  font-size: 9px;
  color: #c2cbc6;
}
.item-total { color: #8ee0b7; font-family: "Cinzel", serif; font-size: 11px; text-align: right; line-height: 1.35; }
.manual-price {
  width: 118px;
  border: 0;
  border-bottom: 1px dashed var(--gold-dark);
  background: transparent;
  color: var(--gold-pale);
  outline: none;
  font-size: 10px;
}

.skeleton-card {
  min-height: 104px;
  border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--surface) 15%, #18201f 30%, var(--surface) 45%);
  background-size: 220% 100%;
  animation: shimmer 1.2s linear infinite;
}

.disclaimer {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.disclaimer > span {
  flex: 0 0 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--gold);
  font-size: 9px;
}
.disclaimer p { margin: 0; color: var(--muted); font-size: 8px; line-height: 1.65; }

.toast {
  position: fixed;
  z-index: 30;
  right: 24px;
  bottom: 24px;
  max-width: 340px;
  padding: 13px 16px;
  border: 1px solid var(--line-strong);
  background: #111817;
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 11px;
  transform: translateY(30px);
  opacity: 0;
  pointer-events: none;
  transition: .25s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(231, 122, 109, .6); }

@keyframes pulse { 50% { opacity: .5; transform: scale(.85); } }
@keyframes reveal { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { to { background-position-x: -220%; } }
@keyframes refresh-ready { 50% { transform: rotate(180deg); } }

@media (max-width: 1120px) {
  .hero-meta { position: static; margin-top: 30px; }
  .calculator-shell { grid-template-columns: 320px minmax(0, 1fr); }
  .control-panel { padding: 28px; }
  .results-panel { padding: 28px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card.primary { grid-column: 1 / -1; }
  .coverage-row { grid-template-columns: 1fr auto; }
  .coverage-track { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 820px) {
  .site-header, main { width: min(100% - 28px, 680px); }
  .hero { padding: 55px 0 42px; }
  .hero h1 { font-size: clamp(38px, 11vw, 62px); }
  .hero-meta { gap: 22px; flex-wrap: wrap; }
  .calculator-shell { grid-template-columns: 1fr; }
  .control-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .results-panel { padding: 28px 22px; }
  .items-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .site-header { min-height: 72px; }
  .market-state span:last-child { display: none; }
  .hero { padding-top: 42px; }
  .hero h1 { letter-spacing: -.055em; }
  .hero-meta div { min-width: 75px; }
  .control-panel { padding: 26px 20px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card.primary { grid-column: auto; }
  .results-topbar { align-items: flex-start; }
  .refresh-button { font-size: 0; }
  .refresh-button span { font-size: 16px; margin: 0; }
  .coverage-row { grid-template-columns: 1fr; }
  .coverage-track { grid-column: auto; grid-row: auto; }
  .coverage-row p { line-height: 1.5; }
  .drop-heading { align-items: flex-start; gap: 12px; }
  .legend { flex-direction: column; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
