:root {
  --void: #05070c;
  --ink: #e8eef7;
  --muted: #8b9bb0;
  --accent: #70c0e8;
  --accent-soft: rgba(112, 192, 232, 0.14);
  --line: rgba(232, 238, 247, 0.1);
  --panel: rgba(12, 16, 24, 0.88);
  --warn: #e4b84a;
  --ok: #8fd0a8;
  --font-display: "Syne", "Segoe UI", sans-serif;
  --font-ui: "Sora", "Segoe UI", sans-serif;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

@font-face {
  font-family: "Duitech";
  src: url("../fonts/Duitech.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Futech";
  src: url("../fonts/Futech.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Galactech";
  src: url("../fonts/Galactech.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geekomet";
  src: url("../fonts/Geekomet.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Grete";
  src: url("../fonts/Grete.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Kotech";
  src: url("../fonts/Kotech.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Magistech";
  src: url("../fonts/magistech.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Motech";
  src: url("../fonts/Motech.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Netech";
  src: url("../fonts/Netech.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Ortech";
  src: url("../fonts/Ortech.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Rubeus";
  src: url("../fonts/Rubeus.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Techetic";
  src: url("../fonts/Techetic.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Techmoon";
  src: url("../fonts/Techmoon.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Techmoon 2";
  src: url("../fonts/Techmoon2.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Techno Codex";
  src: url("../fonts/Techno-Codex.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vontech";
  src: url("../fonts/Vontech.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(112, 192, 232, 0.16), transparent 60%),
    var(--void);
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--accent); }

.glow {
  pointer-events: none;
  position: fixed;
  inset: auto 0 0 0;
  height: 40vh;
  background: radial-gradient(50% 80% at 80% 100%, rgba(112, 192, 232, 0.08), transparent 70%);
}

.top, .wrap, .foot {
  position: relative;
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 8px;
}

.brand {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand span { color: var(--accent); }


.intro { padding: 18px 0 8px; }

h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.intro p, .hint, .foot p {
  margin: 0;
  color: var(--muted);
}

.intro p { max-width: 62ch; }

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding: 22px 0 28px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.controls { padding: 18px 18px 8px; }

.preview {
  padding: 18px;
  position: sticky;
  top: 16px;
}

.field { margin: 0 0 16px; }

.field-head, .fit-row, .colors, .actions, .chips, .split {
  display: flex;
  gap: 10px;
}

.field-head, .fit-row { justify-content: space-between; align-items: baseline; }

.fit-row {
  flex-direction: column;
  align-items: stretch;
  margin-top: 10px;
}

.split { align-items: end; }
.split .field { flex: 1; }

label, legend {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

legend { padding: 0; }

fieldset {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}

.count {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-size: 0.85rem;
}

textarea, select {
  width: 100%;
  margin-top: 8px;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  resize: vertical;
}

textarea:focus, select:focus, input[type="range"]:focus-visible {
  outline: 2px solid rgba(112, 192, 232, 0.55);
  outline-offset: 2px;
}

.chips { flex-wrap: wrap; margin-top: 8px; }

.chip, .btn {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  padding: 7px 12px;
  cursor: pointer;
}

.chip:hover, .btn:hover { border-color: rgba(112, 192, 232, 0.45); }

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.segmented.two { grid-template-columns: 1fr 1fr; }

.word-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

#wordFields[hidden] { display: none; }

.word-font { margin-top: 10px; }

.word-grid .span { grid-column: 1 / -1; }

.word-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.flip {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.flip input { accent-color: var(--accent); }

.word-grid input[type="text"] {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.word-grid input:focus {
  outline: 2px solid rgba(112, 192, 232, 0.55);
  outline-offset: 2px;
}

.segmented label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.segmented small {
  color: var(--muted);
  font-weight: 500;
}

.segmented input { position: absolute; opacity: 0; pointer-events: none; }

.segmented label:has(input:checked) {
  background: var(--accent-soft);
  border-color: rgba(112, 192, 232, 0.7);
  color: var(--accent);
}

.segmented label:has(input:focus-visible) {
  outline: 2px solid rgba(112, 192, 232, 0.55);
  outline-offset: 2px;
}

.hint { font-size: 0.82rem; margin-top: 8px; }

input[type="range"] {
  width: 100%;
  margin-top: 10px;
  accent-color: var(--accent);
}

.colors { align-items: center; flex-wrap: wrap; margin-top: 8px; }

.swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
}

.swatch input[type="color"] {
  width: 42px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.swatch.is-off { opacity: 0.4; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
}

.stage {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 12px;
  border-radius: 14px;
  background: #0b1018;
}

.stage-world {
  position: relative;
  margin-inline: auto;
}

.qr-plate { position: absolute; }

.qr-plate canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.btn-fit.is-on {
  box-shadow: inset 0 0 0 2px #071018;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 0;
  min-height: 1.6em;
}

.stats span {
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  font-size: 0.8rem;
}

.stats .ok { color: var(--ok); border-color: rgba(143, 208, 168, 0.35); }
.stats .warn { color: var(--warn); border-color: rgba(228, 184, 74, 0.4); }

.error {
  margin: 10px 0 0;
  color: #ffb4b4;
}

.actions { flex-wrap: wrap; margin-top: 14px; }

.btn-primary, .btn-fit {
  background: var(--accent);
  color: #071018;
  border-color: transparent;
  font-weight: 600;
}

.btn-primary:hover, .btn-fit:hover { filter: brightness(1.05); }

.btn:disabled, .btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}

.status {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--accent);
  font-size: 0.85rem;
}

.foot {
  padding: 8px 0 36px;
  font-size: 0.82rem;
  max-width: 68ch;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .preview { position: static; }
  .segmented { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
}
