:root {
  color-scheme: dark;
  --bg: #0d0809;
  --surface: #1a0d10;
  --wine: #5e1421;
  --wine-light: #842238;
  --gold: #d6ba79;
  --cream: #f1e5ca;
  --muted: #b6a991;
  --line: rgba(214, 186, 121, 0.3);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% -10%, rgba(132, 34, 56, 0.42), transparent 40%),
    linear-gradient(180deg, #16090c 0%, var(--bg) 58%);
}

button, input { font: inherit; }

.page-shell {
  width: min(100%, 500px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.hero { text-align: center; margin: 4px 0 22px; }
.eyebrow { margin: 0 0 10px; color: var(--gold); font-size: 0.69rem; font-weight: 800; letter-spacing: 0.19em; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 9vw, 3rem); line-height: 0.98; font-weight: 500; letter-spacing: -0.035em; }
h1 span { display: block; margin-top: 7px; color: var(--gold); font-size: 0.48em; letter-spacing: 0.02em; }
.tagline { margin: 14px 0 0; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-style: italic; }

.creator {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(155deg, rgba(94, 20, 33, 0.2), rgba(26, 13, 16, 0.94) 38%);
  box-shadow: var(--shadow);
}

.editor {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(214, 186, 121, 0.48);
  border-radius: 16px;
  background: #120b0d;
  touch-action: none;
  cursor: grab;
  user-select: none;
}
.editor:active { cursor: grabbing; }
.editor:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
#previewCanvas { display: block; width: 100%; height: 100%; }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 7px; padding: 30px; text-align: center; pointer-events: none; }
.empty-state[hidden] { display: none; }
.empty-state strong { font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; font-weight: 500; }
.empty-state span { color: var(--muted); font-size: 0.82rem; }
.empty-mark { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 5px; border: 1px solid var(--line); border-radius: 50%; color: var(--gold); font-family: Georgia, serif; font-size: 1.1rem; }
.editor-hint { min-height: 20px; margin: 10px 2px 5px; color: var(--muted); font-size: 0.78rem; text-align: center; }

.zoom-control { margin: 14px 4px 4px; }
.zoom-control label { display: block; margin-bottom: 7px; color: var(--gold); font-size: 0.73rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.zoom-row { display: grid; grid-template-columns: 18px 1fr 18px; align-items: center; gap: 8px; color: var(--gold); }
input[type="range"] { width: 100%; accent-color: var(--gold); cursor: pointer; }

.actions { display: grid; gap: 9px; margin-top: 15px; }
.button { min-height: 50px; padding: 12px 18px; border-radius: 999px; font-weight: 800; letter-spacing: 0.01em; cursor: pointer; transition: transform 160ms ease, background 160ms ease, opacity 160ms ease; }
.button:active { transform: scale(0.985); }
.button:focus-visible { outline: 3px solid var(--cream); outline-offset: 2px; }
.button-primary { border: 1px solid #eed796; color: #211309; background: linear-gradient(135deg, #ead494, #b99043); box-shadow: 0 8px 24px rgba(185, 144, 67, 0.16); }
.button-primary:hover { background: linear-gradient(135deg, #f2dfa7, #c69e50); }
.button-secondary { border: 1px solid var(--line); color: var(--cream); background: rgba(255, 255, 255, 0.035); }
.button-secondary:hover { background: rgba(255, 255, 255, 0.07); }
.button[hidden], .zoom-control[hidden] { display: none; }
.status { min-height: 0; margin-top: 8px; color: #f0bdc6; font-size: 0.8rem; text-align: center; }
.status:empty { margin: 0; }

footer { padding: 24px 0 4px; color: var(--gold); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em; text-align: center; text-transform: uppercase; }
footer span { margin: 0 4px; color: var(--wine-light); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (min-width: 560px) {
  .page-shell { padding-inline: 0; }
  .creator { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
}
