* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #FFB6C8;
    font-family: 'Mali', cursive;
}

.page {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    padding: 24px;
    overflow: hidden;
}

/* ข้อความด้านบน: ให้คนสวยของเค้าาา */
.top-text {
    color: #A34F6C;
    font-size: 17px;
    text-align: center;

    margin-bottom: 75px;
    transform: translateY(-15px);
}

/* กลุ่มข้อความเปิดเลยและซอง */
.envelope-area {
    width: 100%;
    max-width: 430px;

    display: flex;
    flex-direction: column;
    align-items: center;

    transform: translateY(-12px);
}

/* คำว่าเปิดเลย */
.open-text {
    font-size: 30px;
    font-weight: 600;
    color: #A34F6C;

    margin-bottom: 18px;

    animation: wiggleText 2s ease-in-out infinite;
}

/* รูปซอง */
.envelope {
    display: block;

    width: 80%;
    height: auto;

    object-fit: contain;
    cursor: pointer;

    -webkit-tap-highlight-color: transparent;
}

/* ข้อความด้านล่าง */
.bottom-text {
    color: #A34F6C;
    font-size: 13px;

    margin-top: 24px;
}

/* ข้อความเปิดเลยดุ๊กดิ๊ก */
@keyframes wiggleText {
    0%, 100% {
        transform: rotate(0deg) translateY(0);
    }

    25% {
        transform: rotate(-2deg) translateY(-3px);
    }

    75% {
        transform: rotate(2deg) translateY(2px);
    }
}

/* รองรับหน้าจอมือถือ */
@media (max-width: 480px) {
    .page {
        padding: 22px;
    }

    .top-text {
        font-size: 17px;
        margin-bottom: 65px;
        transform: translateY(-20px);
    }

    .envelope-area {
        max-width: 100%;
    }

    .open-text {
        font-size: 25px;
        margin-bottom: 10px;
    }
}

/* ซองกระตุก */
.envelope.is-opening {
    animation: shakeEnvelope 0.35s ease-in-out;
}

/* ซองค่อย ๆ จางหาย */
.envelope.fade-out {
    animation: fadeEnvelope 0.8s ease forwards;
    pointer-events: none;
}

@keyframes shakeEnvelope {
    0%, 100% {
        transform: translateX(0) rotate(0);
    }
    25% {
        transform: translateX(-5px) rotate(-2deg);
    }
    50% {
        transform: translateX(5px) rotate(2deg);
    }
    75% {
        transform: translateX(-3px) rotate(-1deg);
    }
}

@keyframes fadeEnvelope {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-25px) scale(0.95);
    }
}

/* หน้าคำถาม: ซ่อนเอาไว้ก่อน */
.question-screen {
    position: fixed;
    inset: 0;
    z-index: 10;

    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding: 20px;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(15px) scale(0.98);

    transition:
        opacity 0.7s ease,
        transform 0.7s ease,
        visibility 0.7s ease;
}

/* หน้าคำถามค่อย ๆ ปรากฏ */
.question-screen.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* จัดหน้าคำถามให้แยกจากหน้าซอง */
.question-screen {
    position: fixed;
    inset: 0;
    z-index: 999;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #FFB6C8;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(15px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.question-screen.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.question-card {
    width: 100%;
    max-width: 360px;
    margin: auto;
    padding: 24px 20px;
    border-radius: 25px;
    border: 2px solid #F5C5D4;
    background: #FFF7FA;
    box-shadow: 0 10px 30px #A34F6C30;
    color: #A34F6C;
    text-align: center;
}

.question-card h2 {
    margin: 15px 0;
    font-size: 21px;
    line-height: 1.6;
}

.question-description {
    margin-bottom: 15px;
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
}

.answer-btn {
    width: 100%;
    padding: 12px;
    border: 1px solid #F0B6CB;
    border-radius: 15px;
    background: #FCE3EC;
    color: #A34F6C;
    font-family: 'Mali', cursive;
    font-size: 14px;
    cursor: pointer;
}

.quiz-image-box {
    display: none;
    margin: 15px auto;
}

.quiz-image-box.visible {
    display: block;
}

.quiz-image-box img {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    margin: auto;
}

.question-footer {
    margin-top: 18px;
    font-size: 12px;
}

@media (max-height: 650px) {
    .question-screen {
        align-items: flex-start;
    }
}
/* ปุ่มคำตอบ */

.answer-btn {
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

/* ตอนกดปุ่ม */
.answer-btn:active {
    transform: scale(0.93) translateY(3px);
    box-shadow: 0 2px 4px #A34F6C30;
}


/* ฉากบทสนทนาตอนจบ */
.ending-dialogue {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #FFB6C8;
    cursor: pointer;
    animation: dialogueFadeIn 0.6s ease;
}

.dialogue-box {
    width: 100%;
    max-width: 420px;
    min-height: 180px;
    padding: 28px 22px;
    border: 2px solid #F5C5D4;
    border-radius: 24px;
    background: #FFF7FA;
    box-shadow: 0 10px 35px #A34F6C25;
    text-align: center;
    color: #A34F6C;
}

.dialogue-name {
    font-size: 14px;
    margin-bottom: 25px;
    opacity: 0.8;
}

.dialogue-text {
    min-height: 60px;
    font-size: 23px;
    font-weight: 600;
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.dialogue-hint {
    margin-top: 20px;
    font-size: 12px;
    animation: hintBlink 1.2s ease-in-out infinite;
}

.ending-final {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    animation: dialogueFadeIn 0.8s ease;
}

.ending-final p:first-child {
    font-size: 30px;
    font-weight: 600;
}

.ending-final p:last-child {
    font-size: 16px;
}

@keyframes dialogueFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes hintBlink {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}


.proposal-box {
    text-align: center;
    animation: proposalAppear 0.7s ease;
}

.proposal-title {
    font-size: 30px;
    font-weight: bold;
    color: #ff5b91;
    margin: 20px 0;
    animation: proposalHeart 1.2s ease-in-out infinite;
}

.proposal-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin: 20px auto;
}

.proposal-options .answer-btn {
    width: 100%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.proposal-options .answer-btn:hover {
    transform: scale(1.04);
}

.proposal-timer {
    margin-top: 18px;
    font-size: 15px;
    color: #ff5b91;
}

#proposalCount {
    font-size: 24px;
    font-weight: bold;
}

.count-pop {
    display: inline-block;
    font-size: 64px;
    animation: countPop 0.8s ease;
}

@keyframes countPop {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes proposalAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes proposalHeart {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* =================================
   💗 GLOBAL THEME
================================= */

* {
    box-sizing: border-box;
}

button {
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.question-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    padding: 24px 16px;
    background:#FFB6C8;
}

.question-screen.show {
    display: flex;
}

/* =================================
   🎀 QUESTION CARD
================================= */

.question-card {
    width: 100%;
    max-width: 480px;
    padding: 30px 24px;
    border: 1px solid rgba(255, 182, 200, 0.6);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow:
        0 15px 45px rgba(236, 110, 153, 0.15),
        0 0 0 7px rgba(255, 255, 255, 0.5);
    text-align: center;
    animation: cardAppear 0.7s ease;
}

.question-label,
#questionProgress {
    color: #ee78a0;
    font-size: 13px;
    letter-spacing: 2px;
}

#questionTitle {
    color: #bd527c;
    font-size: 24px;
    line-height: 1.6;
    margin: 22px 0 16px;
}

#questionDescription {
    color: #a87b8d;
    font-size: 14px;
}

/* =================================
   💌 ANSWER BUTTONS
================================= */

#answerOptions,
.proposal-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 22px;
}

.answer-btn {
    display: block;
    width: 100%;
    padding: 13px 18px;
    border: 1.5px solid #ffc4d6;
    border-radius: 16px;
    background: #fff7fa;
    color: #bd527c;
    font-size: 16px;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        background 0.2s ease,
        box-shadow 0.2s ease;
}

.answer-btn:hover {
    background: #ffe1eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(236, 110, 153, 0.15);
}

.answer-btn:active {
    transform: scale(0.97);
}

#questionFooter {
    margin-top: 24px;
    color: #d88ba6;
    font-size: 13px;
}

/* =================================
   💗 VISUAL NOVEL DIALOGUE
================================= */

.ending-dialogue {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at center, #fff0f5, #ffe0eb);
    animation: sceneFadeIn 0.8s ease;
}

.dialogue-box {
    width: 100%;
    max-width: 600px;
    min-height: 240px;
    padding: 30px 26px;
    border: 1px solid #ffc4d6;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 15px 50px rgba(190, 75, 120, 0.16);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.dialogue-name {
    color: #e67da1;
    font-size: 14px;
    letter-spacing: 1px;
    margin: 0 0 25px;
}

.dialogue-text {
    min-height: 60px;
    color: #9f456a;
    font-size: 22px;
    line-height: 1.9;
    overflow-wrap: anywhere;
}

.dialogue-hint {
    color: #bd91a2;
    font-size: 12px;
    margin-top: 28px;
    animation: hintBlink 1.5s infinite;
}

/* =================================
   ⏳ COUNTDOWN
================================= */

.count-pop {
    display: inline-block;
    color: #ff6598;
    font-size: 68px !important;
    font-weight: bold;
    animation: countPop 0.8s ease;
}

@keyframes countPop {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    55% {
        transform: scale(1.3);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =================================
   💖 BE MY PARTNER?
================================= */

.proposal-box {
    animation: cardAppear 0.7s ease;
}

.proposal-title {
    color: #f05e91;
    font-size: 30px;
    font-weight: bold;
    line-height: 1.6;
    margin: 12px 0 22px;
    animation: heartBeat 1.5s infinite;
}

.proposal-options {
    max-width: 350px;
    margin: 10px auto;
}

.proposal-timer {
    margin-top: 20px;
    color: #bd7893;
    font-size: 14px;
}

#proposalCount {
    color: #f05e91;
    font-size: 23px;
    font-weight: bold;
}

/* =================================
   🖤 BLACK SCREEN LOVE LETTER
================================= */

.love-ending {
    position: fixed;
    inset: 0;
    z-index: 9999;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 30px 24px;
    background: #000;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    cursor: pointer;
    animation: blackFadeIn 1.3s ease;
}

.love-ending-name {
    color: #ffb6c8;
    font-size: 15px;
    letter-spacing: 2px;
    margin-bottom: 38px;
}

.love-ending-text {
    width: 100%;
    max-width: 680px;
    min-height: 100px;
    color: #fff;
    font-size: 22px;
    line-height: 2;
    overflow-wrap: anywhere;
}

.love-ending-hint {
    position: absolute;
    bottom: 30px;
    color: #999;
    font-size: 13px;
    animation: hintBlink 1.5s infinite;
}

.love-ending-final {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #000;
    color: #ffb6c8;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 18px;
    padding: 30px;
    text-align: center;
    animation: blackFadeIn 1.5s ease;
}

.love-ending-final p {
    max-width: 650px;
    line-height: 1.9;
}

/* =================================
   ✨ ANIMATIONS
================================= */

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes sceneFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes blackFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes hintBlink {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.045); }
}

/* =================================
   📱 MOBILE
================================= */

@media (max-width: 600px) {
    .question-card {
        padding: 25px 18px;
        border-radius: 23px;
    }

    #questionTitle {
        font-size: 21px;
    }

    .dialogue-box {
        padding: 25px 18px;
        min-height: 220px;
    }

    .dialogue-text {
        font-size: 19px;
    }

    .proposal-title {
        font-size: 26px;
    }

    .answer-btn {
        font-size: 15px;
        padding: 13px;
    }

    .love-ending {
        padding: 25px 20px;
    }

    .love-ending-text {
        font-size: 18px;
        line-height: 2;
    }

    .love-ending-name {
        margin-bottom: 28px;
    }
}

/* กรอบข้อความบนจอดำ */
.love-ending-text {
    position: relative;
    width: 100%;
    max-width: 700px;
    min-height: 180px;
    padding: 35px 28px;

    display: flex;
    justify-content: center;
    align-items: center;

    border: 1.5px solid rgba(255, 182, 200, 0.8);
    border-radius: 24px;

    background: linear-gradient(
        145deg,
        rgba(255, 182, 200, 0.07),
        rgba(255, 255, 255, 0.015)
    );

    box-shadow:
        0 0 12px rgba(255, 105, 150, 0.12),
        inset 0 0 18px rgba(255, 182, 200, 0.04);

    color: #fff;
    font-size: 22px;
    line-height: 2;
    overflow-wrap: anywhere;
}

/* กรอบมีแสงนุ่ม ๆ */
.love-ending-text::before {
    content: "";
    position: absolute;
    inset: -7px;
    border: 1px solid rgba(255, 182, 200, 0.2);
    border-radius: 29px;
    pointer-events: none;
}

/* ชื่อด้านบน */
.love-ending-name {
    color: #ffb6c8;
    font-size: 15px;
    letter-spacing: 3px;
    margin-bottom: 30px;
    text-shadow: 0 0 12px rgba(255, 105, 150, 0.5);
}

/* ข้อความแตะเพื่อไปต่อ */
.love-ending-hint {
    color: #ffb6c8;
    text-shadow: 0 0 8px rgba(255, 105, 150, 0.4);
}

/* รองรับมือถือ */
@media (max-width: 600px) {
    .love-ending-text {
        min-height: 160px;
        padding: 25px 18px;
        font-size: 18px;
        border-radius: 20px;
    }
}


/* ฉากจบสุดท้ายสีชมพู */
.love-ending-final {
    position: fixed;
    inset: 0;
    z-index: 10000;

    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;

    padding: 30px 20px;
    text-align: center;
    color: #c94f83;

    background:
        radial-gradient(circle at 15% 20%, #fff 0%, transparent 28%),
        radial-gradient(circle at 85% 80%, #ffc4df 0%, transparent 35%),
        linear-gradient(135deg, #ffe6f0, #ffc8df, #fff0f6);

    animation: pinkEndingAppear 1.2s ease;
}

/* กรอบฉากจบ */
.love-ending-final .final-card {
    width: 100%;
    max-width: 500px;
    padding: 28px 22px;

    background: rgba(255, 255, 255, 0.65);
    border: 2px solid #fff;
    border-radius: 30px;

    box-shadow:
        0 10px 35px rgba(214, 91, 145, 0.18),
        0 0 0 6px rgba(255, 255, 255, 0.25);
}

/* GIF แมวเต้น */
.love-ending-final .cat-dance {
    display: block;
    width: 100%;
    max-width: 280px;
    max-height: 280px;
    object-fit: contain;
    margin: 0 auto 18px;
    border-radius: 20px;
}

/* ข้อความฉลอง */
.love-ending-final h1 {
    color: #e45b98;
    font-size: clamp(26px, 6vw, 38px);
    margin: 8px 0;
}

.love-ending-final p {
    color: #b84d7c;
    font-size: 17px;
    line-height: 1.9;
    margin: 8px 0;
}

.love-ending-final .the-end {
    color: #e45b98;
    font-size: 13px;
    letter-spacing: 5px;
    margin-top: 18px;
}

@keyframes pinkEndingAppear {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 600px) {
    .love-ending-final .final-card {
        padding: 22px 16px;
    }

    .love-ending-final .cat-dance {
        max-width: 220px;
        max-height: 220px;
    }

    .love-ending-final p {
        font-size: 15px;
    }
}

/* ปิดสีฟ้าตอนแตะหน้าจอบนมือถือ */
* {
    -webkit-tap-highlight-color: transparent;
}

/* ป้องกันกรอบสีฟ้าตอนกดปุ่ม */
button,
a,
input,
textarea {
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

/* ปิดการไฮไลต์ข้อความตอนแตะค้าง */
button,
a {
    -webkit-user-select: none;
    user-select: none;
}

.timeout-box {
    animation: timeoutFadeIn 2s ease both;
}

.timeout-message {
    animation: timeoutTextIn 2.5s ease both;
}

.timeout-subtitle {
    opacity: 0;
    animation: timeoutTextIn 2s ease 1s forwards;
}

@keyframes timeoutFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes timeoutTextIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* เอฟเฟกต์เด้งดึ๋งตอนเปลี่ยนคำถาม */
.question-card.bouncy {
    animation: softBounce 0.35s ease-out;
    transform-origin: center;
}

@keyframes softBounce {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.025, 0.98); }
    65%  { transform: scale(0.99, 1.01); }
    100% { transform: scale(1); }
}