@font-face {
    font-family: 'Lora';
    src: url('../asset/fonts/Lora-Italic-VariableFont_wght.ttf') format('truetype');
    font-weight: 400 700;
    font-style: italic;
    font-display: swap;
}

html,
body {
    width: 100%;
    height: 100%;
}

/* ========== Màn intro ========== */
.intro-screen {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    overflow: hidden;
    background: radial-gradient(ellipse 100% 90% at 50% 35%, #1a4d32 0%, #0d2818 42%, #061208 100%);
    transition: opacity 0.18s ease, visibility 0.18s ease;
}

.intro-screen--leaving {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Chạm cỏ — icon sáng lên rồi vào màn chính */
.intro-screen--tap-glow .intro-icon {
    animation: none;
    transform: scale(1.08);
    filter:
        drop-shadow(0 0 18px rgba(255, 255, 255, 0.85))
        drop-shadow(0 0 36px rgba(110, 231, 183, 0.95))
        drop-shadow(0 0 56px rgba(52, 211, 153, 0.75));
    transition: filter 0.15s ease, transform 0.15s ease;
}

.intro-screen--tap-glow .intro-glow {
    opacity: 1;
    transform: scale(1.15);
}

.intro-glow {
    position: absolute;
    width: min(90vw, 420px);
    height: min(90vw, 420px);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(74, 222, 128, 0.35) 0%, rgba(52, 211, 153, 0.08) 45%, transparent 70%);
    animation: introGlowPulse 3s ease-in-out infinite;
    pointer-events: none;
}

.intro-sparkles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.intro-sparkles span {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(167, 243, 208, 0.9);
    box-shadow: 0 0 10px rgba(110, 231, 183, 0.8);
    animation: introSparkle 2.4s ease-in-out infinite;
}

.intro-sparkles span:nth-child(1) { top: 18%; left: 22%; animation-delay: 0s; }
.intro-sparkles span:nth-child(2) { top: 28%; right: 18%; animation-delay: 0.4s; }
.intro-sparkles span:nth-child(3) { top: 62%; left: 14%; animation-delay: 0.8s; }
.intro-sparkles span:nth-child(4) { top: 70%; right: 24%; animation-delay: 1.2s; }
.intro-sparkles span:nth-child(5) { top: 42%; left: 8%; animation-delay: 0.6s; }
.intro-sparkles span:nth-child(6) { top: 48%; right: 10%; animation-delay: 1s; }

.intro-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: min(94vw, 680px);
    padding: clamp(0.85rem, 2.8vw, 1.5rem);
}

.intro-eyebrow {
    margin: 0 0 0.5rem;
    font-family: 'Lora', Georgia, serif;
    font-style: italic;
    font-size: clamp(0.95rem, 3.5vw, 1.15rem);
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: rgba(167, 243, 208, 0.85);
}

.intro-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    margin: 0 0 1.75rem;
    font-family: 'Lora', Georgia, serif;
    font-style: italic;
    font-weight: 600;
    line-height: 1.2;
    color: #ecfdf5;
    text-shadow: 0 0 24px rgba(52, 211, 153, 0.45);
}

.intro-title-line {
    font-size: clamp(1.35rem, 5.2vw, 2rem);
    white-space: nowrap;
    max-width: 100%;
}

.intro-title-recipient {
    font-size: clamp(1.65rem, 6.5vw, 2.5rem);
    font-weight: 700;
    color: #a7f3d0;
    text-shadow: 0 0 28px rgba(52, 211, 153, 0.55);
    max-width: min(92vw, 18ch);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.intro-start-btn {
    position: relative;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.intro-start-btn:focus-visible {
    outline: 2px solid rgba(167, 243, 208, 0.9);
    outline-offset: 6px;
    border-radius: 12px;
}

.intro-icon {
    display: block;
    width: min(52vw, 200px);
    height: auto;
    filter: drop-shadow(0 8px 28px rgba(0, 0, 0, 0.45));
    animation: introIconFloat 2.8s ease-in-out infinite;
    transition: transform 0.35s ease;
}

.intro-start-btn:hover .intro-icon,
.intro-start-btn:focus .intro-icon {
    transform: scale(1.06);
}

.intro-start-btn:active .intro-icon {
    transform: scale(0.96);
}

.intro-hint {
    margin: 1.25rem 0 0;
    font-family: 'Lora', Georgia, serif;
    font-style: italic;
    font-size: clamp(0.9rem, 3.2vw, 1.05rem);
    color: rgba(209, 250, 229, 0.75);
    animation: introHintPulse 2s ease-in-out infinite;
}

.app-main--hidden {
    visibility: hidden;
    pointer-events: none;
}

.app-main--visible {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
}

@keyframes introGlowPulse {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.08); opacity: 1; }
}

@keyframes introSparkle {
    0%, 100% { opacity: 0.2; transform: scale(0.6); }
    50% { opacity: 1; transform: scale(1.2); }
}

@keyframes introIconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes introHintPulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

@keyframes appMainIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .intro-glow,
    .intro-sparkles span,
    .intro-icon,
    .intro-hint {
        animation: none;
    }

}

/* ========== Màn chính ========== */
body {
    background: radial-gradient(ellipse 120% 90% at 50% 40%, #0f2a1c 0%, #0a1f14 45%, #071810 100%);
    overflow: hidden;
    touch-action: none;
    min-height: 100dvh;
}

.image-text-fly-screen {
    position: relative;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    touch-action: none;
    background: radial-gradient(ellipse 80% 60% at 50% 45%, rgba(52, 211, 153, 0.045) 0%, transparent 55%);
}

.wishes-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    transform-style: preserve-3d;
}

.wishes-layer-space {
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform-origin: center center;
    will-change: transform;
}

.falling-container {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    transform-style: preserve-3d;
}

/* Lớp trang trí cố định — luôn trên mọi phần tử rơi */
.ui-deco-layer {
    position: fixed;
    inset: 0;
    z-index: 100;
    pointer-events: none;
}

/* Dây cỏ leoTren — dải liền mạch phía trên */
.top-deco-strip {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: min(20vh, 155px);
    overflow: hidden;
    pointer-events: none;
    -webkit-mask-image: linear-gradient(
        to bottom,
        #000 0%,
        #000 62%,
        rgba(0, 0, 0, 0.55) 82%,
        transparent 100%
    );
    mask-image: linear-gradient(
        to bottom,
        #000 0%,
        #000 62%,
        rgba(0, 0, 0, 0.55) 82%,
        transparent 100%
    );
}

.top-deco-strip::before {
    content: '';
    position: absolute;
    inset: -10% 0 30%;
    z-index: 0;
    background: radial-gradient(
        ellipse 90% 80% at 50% 0%,
        rgba(74, 222, 128, 0.14) 0%,
        rgba(52, 211, 153, 0.06) 45%,
        transparent 72%
    );
    pointer-events: none;
}

.top-deco-strip::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        transparent 55%,
        rgba(7, 24, 16, 0.35) 78%,
        rgba(7, 24, 16, 0.75) 100%
    );
    pointer-events: none;
}

.top-deco-tile {
    position: absolute;
    top: 0;
    z-index: 1;
    object-fit: contain;
    object-position: bottom center;
    mix-blend-mode: lighten;
    filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.4));
    transform-origin: center bottom;
}

.top-deco-tile--flip {
    transform: scaleX(-1);
}

@media (prefers-reduced-motion: no-preference) {
    .top-deco-tile {
        animation: topDecoFloat 7s ease-in-out infinite;
    }

    .top-deco-tile--flip {
        animation: topDecoFloatFlip 7s ease-in-out infinite;
    }

    .top-deco-tile:nth-child(3n) { animation-delay: -1.5s; }
    .top-deco-tile:nth-child(3n + 1) { animation-delay: -3s; }
    .top-deco-tile:nth-child(3n + 2) { animation-delay: -4.5s; }
}

@keyframes topDecoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

@keyframes topDecoFloatFlip {
    0%, 100% { transform: scaleX(-1) translateY(0); }
    50% { transform: scaleX(-1) translateY(4px); }
}

.corner-deco {
    position: absolute;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    object-fit: contain;
    mix-blend-mode: lighten;
}

/* Chuông góc trên — khung cố định, lật ảnh bên trong (tránh mất icon góc phải) */
.chuong-slot {
    position: absolute;
    top: 0;
    z-index: 110;
    width: min(28vw, 150px);
    pointer-events: none;
    line-height: 0;
}

.chuong-slot--left {
    left: 0;
}

.chuong-slot--right {
    right: 0;
}

.chuong-icon {
    display: block;
    width: 100%;
    height: auto;
    max-height: min(28vh, 210px);
    mix-blend-mode: lighten;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}

.chuong-icon--flip {
    transform: scaleX(-1);
}

.corner-deco--bottom-left {
    left: 0;
    bottom: 0;
    width: min(38vw, 200px);
    max-height: 32vh;
    height: auto;
}

.corner-deco--bottom-right {
    right: 0;
    bottom: 0;
    width: min(40vw, 220px);
    max-height: 34vh;
    height: auto;
}

.fly-gradient-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background: linear-gradient(
        to top,
        rgba(8, 26, 16, 0.35) 0%,
        transparent 30%,
        transparent 70%,
        rgba(8, 26, 16, 0.35) 100%
    );
    opacity: 0.55;
}

#falling-container {
    contain: strict;
}

.falling-item {
    will-change: transform;
    backface-visibility: hidden;
    pointer-events: auto;
    touch-action: none;
    transform-style: preserve-3d;
}

.wish-inner {
    display: inline-block;
    width: fit-content;
    max-width: fit-content;
    transform-style: preserve-3d;
    transform-origin: center center;
    will-change: transform;
}

.wish-text,
img.wish-image,
.photo-frame {
    touch-action: none;
    cursor: grab;
}

.falling-item:active .wish-text,
.falling-item:active img.wish-image,
.falling-item:active .photo-frame {
    cursor: grabbing;
}

/* Khung ảnh — viền ôm sát, không padding thừa */
.photo-frame {
    display: table;
    width: fit-content;
    max-width: fit-content;
    box-sizing: content-box;
    line-height: 0;
    font-size: 0;
    padding: 0;
    margin: 0;
    border: 2px solid rgba(52, 211, 153, 0.38);
    border-radius: 10px;
    background: #152219;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.32),
        0 0 12px rgba(52, 211, 153, 0.22);
    overflow: hidden;
}

.photo-frame img.wish-image {
    display: block;
    width: auto;
    height: auto;
    max-width: unset;
    max-height: unset;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
}

/* Lời chúc rơi — font Lora Italic, nét rõ */
.blessing-text {
    font-family: 'Lora', Georgia, 'Times New Roman', serif;
    font-style: italic;
    font-weight: 600;
    letter-spacing: 0.02em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.65),
        0 0 6px rgba(52, 211, 153, 0.35);
}

/* ========== Responsive ========== */
/* Điện thoại nhỏ */
@media (max-width: 479px) {
    .intro-content {
        width: min(96vw, 420px);
        padding: 0.75rem;
    }

    .intro-eyebrow {
        letter-spacing: 0.2em;
        margin-bottom: 0.35rem;
    }

    .intro-title {
        margin-bottom: 1.1rem;
        gap: 0.2rem;
    }

    .intro-title-line {
        white-space: normal;
        line-height: 1.25;
        font-size: clamp(1.1rem, 6.2vw, 1.35rem);
    }

    .intro-title-recipient {
        max-width: 88vw;
        font-size: clamp(1.35rem, 8vw, 1.8rem);
    }

    .intro-icon {
        width: min(58vw, 170px);
    }

    .intro-hint {
        margin-top: 0.85rem;
        font-size: clamp(0.78rem, 3.8vw, 0.92rem);
    }

    .top-deco-strip {
        height: min(16vh, 108px);
    }

    .chuong-slot {
        width: min(31vw, 112px);
    }

    .corner-deco--bottom-left {
        width: min(34vw, 138px);
        max-height: 24vh;
    }

    .corner-deco--bottom-right {
        width: min(36vw, 148px);
        max-height: 24vh;
    }
}

/* iPad / tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .intro-content {
        width: min(78vw, 760px);
    }

    .intro-title-line {
        font-size: clamp(1.55rem, 4.1vw, 2.1rem);
    }

    .intro-title-recipient {
        font-size: clamp(2rem, 5.2vw, 2.8rem);
    }

    .intro-icon {
        width: min(36vw, 240px);
    }

    .top-deco-strip {
        height: min(17vh, 130px);
    }
}

/* laptop/desktop lớn */
@media (min-width: 1280px) {
    .intro-content {
        width: min(68vw, 900px);
    }

    .intro-title-line {
        font-size: clamp(1.8rem, 2.6vw, 2.35rem);
    }

    .intro-title-recipient {
        font-size: clamp(2.2rem, 3.6vw, 3.2rem);
        max-width: min(72vw, 26ch);
    }

    .intro-icon {
        width: min(18vw, 260px);
    }

    .top-deco-strip {
        height: min(18vh, 165px);
    }

    .corner-deco--bottom-left {
        width: min(20vw, 230px);
    }

    .corner-deco--bottom-right {
        width: min(22vw, 250px);
    }
}

/* ========== Watermark xem trước (create.html → ?preview=1) ========== */
.preview-demo-watermark {
    position: fixed;
    inset: 0;
    z-index: 450;
    pointer-events: none;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.preview-demo-watermark.is-active {
    opacity: 1;
    visibility: visible;
}

.preview-demo-watermark__grid {
    position: absolute;
    inset: -38%;
    display: grid;
    grid-template-columns: repeat(var(--preview-wm-cols, 5), 1fr);
    row-gap: clamp(36px, 8vw, 72px);
    column-gap: clamp(6px, 1.6vw, 14px);
    transform: rotate(-28deg);
    justify-items: center;
    align-content: center;
}

.preview-demo-watermark__grid span {
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: clamp(1rem, 4.2vw, 1.65rem);
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.16);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
    white-space: nowrap;
    user-select: none;
}

.preview-demo-watermark__badge {
    position: fixed;
    top: max(10px, env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 7px 16px;
    border-radius: 999px;
    background: rgba(6, 24, 16, 0.62);
    border: 1px solid rgba(167, 243, 208, 0.45);
    color: rgba(236, 253, 245, 0.96);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: clamp(0.72rem, 2.8vw, 0.86rem);
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow:
        0 4px 18px rgba(0, 0, 0, 0.28),
        0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    pointer-events: none;
}
