:root {
  --bg: #f2f5ef;
  --surface: #ffffff;
  --surface-soft: #f7f9f4;
  --ink: #18231d;
  --muted: #647068;
  --line: #dbe2da;
  --green: #21623e;
  --green-dark: #173f2a;
  --green-soft: #e3efe6;
  --gold: #d7a845;
  --danger: #a52d2d;
  --shadow: 0 22px 60px rgba(25, 46, 33, 0.12);
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 9px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, input { font: inherit; }
button { cursor: pointer; }
img, svg { display: block; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}
.brand img { border-radius: 8px; }

.github-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(25, 46, 33, 0.05);
  transition: transform 160ms ease, border-color 160ms ease;
}
.github-button:hover { transform: translateY(-1px); border-color: #aeb8af; }
.github-button svg { width: 19px; height: 19px; fill: currentColor; }

main { overflow: hidden; }
.hero {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 80px;
}
.hero-copy { max-width: 750px; margin-bottom: 34px; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 {
  margin-bottom: 14px;
  font-size: clamp(2.4rem, 6vw, 4.9rem);
  line-height: 0.98;
  letter-spacing: -0.065em;
}
.hero-copy p {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1.02rem, 2vw, 1.2rem);
  line-height: 1.65;
}

.calculator-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.input-panel, .result-panel { padding: clamp(25px, 4vw, 42px); }
.input-panel { border-right: 1px solid var(--line); }
.result-panel {
  position: relative;
  color: #f8fbf7;
  background:
    linear-gradient(145deg, rgba(255,255,255,.035) 25%, transparent 25%) 0 0 / 28px 28px,
    linear-gradient(325deg, rgba(255,255,255,.025) 25%, transparent 25%) 0 0 / 28px 28px,
    var(--green-dark);
}
.panel-heading h2, .result-topline h2 { margin-bottom: 0; font-size: clamp(1.45rem, 3vw, 2rem); letter-spacing: -0.035em; }
.eyebrow {
  margin-bottom: 7px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.result-panel .eyebrow { color: #9ed3ae; }

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 26px 0 24px;
  padding: 4px;
  border-radius: 12px;
  background: #edf1eb;
}
.mode-button {
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}
.mode-button.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 3px 10px rgba(25,46,33,.09); }

.field-group { margin-bottom: 20px; }
.field-group label, .stack-size-fieldset legend {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 780;
}
.optional { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid #cad3ca;
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(33,98,62,.13); }
input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(165,45,45,.09); }
.field-hint, .field-error { margin: 7px 0 0; font-size: 0.78rem; line-height: 1.45; }
.field-hint { color: var(--muted); }
.field-error { min-height: 1.1em; color: var(--danger); }
.stacks-fields { grid-template-columns: 1fr 1fr; gap: 14px; }
.stacks-fields:not([hidden]) { display: grid; }

.stack-size-fieldset { margin: 0; padding: 0; border: 0; }
.stack-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.preset-button {
  min-height: 45px;
  border: 1px solid #cad3ca;
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}
.preset-button.is-selected { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }
.custom-stack-wrap { margin-top: 10px; }
.form-actions { display: grid; grid-template-columns: 0.7fr 1.3fr; gap: 10px; margin-top: 24px; }
.primary-button, .secondary-button {
  min-height: 50px;
  border-radius: 10px;
  font-weight: 800;
}
.primary-button { border: 1px solid var(--green); background: var(--green); color: #fff; }
.primary-button:hover { background: #194f31; }
.secondary-button { border: 1px solid #cad3ca; background: #fff; color: var(--ink); }

.result-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.status-dot { width: 10px; height: 10px; margin-top: 10px; border-radius: 50%; background: #80d09a; box-shadow: 0 0 0 5px rgba(128,208,154,.12); }
.result-label { margin: 10px 0 24px; color: #bdcbbf; font-size: 0.92rem; }
.primary-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card { min-width: 0; padding: 16px; border: 1px solid rgba(255,255,255,.11); border-radius: 12px; background: rgba(255,255,255,.055); }
.stat-card span { display: block; margin-bottom: 8px; color: #afbeb2; font-size: 0.72rem; line-height: 1.3; }
.stat-card strong { font-size: clamp(1.25rem, 3vw, 1.8rem); font-variant-numeric: tabular-nums; }
.storage-heading { display: flex; justify-content: space-between; gap: 16px; margin: 28px 0 10px; }
.storage-heading h3 { margin-bottom: 0; font-size: 0.98rem; }
.storage-heading span { color: #9eafa2; font-size: 0.73rem; }
.storage-list { border-top: 1px solid rgba(255,255,255,.11); }
.storage-row { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; min-height: 74px; border-bottom: 1px solid rgba(255,255,255,.1); }
.storage-copy h4 { margin: 0 0 3px; font-size: 0.88rem; }
.storage-copy p { margin: 0; color: #aebcaf; font-size: 0.75rem; }
.storage-total { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.storage-icon { width: 34px; height: 30px; display: flex; align-items: center; justify-content: center; }
.chest-icon span, .double-chest-icon span { width: 25px; height: 20px; border: 2px solid #d6b059; border-radius: 3px; box-shadow: inset 0 -6px rgba(215,168,69,.18); }
.double-chest-icon span { width: 15px; }
.double-chest-icon span + span { margin-left: -2px; }
.shulker-icon span { width: 23px; height: 23px; border: 2px solid #c68ecc; border-radius: 4px; box-shadow: inset 0 -7px rgba(198,142,204,.18); }
.inventory-icon { display: grid; grid-template-columns: repeat(2, 10px); grid-template-rows: repeat(2, 10px); gap: 3px; }
.inventory-icon span { border: 1px solid #8fc29f; background: rgba(143,194,159,.12); }
.verification-line { margin-top: 22px; padding: 13px 15px; border-radius: 10px; background: rgba(0,0,0,.17); color: #d8e4da; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
.calculation-error { min-height: 1.2em; margin: 12px 0 0; color: #ffb9b9; font-size: 0.82rem; }

.content-section { width: min(1040px, calc(100% - 40px)); margin: 0 auto; padding: 74px 0; }
.section-heading { max-width: 660px; margin-bottom: 30px; }
.section-heading h2, .split-content h2 { margin-bottom: 0; font-size: clamp(1.8rem, 4vw, 2.8rem); letter-spacing: -0.045em; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature-grid article { padding: 25px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); }
.feature-grid h3 { margin: 15px 0 8px; font-size: 1.05rem; }
.feature-grid p, .split-content p, .faq-list p { color: var(--muted); line-height: 1.7; }
.step-number { color: var(--green); font-family: ui-monospace, monospace; font-size: 0.82rem; font-weight: 800; }
.split-content { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 55px; }
.formula-card { display: grid; gap: 12px; padding: 25px; border-radius: 18px; background: var(--ink); }
.formula-card code { padding: 13px 14px; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; color: #dce9df; background: rgba(255,255,255,.04); white-space: normal; }
.faq-list { border-top: 1px solid var(--line); }
details { border-bottom: 1px solid var(--line); }
summary { padding: 20px 0; font-weight: 760; cursor: pointer; }
details p { max-width: 760px; padding: 0 0 20px; margin: 0; }
footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 32px 0 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; text-align: center; }

.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  .hero { padding-top: 35px; }
  .calculator-shell { grid-template-columns: 1fr; }
  .input-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .feature-grid { grid-template-columns: 1fr; }
  .split-content { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 540px) {
  .site-header, .hero, .content-section, footer { width: min(100% - 24px, 1180px); }
  .site-header { padding-top: 14px; }
  .brand span { font-size: 0.93rem; }
  .github-button { min-height: 40px; padding: 0 11px; }
  .hero { padding-bottom: 52px; }
  h1 { font-size: 2.65rem; }
  .input-panel, .result-panel { padding: 23px 18px; }
  .mode-button { font-size: 0.78rem; }
  .stack-presets { grid-template-columns: repeat(2, 1fr); }
  .stacks-fields:not([hidden]) { grid-template-columns: 1fr; gap: 0; }
  .primary-stats { grid-template-columns: 1fr 1fr; }
  .stat-card:last-child { grid-column: 1 / -1; }
  .storage-heading { align-items: flex-end; }
  .storage-row { grid-template-columns: 36px 1fr auto; }
  .storage-copy p { max-width: 190px; }
  .form-actions { grid-template-columns: 1fr; }
  .content-section { padding: 52px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
