/* ============================================================
   FOREVER vanessa — Valentine Puzzle Site
   Mobile-first · S24 Ultra optimized · Design-heavy
   ============================================================ */

/* ---------- Custom Properties ---------- */
:root {
    --primary: #ff4d6d;
    --primary-deep: #c9184a;
    --secondary: #ff8fab;
    --accent: #ffd700;
    --accent-soft: #f4a261;
    --bg: #0a0008;
    --bg-card: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.55);
    --glow-primary: 0 0 20px rgba(255, 77, 109, 0.45);
    --glow-accent: 0 0 20px rgba(255, 215, 0, 0.35);
    --radius: 16px;
    --radius-sm: 10px;
    --font-script: 'Great Vibes', cursive;
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Poppins', sans-serif;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
    overflow: hidden;
    height: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }

/* ---------- Floating Hearts Background ---------- */
#hearts-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.floating-heart {
    position: absolute;
    bottom: -60px;
    animation: floatUp var(--dur) linear forwards;
    opacity: 0;
    font-size: var(--size);
    filter: blur(var(--blur, 0px));
    will-change: transform, opacity;
}

@keyframes floatUp {
    0%   { transform: translateY(0) translateX(0) rotate(0deg) scale(0.5); opacity: 0; }
    10%  { opacity: var(--peak-opacity, 0.6); transform: translateY(-10vh) translateX(calc(var(--drift) * 0.1)) rotate(20deg) scale(0.8); }
    50%  { opacity: var(--peak-opacity, 0.6); transform: translateY(-50vh) translateX(var(--drift)) rotate(180deg) scale(1); }
    100% { opacity: 0; transform: translateY(-110vh) translateX(calc(var(--drift) * -0.5)) rotate(360deg) scale(0.6); }
}

/* ---------- Progress Bar ---------- */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.06);
}
.progress-track { height: 100%; width: 100%; }
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    box-shadow: 0 0 12px var(--primary), 0 0 4px var(--accent);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 2px 2px 0;
}

/* ---------- Sections (shared) ---------- */
.section {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 16px;
    padding-top: calc(16px + var(--safe-top));
    padding-bottom: calc(16px + var(--safe-bottom));
    overflow: hidden;
}
.section.active {
    display: flex;
    animation: sectionIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.section.leaving {
    display: flex;
    animation: sectionOut 0.4s ease forwards;
}

@keyframes sectionIn {
    from { opacity: 0; transform: translateY(40px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes sectionOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to   { opacity: 0; transform: translateY(-30px) scale(0.97); }
}

.section-content {
    width: 100%;
    max-width: min(420px, calc(100vw - 32px));
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 10px 0;
    box-sizing: border-box;
}
.section-content::-webkit-scrollbar { display: none; }

.section-tag {
    font-size: 0.7rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-dim);
    font-weight: 500;
}

.section-q {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    line-height: 1.35;
    background: linear-gradient(135deg, var(--text) 30%, var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.section-sub {
    font-size: 0.9rem;
    color: var(--text-dim);
    line-height: 1.5;
}

.highlight-line {
    font-family: var(--font-script);
    font-size: 1.9rem;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(255, 77, 109, 0.4);
}

/* ---------- WELCOME ---------- */
.welcome-content { gap: 18px; }

.welcome-domain {
    font-family: var(--font-body);
    font-size: clamp(0.65rem, 2.2vw, 0.8rem);
    letter-spacing: clamp(2px, 1vw, 4px);
    text-transform: lowercase;
    color: var(--accent);
    background: linear-gradient(90deg, var(--accent), var(--accent-soft));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    padding: 10px 18px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 30px;
    position: relative;
    max-width: 100%;
    box-sizing: border-box;
    word-break: break-all;
}
.welcome-domain::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(255,215,0,0.1), transparent);
    z-index: -1;
}

.welcome-divider {
    font-size: 1rem;
    color: var(--text-dim);
    letter-spacing: 8px;
}

.welcome-title {
    font-family: var(--font-script);
    font-size: 3rem;
    font-weight: 400;
    color: var(--text);
    text-shadow: 0 0 30px rgba(255, 77, 109, 0.3);
    line-height: 1.2;
}

.welcome-text {
    font-size: 0.95rem;
    color: var(--text-dim);
    line-height: 1.7;
    max-width: 300px;
}

.bookmark-hint {
    font-size: 0.75rem;
    color: var(--accent);
    opacity: 0.7;
    font-style: italic;
}

/* ---------- Staggered entrance ---------- */
.anim-in {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.7s ease forwards;
}
.d1 { animation-delay: 0.3s; }
.d2 { animation-delay: 0.7s; }
.d3 { animation-delay: 1.1s; }
.d4 { animation-delay: 1.5s; }
.d5 { animation-delay: 1.9s; }

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

/* ---------- Buttons ---------- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 36px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    background: linear-gradient(135deg, var(--primary), var(--primary-deep));
    color: var(--text);
    box-shadow: var(--glow-primary);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    overflow: hidden;
    min-height: 50px;
    touch-action: manipulation;
}
.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    border-radius: inherit;
}
.btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 0 10px rgba(255, 77, 109, 0.3);
}

/* ---------- Option Cards (Section 1) ---------- */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.opt-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 22px 10px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.3s ease;
    min-height: 100px;
    touch-action: manipulation;
}
.opt-card .opt-emoji { font-size: 2rem; }
.opt-card .opt-label {
    font-size: 0.85rem;
    font-weight: 500;
}
.opt-card:active {
    transform: scale(0.96);
}
.opt-card.correct {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}
.opt-card.wrong {
    animation: shake 0.5s ease;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-8px); }
    40%      { transform: translateX(8px); }
    60%      { transform: translateX(-6px); }
    80%      { transform: translateX(6px); }
}

/* ---------- Option Pills (sections 2, 4) ---------- */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.opt-pill {
    padding: 14px 16px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 50px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: all 0.3s ease;
    text-align: center;
    touch-action: manipulation;
    min-height: 50px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.opt-pill:active {
    transform: scale(0.97);
}
.opt-pill.selected {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.25);
}
.opt-pill.correct-pick {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.25);
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    0%   { transform: scale(0.9); }
    50%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* ---------- Feedback ---------- */
.feedback {
    font-size: 0.9rem;
    min-height: 24px;
    transition: opacity 0.3s;
}
.feedback.error { color: #ff6b6b; }
.feedback.success { color: #22c55e; }

/* ---------- Overlays (angry / pizza) ---------- */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 0, 8, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.overlay.show {
    opacity: 1;
    visibility: visible;
}

.overlay-box {
    text-align: center;
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0%   { transform: scale(0.3) rotate(-10deg); opacity: 0; }
    50%  { transform: scale(1.1) rotate(3deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Angry overlay */
.angry-emoji {
    font-size: 5rem;
    animation: headShake 0.8s ease;
}

@keyframes headShake {
    0%   { transform: rotate(0); }
    15%  { transform: rotate(-12deg); }
    30%  { transform: rotate(10deg); }
    45%  { transform: rotate(-8deg); }
    60%  { transform: rotate(6deg); }
    75%  { transform: rotate(-3deg); }
    100% { transform: rotate(0); }
}

.angry-text {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    margin-top: 10px;
    color: var(--primary);
}
.angry-sub {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-top: 6px;
}

/* Pizza overlay */
.pizza-title {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--accent);
    text-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
}
.pizza-sub {
    font-size: 1rem;
    color: var(--text-dim);
    margin-top: 8px;
}

.pizza-drop {
    position: absolute;
    font-size: var(--size);
    animation: pizzaFall var(--dur) linear forwards;
    pointer-events: none;
}
@keyframes pizzaFall {
    0%   { transform: translateY(-60px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0.3; }
}

/* ---------- PUZZLE (Section 3) ---------- */
.puzzle-wrapper {
    width: 100%;
    max-width: min(340px, calc(100vw - 48px));
    position: relative;
    box-sizing: border-box;
}

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 3px;
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
}

.puzzle-piece {
    background-image: url('images/couple.jpg');
    background-size: 400% 400%;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    touch-action: manipulation;
    position: relative;
}
.puzzle-piece:active { transform: scale(0.94); }
.puzzle-piece.selected {
    box-shadow: 0 0 0 3px var(--primary), var(--glow-primary);
    transform: scale(1.04);
    z-index: 2;
    filter: brightness(1.2);
}
.puzzle-piece.solved-piece {
    animation: solvedPop 0.4s ease forwards;
}
@keyframes solvedPop {
    0%   { transform: scale(1); filter: brightness(1); }
    50%  { transform: scale(1.08); filter: brightness(1.3); }
    100% { transform: scale(1); filter: brightness(1); border-radius: 0; }
}

.puzzle-moves {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* puzzle solved glow */
.puzzle-grid.solved {
    box-shadow: 0 0 40px rgba(255, 77, 109, 0.4), 0 0 80px rgba(255, 215, 0, 0.2);
    border-color: var(--primary);
}
.puzzle-grid.solved .puzzle-piece {
    border-radius: 0;
    gap: 0;
}

/* ---------- SECTION 5 — Form ---------- */
form {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
}

textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    resize: vertical;
    min-height: 140px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
textarea::placeholder { color: var(--text-dim); }
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(255, 77, 109, 0.15);
}

.form-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.form-success.hidden { display: none; }
.success-icon {
    font-size: 3.5rem;
    animation: heartBeat 1s ease infinite;
}
.success-msg {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--secondary);
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    15%      { transform: scale(1.15); }
    30%      { transform: scale(1); }
    45%      { transform: scale(1.1); }
    60%      { transform: scale(1); }
}

/* ---------- SECTION 6 — Input ---------- */
.input-row {
    display: flex;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.input-row input {
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    font-size: 1rem;
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    background: var(--bg-card);
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    min-height: 50px;
}
.input-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(255, 77, 109, 0.15);
}
.input-row .btn-primary {
    flex-shrink: 0;
    padding: 14px 22px;
}

.hint {
    font-size: 0.8rem;
    color: var(--accent);
    opacity: 0.8;
    font-style: italic;
    animation: fadeUp 0.5s ease;
}
.hint.hidden { display: none; }

/* ---------- SECTION 7 — Finale ---------- */
.finale-content {
    gap: 20px !important;
}

.congrats-title {
    font-family: var(--font-script);
    font-size: 2.6rem;
    font-weight: 400;
    line-height: 1.3;
    color: var(--accent);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
}

.finale-text {
    font-size: 0.95rem;
    color: var(--text-dim);
    line-height: 1.6;
}

.code-reveal {
    display: flex;
    gap: clamp(8px, 2.5vw, 12px);
    justify-content: center;
    margin: 10px 0;
    width: 100%;
    max-width: 100%;
}

.code-digit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(56px, 17vw, 68px);
    height: clamp(68px, 21vw, 85px);
    font-family: var(--font-heading);
    font-size: clamp(2rem, 6.5vw, 2.6rem);
    font-weight: 700;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, rgba(255,77,109,0.15), rgba(255,215,0,0.1));
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: var(--accent);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.15);
    opacity: 0;
    transform: scale(0.3) rotateY(90deg);
    transition: none;
}
.code-digit.revealed {
    animation: digitReveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes digitReveal {
    0%   { opacity: 0; transform: scale(0.3) rotateY(90deg); }
    60%  { transform: scale(1.15) rotateY(-5deg); }
    100% { opacity: 1; transform: scale(1) rotateY(0); }
}

.finale-instruction {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    opacity: 0;
    animation: fadeUp 0.6s ease 3.5s forwards;
}

.finale-love {
    font-family: var(--font-script);
    font-size: 1.8rem;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(255, 77, 109, 0.4);
    opacity: 0;
    animation: fadeUp 0.6s ease 4s forwards;
}

/* ---------- Confetti Canvas ---------- */
#fireworksCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}
#fireworksCanvas.active { opacity: 1; }

#confettiCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}
#confettiCanvas.active { opacity: 1; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }

/* ---------- RESPONSIVE FINE-TUNING ---------- */

/* Small phones (< 380px width) */
@media (max-width: 379px) {
    .welcome-title { font-size: 2.4rem; }
    .section-q { font-size: 1.25rem; }
    .highlight-line { font-size: 1.5rem; }
    .code-digit { width: 56px; height: 70px; font-size: 2rem; }
    .congrats-title { font-size: 2rem; }
    .opt-card { padding: 16px 8px; min-height: 85px; }
    .opt-card .opt-emoji { font-size: 1.6rem; }
}

/* iPhone models — iPhone 12/13/14/15 (390px), iPhone Pro Max (430px) */
@media (min-width: 380px) and (max-width: 411px) {
    .welcome-title { font-size: 2.8rem; }
    .section-q { font-size: 1.35rem; }
    .highlight-line { font-size: 1.6rem; }
    .opt-card { padding: 18px 8px; min-height: 85px; font-size: 0.92rem; }
    .opt-card .opt-emoji { font-size: 1.7rem; }
    .opt-pill { padding: 12px 16px; font-size: 0.95rem; }
    .congrats-title { font-size: 2.2rem; }
    .section-content { gap: 14px; }
    .puzzle-wrapper { max-width: min(300px, calc(100vw - 48px)); }
    .options-grid { gap: 8px; }
}

/* S24 Ultra & similar large phones (412px+) */
@media (min-width: 412px) {
    .section-q { font-size: 1.55rem; }
    .welcome-title { font-size: 3.2rem; }
    .opt-card { padding: 26px 12px; }
    .puzzle-wrapper { max-width: 360px; }
}

/* Extra tall screens — give more breathing room */
@media (min-height: 800px) {
    .section-content { gap: 20px; }
    .welcome-content { gap: 24px; }
}

/* Landscape (just in case) */
@media (orientation: landscape) and (max-height: 500px) {
    .section-content { gap: 10px; }
    .welcome-title { font-size: 2rem; }
    .section-q { font-size: 1.1rem; }
    .opt-card { padding: 12px 8px; min-height: 70px; }
    .code-digit { width: 50px; height: 60px; font-size: 1.6rem; }
}

/* Tablet+ safety net */
@media (min-width: 768px) {
    .section-content { max-width: 500px; }
    .puzzle-wrapper { max-width: 400px; }
}
