:root {
  --fog: #e8f1e4;
  --moss: #9bb59a;
  --pine: #244036;
  --ink: #163028;
  --lichen: #6f9a78;
  --brass: #7a6940;
  --soil: #d7e4d2;
  --line: rgba(22, 48, 40, 0.22);
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(80vw 50vh at 50% -8%, #f4f8f1 0%, transparent 58%),
    radial-gradient(55vw 50vh at 100% 110%, #c5d8c2 0%, transparent 50%),
    radial-gradient(45vw 36vh at 0% 100%, #d5e4cf 0%, transparent 46%),
    linear-gradient(180deg, #edf3e9 0%, #d3e0d0 52%, #c3d2c0 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  animation: grain 8s steps(4, end) infinite;
}

.mist {
  position: fixed;
  inset: auto;
  pointer-events: none;
  width: 70vw;
  height: 40vh;
  border-radius: 50%;
  filter: blur(40px);
  background: rgba(255, 255, 255, 0.28);
}

.mist-a {
  top: 8vh;
  left: -12vw;
  animation: drift 18s ease-in-out infinite;
}

.mist-b {
  right: -16vw;
  bottom: 4vh;
  width: 55vw;
  animation: drift 22s ease-in-out infinite reverse;
}

main {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 8vh 6vw 10vh;
  gap: 5vh;
}

header {
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  font-weight: 600;
  line-height: 1.25;
  animation: rise 1.1s ease both;
}

.lead {
  margin: 0.8rem 0 0;
  font-size: 1.05rem;
  line-height: 1.6;
  font-weight: 400;
  animation: rise 1.1s ease 0.12s both;
}

form {
  width: min(920px, 100%);
  display: grid;
  gap: 2.4rem;
  justify-items: center;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.direction {
  margin: 0;
  padding: 0;
  border: 0;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  animation: rise 1.1s ease 0.16s both;
}

.direction-option {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--soil) 72%, white);
  cursor: pointer;
  font-size: 0.95rem;
  user-select: none;
}

.direction-option:has(input:checked) {
  border-color: var(--pine);
  background: color-mix(in srgb, #e7f2e2 80%, white);
}

.direction-option input {
  accent-color: var(--pine);
}

.plots {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.plot {
  position: relative;
  display: grid;
  gap: 0.45rem;
  padding: 1.7rem 1.4rem 1.3rem;
  min-height: 210px;
  border: 1px dashed var(--line);
  background: color-mix(in srgb, var(--soil) 72%, white);
  cursor: pointer;
  transition: transform 0.35s ease, border-color 0.35s ease, background 0.35s ease;
  animation: rise 1.1s ease 0.2s both;
}

.plot:nth-child(2) {
  animation-delay: 0.28s;
}

.plot:hover,
.plot:focus-visible {
  transform: translateY(-4px);
  border-color: var(--pine);
  outline: none;
}

.plot.is-over {
  transform: translateY(-6px);
  border-color: var(--lichen);
  background: color-mix(in srgb, #e7f2e2 80%, white);
}

.plot.is-ready {
  border-style: solid;
  border-color: var(--pine);
}

.plot input {
  display: none;
}

.plot-kicker {
  font-size: 0.82rem;
  color: var(--brass);
}

.plot-title {
  font-size: 1.25rem;
  font-weight: 600;
}

.plot-hint,
.plot-status {
  font-size: 0.92rem;
  line-height: 1.55;
}

.plot-status {
  color: var(--lichen);
  min-height: 1.4em;
}

.plot-info {
  display: grid;
  gap: 0.2rem;
  margin-top: 0.35rem;
  font-size: 0.92rem;
  line-height: 1.55;
}

.plot-info[hidden] {
  display: none;
}

.plot-info p {
  margin: 0;
}

.plot-info .info-name {
  font-weight: 600;
}

.plot-info .info-warn {
  color: #7a3328;
}

.zip-link {
  justify-self: start;
  margin-top: 0.4rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--brass);
  font: inherit;
  font-size: 0.88rem;
  text-decoration: underline;
  text-underline-offset: 0.22em;
  cursor: pointer;
}

.make {
  appearance: none;
  border: 0;
  padding: 0.95rem 2.4rem;
  min-width: 12.5rem;
  background: var(--pine);
  color: var(--fog);
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease;
  animation: rise 1.1s ease 0.36s both;
}

.make:hover:not(:disabled) {
  background: #1b332c;
  transform: translateY(-2px);
}

.make:disabled {
  cursor: not-allowed;
  background: #7e9088;
}

.make.is-busy {
  animation: pulse 1.4s ease-in-out infinite;
}

.note {
  margin: 0;
  color: color-mix(in srgb, var(--ink) 62%, white);
  font-size: 0.9rem;
}

.note.is-error {
  color: #7a3328;
}

.mode {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  animation: rise 1.1s ease 0.1s both;
}

.mode-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--soil) 72%, white);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
}

.mode-btn.is-active {
  border-color: var(--pine);
  background: color-mix(in srgb, #e7f2e2 80%, white);
}

.inventory-panel {
  width: min(920px, 100%);
  display: grid;
  gap: 1.5rem;
  justify-items: stretch;
  animation: rise 1.1s ease 0.16s both;
}

.inventory-upload {
  min-height: 160px;
}

.inventory-body {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.4rem;
}

.inventory-list-wrap,
.inventory-add {
  display: grid;
  gap: 0.8rem;
  align-content: start;
  padding: 1.2rem 1.1rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--soil) 72%, white);
}

.inventory-list-wrap h2,
.inventory-add h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.inventory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
  max-height: 28rem;
  overflow: auto;
}

.inventory-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.inv-item-main {
  display: grid;
  gap: 0.15rem;
}

.inv-item-main strong {
  font-weight: 600;
}

.inv-prefab {
  font-size: 0.8rem;
  color: var(--brass);
}

.inv-qty {
  display: grid;
  gap: 0.15rem;
  font-size: 0.8rem;
}

.inv-qty input,
.field input,
.field select {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #f7faf5;
  padding: 0.35rem 0.45rem;
  min-width: 4.2rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.field-inline {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.7rem;
}

.field select {
  width: 100%;
  min-height: 11rem;
}

.inventory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.make-secondary {
  background: color-mix(in srgb, var(--pine) 72%, #5a6e64);
}

.inv-remove {
  appearance: none;
  border: 0;
  background: none;
  color: #7a3328;
  font: inherit;
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.inventory-empty {
  margin: 0;
  color: color-mix(in srgb, var(--ink) 62%, white);
}

.ad-slot {
  width: min(920px, 100%);
}

.ad-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 90px;
  padding: 1rem;
  border: 1px dashed var(--line);
  color: inherit;
  text-decoration: none;
  background: color-mix(in srgb, var(--soil) 55%, white);
}

.ad-label {
  position: absolute;
  top: 0.45rem;
  left: 0.55rem;
  font-size: 0.75rem;
  color: var(--brass);
}

.ad-copy {
  color: color-mix(in srgb, var(--ink) 55%, white);
  font-size: 0.9rem;
}

.ad-img {
  max-width: 100%;
  max-height: 90px;
  object-fit: contain;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(6vw, -2vh, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes grain {
  0%,
  100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-1%, 1%);
  }
  50% {
    transform: translate(1%, -1%);
  }
  75% {
    transform: translate(-1%, -1%);
  }
}

@keyframes pulse {
  50% {
    filter: brightness(1.12);
  }
}

@media (max-width: 760px) {
  main {
    padding-top: 10vh;
    align-content: start;
  }

  .plots,
  .inventory-body {
    grid-template-columns: 1fr;
  }

  .inventory-list li {
    grid-template-columns: 1fr;
  }
}
