:root {
  --night: #0e1830;
  --night-2: #16264a;
  --ink: #f6f1e7;
  --muted: #b9c2d6;
  --red: #d7263d;
  --red-dark: #a51b2e;
  --green: #1f8a5b;
  --gold: #f2c14e;
  --card: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .14);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(120% 70% at 50% 0%, var(--night-2), var(--night) 70%) fixed, var(--night);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
main { max-width: 520px; margin: 0 auto; padding: 0 16px; position: relative; z-index: 1; }
[hidden] { display: none !important; }

/* ---------- snow ---------- */
.snow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .55;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 120px 80px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 200px 150px, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 280px 40px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 60px 190px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 330px 220px, #fff 50%, transparent 51%);
  background-size: 360px 260px;
  animation: snow 14s linear infinite;
}
@keyframes snow { to { background-position: 40px 260px; } }
@media (prefers-reduced-motion: reduce) { .snow { animation: none; } }

/* ---------- screens ---------- */
.screen { min-height: 100dvh; display: flex; flex-direction: column; padding-top: max(12px, env(safe-area-inset-top)); }

.brand { text-align: center; padding: 18px 0 6px; }
h1 { margin: 0; line-height: 0; }
h1 .logo {
  display: block; width: min(100%, 460px); height: auto; margin: 4px auto 0;
  filter: drop-shadow(0 3px 0 var(--red-dark)) drop-shadow(0 6px 14px rgba(0, 0, 0, .45));
}
.tag { margin: 8px 0 0; color: var(--muted); font-size: 17px; }
.tag b { color: var(--ink); font-family: Anton, Impact, sans-serif; font-weight: 400; letter-spacing: .5px; }

h2 { font: 400 22px/1.2 "Lilita One", system-ui, sans-serif; margin: 0; }

/* ---------- stage (scene canvas) ---------- */
.stage {
  position: relative; margin: 18px 0 0;
  border-radius: var(--radius); overflow: hidden;
  background: #000; aspect-ratio: 480 / 260;
  box-shadow: 0 0 0 3px rgba(242, 193, 78, .9), 0 0 0 9px var(--red), 0 14px 40px rgba(0, 0, 0, .5);
  margin-left: 9px; margin-right: 9px;
}
.stage canvas, .stage img { display: block; width: 100%; height: 100%; }
.stage .loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 15px; transition: opacity .3s;
}
.stage.ready .loading { opacity: 0; pointer-events: none; }

.steps {
  list-style: none; padding: 0; margin: 24px 0 8px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center;
  color: var(--muted); font-size: 14px;
}
.steps b {
  display: grid; place-items: center; width: 30px; height: 30px; margin: 0 auto 6px;
  border-radius: 50%; background: var(--green); color: #fff; font-size: 15px;
}

/* ---------- buttons ---------- */
.actions { display: grid; gap: 10px; padding: 16px 0 calc(16px + var(--safe-b)); margin-top: auto; }
.actions.sticky {
  position: sticky; bottom: 0; z-index: 2;
  background: linear-gradient(to top, var(--night) 70%, rgba(14, 24, 48, 0));
  padding-top: 26px;
}
.btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 20px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: 600 18px/1 system-ui, -apple-system, sans-serif; text-decoration: none;
  cursor: pointer; user-select: none; touch-action: manipulation;
  transition: transform .08s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(180deg, #e83a50, var(--red));
  border-color: transparent; box-shadow: 0 6px 0 var(--red-dark), 0 10px 24px rgba(215, 38, 61, .35);
}
.btn.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--red-dark); }
.btn.big { min-height: 62px; font-size: 20px; }
.btn input[type=file] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; font-size: 0; }
.btn:focus-visible, .icon:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.privacy { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.icon {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 28px; line-height: 1; padding-bottom: 4px;
  cursor: pointer; touch-action: manipulation;
}

/* ---------- fit screen ---------- */
.fit-body { display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 6px; }
.frame {
  /* silver picture frame with a white mat, like the one Kevin holds */
  padding: 12px; border-radius: 6px;
  background: linear-gradient(135deg, #f4f4f2, #9c9a93 30%, #e7e5df 55%, #8f8c84 80%, #dcdad3);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .55), inset 0 0 0 2px rgba(0, 0, 0, .25);
}
.editor {
  position: relative; overflow: hidden;
  height: min(48dvh, 430px); aspect-ratio: .63;
  border: 10px solid #ecebe6; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2);
  background: #1b1b1b; touch-action: none; cursor: grab;
}
.editor.active { cursor: grabbing; }
.editor canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.guide {
  position: absolute; left: 22%; width: 56%; top: 25%; height: 42%;
  border: 2px dashed rgba(255, 255, 255, .75); border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .12);
  transition: opacity .25s; pointer-events: none;
}
.editor.active .guide { opacity: .35; }

.controls { width: 100%; display: grid; gap: 12px; }
.zoom { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 22px; }
.zoom input { flex: 1; accent-color: var(--gold); height: 32px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mini { margin: 0; width: 52%; max-width: 220px; }
.mini canvas { display: block; width: 100%; border-radius: 10px; box-shadow: 0 0 0 2px var(--line); background: #000; }
.mini figcaption { color: var(--muted); font-size: 12px; margin-top: 4px; }
.hint { margin: 0; text-align: center; color: var(--muted); font-size: 13px; }

.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { width: 52px; height: 32px; border-radius: 16px; background: rgba(255, 255, 255, .2); position: relative; transition: background .2s; }
.knob { position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track .knob { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- result ---------- */
.bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .12); margin: 22px 9px 0; overflow: hidden; --p: 0; }
.bar span { display: block; height: 100%; width: calc(var(--p) * 100%); background: linear-gradient(90deg, var(--green), var(--gold)); transition: width .15s; }
.status { text-align: center; margin: 10px 0 0; min-height: 1.4em; color: var(--muted); }
body:not(.working) #result .bar { visibility: hidden; }
body.working #result .actions { opacity: .45; pointer-events: none; }
.ios-tip { display: none; }
@supports (-webkit-touch-callout: none) { .ios-tip { display: block; } }

footer {
  position: relative; z-index: 1; text-align: center; color: rgba(185, 194, 214, .7);
  font-size: 12px; padding: 8px 16px calc(20px + var(--safe-b));
}
footer { line-height: 1.7; }
footer a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; padding: 6px 0; display: inline-block; }
footer a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
/* "Woofs Created" counter: a small 90s-style hit counter at the very bottom */
.counter { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; }
.digits { display: inline-flex; gap: 1px; padding: 2px; background: #000; border: 2px ridge #a9a9a9; border-radius: 2px; }
.digits span {
  display: grid; place-items: center; width: 13px; height: 18px;
  background: linear-gradient(#1c1c1c, #000 55%, #141414);
  color: #39ff14; text-shadow: 0 0 4px rgba(57, 255, 20, .7);
  font: 700 13px/1 "Courier New", Courier, monospace;
}
.counter-label { font-size: 12px; }
.lang-pick { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; }
.lang-pick select {
  min-height: 36px; padding: 4px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--night-2); color: var(--ink); font: inherit; font-size: 13px;
}
.lang-pick select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
body[data-screen="fit"] footer, body[data-screen="result"] footer { display: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%);
  max-width: calc(100% - 32px); z-index: 10;
  background: #fff; color: #111; padding: 12px 16px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4); font-weight: 600; text-align: center;
}

/* short phones: shrink the frame so the button stays on screen */
@media (max-height: 700px) {
  .editor { height: 40dvh; }
  .brand { padding-top: 8px; }
  .steps { margin-top: 16px; }
}

/* ---------- about / FAQ (home only, also what search engines read) ---------- */
.about {
  position: relative; z-index: 1; max-width: 520px; margin: 8px auto 0; padding: 8px 20px 12px;
  color: var(--muted); font-size: 15px;
}
.about h2 { color: var(--ink); font-size: 24px; margin: 12px 0 8px; }
.about h3 { color: var(--ink); font: 400 19px/1.2 "Lilita One", system-ui, sans-serif; margin: 22px 0 8px; }
.about ol { padding-left: 22px; margin: 0; }
.about li { margin: 4px 0; }
.about b, .about em, .about i { color: var(--ink); }
.about details { border-top: 1px solid var(--line); padding: 4px 0; }
.about details:last-of-type { border-bottom: 1px solid var(--line); }
.about summary { cursor: pointer; color: var(--ink); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.about details p { margin: 0 0 12px; }
body:not([data-screen="home"]) .about { display: none; }

.send-it { text-align: center; margin: 6px 0 0; font: 400 20px/1.3 "Lilita One", system-ui, sans-serif; color: var(--gold); }
body.working .send-it { visibility: hidden; }
