:root {
  --page: #241f2a;
  --page-deep: #15131a;
  --card: #302b35;
  --card-dark: #211e27;
  --line: #61586a;
  --line-bright: #dfbd70;
  --text: #faf2de;
  --muted: #d2c8d8;
  --accent: #e2bf72;
  --purple: #4b3673;
  --green: #70a96d;
  --red: #dc5a65;
}

* {
  box-sizing: border-box;
}

body {
  background:
    radial-gradient(circle at 50% 0, rgba(226, 191, 114, 0.16), transparent 30rem),
    radial-gradient(circle at 88% 8%, rgba(143, 101, 216, 0.2), transparent 22rem),
    linear-gradient(180deg, var(--page) 0%, var(--page-deep) 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.tool-header {
  align-items: center;
  border-bottom: 1px solid rgba(226, 191, 114, 0.18);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1180px;
  padding: 16px 20px;
}

.tool-brand,
.tool-header nav {
  align-items: center;
  display: flex;
}

.tool-brand {
  gap: 10px;
  font-weight: 900;
}

.tool-brand img {
  height: 38px;
  width: 38px;
}

.tool-header nav {
  background: rgba(24, 21, 30, 0.78);
  border: 1px solid rgba(226, 191, 114, 0.24);
  border-radius: 8px;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
}

.tool-header .site-account {
  margin-left: auto;
}

.tool-header nav a {
  border-radius: 6px;
  color: #dddddd;
  font-size: 14px;
  font-weight: 800;
  padding: 10px 12px;
}

.tool-header nav a:hover {
  background: #3b3347;
  color: #ffffff;
}

.tool-header nav a.discord-button {
  background: #5865f2;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

main {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px 20px 42px;
}

.upgrade-hero,
.control-panel,
.tool-section {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 8px;
}

.upgrade-hero {
  padding: 26px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  color: var(--accent);
  line-height: 1;
  margin: 0;
  text-shadow: 2px 2px 0 #171717;
}

h1 {
  font-size: clamp(38px, 6vw, 58px);
  margin-top: 8px;
}

h2 {
  font-size: 28px;
}

p {
  color: var(--muted);
  font-weight: 800;
  line-height: 1.5;
  margin: 8px 0 0;
}

.control-panel {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(150px, 1fr) minmax(135px, 0.72fr) minmax(126px, auto) minmax(180px, auto) minmax(150px, auto) auto;
  padding: 14px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 900;
  gap: 6px;
}

input,
button {
  background: var(--card-dark);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-weight: 900;
  min-height: 42px;
  padding: 8px 10px;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--line-bright);
}

.ems-left-card {
  background: rgba(226, 191, 114, 0.12);
  border: 1px solid rgba(226, 191, 114, 0.22);
  border-radius: 8px;
  display: grid;
  min-height: 42px;
  padding: 7px 10px;
}

.ems-left-card span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.ems-left-card strong {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
}

.check-row {
  align-items: center;
  background: var(--card-dark);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: row;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
}

.check-row input {
  min-height: auto;
  width: 18px;
}

.workspace-grid {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.75fr);
}

.tool-section {
  padding: 18px;
}

.side-column {
  display: grid;
  gap: 18px;
}

.side-column .inventory-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.shopping-panel {
  padding: 0;
}

.shopping-panel summary {
  align-items: start;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
  padding: 18px;
}

.shopping-panel summary::-webkit-details-marker {
  display: none;
}

.shopping-panel summary::after {
  background: rgba(226, 191, 114, 0.12);
  border: 1px solid rgba(226, 191, 114, 0.22);
  border-radius: 999px;
  color: var(--accent);
  content: "Open";
  font-size: 13px;
  font-weight: 900;
  padding: 6px 10px;
  white-space: nowrap;
}

.shopping-panel[open] summary::after {
  content: "Close";
}

.shopping-actions {
  border-top: 1px solid rgba(226, 191, 114, 0.16);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 12px;
}

.section-heading {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.building-list,
.inventory-grid,
.shopping-list {
  display: grid;
  gap: 10px;
}

.building-list {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.building-card {
  align-items: start;
  background: var(--card-dark);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 84px minmax(0, 1fr);
  padding: 12px;
}

.building-card.is-muted {
  opacity: 0.58;
}

.building-card.is-complete {
  border-color: rgba(112, 169, 109, 0.86);
  background: color-mix(in srgb, var(--card-dark) 82%, #1f5c36 18%);
}

.building-card.is-personal-train .building-visual {
  width: 112px;
}

.building-card.is-personal-train {
  grid-template-columns: 112px minmax(0, 1fr);
}

.building-visual {
  align-items: center;
  height: 92px;
  background: rgba(112, 169, 109, 0.12);
  border: 1px solid rgba(250, 242, 222, 0.09);
  border-radius: 8px;
  display: grid;
  justify-items: center;
  padding: 10px;
  width: 84px;
}

.building-visual img {
  max-height: 68px;
  max-width: 68px;
  object-fit: contain;
}

.building-main {
  display: grid;
  gap: 9px;
  min-width: 0;
}

.include-row {
  align-items: center;
  display: flex;
  flex-direction: row;
  font-size: 16px;
  gap: 8px;
  min-width: 0;
}

.include-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.include-row em {
  background: rgba(112, 169, 109, 0.25);
  border: 1px solid rgba(112, 169, 109, 0.45);
  border-radius: 999px;
  color: #c6f4bd;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  margin-left: auto;
  padding: 4px 7px;
  white-space: nowrap;
}

.include-row input {
  min-height: auto;
  width: 18px;
}

.level-row {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(82px, 1fr) minmax(84px, 0.62fr);
}

.level-field input,
.inventory-item input {
  width: 100%;
}

.level-target {
  background: rgba(226, 191, 114, 0.12);
  border: 1px solid rgba(226, 191, 114, 0.18);
  border-radius: 6px;
  display: grid;
  min-height: 42px;
  padding: 6px 8px;
}

.target-field input[readonly] {
  background: rgba(226, 191, 114, 0.12);
  border-color: rgba(226, 191, 114, 0.18);
}

.level-target span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.level-target strong {
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
}

.upgrade-meter {
  background: rgba(250, 242, 222, 0.08);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.upgrade-meter span {
  background: var(--green);
  display: block;
  height: 100%;
}

.building-note {
  font-size: 12px;
  margin: 0;
}

.upgrade-once {
  justify-self: start;
  min-height: 34px;
  padding: 6px 10px;
}

.upgrade-once:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.building-total {
  align-content: center;
  background: rgba(226, 191, 114, 0.12);
  border: 1px solid rgba(226, 191, 114, 0.18);
  border-radius: 6px;
  display: grid;
  grid-column: 1 / -1;
  justify-items: center;
  padding: 8px;
}

.building-total span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.building-total strong {
  color: #ffffff;
  font-size: 26px;
}

.material-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  grid-column: 1 / -1;
  justify-content: center;
}

.material-tags span,
.inventory-item span,
.shopping-row span {
  background: rgba(226, 191, 114, 0.13);
  border: 1px solid rgba(226, 191, 114, 0.2);
  border-radius: 999px;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  padding: 6px 8px;
}

.material-pill {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.material-pill.icon-only {
  border-radius: 12px;
  height: 42px;
  justify-content: center;
  padding: 5px;
  width: 42px;
}

.material-pill img {
  height: 22px;
  object-fit: contain;
  width: 22px;
}

.material-pill.icon-only img {
  height: 30px;
  width: 30px;
}

.inventory-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.inventory-item {
  background: var(--card-dark);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.shopping-row {
  align-items: center;
  background: var(--card-dark);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 46px minmax(0, 1fr);
  justify-items: stretch;
  min-height: 78px;
  padding: 10px;
}

.export-material-toggle {
  cursor: pointer;
  margin: 0;
  min-height: 0;
}

.export-material-toggle:hover,
.export-material-toggle:focus-visible {
  border-color: var(--line-bright);
}

.shopping-row.is-export-excluded {
  opacity: 0.46;
}

.shopping-row.is-export-excluded strong {
  text-decoration: line-through;
}

.shopping-row.is-export-excluded .export-material-toggle {
  filter: grayscale(1);
}

.shopping-list {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  padding: 0 18px 18px;
}

.shopping-row strong {
  color: var(--accent);
  font-size: 32px;
  font-variant-numeric: tabular-nums;
  justify-self: end;
  line-height: 1;
  padding-right: 2px;
  text-align: right;
}

.empty-state {
  background: var(--card-dark);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 14px;
}

footer {
  color: #a9a9a9;
  font-size: 13px;
  font-weight: 700;
  margin: 0 auto;
  max-width: 1180px;
  padding: 0 20px 30px;
}

@media (max-width: 980px) {
  .tool-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .tool-header nav {
    width: 100%;
  }

  .tool-header .site-account {
    margin-left: 0;
  }

  .workspace-grid,
  .building-list,
  .inventory-grid {
    grid-template-columns: 1fr;
  }

  .side-column {
    display: contents;
  }

  .shopping-panel {
    order: -1;
  }

  .inventory-panel {
    order: 2;
  }
}

@media (max-width: 620px) {
  main {
    padding: 20px 12px 34px;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .building-card {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .building-visual {
    height: 92px;
    width: 84px;
  }

  .level-row {
    grid-template-columns: minmax(74px, 1fr) minmax(78px, 0.72fr);
  }

  .section-heading {
    display: grid;
  }
}
