/* --- GLOBAL RESET & VARIABEL --- */
:root {
    --bg-color: #f3e5f5;
    --primary: #6c5ce7;
    --envelope-color: #ff7675;
    --envelope-flap: #ff5e57;
    --accent: #fdcb6e;
    --text-dark: #2d3436;
    --btn-native: #2d3436; /* Warna tombol share (Hitam Elegan) */
}

* { box-sizing: border-box; }

body {
    margin: 0; padding: 0;
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(#d1c4e9 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- CONTAINER (Mobile Friendly) --- */
.container {
    width: 100%; 
    max-width: 420px; /* Lebar HP */
    padding: 20px;
    text-align: center;
    margin: 0 auto;
}

/* --- SCENE 1: AMPLOP --- */
.envelope-wrapper {
    position: relative; cursor: pointer; margin: 20px auto;
    width: 280px; height: 180px; transition: transform 0.3s;
    max-width: 100%;
}
.envelope-wrapper:active { transform: scale(0.95); }

.envelope {
    position: relative; width: 100%; height: 100%;
    background: var(--envelope-color); border-radius: 0 0 10px 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.front { position: absolute; width: 0; height: 0; z-index: 3; }
.flap {
    border-left: 140px solid transparent; border-right: 140px solid transparent;
    border-top: 100px solid var(--envelope-flap);
    top: 0; left: 0; transform-origin: top; transition: transform 0.4s ease; z-index: 4;
}
.pocket {
    border-left: 140px solid var(--envelope-color); border-right: 140px solid var(--envelope-color);
    border-bottom: 90px solid #fab1a0;
    bottom: 0; left: 0; border-radius: 0 0 10px 10px; z-index: 3;
}
.letter {
    position: absolute; background: #fff; width: 90%; height: 90%;
    top: 5%; left: 5%; border-radius: 5px; z-index: 2; transition: transform 0.4s ease;
}
.seal {
    position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);
    background: var(--accent); width: 40px; height: 40px; border-radius: 50%; z-index: 5;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: bold; font-size: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.instruction { margin-top: 40px; color: #636e72; font-size: 0.9rem; animation: pulse 2s infinite; }

.envelope-wrapper.open .flap { transform: rotateX(180deg); z-index: 1; }
.envelope-wrapper.open .letter { transform: translateY(-60px); z-index: 2; }


/* --- SCENE 2: HASIL GAMBAR --- */
.result-container {
    display: none; flex-direction: column; align-items: center; width: 100%;
    opacity: 0; transition: opacity 0.5s;
}
.result-container.fade-in { opacity: 1; }

.image-preview {
    width: 100%; display: flex; justify-content: center; margin-bottom: 20px;
    background: #fff; padding: 5px; border-radius: 18px;
    box-shadow: 0 10px 30px rgba(108, 92, 231, 0.2); 
}

/* GAMBAR RESPONSIF PENUH */
.generated-img {
    display: block; width: 100%; height: auto;
    max-width: 100%; border-radius: 12px;
}

/* --- TOMBOL --- */
.action-buttons { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.instruction-small { font-size: 0.85rem; color: #636e72; margin-bottom: 5px; font-weight: 600; }

.btn-share {
    width: 100%; padding: 16px; border: none; border-radius: 50px;
    font-size: 1rem; font-weight: 700; color: white; cursor: pointer;
    text-decoration: none; display: flex; justify-content: center; align-items: center; gap: 10px;
    transition: transform 0.2s; box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}
.btn-share:active { transform: scale(0.96); }

/* Tombol Native (Hitam Elegan) */
.btn-share.native {
    background: var(--btn-native);
    /* Gradient halus optional */
    background: linear-gradient(135deg, #2d3436 0%, #000000 100%);
}

.btn-reload {
    margin-top: 10px; color: var(--primary); text-decoration: none; font-weight: 600;
    font-size: 0.9rem; border-bottom: 1px dashed transparent;
}
.btn-reload:hover { border-bottom-color: var(--primary); }

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

/* RESPONSIVE EXTRA */
@media (max-width: 360px) {
    .container { padding: 15px; }
    .btn-share { font-size: 0.9rem; padding: 14px; }
}