:root {
  color-scheme: dark;
  --sky-top: #0b1721;
  --sky-mid: #172c38;
  --sky-low: #6f6750;
  --ink: #f2ead4;
  --muted: #b8bea9;
  --gold: #f0b94b;
  --gold-light: #ffd875;
  --grass: #638846;
  --grass-light: #7fa354;
  --grass-dark: #3f5f37;
  --earth: #76523b;
  --earth-dark: #493426;
  --stone: #68747a;
  --stone-dark: #424e54;
  --night-panel: rgba(11, 23, 33, .92);
  --night-panel-light: rgba(23, 44, 56, .92);
  --line: rgba(226, 220, 190, .2);
  --line-strong: rgba(240, 185, 75, .45);
  --pixel-shadow: 6px 6px 0 rgba(3, 9, 13, .4);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--sky-top);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(180deg, var(--sky-top) 0, #10202b 26rem, var(--sky-mid) 52rem, #3e4a46 78rem, var(--sky-low) 100%);
  background-size: 24px 24px, 24px 24px, auto;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }

.world-decor {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.pixel-star {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 237, 180, .78);
  box-shadow: 7px 0 rgba(255,237,180,.35), 0 7px rgba(255,237,180,.35), -7px 0 rgba(255,237,180,.18), 0 -7px rgba(255,237,180,.18);
}
.star-one { top: 110px; left: 7%; }
.star-two { top: 210px; right: 14%; transform: scale(.7); }
.star-three { top: 390px; left: 44%; transform: scale(.55); }

.pixel-moon {
  position: absolute;
  top: 95px;
  right: 7vw;
  width: 56px;
  height: 56px;
  opacity: .22;
  background: var(--gold-light);
  box-shadow: 8px 8px 0 rgba(240,185,75,.22), -5px -5px 0 rgba(255,255,255,.08);
}

.pixel-cloud {
  position: absolute;
  top: 290px;
  left: 4vw;
  width: 112px;
  height: 22px;
  opacity: .09;
  background: #dce3d7;
  box-shadow: 24px -16px #dce3d7, 66px -8px #dce3d7, 94px 0 #dce3d7;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  min-height: 74px;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 0 max(24px, calc((100vw - 1480px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(8, 18, 25, .86);
  backdrop-filter: blur(13px);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 3px;
  opacity: .5;
  background: repeating-linear-gradient(90deg, var(--grass-light) 0 32px, var(--grass) 32px 64px, var(--grass-dark) 64px 96px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: .11em;
  font-size: .92rem;
  font-weight: 750;
}
.brand strong { color: var(--gold); }

.brand-cube, .empty-cube {
  width: 22px;
  aspect-ratio: 1;
  display: block;
  background: var(--gold);
  box-shadow: 4px -4px 0 rgba(255,216,117,.5), -4px 4px 0 rgba(86,53,20,.75);
}

.beta-badge {
  padding: 4px 7px;
  border: 1px solid rgba(127,163,84,.62);
  color: var(--grass-light);
  background: rgba(63,95,55,.17);
  font: 750 .62rem/1 ui-monospace, "Cascadia Mono", monospace;
  letter-spacing: .12em;
}

.topbar p {
  margin: 0 0 0 auto;
  color: var(--muted);
  font: .66rem/1.4 ui-monospace, "Cascadia Mono", monospace;
  letter-spacing: .05em;
}

.app-shell {
  position: relative;
  z-index: 2;
  width: min(1480px, calc(100% - 48px));
  min-height: calc(100vh - 74px);
  margin: 34px auto 0;
  display: grid;
  grid-template-columns: minmax(370px, 485px) minmax(0, 1fr);
  align-items: stretch;
  border: 1px solid var(--line);
  background: rgba(7, 15, 20, .52);
  box-shadow: 12px 12px 0 rgba(3,9,13,.26), 0 28px 80px rgba(0,0,0,.22);
}

.control-panel {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(15,31,40,.96), rgba(21,39,44,.95));
}

.panel-section {
  position: relative;
  padding: 29px clamp(20px, 2.5vw, 34px);
  border-bottom: 1px solid var(--line);
}

.panel-section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 42px;
  height: 4px;
  background: var(--grass-light);
  box-shadow: 42px 0 var(--grass), 84px 0 var(--grass-dark);
}

.intro-section {
  padding-top: 37px;
  background: linear-gradient(135deg, rgba(127,163,84,.08), transparent 45%);
}

.step {
  display: block;
  margin-bottom: 9px;
  color: var(--gold);
  font: 750 .65rem/1.2 ui-monospace, "Cascadia Mono", monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.step.light { color: var(--gold-light); }

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: clamp(1.85rem, 3vw, 2.45rem);
  line-height: 1.02;
  letter-spacing: -.045em;
  text-shadow: 3px 3px 0 rgba(3,9,13,.35);
}
h2 { margin-bottom: 4px; color: var(--ink); font-size: 1.08rem; letter-spacing: -.02em; }

.section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.section-heading p, .section-note { margin-bottom: 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.section-heading.compact { align-items: end; margin-bottom: 15px; }

.dimension-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px; margin-top: 25px; }
.dimension-row label > span:first-child { display: block; margin-bottom: 7px; color: var(--muted); font: 750 .66rem ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.number-field {
  height: 48px;
  display: flex;
  align-items: center;
  border: 1px solid rgba(104,116,122,.72);
  background: rgba(5,13,18,.76);
  box-shadow: inset 3px 3px 0 rgba(0,0,0,.16);
}
.number-field:focus-within { border-color: var(--gold); box-shadow: inset 3px 3px 0 rgba(0,0,0,.16), 0 0 0 2px rgba(240,185,75,.12); }
.number-field input { width: 100%; min-width: 0; height: 100%; padding: 0 12px; border: 0; outline: 0; color: var(--ink); background: transparent; font-weight: 800; }
.number-field small { padding-right: 11px; color: #7f8e8c; font: .58rem ui-monospace, monospace; text-transform: uppercase; }
.dimension-cross { padding-bottom: 14px; color: var(--gold); font-weight: 800; }
.field-hint { margin: 9px 0 0; color: #82908a; font: .66rem ui-monospace, monospace; }
.performance-warning { margin: 12px 0 0; padding: 10px 11px; border: 1px solid rgba(240,185,75,.58); color: #d9cfad; background: rgba(104,66,24,.3); font: .63rem/1.45 ui-monospace, monospace; }
.performance-warning[hidden] { display: none; }
.performance-warning strong { color: var(--gold-light); }

.surface-picker { min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 22px 0 0; padding: 0; border: 0; }
.surface-picker legend { grid-column: 1/-1; margin-bottom: 8px; padding: 0; color: var(--muted); font: 750 .66rem ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.surface-picker label { min-width: 0; cursor: pointer; }
.surface-picker input { position: absolute; opacity: 0; pointer-events: none; }
.surface-option { min-height: 58px; display: grid; grid-template-rows: auto auto; align-content: center; row-gap: 3px; padding: 9px 14px; border: 1px solid rgba(104,116,122,.55); background: rgba(5,13,18,.66); box-shadow: inset -3px -3px rgba(0,0,0,.12); }
.surface-option strong { align-self: end; color: var(--ink); font-size: .73rem; }
.surface-option small { align-self: start; overflow: hidden; color: #82908b; font: .56rem ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.surface-picker input:checked + .surface-option { border-color: var(--gold); background: rgba(73,52,38,.54); box-shadow: inset 4px 0 var(--grass-light), 3px 3px 0 rgba(0,0,0,.22); }
.surface-picker input:focus-visible + .surface-option { outline: 2px solid var(--gold-light); outline-offset: 2px; }

.catalog-count { color: #8d998f; font: .63rem ui-monospace, monospace; white-space: nowrap; }
.search-box {
  height: 49px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid rgba(104,116,122,.68);
  background: rgba(4,12,17,.78);
  box-shadow: inset 3px 3px 0 rgba(0,0,0,.18);
}
.search-box:focus-within { border-color: var(--gold); box-shadow: inset 3px 3px 0 rgba(0,0,0,.18), 0 0 0 2px rgba(240,185,75,.12); }
.search-icon { width: 14px; height: 14px; flex: 0 0 auto; position: relative; border: 2px solid var(--muted); border-radius: 50%; }
.search-icon::after { content: ""; position: absolute; right: -5px; bottom: -2px; width: 6px; height: 2px; background: var(--muted); transform: rotate(45deg); }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: .77rem; }
.search-box input::placeholder { color: #6d7a78; }
kbd { padding: 2px 6px; border: 1px solid rgba(184,190,169,.28); color: #89958e; background: #13232c; font: .67rem ui-monospace, monospace; }

.color-picker-panel { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; margin: 13px 0 14px; }
.color-picker-control { min-width: 0; min-height: 50px; display: grid; grid-template-columns: 34px minmax(0,1fr); align-items: center; gap: 10px; padding: 7px 10px; border: 1px solid rgba(184,190,169,.25); background: rgba(13,29,37,.72); cursor: pointer; }
.color-picker-control:hover, .color-picker-control:focus-within { border-color: var(--gold); background: rgba(73,52,38,.45); }
.color-picker-control input { width: 34px; height: 34px; padding: 0; border: 2px solid var(--stone-dark); background: transparent; cursor: pointer; }
.color-picker-control input::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker-control input::-webkit-color-swatch { border: 0; }
.color-picker-control input::-moz-color-swatch { border: 0; }
.color-picker-control strong { display: block; color: var(--ink); font-size: .71rem; }
.color-picker-control small { display: block; margin-top: 3px; color: #8b9891; font: .59rem ui-monospace, monospace; }
.clear-color { padding: 0 10px; border: 1px solid rgba(184,190,169,.25); color: var(--muted); background: rgba(8,20,27,.72); font: 700 .6rem ui-monospace, monospace; cursor: pointer; }
.clear-color:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-light); }
.clear-color:disabled { opacity: .38; cursor: not-allowed; }

.category-filter { min-width: 0; margin: 0 0 14px; padding: 0; border: 0; }
.category-filter legend { margin-bottom: 7px; color: var(--muted); font: 700 .6rem ui-monospace, monospace; letter-spacing: .13em; text-transform: uppercase; }
.category-options { display: flex; flex-wrap: wrap; gap: 6px; }
.category-chip {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid rgba(184,190,169,.25);
  color: #b8beb2;
  background: rgba(8,20,27,.72);
  font: 700 .61rem ui-monospace, monospace;
  cursor: pointer;
}
.category-chip:hover { border-color: var(--gold); color: var(--ink); }
.category-chip.active { border-color: var(--gold); color: #17130b; background: var(--gold-light); box-shadow: inset -2px -2px rgba(99,66,17,.24); }
.category-chip:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 2px; }

.creative-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 11px;
  border: 1px solid rgba(184,190,169,.2);
  background: rgba(13,29,37,.68);
  cursor: pointer;
}
.creative-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 34px; height: 18px; padding: 2px; display: block; border: 1px solid #66736b; background: #152732; }
.toggle-track i { width: 12px; height: 12px; display: block; background: var(--stone); transition: transform .18s ease, background .18s ease; }
.creative-toggle input:checked + .toggle-track { border-color: var(--grass-light); background: var(--grass-dark); }
.creative-toggle input:checked + .toggle-track i { background: var(--gold-light); transform: translateX(16px); }
.creative-toggle input:focus-visible + .toggle-track { outline: 2px solid var(--gold); outline-offset: 2px; }
.creative-toggle strong { display: block; color: var(--ink); font-size: .7rem; }
.creative-toggle small { display: block; margin-top: 2px; color: #88958d; font-size: .59rem; line-height: 1.35; }

.search-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  max-height: 340px;
  padding: 2px 4px 2px 2px;
  overflow: auto;
  scrollbar-color: var(--stone) rgba(5,13,18,.45);
}

.result-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid rgba(104,116,122,.45);
  background: rgba(8,20,27,.8);
  box-shadow: inset -2px -2px rgba(0,0,0,.16);
  text-align: left;
  cursor: pointer;
}
.result-card:hover, .result-card:focus-visible { border-color: var(--gold); background: rgba(37,54,55,.94); outline: 0; transform: translate(-1px,-1px); box-shadow: 3px 3px 0 rgba(0,0,0,.26); }
.result-card.selected { opacity: .78; cursor: pointer; transform: none; box-shadow: inset 3px 0 var(--grass-light); }
.result-card.selected:hover, .result-card.selected:focus-visible { border-color: #ff8c75; background: rgba(84,48,40,.62); }
.result-card.selected .add-mark { color: #ff8c75; }

.texture-frame {
  width: 42px;
  aspect-ratio: 1;
  display: block;
  overflow: hidden;
  background: var(--stone-dark);
  image-rendering: pixelated;
  box-shadow: inset -3px -3px rgba(0,0,0,.2), inset 2px 2px rgba(255,255,255,.09);
}
.texture-frame img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.result-copy, .selected-copy { min-width: 0; }
.result-copy strong, .selected-copy strong { display: block; overflow: hidden; color: var(--ink); font-size: .72rem; white-space: nowrap; }
.result-copy small, .selected-copy small { display: block; overflow: hidden; margin-top: 3px; color: #7f8d88; font: .57rem ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.scrolling-name > span { display: inline-block; min-width: max-content; }
.scrolling-name.overflowing > span { animation: block-name-scroll var(--marquee-duration, 6s) linear 1s infinite; }
.add-mark { color: var(--gold-light); font-size: 1rem; text-shadow: 2px 2px 0 rgba(0,0,0,.28); }
.no-results { grid-column: 1/-1; padding: 22px 8px; color: var(--muted); font-size: .78rem; text-align: center; }
.weight-total { padding: 6px 9px; border: 1px solid rgba(127,163,84,.74); color: var(--gold-light); background: rgba(63,95,55,.36); font: 750 .68rem ui-monospace, monospace; box-shadow: 3px 3px 0 rgba(0,0,0,.18); }
.palette-tools { display: flex; align-items: center; gap: 8px; }
.clear-palette { min-height: 29px; padding: 0 9px; border: 1px solid rgba(184,190,169,.26); color: var(--muted); background: rgba(8,20,27,.7); font: 700 .61rem ui-monospace, monospace; cursor: pointer; }
.clear-palette:hover:not(:disabled) { border-color: #ff8c75; color: #ffb09f; background: rgba(84,48,40,.48); }
.clear-palette:disabled { opacity: .36; cursor: not-allowed; }
.section-note { margin: -7px 0 13px; }
.selected-blocks { display: grid; gap: 7px; }
.selected-card {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr) 78px 28px;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid rgba(104,116,122,.45);
  background: rgba(8,20,27,.8);
}
.weight-input { height: 34px; display: flex; align-items: center; border: 1px solid rgba(104,116,122,.62); background: rgba(4,12,17,.82); }
.weight-input input { width: 100%; min-width: 0; padding-left: 8px; border: 0; outline: 0; color: var(--gold-light); background: transparent; text-align: right; font: 750 .72rem ui-monospace, monospace; }
.weight-input span { padding: 0 7px 0 3px; color: #81908c; font-size: .65rem; }
.remove-button { width: 28px; height: 28px; border: 0; background: transparent; color: #87938c; cursor: pointer; font-size: 1.05rem; }
.remove-button:hover { color: #ff8c75; background: rgba(118,82,59,.38); }
.palette-empty { padding: 17px; border: 1px dashed rgba(184,190,169,.3); color: #8c9991; background: rgba(8,20,27,.42); font-size: .76rem; text-align: center; }

.preview-panel {
  min-width: 0;
  padding: clamp(25px, 3.4vw, 52px);
  background: linear-gradient(145deg, rgba(11,23,33,.9), rgba(23,44,56,.84));
}
.preview-header, .preview-footer, .materials-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.preview-header { margin-bottom: 18px; }
.preview-header h2 { margin: 0; font-size: 1.48rem; text-shadow: 3px 3px 0 rgba(0,0,0,.28); }
.preview-header h2 span { color: var(--muted); font-weight: 500; }
.preview-actions { display: flex; gap: 8px; }

.button {
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
  font-size: .73rem;
  letter-spacing: .02em;
}
.button:disabled { opacity: .4; cursor: not-allowed; }
.button.secondary { border-color: rgba(184,190,169,.3); color: var(--ink); background: rgba(19,39,50,.9); box-shadow: 3px 3px 0 rgba(0,0,0,.22); }
.button.secondary:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-light); transform: translate(-1px,-1px); box-shadow: 4px 4px 0 rgba(0,0,0,.28); }
.button.icon-button { width: 43px; padding: 0; }
.zoom-icon { width: 22px; height: 22px; display: block; object-fit: contain; filter: brightness(0) invert(94%); }
.button.secondary:hover:not(:disabled) .zoom-icon { filter: brightness(0) saturate(100%) invert(87%) sepia(55%) saturate(707%) hue-rotate(344deg) brightness(104%); }
.png-icon { width: 16px; height: 14px; position: relative; flex: 0 0 auto; display: inline-block; border: 2px solid currentColor; }
.png-icon::before { content: ""; width: 3px; height: 3px; position: absolute; top: 2px; right: 2px; background: currentColor; }
.png-icon::after { content: ""; width: 10px; height: 7px; position: absolute; left: 1px; bottom: 1px; background: currentColor; clip-path: polygon(0 100%, 32% 38%, 52% 64%, 75% 20%, 100% 100%); }
.button.primary { min-width: 194px; color: #2b2114; background: var(--gold); box-shadow: 5px 5px 0 #6e4821; }
.button.primary:hover:not(:disabled) { background: var(--gold-light); transform: translate(-1px,-1px); box-shadow: 6px 6px 0 #6e4821; }

.palette-dialog { width: min(720px,calc(100% - 30px)); max-height: min(760px,calc(100vh - 34px)); margin: auto; padding: 24px; overflow: auto; border: 1px solid var(--gold); color: var(--ink); background: linear-gradient(145deg,#0b1721,#172c38); box-shadow: 10px 10px 0 rgba(0,0,0,.42); }
.palette-dialog::backdrop { background: rgba(1,6,9,.76); backdrop-filter: blur(3px); }
.palette-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.palette-dialog h2 { margin: 7px 0 0; font-size: 1.45rem; }
.palette-dialog>p { margin: 15px 0; color: var(--muted); font-size: .76rem; }
.palette-dialog-header>button { width: 36px; height: 36px; border: 1px solid rgba(184,190,169,.3); color: var(--ink); background: #102530; cursor: pointer; font-weight: 850; }
.palette-dialog-header>button:hover { border-color: var(--gold); color: var(--gold-light); }
.ratio-toggle { display: flex; align-items: center; gap: 9px; margin-bottom: 15px; padding: 10px; border: 1px solid rgba(184,190,169,.23); background: rgba(8,20,27,.68); cursor: pointer; }
.ratio-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.ratio-toggle>span { width: 18px; height: 18px; border: 1px solid var(--stone); background: #0b1921; }
.ratio-toggle input:checked+span { border-color: var(--grass-light); background: var(--grass-light); box-shadow: inset 0 0 0 4px #172c38; }
.ratio-toggle input:focus-visible+span { outline: 2px solid var(--gold); outline-offset: 2px; }
.ratio-toggle strong { font-size: .68rem; }
.published-palettes { display: grid; gap: 8px; }
.published-palette { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 10px; border: 1px solid rgba(104,116,122,.48); background: rgba(7,18,24,.82); }
.published-textures { display: flex; }
.published-textures img { width: 36px; height: 36px; margin-right: -7px; border: 2px solid #3c494e; image-rendering: pixelated; }
.published-palette strong,.published-palette small { display: block; }
.published-palette strong { font-size: .73rem; }
.published-palette small { margin-top: 4px; color: #89958d; font: .57rem ui-monospace,monospace; }
.published-palette button { min-height: 34px; padding: 0 10px; border: 1px solid var(--gold); color: #21180b; background: var(--gold); cursor: pointer; font-size: .64rem; font-weight: 850; }
.published-palette button:hover { background: var(--gold-light); }

.pattern-stage {
  position: relative;
  min-height: 430px;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 38px);
  overflow: hidden;
  border: 1px solid rgba(226,220,190,.28);
  background:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
    #08131a;
  background-size: 16px 16px;
  box-shadow: inset 8px 8px 0 rgba(0,0,0,.14), var(--pixel-shadow);
}
.pattern-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 40%, rgba(127,163,84,.13), transparent 58%);
}
.pattern-stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: repeating-linear-gradient(90deg, var(--grass-light) 0 30px, var(--grass) 30px 60px, var(--grass-dark) 60px 90px);
}
.pattern-grid { --columns: 10; position: relative; z-index: 2; width: min(100%, 760px); display: grid; grid-template-columns: repeat(var(--columns), 1fr); border: 3px solid var(--stone-dark); box-shadow: 8px 8px 0 rgba(0,0,0,.36); user-select: none; -webkit-user-select: none; }
.pattern-grid[hidden] { display: none; }
.pattern-tile { position: relative; min-width: 0; aspect-ratio: 1; overflow: hidden; background: var(--stone-dark); image-rendering: pixelated; user-select: none; -webkit-user-select: none; }
.pattern-texture { position: absolute; inset: 0; display: block; background-position: top left; background-repeat: no-repeat; background-size: 100% auto; image-rendering: pixelated; pointer-events: none; user-select: none; -webkit-user-select: none; }
.pattern-tile::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.11); }

.empty-pattern { position: absolute; z-index: 3; display: grid; justify-items: center; text-align: center; color: var(--ink); }
.empty-pattern[hidden] { display: none; }
.empty-pattern .empty-cube { width: 44px; margin-bottom: 18px; background: var(--grass); box-shadow: 7px -7px 0 var(--grass-light), -7px 7px 0 var(--earth-dark); }
.empty-pattern strong { text-shadow: 2px 2px 0 rgba(0,0,0,.36); }
.empty-pattern p { margin: 7px 0 0; color: var(--muted); font-size: .78rem; }

.zoom-controls { position: fixed; z-index: 12; left: 50%; bottom: 22px; transform: translateX(-50%); min-height: 48px; display: flex; align-items: center; gap: 8px; padding: 7px; border: 1px solid rgba(240,185,75,.55); background: rgba(7,17,23,.94); box-shadow: 5px 5px 0 rgba(0,0,0,.38); }
.zoom-controls[hidden] { display: none; }
.zoom-controls button { min-width: 34px; min-height: 34px; padding: 0 10px; border: 1px solid rgba(184,190,169,.3); color: var(--ink); background: #132732; font: 800 .68rem ui-monospace, monospace; cursor: pointer; }
.zoom-controls button:hover { border-color: var(--gold); color: var(--gold-light); }
.zoom-controls label { display: flex; align-items: center; gap: 8px; color: var(--muted); font: .6rem ui-monospace, monospace; text-transform: uppercase; }
.zoom-controls input { width: min(28vw, 220px); accent-color: var(--gold); cursor: pointer; }
.zoom-controls output { min-width: 46px; color: var(--gold-light); font: 700 .62rem ui-monospace, monospace; text-align: center; }

.pattern-stage:fullscreen, .pattern-stage.is-fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  padding: 28px 28px 92px;
  overflow: auto;
  place-items: start;
  border: 0;
}
.pattern-stage.is-fullscreen { position: fixed; z-index: 1000; inset: 0; }
.pattern-stage:fullscreen .pattern-grid, .pattern-stage.is-fullscreen .pattern-grid { width: var(--fullscreen-width); max-width: none; margin: auto; flex: 0 0 auto; }
.pattern-stage:fullscreen .empty-pattern, .pattern-stage.is-fullscreen .empty-pattern { position: relative; }
.pattern-stage:fullscreen::after, .pattern-stage.is-fullscreen::after { position: fixed; z-index: 11; bottom: 0; pointer-events: none; }

.preview-footer { padding: 20px 0 30px; border-bottom: 1px solid var(--line); }
.preview-footer > div { display: grid; gap: 4px; }
.meta-label { color: #94a097; font: .61rem ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.preview-footer strong { color: var(--ink); font-size: .84rem; }

.materials { padding-top: 28px; }
.materials-heading { margin-bottom: 14px; }
.materials-heading h2 { margin: 0; font-size: 1.1rem; }
.materials-heading > span { color: #8e9a92; font: .65rem ui-monospace, monospace; }
.materials-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.material-row { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 8px; border: 1px solid rgba(104,116,122,.4); background: rgba(8,20,27,.64); }
.material-row .texture-frame { width: 36px; }
.material-row strong { display: block; overflow: hidden; color: var(--ink); font-size: .73rem; white-space: nowrap; }
.material-row small { display: block; overflow: hidden; color: #82908b; font: .58rem ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }
.material-count { padding: 4px 6px; color: var(--gold-light); background: rgba(73,52,38,.6); font: 750 .75rem ui-monospace, monospace; }
.materials-empty { grid-column: 1/-1; padding: 21px; border: 1px dashed rgba(184,190,169,.28); color: #8b9890; background: rgba(8,20,27,.34); text-align: center; font-size: .76rem; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 360px; padding: 13px 16px; border: 1px solid var(--gold); background: #1a303a; color: var(--ink); box-shadow: 5px 5px 0 rgba(0,0,0,.3); font-size: .76rem; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; }
.toast.visible { opacity: 1; transform: none; }

.footer-zone {
  position: relative;
  isolation: isolate;
  min-height: clamp(105px, 15vh, 160px);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.site-footer {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-block: 21px 25px;
  color: rgba(223, 222, 202, .62);
  border-top: 1px solid var(--line);
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 750;
}

.footer-meta,
.footer-links {
  display: flex;
  align-items: center;
}

.footer-meta { gap: 18px; }
.footer-links { gap: 20px; }

.footer-links a {
  color: rgba(242, 234, 212, .72);
  text-decoration: none;
  text-underline-offset: 5px;
  transition: color .2s ease;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--gold-light);
  text-decoration: underline;
}

.footer-links a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 5px;
}

.license-shell { position: relative; z-index: 1; width: min(1180px, calc(100% - 48px)); min-height: calc(100vh - 230px); margin: 42px auto 64px; }
.license-hero { padding: clamp(28px, 5vw, 62px); border: 1px solid var(--line); background: linear-gradient(145deg, rgba(11,23,33,.96), rgba(23,44,56,.9)); box-shadow: var(--pixel-shadow); }
.license-hero h1 { max-width: 760px; margin: 10px 0 13px; font-size: clamp(2rem, 5vw, 4rem); line-height: .98; text-shadow: 4px 4px 0 rgba(0,0,0,.3); }
.license-hero > p { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.7; }
.back-link { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 26px; color: var(--gold-light); font: 750 .67rem ui-monospace, monospace; letter-spacing: .08em; text-decoration: none; text-transform: uppercase; }
.back-link:hover, .back-link:focus-visible { text-decoration: underline; text-underline-offset: 5px; }
.license-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 18px; }
.license-card { min-width: 0; padding: 24px; border: 1px solid rgba(184,190,169,.28); background: rgba(8,20,27,.82); box-shadow: inset -4px -4px rgba(0,0,0,.14); }
.license-card .step { display: block; margin-bottom: 10px; }
.license-card h2 { margin: 0 0 10px; font-size: 1.05rem; }
.license-card p { margin: 0; color: #aeb7a7; font-size: .76rem; line-height: 1.65; }
.license-card p + p { margin-top: 10px; }
.license-card a { color: var(--gold-light); text-underline-offset: 4px; }
.license-card a:hover, .license-card a:focus-visible { color: #fff1bd; }
.license-card code { color: #cbd1c0; font: .67rem ui-monospace, monospace; overflow-wrap: anywhere; }
.license-card.wide { grid-column: 1/-1; }
.license-icon-row { display: grid; grid-template-columns: 42px minmax(0,1fr); align-items: center; gap: 13px; }
.license-icon-row img { width: 36px; height: 36px; padding: 7px; background: var(--ink); image-rendering: auto; }
.footer-links a[aria-current="page"] { color: var(--gold-light); }

.footer-grid { display: flex; gap: 5px; }
.footer-grid i { display: block; width: 5px; height: 5px; background: rgba(127, 163, 84, .54); }

.terrain {
  position: absolute;
  z-index: 1;
  left: -4%;
  right: -4%;
  bottom: 0;
  height: clamp(105px, 15vh, 160px);
  background:
    linear-gradient(90deg, transparent 0 7%, rgba(255,255,255,.025) 7% 7.4%, transparent 7.4% 23%, rgba(0,0,0,.09) 23% 23.5%, transparent 23.5%),
    var(--earth);
  border-top: 18px solid var(--grass);
  box-shadow: inset 0 10px 0 var(--grass-dark), inset 0 25px 0 rgba(88, 64, 43, .35);
  clip-path: polygon(0 25px, 8% 25px, 8% 12px, 18% 12px, 18% 0, 43% 0, 43% 13px, 60% 13px, 60% 4px, 82% 4px, 82% 18px, 100% 18px, 100% 100%, 0 100%);
}

.terrain::after {
  content: "";
  position: absolute;
  inset: 46px 0 0;
  opacity: .22;
  background:
    linear-gradient(90deg, transparent 24%, #2b201a 24% 31%, transparent 31% 69%, #9a6e49 69% 74%, transparent 74%),
    linear-gradient(transparent 55%, rgba(34, 29, 25, .55) 55%);
  background-size: 190px 43px, 100% 58px;
}

@keyframes block-name-scroll {
  0%, 14% { transform: translateX(0); }
  86%, 100% { transform: translateX(calc(-1 * var(--marquee-distance))); }
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 410px minmax(0,1fr); }
  .search-results, .materials-list { grid-template-columns: 1fr; }
  .pattern-stage { min-height: 360px; }
}

@media (max-width: 800px) {
  .topbar { position: static; min-height: 66px; padding-inline: 20px; }
  .topbar p { display: none; }
  .app-shell { width: min(100% - 24px, 700px); margin-top: 22px; display: block; }
  .control-panel { border-right: 0; }
  .preview-panel { padding: 27px 18px 42px; }
  .search-results { grid-template-columns: repeat(2,minmax(0,1fr)); max-height: 370px; }
  .pattern-stage { min-height: 320px; }
  .license-grid { grid-template-columns: 1fr; }
  .license-card.wide { grid-column: auto; }
}

@media (max-width: 540px) {
  .world-decor { display: none; }
  .brand { font-size: .82rem; }
  .panel-section { padding: 26px 16px; }
  .surface-picker { grid-template-columns: 1fr; }
  .color-picker-panel { grid-template-columns: 1fr; }
  .clear-color { min-height: 34px; }
  .search-results { grid-template-columns: 1fr; }
  .selected-card { grid-template-columns: 38px minmax(0,1fr) 70px 28px; }
  .section-heading.compact { align-items: flex-start; }
  .palette-tools { align-items: flex-end; flex-direction: column-reverse; }
  .preview-header { align-items: flex-end; }
  .preview-actions .button { width: 43px; padding: 0; font-size: 0; }
  .preview-actions .button span { font-size: 1rem; }
  .palette-dialog { padding: 18px 12px; }
  .published-palette { grid-template-columns: auto minmax(0,1fr); }
  .published-palette button { grid-column: 1/-1; width: 100%; }
  .zoom-controls { width: calc(100% - 20px); bottom: 10px; justify-content: center; }
  .zoom-controls label span { display: none; }
  .zoom-controls input { width: min(30vw, 150px); }
  .preview-footer { display: grid; grid-template-columns: 1fr 1fr; }
  .preview-footer .primary { grid-column: 1/-1; width: 100%; }
  .materials-list { grid-template-columns: 1fr; }
  .site-footer { width: min(100% - 30px, 1180px); align-items: flex-start; flex-direction: column; gap: 16px; padding-block: 18px 22px; line-height: 1.5; }
  .license-shell { width: min(100% - 30px, 1180px); margin-top: 24px; }
  .license-hero { padding: 24px 18px; }
  .license-card { padding: 19px 16px; }
  .footer-meta { width: 100%; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .scrolling-name.overflowing > span { animation: none; }
}
