:root {
    --bg: #f3f1f2;
    --bg-soft: #faf7f8;
    --pink: #e95295;
    --pink-soft: #ff85c1;
    --pink-deep: #c23a78;
    --pink-muted: #d4a0c8;
    --text: #c23a78;
    --shadow: 0 10px 30px rgba(233, 82, 149, 0.12);
    --font-script: "Dancing Script", cursive;
    --font-sans: "Montserrat", system-ui, sans-serif;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --accent: var(--pink);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font-sans);
    background:
        radial-gradient(ellipse 120% 80% at 10% -10%, #ffe4f1 0%, transparent 45%),
        radial-gradient(ellipse 100% 70% at 100% 0%, #f5d0e8 0%, transparent 40%),
        linear-gradient(180deg, #f7f4f5 0%, #efeaeC 100%);
    color: var(--text);
    overflow-x: hidden;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: inherit;
}

.title-script {
    font-family: var(--font-script);
    font-weight: 700;
    color: var(--pink);
    line-height: 1.15;
    margin: 0;
}

/* Ambient blobs */
.bg-blobs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.35;
    animation: float 12s ease-in-out infinite;
}

.blob-1 {
    width: 220px;
    height: 220px;
    background: #ffb6d9;
    top: -40px;
    right: -60px;
}

.blob-2 {
    width: 180px;
    height: 180px;
    background: #f5c6e0;
    bottom: 10%;
    left: -50px;
    animation-delay: -4s;
}

.blob-3 {
    width: 140px;
    height: 140px;
    background: #ffd0e8;
    bottom: -30px;
    right: 20%;
    animation-delay: -7s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(12px, -18px) scale(1.05); }
}

/* Home */
.home {
    position: relative;
    z-index: 1;
    max-width: 480px;
    margin: 0 auto;
    padding: 1.75rem 1.25rem calc(2rem + var(--safe-bottom));
}

.home-header {
    text-align: center;
}

.hearts {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.hearts .title-script {
    font-size: clamp(1.85rem, 7vw, 2.35rem);
    flex: 1;
}

.heart {
    width: 28px;
    height: 28px;
    color: var(--pink);
    flex-shrink: 0;
    margin-top: 0.35rem;
    animation: heartbeat 2.4s ease-in-out infinite;
}

.heart-right {
    animation-delay: 0.4s;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.15); }
    30% { transform: scale(1); }
}

.lead-block {
    font-size: clamp(0.68rem, 2.8vw, 0.78rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    line-height: 1.55;
    margin: 0 0 0.85rem;
    color: var(--pink);
}

.lead-script {
    font-family: var(--font-script);
    font-size: clamp(1.15rem, 4.5vw, 1.4rem);
    font-weight: 600;
    color: var(--pink);
    margin: 0 0 0.75rem;
}

.flourish {
    color: var(--pink-soft);
    margin: 0.5rem auto 1rem;
    max-width: 260px;
}

.flourish svg {
    width: 100%;
    height: auto;
}

.instr {
    font-size: clamp(0.65rem, 2.6vw, 0.74rem);
    font-weight: 700;
    letter-spacing: 0.035em;
    text-transform: uppercase;
    line-height: 1.55;
    margin: 0 0 0.75rem;
    color: var(--pink);
}

/* Clue list */
.clue-list {
    list-style: none;
    margin: 1.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.clue-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(233, 82, 149, 0.12);
}

.clue-row:last-child {
    border-bottom: none;
}

.clue-label {
    font-family: var(--font-script);
    font-size: clamp(1.35rem, 5vw, 1.65rem);
    font-weight: 700;
    color: var(--pink);
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.clue-num {
    font-variant-numeric: tabular-nums;
}

.clue-status {
    font-family: var(--font-sans);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--pink);
    color: #fff;
    border-radius: 999px;
    padding: 0.2rem 0.5rem;
    vertical-align: middle;
    animation: pop-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.clue-row.is-unlocked .clue-status {
    display: inline-block !important;
}

.btn-scan,
.btn-open {
    appearance: none;
    border: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: clamp(0.62rem, 2.5vw, 0.72rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pink);
    text-decoration: none;
    padding: 0.55rem 0.35rem;
    cursor: pointer;
    position: relative;
    transition: color 0.2s, transform 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn-scan::after,
.btn-open::after {
    content: "";
    position: absolute;
    left: 0.35rem;
    right: 0.35rem;
    bottom: 0.3rem;
    height: 1.5px;
    background: currentColor;
    opacity: 0.45;
    transform: scaleX(0.85);
    transition: transform 0.25s, opacity 0.25s;
}

.btn-scan:active,
.btn-open:active {
    transform: scale(0.96);
}

.btn-scan:hover::after,
.btn-open:hover::after {
    transform: scaleX(1);
    opacity: 0.9;
}

.clue-row.is-unlocked .btn-scan {
    display: none;
}

.clue-row.is-unlocked .btn-open {
    display: inline-flex !important;
    align-items: center;
}

.progress-note {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 1.5rem;
    color: var(--pink-deep);
    min-height: 1.2em;
}

/* Scanner overlay */
.scanner-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(40, 10, 30, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    animation: fade-overlay 0.25s ease;
}

.scanner-overlay[hidden] {
    display: none !important;
}

.scanner-sheet {
    width: 100%;
    max-width: 480px;
    background: var(--bg-soft);
    border-radius: 24px 24px 0 0;
    padding: 1.25rem 1.25rem calc(1.5rem + var(--safe-bottom));
    box-shadow: var(--shadow);
    animation: sheet-up 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.scanner-head {
    position: relative;
    text-align: center;
    margin-bottom: 1rem;
}

.scanner-title {
    font-size: 1.75rem;
}

.scanner-hint {
    font-size: 0.75rem;
    font-weight: 600;
    margin: 0.35rem 0 0;
    color: var(--pink-deep);
}

.btn-close {
    position: absolute;
    top: -0.25rem;
    right: 0;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    background: rgba(233, 82, 149, 0.12);
    color: var(--pink);
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

#qr-reader {
    border-radius: 16px;
    overflow: hidden;
    background: #111;
}

#qr-reader video {
    border-radius: 16px !important;
}

.scanner-error {
    color: #c0392b;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    margin: 0.75rem 0 0;
}

.scanner-tip {
    text-align: center;
    font-size: 0.7rem;
    margin: 0.85rem 0 0;
    opacity: 0.75;
}

@keyframes sheet-up {
    from { transform: translateY(40%); opacity: 0.5; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fade-overlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Clue page */
.page-clue {
    background:
        radial-gradient(ellipse 90% 50% at 50% 0%, color-mix(in srgb, var(--accent) 18%, white) 0%, transparent 55%),
        var(--bg);
}

.clue-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(10px);
}

.btn-back {
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--pink);
    padding: 0.4rem 0.6rem;
}

.clue-pill {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--accent, var(--pink));
    color: #fff;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
}

.clue-pill.finale {
    background: linear-gradient(135deg, #e95295, #ff85c1);
}

.clue-stage {
    max-width: 480px;
    margin: 0 auto;
    padding: 0.5rem 0.75rem calc(2rem + var(--safe-bottom));
}

.clue-card {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background: #fff;
    animation: reveal 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.clue-art {
    width: 100%;
    height: auto;
    vertical-align: middle;
}

.clue-text {
    border-top: 1px solid rgba(233, 82, 149, 0.15);
    padding: 0.75rem 1rem 1rem;
    background: var(--bg-soft);
}

.clue-text summary {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    color: var(--pink);
    list-style: none;
}

.clue-text summary::-webkit-details-marker {
    display: none;
}

.clue-text[open] summary {
    margin-bottom: 0.75rem;
}

.clue-text .title-script {
    font-size: 1.6rem;
    text-align: center;
    margin-bottom: 0.75rem;
}

.poem {
    font-size: clamp(0.62rem, 2.5vw, 0.72rem);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1.55;
    text-align: center;
    color: var(--pink-deep);
    margin: 0;
}

.clue-actions {
    display: flex;
    justify-content: center;
    margin-top: 1.25rem;
}

.clue-actions .btn-scan {
    border: 2px solid var(--pink);
    border-radius: 999px;
    padding: 0.7rem 1.4rem;
}

.clue-actions .btn-scan::after {
    display: none;
}

.clue-missing {
    text-align: center;
    padding: 4rem 1.5rem;
}

.clue-missing .title-script {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

/* Confetti */
.confetti {
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    overflow: hidden;
}

.confetti i {
    position: absolute;
    top: -12px;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    opacity: 0.9;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

/* Animations */
.fade-in {
    animation: fade-up 0.7s ease both;
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }
.delay-6 { animation-delay: 0.55s; }
.delay-7 { animation-delay: 0.6s; }
.delay-8 { animation-delay: 0.65s; }

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes pop-in {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (min-width: 768px) {
    .home {
        padding-top: 2.5rem;
    }

    .scanner-overlay {
        align-items: center;
        padding: 1rem;
    }

    .scanner-sheet {
        border-radius: 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
