:root {
    --ink: #24161c;
    --ink-soft: #4a3540;
    --blush: #f3c4d0;
    --blush-deep: #d9849a;
    --rose: #c45d78;
    --dusk: #2b1a28;
    --dusk-mid: #4a2a3d;
    --champagne: #f0d9b5;
    --cream: #fff7f4;
    --mist: rgba(255, 247, 244, 0.72);
    --glass: rgba(255, 247, 244, 0.14);
    --font-display: "Cormorant Garamond", Georgia, serif;
    --font-script: "Pinyon Script", cursive;
    --font-body: "Outfit", system-ui, sans-serif;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --shadow: 0 24px 60px rgba(36, 22, 28, 0.28);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--cream);
    background: var(--dusk);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Atmosphere */
.atmosphere {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(1200px 700px at 15% -10%, #7a3a52 0%, transparent 55%),
        radial-gradient(900px 600px at 90% 10%, #3d2550 0%, transparent 50%),
        linear-gradient(165deg, #1a1018 0%, #3a1f32 42%, #5a2e40 100%);
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.55;
    animation: drift 18s var(--ease) infinite alternate;
}

.orb-a {
    width: 280px;
    height: 280px;
    background: #e896ab;
    top: 12%;
    left: -60px;
}

.orb-b {
    width: 340px;
    height: 340px;
    background: #8b5a7a;
    bottom: 5%;
    right: -80px;
    animation-delay: -6s;
    animation-duration: 22s;
}

.orb-c {
    width: 180px;
    height: 180px;
    background: var(--champagne);
    top: 55%;
    left: 40%;
    opacity: 0.22;
    animation-duration: 14s;
}

.grain {
    position: absolute;
    inset: 0;
    opacity: 0.12;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    mix-blend-mode: soft-light;
}

.sparkles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

@keyframes drift {
    from { transform: translate3d(0, 0, 0) scale(1); }
    to { transform: translate3d(40px, -30px, 0) scale(1.08); }
}

/* Screens */
.screen {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.25rem 3rem;
}

.screen.is-active {
    display: flex;
}

.screen[hidden] {
    display: none !important;
}

.hero-inner,
.thanks-inner {
    width: min(560px, 100%);
    text-align: center;
}

.brand {
    font-family: var(--font-script);
    font-size: clamp(2.4rem, 8vw, 3.4rem);
    color: var(--champagne);
    margin: 0 0 0.75rem;
    line-height: 1;
    text-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(2.4rem, 8vw, 3.6rem);
    line-height: 1.1;
    margin: 0.5rem 0 1rem;
    letter-spacing: -0.02em;
}

.hero-title em {
    font-style: italic;
    color: var(--blush);
}

.hero-lede {
    font-weight: 300;
    font-size: 1.05rem;
    line-height: 1.65;
    color: rgba(255, 247, 244, 0.86);
    margin: 0 auto 1.75rem;
    max-width: 34rem;
}

.from-line {
    margin-top: 1.5rem;
    font-family: var(--font-display);
    font-style: italic;
    opacity: 0.8;
}

/* Seal */
.floaters {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.floaters span {
    position: absolute;
    left: var(--x);
    bottom: -10%;
    color: rgba(243, 196, 208, 0.35);
    font-size: clamp(0.9rem, 2vw, 1.4rem);
    animation: floatUp 14s linear infinite;
    animation-delay: var(--d);
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% { opacity: 0.7; }
    90% { opacity: 0.35; }
    100% {
        transform: translateY(-110vh) rotate(40deg);
        opacity: 0;
    }
}

.letter-seal {
    width: 72px;
    height: 72px;
    margin: 0.5rem auto 1.25rem;
    position: relative;
    display: grid;
    place-items: center;
    animation: sealPulse 2.8s ease-in-out infinite;
}

.seal-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(240, 217, 181, 0.55);
    box-shadow:
        0 0 0 8px rgba(196, 93, 120, 0.15),
        inset 0 0 24px rgba(240, 217, 181, 0.2);
}

.seal-ring-outer {
    inset: -10px;
    border-color: rgba(243, 196, 208, 0.25);
    box-shadow: none;
    animation: ringSpin 10s linear infinite;
}

@keyframes ringSpin {
    to { transform: rotate(360deg); }
}

.seal-heart {
    color: var(--blush);
    font-size: 1.6rem;
    transform-origin: center;
    animation: heartBeat 1.4s ease-in-out infinite;
}

.letter-seal.is-opening .seal-ring {
    animation: sealBurst 0.7s var(--ease) forwards;
}

.letter-seal.is-opening .seal-heart {
    animation: heartFly 0.7s var(--ease) forwards;
}

@keyframes sealPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.12); }
    40% { transform: scale(0.96); }
    60% { transform: scale(1.08); }
}

@keyframes sealBurst {
    to {
        transform: scale(1.8);
        opacity: 0;
    }
}

@keyframes heartFly {
    to {
        transform: translateY(-40px) scale(1.4);
        opacity: 0;
    }
}

/* Reveal on load */
.reveal {
    opacity: 0;
    transform: translateY(22px);
    animation: riseIn 0.9s var(--ease) forwards;
    animation-delay: var(--d, 0s);
}

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

/* Buttons */
.btn {
    position: relative;
    appearance: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    border-radius: 999px;
    padding: 0.95rem 1.6rem;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    color: var(--dusk);
    background: linear-gradient(135deg, var(--champagne) 0%, var(--blush) 55%, #f0a8ba 100%);
    box-shadow: 0 12px 30px rgba(216, 132, 154, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(216, 132, 154, 0.45);
}

.btn-ghost {
    color: var(--cream);
    background: transparent;
    border: 1px solid rgba(255, 247, 244, 0.28);
}

.btn-ghost:hover {
    background: var(--glass);
}

.btn-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
    transform: translateX(-120%);
    animation: shine 3.2s ease-in-out infinite;
}

.click-ripple {
    position: absolute;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    pointer-events: none;
    animation: rippleOut 0.6s var(--ease) forwards;
}

@keyframes rippleOut {
    to {
        transform: scale(18);
        opacity: 0;
    }
}

.btn.is-pressed {
    transform: scale(0.97);
}

@keyframes shine {
    0%, 60%, 100% { transform: translateX(-120%); }
    75% { transform: translateX(120%); }
}

/* Quiz shell */
.screen-quiz {
    align-items: flex-start;
    padding-top: 1.25rem;
}

.quiz-top {
    position: sticky;
    top: 0;
    z-index: 5;
    width: min(560px, 100%);
    margin: 0 auto 1rem;
    padding: 0.5rem 0;
    backdrop-filter: blur(10px);
}

.progress-wrap {
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 247, 244, 0.12);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--blush-deep), var(--champagne));
    transition: width 0.55s var(--ease);
    box-shadow: 0 0 16px rgba(240, 217, 181, 0.45);
}

.step-label {
    margin: 0.55rem 0 0;
    font-size: 0.78rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.7;
    text-align: right;
}

#preferenceForm {
    width: min(560px, 100%);
    margin: 0 auto;
}

.panel {
    background: linear-gradient(160deg, rgba(255, 247, 244, 0.12), rgba(255, 247, 244, 0.05));
    border: 1px solid rgba(255, 247, 244, 0.16);
    border-radius: 28px;
    padding: 1.6rem 1.35rem 1.4rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    animation: panelIn 0.55s var(--ease);
}

.panel[hidden] {
    display: none !important;
}

.panel.is-leaving {
    animation: panelOut 0.35s var(--ease) forwards;
}

@keyframes panelIn {
    from {
        opacity: 0;
        transform: translateY(28px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes panelOut {
    to {
        opacity: 0;
        transform: translateY(-16px) scale(0.98);
    }
}

.panel-kicker {
    margin: 0 0 0.35rem;
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--champagne);
}

.panel-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(1.9rem, 6vw, 2.4rem);
    margin: 0 0 0.4rem;
    line-height: 1.15;
}

.panel-sub {
    margin: 0 0 1.25rem;
    color: rgba(255, 247, 244, 0.75);
    font-weight: 300;
    line-height: 1.5;
}

.letter-body {
    font-family: var(--font-display);
    font-size: 1.15rem;
    line-height: 1.7;
    color: rgba(255, 247, 244, 0.9);
}

.letter-body p {
    margin: 0 0 1rem;
    opacity: 0;
    transform: translateY(12px);
}

.panel.is-active .letter-body[data-stagger] p {
    animation: riseIn 0.7s var(--ease) forwards;
}

.panel.is-active .letter-body[data-stagger] p:nth-child(1) { animation-delay: 0.08s; }
.panel.is-active .letter-body[data-stagger] p:nth-child(2) { animation-delay: 0.22s; }
.panel.is-active .letter-body[data-stagger] p:nth-child(3) { animation-delay: 0.36s; }

.letter-body p:last-child {
    margin-bottom: 0;
}

.field input:focus,
.field textarea:focus,
.chip.is-selected,
.choice input:checked + span {
    outline: none;
}

.panel.is-active .field {
    animation: riseIn 0.55s var(--ease) both;
}

.panel.is-active .field:nth-of-type(1) { animation-delay: 0.05s; }
.panel.is-active .field:nth-of-type(2) { animation-delay: 0.1s; }
.panel.is-active .field:nth-of-type(3) { animation-delay: 0.15s; }
.panel.is-active .field:nth-of-type(4) { animation-delay: 0.2s; }
.panel.is-active .field:nth-of-type(5) { animation-delay: 0.25s; }
.panel.is-active .field:nth-of-type(6) { animation-delay: 0.3s; }

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.field span,
.chip-field legend,
.choice-field legend {
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    color: rgba(255, 247, 244, 0.78);
}

.field input,
.field textarea {
    width: 100%;
    border: 1px solid rgba(255, 247, 244, 0.18);
    background: rgba(18, 10, 14, 0.35);
    color: var(--cream);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    font: inherit;
    font-size: 0.98rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.field input[type="file"] {
    padding: 0.7rem;
    font-size: 0.88rem;
}

.field input:focus,
.field textarea:focus {
    border-color: rgba(240, 217, 181, 0.55);
    box-shadow: 0 0 0 3px rgba(216, 132, 154, 0.25);
}

.field textarea {
    resize: vertical;
    min-height: 88px;
}

.chip-field,
.choice-field {
    border: none;
    margin: 0 0 1.25rem;
    padding: 0;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 0.65rem;
}

.chip {
    appearance: none;
    border: 1px solid rgba(255, 247, 244, 0.22);
    background: rgba(255, 247, 244, 0.06);
    color: var(--cream);
    border-radius: 999px;
    padding: 0.55rem 0.9rem;
    font: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: transform 0.2s var(--ease), background 0.2s, border-color 0.2s;
}

.chip:hover {
    transform: translateY(-2px);
    border-color: rgba(240, 217, 181, 0.45);
}

.chip.is-selected {
    background: linear-gradient(135deg, rgba(240, 217, 181, 0.95), rgba(243, 196, 208, 0.95));
    color: var(--dusk);
    border-color: transparent;
    animation: chipPop 0.35s var(--ease);
}

@keyframes chipPop {
    0% { transform: scale(0.92); }
    60% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

.chip-inputs {
    display: none;
}

.choices {
    display: grid;
    gap: 0.55rem;
    margin-top: 0.7rem;
}

.choice {
    display: block;
    cursor: pointer;
}

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice span {
    display: block;
    padding: 0.85rem 1rem;
    border-radius: 14px;
    border: 1px solid rgba(255, 247, 244, 0.18);
    background: rgba(255, 247, 244, 0.05);
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
    letter-spacing: 0;
    font-size: 0.95rem;
    color: var(--cream);
}

.choice:hover span {
    border-color: rgba(240, 217, 181, 0.4);
}

.choice input:checked + span {
    background: linear-gradient(135deg, rgba(240, 217, 181, 0.2), rgba(216, 132, 154, 0.28));
    border-color: rgba(240, 217, 181, 0.55);
    transform: scale(1.01);
    animation: chipPop 0.35s var(--ease);
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    justify-content: flex-end;
    margin-top: 1.4rem;
}

.panel-actions-choice {
    position: relative;
    min-height: 3.2rem;
    justify-content: center;
    gap: 0.85rem;
    align-items: center;
}

.runaway-btn {
    z-index: 40;
    flex: 0 0 auto;
    white-space: nowrap;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    gap: 0.35rem;
    transition:
        left 0.65s cubic-bezier(0.34, 1.45, 0.64, 1),
        top 0.65s cubic-bezier(0.34, 1.45, 0.64, 1),
        transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.3s ease;
    will-change: left, top, transform;
}

.runaway-emoji {
    display: inline-block;
    font-size: 1.1em;
    line-height: 1;
    min-width: 1.25em;
    text-align: center;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.runaway-emoji.is-pop {
    animation: emojiPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes emojiPop {
    0% { transform: scale(0.7); }
    55% { transform: scale(1.35); }
    100% { transform: scale(1); }
}

.runaway-btn.is-bounce .runaway-emoji,
.runaway-btn.is-bounce-alt .runaway-emoji {
    transform: scale(1.15);
}

.runaway-label {
    display: inline-block;
}

.runaway-btn.is-fleeing {
    position: fixed !important;
    margin: 0 !important;
    flex: none !important;
    max-width: none !important;
    z-index: 9999 !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 36px rgba(36, 22, 28, 0.35);
    transform-origin: center center;
    /* Keep glass look when detached from the panel */
    background: rgba(36, 22, 28, 0.72) !important;
    border: 1px solid rgba(255, 247, 244, 0.35) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.runaway-btn.is-fleeing.is-bounce {
    transform: scale(1.06) rotate(-3deg);
}

.runaway-btn.is-fleeing.is-bounce-alt {
    transform: scale(1.06) rotate(3deg);
}

.runaway-hint {
    text-align: center;
    margin: 0.85rem 0 0;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--champagne);
    animation: riseIn 0.5s var(--ease);
}

.closing-note {
    margin: 0.5rem 0 0.25rem;
    padding: 1rem 1.1rem;
    border-radius: 16px;
    background: rgba(240, 217, 181, 0.1);
    border: 1px solid rgba(240, 217, 181, 0.2);
    font-family: var(--font-display);
    font-size: 1.05rem;
    line-height: 1.55;
}

.form-errors {
    margin-top: 1rem;
    color: #ffc9d4;
    font-size: 0.9rem;
}

/* Thanks */
.thanks-page .screen-thanks {
    text-align: center;
}

.heart-rain {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.heart-rain span {
    position: absolute;
    top: -10%;
    color: rgba(243, 196, 208, 0.75);
    font-size: 1rem;
    animation: fall linear forwards;
    text-shadow: 0 0 12px rgba(216, 132, 154, 0.5);
}

@keyframes fall {
    to {
        transform: translateY(110vh) rotate(360deg);
        opacity: 0;
    }
}

@media (max-width: 480px) {
    .panel {
        padding: 1.35rem 1.1rem 1.2rem;
        border-radius: 22px;
    }

    .panel-actions {
        flex-direction: column-reverse;
    }

    .panel-actions .btn {
        width: 100%;
    }

    .panel-actions-choice {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .panel-actions-choice .btn:not(.is-fleeing) {
        width: auto;
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
