:root { color-scheme: dark; }
* { box-sizing: border-box; margin: 0; padding: 0; }
@property --a { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes flow { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }
@keyframes spin { to { --a: 360deg; } }
@keyframes stripes { to { background-position: 79.2px 0; } }
@keyframes spot { 0% { background-position: 0% 0%, 100% 100%, 0 0; } 50% { background-position: 100% 60%, 0% 20%, 0 0; } 100% { background-position: 0% 0%, 100% 100%, 0 0; } }
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }

body {
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: #fff;
  display: flex; justify-content: center; padding: 40px 18px 80px;
  position: relative; overflow-x: hidden;
}

/* ---- Фони (працюють і на body, і на мініатюрах .swatch) ---- */
:is(body, .swatch), :is(body, .swatch)[data-bg="aurora"] {
  --b1: #5ee7df; --b2: #ff7eb3; --bo: .45;
  background: linear-gradient(125deg, #0f2027, #2c5364, #6a3093, #a044ff, #ff6b9a, #2c5364, #0f2027);
  background-size: 400% 400%; animation: flow 18s ease-in-out infinite;
}
:is(body, .swatch)[data-bg="sunset"] {
  --b1: #ffb199; --b2: #ff0844; --bo: .4;
  background: linear-gradient(125deg, #2b1055, #7a2f6e, #d76d77, #ffaf7b, #d76d77, #3a1c71);
  background-size: 400% 400%; animation: flow 20s ease-in-out infinite;
}
:is(body, .swatch)[data-bg="ocean"] {
  --b1: #01baef; --b2: #20bf55; --bo: .38;
  background: linear-gradient(125deg, #02111f, #0b4f6c, #01baef, #0b4f6c, #02111f);
  background-size: 400% 400%; animation: flow 22s ease-in-out infinite;
}
:is(body, .swatch)[data-bg="mint"] {
  --b1: #a8e063; --b2: #56ab2f; --bo: .35;
  background: linear-gradient(125deg, #0b3d2e, #1e8f6a, #a8e063, #1e8f6a, #0b3d2e);
  background-size: 400% 400%; animation: flow 20s ease-in-out infinite;
}
:is(body, .swatch)[data-bg="neon"] {
  --b1: #ff00cc; --b2: #00f5d4; --bo: .3;
  background: linear-gradient(rgba(0,0,0,.4), rgba(0,0,0,.4)), conic-gradient(from var(--a) at 50% 50%, #ff00cc, #3333ff, #00f5d4, #3333ff, #ff00cc);
  animation: spin 14s linear infinite;
}
/* Чорно-білі */
:is(body, .swatch)[data-bg="bw-flow"] {
  --b1: #ffffff; --b2: #bbbbbb; --bo: .16;
  background: linear-gradient(125deg, #000, #333, #8a8a8a, #333, #000);
  background-size: 400% 400%; animation: flow 16s ease-in-out infinite;
}
:is(body, .swatch)[data-bg="bw-pulse"] {
  --b1: #ffffff; --b2: #999999; --bo: .14;
  background: conic-gradient(from var(--a) at 50% 50%, #0a0a0a, #5a5a5a, #111, #8a8a8a, #0a0a0a);
  animation: spin 18s linear infinite;
}
:is(body, .swatch)[data-bg="bw-stripes"] {
  --b1: #ffffff; --b2: #888888; --bo: .10;
  background: repeating-linear-gradient(45deg, #070707 0 28px, #1d1d1d 28px 56px);
  animation: stripes 3s linear infinite;
}
:is(body, .swatch)[data-bg="bw-spot"] {
  --b1: #ffffff; --b2: #777777; --bo: .14;
  background: radial-gradient(circle at 30% 30%, #7a7a7a, transparent 45%), radial-gradient(circle at 70% 70%, #4a4a4a, transparent 50%), #060606;
  background-size: 200% 200%, 200% 200%, 100% 100%; animation: spot 14s ease-in-out infinite;
}

.blob { position: fixed; border-radius: 50%; filter: blur(70px); opacity: var(--bo, .4); pointer-events: none; animation: drift 22s ease-in-out infinite alternate; }
.b1 { width: 340px; height: 340px; background: var(--b1); top: -80px; left: -80px; }
.b2 { width: 420px; height: 420px; background: var(--b2); bottom: -120px; right: -100px; animation-duration: 28s; }

.wrap { position: relative; z-index: 1; width: 100%; max-width: 460px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.gif {
  width: 100%; max-height: 300px; object-fit: cover; border-radius: 24px;
  border: 1px solid rgba(255,255,255,.28); box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
h1 { font-size: clamp(28px, 7vw, 38px); font-weight: 800; letter-spacing: -.02em; text-align: center; }
.text { text-align: center; line-height: 1.6; color: rgba(255,255,255,.88); font-size: 16px; white-space: pre-line; }
.socials { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.soc {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: 18px;
  color: #fff; text-decoration: none; font-weight: 600; font-size: 16px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.26);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  transition: transform .18s ease, background .18s ease;
}
.soc:hover { transform: translateY(-2px); background: rgba(255,255,255,.22); }
.soc:active { transform: scale(.98); }
.soc svg { width: 24px; height: 24px; flex-shrink: 0; fill: currentColor; }
.soc span { flex: 1; }
.soc .arrow { opacity: .6; flex: 0; }

/* ---- Наліпки ---- */
.stickers { position: absolute; inset: 0; overflow: hidden; z-index: 5; pointer-events: none; }
.sticker {
  position: absolute; display: block; max-width: none; height: auto; user-select: none; -webkit-user-drag: none;
  border-radius: 8px;
  filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(0 8px 12px rgba(0,0,0,.4));
  transition: transform .2s ease;
}
.sticker:hover { transform: var(--tf) scale(1.04); }
body.editing .sticker { pointer-events: auto; cursor: grab; touch-action: none; }
body.editing .sticker.sel { outline: 2px dashed #fff; outline-offset: 6px; }
body.editing .sticker:active { cursor: grabbing; }

.toolbar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50;
  width: min(94vw, 520px); padding: 12px; border-radius: 18px;
  background: rgba(15,20,35,.75); border: 1px solid rgba(255,255,255,.25);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px;
}
.toolbar button { padding: 10px 14px; border-radius: 12px; border: none; font: inherit; font-weight: 700; cursor: pointer; background: #fff; color: #111; }
.toolbar button.ghost { background: rgba(255,255,255,.16); color: #fff; }
.toolbar button.del { background: rgba(255,80,100,.35); color: #fff; }
.toolbar label { display: flex; align-items: center; gap: 6px; flex: 1 1 140px; }
.toolbar input[type=range] { flex: 1; min-width: 0; }
.toolbar .tmsg { flex-basis: 100%; min-height: 18px; font-size: 13px; }

@media (prefers-reduced-motion: reduce) { body, .swatch, .blob { animation: none !important; } }
