@font-face {
  font-family: 'Bangers';
  font-style: normal;
  font-weight: 400;
  src: url('../assets/fonts/bangers.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 600;
  src: url('../assets/fonts/baloo2-600.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Baloo 2';
  font-style: normal;
  font-weight: 800;
  src: url('../assets/fonts/baloo2-800.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg: #fbf1de;
  --panel: #fffdf8;
  --ink: #1b1420;
  --line: #1b1420;
  --sub: #5b5163;
  --red: #e31b23;
  --red-ink: #b3121a;
  --blue: #1b3fa0;
  --gold: #ffc53d;
  --shadow: #1b1420;
  --field-bg: #f4e9d4;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #120e1a;
    --panel: #1e1830;
    --ink: #f3ece0;
    --line: #e8dfc9;
    --sub: #b9aecf;
    --red: #ff5864;
    --red-ink: #ff3b48;
    --blue: #7fa2ff;
    --gold: #ffc53d;
    --shadow: #05030a;
    --field-bg: #150f22;
  }
}

* { box-sizing: border-box; }
html {
  background: var(--bg);
  background-image:
    radial-gradient(circle, color-mix(in srgb, var(--ink) 10%, transparent) 1.6px, transparent 1.6px);
  background-size: 22px 22px;
}
body {
  margin: 0;
  background: transparent;
  color: var(--ink);
  font-family: 'Baloo 2', 'Segoe UI', sans-serif;
  font-weight: 600;
  overflow-x: hidden;
}
h1, h2, h3 { font-weight: normal; text-wrap: balance; }

.comic-panel {
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 18px;
  box-shadow: 7px 7px 0 var(--shadow);
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }

header.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 16px 40px;
  gap: 24px;
}
.logo-mark {
  width: min(560px, 92%);
  height: auto;
  display: block;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}
.hero p.tagline {
  max-width: 46ch;
  margin: 4px 0 0;
  color: var(--sub);
  font-size: 17px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
}

.panel { padding: 26px; }

.step { margin-bottom: 28px; }
.step:last-child { margin-bottom: 0; }
.step-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--red);
  color: #fff8ec;
  border: 3px solid var(--line);
  font-family: 'Bangers', cursive;
  font-size: 18px;
  flex: none;
}
.step-head h2 {
  font-family: 'Bangers', cursive;
  font-size: 24px;
  letter-spacing: 0.5px;
  margin: 0;
  color: var(--ink);
}

.template-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 14px;
}
.template-card {
  font: inherit;
  cursor: pointer;
  background: var(--field-bg);
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 4px 4px 0 var(--shadow);
  transition: transform 0.12s ease;
  color: var(--ink);
}
.template-card img { width: 100%; aspect-ratio: 4/5; object-fit: contain; }
.template-card span { font-weight: 800; font-size: 13px; text-align: center; }
.template-card:hover { transform: translate(-2px, -2px); }
.template-card.selected {
  border-color: var(--red);
  box-shadow: 4px 4px 0 var(--red);
  transform: rotate(-1.5deg);
}

.drop-zone {
  border: 3px dashed var(--line);
  border-radius: 14px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--field-bg);
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--blue); }
.drop-zone strong { font-family: 'Bangers', cursive; font-size: 20px; letter-spacing: 0.5px; }
.drop-zone .drop-hint { color: var(--sub); font-size: 13px; margin: 6px 0 0; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field span.label { font-weight: 800; font-size: 14px; }
.field input[type="text"] {
  font: inherit;
  padding: 11px 13px;
  border: 3px solid var(--line);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--ink);
}
.field input[type="text"]:focus, .drop-zone:focus-visible, .btn:focus-visible, .template-card:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.field input[type="range"] {
  width: 100%;
  accent-color: var(--red);
}

.btn {
  font-family: 'Bangers', cursive;
  letter-spacing: 1px;
  font-size: 19px;
  border: 3px solid var(--line);
  border-radius: 12px;
  padding: 13px 18px;
  cursor: pointer;
  width: 100%;
  background: var(--gold);
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--shadow); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--red); color: #fff8ec; }
.btn.ghost { background: var(--field-bg); margin-bottom: 16px; width: auto; font-size: 16px; }

.preview-panel h2 { font-family: 'Bangers', cursive; font-size: 24px; margin: 0 0 6px; }
.drag-hint { color: var(--sub); font-size: 13px; font-weight: 700; margin: 0 0 14px; }

.canvas-wrap {
  position: relative;
  background: var(--field-bg);
  border: 3px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  justify-content: center;
}
.canvas-wrap .bolt-tl, .canvas-wrap .bolt-tr, .canvas-wrap .bolt-bl, .canvas-wrap .bolt-br {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--sub);
  border: 2px solid var(--line);
}
.bolt-tl { top: 10px; left: 10px; }
.bolt-tr { top: 10px; right: 10px; }
.bolt-bl { bottom: 10px; left: 10px; }
.bolt-br { bottom: 10px; right: 10px; }

#posterCanvas {
  width: 100%;
  max-width: 430px;
  height: auto;
  border-radius: 8px;
  touch-action: none;
  cursor: grab;
  box-shadow: 0 12px 26px rgba(0,0,0,0.28);
}
#posterCanvas:active { cursor: grabbing; }

.result-section { margin-top: 20px; text-align: center; }
.result-ok {
  font-family: 'Bangers', cursive;
  font-size: 22px;
  color: var(--blue);
  letter-spacing: 0.5px;
  margin: 0 0 12px;
}
@media (prefers-reduced-motion: no-preference) {
  .result-section:not([hidden]) { animation: pop 0.35s cubic-bezier(.2,1.4,.4,1); }
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }

footer.site-footer {
  text-align: center;
  padding: 26px 16px 4px;
  color: var(--sub);
  font-size: 13px;
  font-weight: 600;
}
