@font-face {
  font-family: Anton;
  src: url("./fonts/anton-latin.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #12110e;
  --ink: #f6f1e8;
  --muted: #d9cbb8;
  --line: #3f382e;
  --panel: #1c1914;
  --field: #100e0b;
  --yellow: #ffd23f;
  --red: #ff4d3a;
  --warn: #ffb020;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 0% -10%, #3a2a14 0%, transparent 60%),
    radial-gradient(700px 380px at 100% 0%, #3a1410 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.45 ui-sans-serif, system-ui, sans-serif;
}

.wrap {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

h1 {
  margin: 0;
  font-family: Anton, Impact, sans-serif;
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  font-weight: 400;
  letter-spacing: 0.03em;
  line-height: 0.9;
}

.top { padding: 18px 0 6px; }

.top p {
  margin: 8px 0 0;
  max-width: 36rem;
  color: var(--muted);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 20px;
  align-items: start;
  padding-bottom: 8px;
}

.stage {
  background: #0c0b09;
  border-radius: 18px;
  padding: 10px;
  box-shadow: 0 18px 50px rgb(0 0 0 / 35%);
}

.stage.drag { outline: 3px dashed var(--yellow); outline-offset: -14px; }

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  background: #000;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

button, .file {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #2a251e;
  color: var(--ink);
  min-height: 44px;
  padding: 10px 16px;
  touch-action: manipulation;
}

#download {
  background: var(--red);
  border-color: var(--red);
  color: #1a0907;
  font-weight: 750;
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

legend, .field-name, .check {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

legend { margin-bottom: 8px; }

.templates {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 72px));
  justify-content: center;
  gap: 8px;
  margin: 0 0 8px;
}

.templates button {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 12px;
  border: 2px solid transparent;
  overflow: hidden;
  background: #000;
}

.templates button[aria-pressed="true"] {
  border-color: var(--yellow);
}

.templates img, .swatch {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px #4a4338;
}

.file {
  display: inline-flex;
  align-items: center;
  position: relative;
}

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

.fine, .foot, .status {
  color: var(--muted);
  font-size: 0.9rem;
}

.fine { margin: 8px 0 0; text-transform: none; letter-spacing: 0; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field-name { display: flex; justify-content: space-between; align-items: baseline; }

textarea {
  width: 100%;
  resize: vertical;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #4a4338;
  background: var(--field);
  color: var(--ink);
  font: 16px/1.35 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0;
  text-transform: none;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--yellow);
  height: 28px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1rem;
  color: var(--ink);
  min-height: 44px;
}

.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--yellow); }

.warn {
  margin: 0;
  color: var(--warn);
  font-size: 0.95rem;
}

.status { min-height: 1.4em; margin: 10px 0 0; }

.foot { padding: 4px 0 20px; }

.foot p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.file:focus-within {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .top { padding-top: 18px; }
  .actions button { flex: 1 1 auto; }
  .templates {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
