* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Mitr', sans-serif;
    background-color: #ffeef2;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 16px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
}

@media (max-width: 360px) {
    .btn {
        min-width: 96px;
        padding: 10px 16px;
    }
    .btn-container {
        gap: 10px;
    }
}

@media (max-height: 480px) {
    .card {
        padding-top: 18px;
        padding-bottom: 18px;
    }
    .emoji .material-icons {
        font-size: 40px;
    }
}

/* ========== จดหมายปิด ========== */
.letter-closed {
    background: #fff;
    width: 100%;
    max-width: 280px;
    min-height: 160px;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(255, 150, 170, 0.35);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    border: 2px solid #ffd6e0;
}

.letter-closed:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 45px rgba(255, 150, 170, 0.45);
}

.letter-closed .envelope-icon {
    font-size: clamp(40px, 12vw, 52px);
    color: #ff5e7e;
    margin-bottom: 12px;
}

.letter-closed .ask-text {
    color: #ff5e7e;
    font-size: clamp(15px, 4vw, 17px);
    font-weight: 500;
    text-align: center;
}

.letter-closed .sub-text {
    color: #999;
    font-size: clamp(12px, 3.2vw, 13px);
    margin-top: 6px;
    text-align: center;
}

/* ========== การ์ดข้อความ (ซ่อนตอนแรก) ========== */
.card {
    background: white;
    padding: clamp(22px, 6vw, 36px) clamp(16px, 5vw, 28px);
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(255, 182, 193, 0.4);
    text-align: center;
    max-width: 400px;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    display: none; /* ซ่อนไว้ก่อน */
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.emoji {
    margin-bottom: 14px;
    display: inline-block;
    animation: heartBeat 1.2s infinite;
}

.emoji .material-icons {
    font-size: clamp(44px, 12vw, 58px);
    color: #ff5e7e;
}

h1 {
    color: #ff5e7e;
    font-size: clamp(19px, 5.5vw, 23px);
    margin: 0 0 16px 0;
}

.message {
    color: #555;
    font-size: clamp(13.5px, 3.8vw, 15px);
    line-height: 1.75;
    margin-bottom: 6px;
}

.shy-text {
    color: #ff8fa3;
    font-size: clamp(12px, 3.4vw, 13px);
    margin: 14px 0 26px 0;
}

.btn-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-top: 20px;
}

.btn {
    font-family: 'Mitr', sans-serif;
    padding: 11px 22px;
    font-size: clamp(14px, 3.8vw, 15.5px);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 110px;
    max-width: 100%;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.btn-yes {
    background-color: #ff5e7e;
    color: white;
    box-shadow: 0 6px 16px rgba(255, 94, 126, 0.35);
}

.btn-yes:hover {
    background-color: #ff4066;
    transform: scale(1.05);
}

.btn-yes:disabled {
    background-color: #ffb3c1;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.btn-no {
    background-color: #e8e8e8;
    color: #666;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.12); }
    28% { transform: scale(1); }
    42% { transform: scale(1.12); }
    70% { transform: scale(1); }
}
