/* ============================================================
   Base
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-0: #0a0614;
    --bg-1: #140a2a;
    --accent: #a855f7;
    --accent-2: #6C5CE7;
    --pink:   #ec4899;
    --amber:  #f59e0b;
    --text:   #ffffff;
    --muted:  rgba(255,255,255,0.55);
    --line:   rgba(255,255,255,0.10);
}

html, body { height: 100%; }

body {
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background: var(--bg-0);
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Анимированный фон: 3 blob-градиента + шум
   ============================================================ */
.bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background:
        radial-gradient(ellipse at top left,  rgba(108,92,231,.18), transparent 55%),
        radial-gradient(ellipse at bottom right, rgba(236,72,153,.12), transparent 50%),
        linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
}

.blob {
    position: absolute;
    width: 60vmax;
    height: 60vmax;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .55;
    mix-blend-mode: screen;
    will-change: transform;
}

.blob--a { background: radial-gradient(circle, #6C5CE7 0%, transparent 65%); top: -20vmax; left: -15vmax; animation: float1 22s ease-in-out infinite; }
.blob--b { background: radial-gradient(circle, #ec4899 0%, transparent 65%); bottom: -25vmax; right: -15vmax; animation: float2 28s ease-in-out infinite; }
.blob--c { background: radial-gradient(circle, #f59e0b 0%, transparent 65%); top: 30%; left: 40%; width: 40vmax; height: 40vmax; opacity:.35; animation: float3 32s ease-in-out infinite; }

@keyframes float1 {
    0%,100% { transform: translate(0,0) scale(1); }
    50%     { transform: translate(8vmax, 6vmax) scale(1.15); }
}
@keyframes float2 {
    0%,100% { transform: translate(0,0) scale(1); }
    50%     { transform: translate(-6vmax,-8vmax) scale(1.1); }
}
@keyframes float3 {
    0%,100% { transform: translate(0,0) scale(1) rotate(0); }
    50%     { transform: translate(-10vmax, 4vmax) scale(1.2) rotate(60deg); }
}

.grain {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .28 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
    opacity: .05;
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* ============================================================
   Progress bar
   ============================================================ */
.progress-bar {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--pink));
    transition: width .6s cubic-bezier(.4,0,.2,1);
    z-index: 100;
    box-shadow: 0 0 12px rgba(168,85,247,.6);
}

/* ============================================================
   App layout
   ============================================================ */
#app {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.screen {
    display: none;
    grid-area: 1 / 1;
    width: 100%;
    max-width: 480px;
}

.screen.active {
    display: block;
    animation: fadeUp .55s cubic-bezier(.4,0,.2,1);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(24px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   Card
   ============================================================ */
.card {
    position: relative;
    background:
        linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02)),
        rgba(15,12,34,.65);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 40px 28px;
    text-align: center;
    box-shadow:
        0 20px 60px rgba(0,0,0,.55),
        inset 0 1px 0 rgba(255,255,255,.06);
    transition: transform .25s ease;
}

/* Hero-карточка: блестящая рамка */
.card--hero::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(135deg, rgba(168,85,247,.7), rgba(236,72,153,.3), rgba(245,158,11,.6));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
            mask-composite: exclude;
    opacity: .8;
    animation: borderSpin 8s linear infinite;
    pointer-events: none;
}
@keyframes borderSpin { to { filter: hue-rotate(360deg); } }

.hero-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.hero-stars span {
    position: absolute;
    font-size: 14px;
    color: rgba(255,255,255,.6);
    text-shadow: 0 0 8px rgba(255,255,255,.4);
    animation: twinkle 2.8s ease-in-out infinite;
}
.hero-stars span:nth-child(1) { top: 10%;  left: 12%; animation-delay: 0s; }
.hero-stars span:nth-child(2) { top: 24%;  right: 14%; animation-delay: .8s; font-size: 10px; }
.hero-stars span:nth-child(3) { bottom: 30%; left: 10%; animation-delay: 1.6s; font-size: 8px; }
@keyframes twinkle {
    0%,100% { opacity: .3; transform: scale(.8); }
    50%     { opacity: 1; transform: scale(1.2); }
}

/* ============================================================
   Typography
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(168,85,247,.14);
    border: 1px solid rgba(168,85,247,.35);
    color: #d8b4fe;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 6px 14px;
    border-radius: 100px;
    margin-bottom: 22px;
}
.badge-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #a855f7;
    box-shadow: 0 0 8px #a855f7;
    animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

h1 {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -.02em;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #fff 20%, #c4b5fd 70%, #f0abfc 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 6s ease-in-out infinite;
}
h1 em {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-weight: 900;
    background: linear-gradient(135deg, #fcd34d, #f472b6, #a78bfa);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
}
@keyframes shimmer { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.01em;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--muted);
    font-size: .95rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* ============================================================
   Hero thumbs
   ============================================================ */
.hero-thumbs {
    display: flex;
    justify-content: center;
    margin-top: 22px;
}
.hero-thumbs img {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(10,6,20,.9);
    margin-left: -12px;
    box-shadow: 0 4px 14px rgba(0,0,0,.4);
    transition: transform .3s;
}
.hero-thumbs img:first-child { margin-left: 0; }
.hero-thumbs img:hover { transform: translateY(-6px) scale(1.08); z-index: 2; }

.hero-hint {
    margin-top: 14px;
    font-size: .8rem;
    color: rgba(255,255,255,.45);
}

/* ============================================================
   Step dots
   ============================================================ */
.step-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 22px;
}
.step-dots span {
    width: 20px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,.12);
    transition: all .35s ease;
}
.step-dots span.active {
    width: 32px;
    background: linear-gradient(90deg, var(--accent-2), var(--pink));
    box-shadow: 0 0 10px rgba(168,85,247,.5);
}
.step-dots span.done { background: rgba(168,85,247,.5); }

/* ============================================================
   Options
   ============================================================ */
.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.opt {
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 16px 20px;
    color: #fff;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    opacity: 0;
    transform: translateY(8px);
    animation: optIn .4s forwards cubic-bezier(.4,0,.2,1);
    transition: border-color .25s, background .25s, transform .2s;
}

@keyframes optIn { to { opacity: 1; transform: translateY(0); } }

.opt::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(108,92,231,.25), rgba(236,72,153,.12));
    opacity: 0;
    transition: opacity .25s;
}
.opt > span { position: relative; z-index: 1; }
.opt-arrow {
    opacity: 0;
    transform: translateX(-6px);
    transition: all .25s;
    color: #c4b5fd;
}

.opt:hover::before { opacity: 1; }
.opt:hover         { border-color: rgba(168,85,247,.45); }
.opt:hover .opt-arrow { opacity: 1; transform: translateX(0); }
.opt:active        { transform: scale(.97); }
.opt.selected {
    border-color: #a855f7;
    background: rgba(168,85,247,.22);
    box-shadow: 0 0 0 3px rgba(168,85,247,.15);
}
.opt.selected .opt-arrow { opacity: 1; transform: translateX(0); }

@media (hover: hover) {
    .opt:hover { transform: translateX(4px); }
}

/* ============================================================
   Buttons
   ============================================================ */
.cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, #6C5CE7 0%, #a855f7 55%, #ec4899 100%);
    background-size: 200% 200%;
    border: none;
    border-radius: 16px;
    padding: 16px 34px;
    color: #fff;
    font-family: inherit;
    font-size: 1.03rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .3s ease;
    text-decoration: none;
    margin-top: 24px;
    box-shadow: 0 10px 30px rgba(168,85,247,.35);
    animation: ctaGlow 4s ease-in-out infinite;
}
@keyframes ctaGlow { 0%,100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

.cta:hover   { box-shadow: 0 14px 40px rgba(168,85,247,.55); }
.cta:active  { transform: scale(.97); }
.cta:disabled { opacity: .45; pointer-events: none; box-shadow: none; animation: none; }

@media (hover: hover) {
    .cta:hover { transform: translateY(-2px); }
}

.retry-btn {
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.2);
    color: #fff;
    padding: 12px 30px;
    border-radius: 12px;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 16px;
    transition: all .2s;
}
.retry-btn:hover {
    border-color: rgba(255,255,255,.4);
    background: rgba(255,255,255,.08);
}

.store-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    color: #000;
    font-weight: 600;
    font-size: 1rem;
    padding: 14px 30px;
    border-radius: 14px;
    text-decoration: none;
    margin-top: 20px;
    transition: all .3s ease;
    box-shadow: 0 6px 20px rgba(255,255,255,.15);
}
.store-link:hover { box-shadow: 0 12px 30px rgba(255,255,255,.25); }

@media (hover: hover) {
    .store-link:hover { transform: translateY(-2px); }
}

/* ============================================================
   Upload
   ============================================================ */
.upload-zone {
    border: 2px dashed rgba(255,255,255,.14);
    border-radius: 20px;
    padding: 44px 20px;
    margin: 16px 0 0;
    cursor: pointer;
    transition: all .3s ease;
    position: relative;
    background: rgba(255,255,255,.02);
}

.upload-zone:hover,
.upload-zone.drag {
    border-color: rgba(168,85,247,.6);
    background: rgba(168,85,247,.08);
    transform: translateY(-2px);
}

.upload-zone.has-img { border: none; padding: 0; overflow: hidden; background: none; }

.upload-zone img {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    border-radius: 18px;
    display: block;
}

.upload-zone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-icon {
    color: rgba(255,255,255,.65);
    margin-bottom: 14px;
    display: inline-block;
    animation: floaty 3s ease-in-out infinite;
}
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.upload-hint { color: rgba(255,255,255,.7); font-size: .95rem; font-weight: 500; }
.upload-sub  { color: rgba(255,255,255,.35); font-size: .78rem; margin-top: 6px; }

/* ============================================================
   Quiz — gen-hint
   ============================================================ */
.gen-hint {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(168,85,247,.15);
    border: 1px solid rgba(168,85,247,.3);
    border-radius: 100px;
    padding: 6px 14px;
    font-size: .75rem;
    color: #d8b4fe;
    margin-bottom: 16px;
    font-weight: 500;
}
.gen-dot {
    width: 6px; height: 6px;
    background: #a855f7;
    border-radius: 50%;
    box-shadow: 0 0 8px #a855f7;
    animation: pulse 1.5s ease-in-out infinite;
}

/* ============================================================
   Result screen
   ============================================================ */
#s-result.screen { max-width: min(92vw, 720px); }

.result-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 10px;
}
.result-title .sparkle {
    font-size: 1.2rem;
    animation: spin 4s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-frame {
    width: 100%;
    height: 70vh;
    max-height: 70dvh;
    min-height: 220px;
    margin: 12px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: rgba(0,0,0,.22);
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0,0,0,.45);
}

.result-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    border-radius: 14px;
    animation: reveal .9s cubic-bezier(.4,0,.2,1);
}
@keyframes reveal {
    from { opacity: 0; transform: scale(1.05); filter: blur(14px); }
    to   { opacity: 1; transform: scale(1);    filter: blur(0); }
}

.error-msg {
    background: rgba(239,68,68,.15);
    border: 1px solid rgba(239,68,68,.3);
    border-radius: 12px;
    padding: 14px 18px;
    color: #fca5a5;
    font-size: .9rem;
    margin-top: 16px;
}

/* ============================================================
   Loading screen — прогресс + polaroid-стек
   ============================================================ */
#s-loading.screen { max-width: 460px; }

.card--loading {
    padding: 28px 22px 22px;
    text-align: left;
}

.loading-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.loading-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
}
.dot-glow {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #a855f7;
    box-shadow: 0 0 12px #a855f7, 0 0 24px rgba(168,85,247,.6);
    animation: pulse 1.4s ease-in-out infinite;
}
.loading-pct {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1rem;
    background: linear-gradient(135deg, #c4b5fd, #f0abfc);
    -webkit-background-clip: text;
            background-clip: text;
    -webkit-text-fill-color: transparent;
}

.loading-bar {
    height: 6px;
    background: rgba(255,255,255,.07);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 18px;
}
.loading-bar span {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 100px;
    background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--pink));
    background-size: 200% 100%;
    animation: ctaGlow 3s ease-in-out infinite;
    transition: width .3s ease;
    position: relative;
}
.loading-bar span::after {
    content: '';
    position: absolute;
    inset: 0 0 0 auto;
    width: 40px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
    filter: blur(2px);
    animation: sweep 1.6s linear infinite;
}
@keyframes sweep {
    0%   { transform: translateX(-40px); }
    100% { transform: translateX(40px); }
}

/* Шаги */
.steps {
    list-style: none;
    padding: 0;
    margin: 0 0 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.steps li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .88rem;
    color: rgba(255,255,255,.35);
    transition: color .3s ease;
}
.steps li .step-ico {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,.18);
    position: relative;
    flex-shrink: 0;
    transition: all .3s ease;
}
.steps li.active { color: rgba(255,255,255,.85); }
.steps li.active .step-ico {
    border-color: #a855f7;
}
.steps li.active .step-ico::before {
    content: '';
    position: absolute;
    inset: 3px;
    border-radius: 50%;
    border: 1.5px solid #a855f7;
    border-top-color: transparent;
    animation: spin .7s linear infinite;
}
.steps li.done { color: rgba(255,255,255,.6); }
.steps li.done .step-ico {
    background: linear-gradient(135deg, var(--accent-2), var(--pink));
    border-color: transparent;
}
.steps li.done .step-ico::before {
    content: '';
    position: absolute;
    left: 4px; top: 2px;
    width: 5px; height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Разделитель "Meanwhile — real Lumi shots" */
.loading-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 16px;
}
.loading-divider::before,
.loading-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent);
}
.loading-divider span {
    font-size: .72rem;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: rgba(255,255,255,.45);
    font-weight: 600;
}

/* Polaroid-стек: 3 карточки, одна спереди, две по сторонам, сзади спрятано */
.polaroid-stack {
    position: relative;
    width: 100%;
    height: 360px;
    perspective: 1200px;
    margin-bottom: 14px;
}

.slide {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 220px;
    height: 300px;
    padding: 10px 10px 34px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 20px 50px rgba(0,0,0,.5);
    transition:
        transform .7s cubic-bezier(.4,0,.2,1),
        opacity .5s ease,
        filter .5s ease;
    will-change: transform;
    transform-origin: center center;
    transform-style: preserve-3d;
}
.slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 2px;
}
.slide-cap { display: none; }

.slide.pos-active {
    transform: translate(-50%, -50%) rotate(-2deg) translateZ(0);
    opacity: 1;
    z-index: 3;
    filter: none;
}
.slide.pos-prev {
    transform: translate(-125%, -50%) rotate(-10deg) scale(.85);
    opacity: .55;
    z-index: 2;
    filter: brightness(.85);
}
.slide.pos-next {
    transform: translate(25%, -50%) rotate(8deg) scale(.85);
    opacity: .55;
    z-index: 2;
    filter: brightness(.85);
}
.slide.pos-hidden {
    transform: translate(-50%, -50%) scale(.7);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
}

.slides-dots {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.slides-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    transition: all .3s ease;
}
.slides-dots span.active {
    width: 22px; border-radius: 100px;
    background: linear-gradient(90deg, var(--accent-2), var(--pink));
    box-shadow: 0 0 10px rgba(168,85,247,.6);
}

/* ============================================================
   Responsive — phones ≤480px
   ============================================================ */
@media (max-width: 480px) {
    #app       { padding: 12px; }
    .card      { padding: 28px 18px; border-radius: 22px; }
    h1         { font-size: 1.6rem; }
    h2         { font-size: 1.2rem; }
    .subtitle  { font-size: .88rem; margin-bottom: 20px; }
    .opt       { padding: 14px 16px; font-size: .9rem; border-radius: 14px; }
    .opt:hover { transform: none; }
    .cta       { padding: 14px 28px; font-size: .95rem; margin-top: 18px; }
    .upload-zone { padding: 34px 16px; margin: 12px 0 0; border-radius: 16px; }
    .hero-thumbs img { width: 46px; height: 46px; }
    .result-frame { height: 70vh; max-height: 70dvh; border-radius: 16px; }
    .slides { height: 58vh; max-height: 58dvh; min-height: 300px; border-radius: 16px; }
    .store-link { padding: 12px 24px; font-size: .9rem; }
}

/* Loading-экран на узких phone-экранах: немного меньше паддинг */
@media (max-width: 480px) {
    .card--loading        { padding: 22px 18px 18px; }
    .polaroid-stack       { height: 340px; }
    .polaroid-stack .slide { width: 200px; height: 270px; }
}

/* Уважаем reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .blob, .hero-stars span, .gen-dot, .cta, h1, .sparkle, .upload-icon { animation: none !important; }
    .slide { transition: opacity .3s ease; }
}
