/* --- VARIABLES & RESET --- */
:root {
    --primary-pink: #FFB7C5;
    --soft-pink: #FFD1DC;
    --cream: #FFF5F7;
    --white: #FFFFFF;
    --text-dark: #5D4E60;
    --text-light: #8E7C92;
    --accent-red: #FF6B81;
    --shadow-soft: 0 10px 30px rgba(255, 183, 197, 0.3);
    --font-main: 'Mitr', sans-serif;
    --font-heading: 'Kanit', sans-serif;
    --radius-lg: 24px;
    --transition-smooth: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-main);
    background: linear-gradient(135deg, #FFFDF9 0%, #FFE4E1 50%, #E6E6FA 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    color: var(--text-dark);
}

/* --- BACKGROUND DECORATION --- */
.bg-decoration {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -1; pointer-events: none;
}

.floating-shape {
    position: absolute; border-radius: 50%; opacity: 0.6; filter: blur(40px);
    animation: floatShape 20s infinite ease-in-out;
}
.shape-1 { width: 300px; height: 300px; background: var(--soft-pink); top: -50px; left: -50px; }
.shape-2 { width: 200px; height: 200px; background: #E6E6FA; bottom: 10%; right: -50px; animation-delay: -5s; }
.shape-3 { width: 150px; height: 150px; background: var(--primary-pink); top: 40%; left: 20%; animation-delay: -10s; }

@keyframes floatShape {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(20px, -20px); }
}

/* --- PARTICLES --- */
#particle-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 9999;
}
.particle {
    position: absolute; pointer-events: none; animation: particleFade 1s forwards;
}
@keyframes particleFade {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-100px) scale(0); opacity: 0; }
}

/* --- FLOATING INSTAGRAM MESSAGES --- */
.floating-messages {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* ไม่ให้บังปุ่มกด */
    z-index: 5;
    overflow: hidden;
}

.floating-msg {
    position: absolute;
    background: white;
    padding: 10px 16px;
    border-radius: 18px;
    border-bottom-left-radius: 4px; /* สไตล์ IG Bubble */
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
font-size: 1.1rem;
    color: var(--text-dark);
    opacity: 0;
    animation: floatMsg 8s infinite ease-in-out;
    max-width: 200px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.floating-msg i {
    color: var(--accent-red);
    font-size: 1.1rem;
}

@keyframes floatMsg {
    0% { transform: translateY(20px) translateX(0) scale(0.8); opacity: 0; }
    15% { opacity: 1; transform: translateY(0) translateX(10px) scale(1); }
    85% { opacity: 1; transform: translateY(-30px) translateX(-10px) scale(1); }
    100% { transform: translateY(-50px) translateX(0) scale(0.8); opacity: 0; }
}

/* --- MAIN LAYOUT --- */
#app {
    width: 100%; max-width: 500px; padding: 20px; position: relative;
    min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
    z-index: 10;
}

.page {
    display: none; opacity: 0; transition: opacity 0.5s ease; width: 100%;
}
.page.active {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    opacity: 1; animation: fadeInPage 0.6s ease-out;
}
@keyframes fadeInPage {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- GLASS CARD --- */
.glass-card {
    background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px); border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-lg); padding: 40px 30px; width: 100%;
    box-shadow: var(--shadow-soft); text-align: center; position: relative;
    overflow: visible; z-index: 20; /* อยู่เหนือ Floating Msg */
}

/* --- TYPOGRAPHY --- */
.title {
    font-family: var(--font-heading); font-size: 2rem; font-weight: 600;
    color: var(--accent-red); margin-bottom: 10px; line-height: 1.2;
}
.subtitle { font-size: 1.1rem; color: var(--text-dark); margin-bottom: 5px; line-height: 1.5; }
.small-text { font-size: 0.9rem; color: var(--text-light); margin-bottom: 30px; font-style: italic; }
.text-body { font-size: 1rem; color: var(--text-dark); line-height: 1.6; }

/* --- CHARACTER / GIF STYLES --- */
.character-wrapper { margin-bottom: 15px; display: flex; justify-content: center; }
.apology-gif {
    width: 120px; height: auto; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
    animation: bounceSoft 2s infinite ease-in-out;
}
@keyframes bounceSoft {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* เพิ่ม CSS สำหรับ GIF ในหน้า "หายโกรธแล้วว" */
.celebration-gif {
    width: 120px;
    height: auto;
    margin: 0 auto 20px;
    display: block;
    animation: fadeIn 0.8s ease-in-out;
}

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

/* --- BUTTONS --- */
.button-group {
    display: flex; flex-direction: column; gap: 15px; margin-bottom: 30px;
    align-items: center; justify-content: center; min-height: 150px;
}
.btn {
    border: none; padding: 12px 24px; border-radius: 50px; font-family: var(--font-main);
    font-size: 1rem; cursor: pointer; display: inline-flex; align-items: center;
    justify-content: center; gap: 8px; transition: all 0.3s var(--transition-smooth);
    outline: none; position: relative; overflow: hidden; white-space: nowrap;
}
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(255, 107, 129, 0.3); }

.btn-primary {
    background: var(--accent-red); color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 129, 0.3); font-weight: 500;
    transform-origin: center;
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(255, 107, 129, 0.4); }

.btn-secondary {
    background: white; color: var(--text-dark); border: 2px solid var(--soft-pink);
    transform-origin: center;
}
.btn-secondary:hover { background: var(--cream); border-color: var(--primary-pink); }

.btn-outline { background: transparent; border: 1px solid var(--text-light); color: var(--text-light); }
.btn-outline:hover { border-color: var(--accent-red); color: var(--accent-red); }

.mt-4 { margin-top: 20px; }

/* --- FORGIVENESS METER --- */
.forgiveness-meter { margin-top: 20px; text-align: left; width: 100%; }
.meter-label {
    display: flex; justify-content: space-between; font-size: 0.8rem;
    color: var(--text-light); margin-bottom: 5px; font-weight: 600; letter-spacing: 0.5px;
}
.progress-bar-bg {
    width: 100%; height: 8px; background: rgba(0, 0, 0, 0.05);
    border-radius: 10px; overflow: hidden;
}
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--primary-pink), var(--accent-red));
    border-radius: 10px; transition: width 0.5s ease;
}
.status-text {
    text-align: center; font-size: 0.75rem; color: var(--accent-red);
    margin-top: 8px; height: 15px; transition: all 0.3s;
    display: flex; align-items: center; justify-content: center; gap: 5px;
}

/* --- CELEBRATION PAGE --- */
.celebration-icon {
    font-size: 4rem; color: #FFD700; margin-bottom: 20px;
    animation: spinSparkle 3s infinite linear;
}
@keyframes spinSparkle {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(180deg) scale(1.2); }
    100% { transform: rotate(360deg) scale(1); }
}
.animate-pop { animation: popIn 0.5s var(--transition-smooth); }
@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- RESPONSIVE --- */
@media (max-width: 480px) {
    .glass-card { padding: 30px 20px; }
    .title { font-size: 1.8rem; }
    .apology-gif { width: 100px; }
    .celebration-gif { width: 100px; }
    .floating-msg { font-size: 0.8rem; padding: 8px 12px; max-width: 160px; }
}
}

/* Visually hidden for accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}