:root {
    --pink-bg: #fff5f7;
    --pink-glass: rgba(255, 255, 255, 0.7);
    --pink-border: rgba(255, 182, 193, 0.4);
    --pink-text: #593540;
    --pink-accent: #e57388;
    --pink-dark: #b84a62;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: linear-gradient(135deg, var(--pink-bg) 0%, #ffe6ea 100%);
    min-height: 100vh;
    font-family: 'Outfit', sans-serif;
    color: var(--pink-text);
    overflow: hidden;
    user-select: none;
}

canvas#hearts-canvas {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 0;
}

/* Screen Transitions */
.screen {
    position: absolute;
    top: 0; left: 0; width: 100vw; height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(15px);
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.screen.hidden-layout {
    display: none;
}

/* Glass UI Panel */
.glass-panel {
    background: var(--pink-glass);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--pink-border);
    border-radius: 25px;
    padding: 45px 35px;
    text-align: center;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 25px 45px rgba(229, 115, 136, 0.08);
}

.glass-panel.wide {
    max-width: 800px;
}

h2 {
    font-size: 1.6rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--pink-text);
    letter-spacing: 0.5px;
}

.title-font {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: var(--pink-accent);
}

p {
    font-size: 1rem;
    font-weight: 300;
    margin-bottom: 25px;
    line-height: 1.6;
    color: rgba(89, 53, 64, 0.8);
}

.hint {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* PIN Screen */
.melody-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: white;
    padding: 6px;
    box-shadow: 0 10px 20px rgba(229, 115, 136, 0.15);
    margin-top: -85px;
    margin-bottom: 25px;
    border: 3px solid #ffedf0;
}

.pin-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.pin-box {
    width: 45px;
    height: 55px;
    border-radius: 12px;
    border: 2px solid var(--pink-border);
    background: rgba(255, 255, 255, 0.9);
    font-size: 1.5rem;
    text-align: center;
    color: var(--pink-dark);
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.02);
}

.pin-box:focus {
    border-color: var(--pink-accent);
    background: white;
    box-shadow: 0 5px 15px rgba(229, 115, 136, 0.1);
    transform: translateY(-2px);
}

.error-msg {
    color: #df4759;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s;
    margin-top: -10px;
    margin-bottom: 0;
}

.error-msg.show {
    opacity: 1;
}

/* Cards Flip */
.cards-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    perspective: 1000px;
}

.card {
    width: 110px;
    height: 155px;
    cursor: pointer;
    background: transparent;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 20px rgba(229, 115, 136, 0.12);
}

.card-front {
    background: linear-gradient(135deg, white, #fffcfd);
    border: 1px solid var(--pink-border);
}

.card-front:hover {
    background: #fffcfd;
    box-shadow: 0 12px 25px rgba(229, 115, 136, 0.2);
}

.q-mark {
    font-size: 3rem;
    color: #f1a3b3;
    font-family: 'Playfair Display', serif;
}

.card-back {
    background: white;
    transform: rotateY(180deg);
    padding: 10px;
    border: 2px solid var(--pink-accent);
}

.card-back img {
    width: 60px;
    border-radius: 5px;
    margin-bottom: 12px;
}

.card-back p {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--pink-dark);
    margin: 0;
}

.btn {
    margin-top: 35px;
    padding: 14px 40px;
    font-size: 1rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    color: white;
    background: var(--pink-accent);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(229, 115, 136, 0.25);
    transition: all 0.3s;
    letter-spacing: 0.5px;
}

.btn:hover {
    background: #d8647a;
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(229, 115, 136, 0.35);
}

.btn.hidden {
    display: none;
}

/* Scratch Card */
.scratch-container {
    position: relative;
    width: 280px;
    height: 280px;
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    border: 4px solid white;
    box-shadow: 0 15px 35px rgba(229, 115, 136, 0.15);
    touch-action: none;
    background: white;
}

.scratch-content {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.scratch-content img {
    width: 100px;
    margin-bottom: 20px;
}

.scratch-content h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--pink-dark);
    line-height: 1.3;
}

canvas#scratch-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2;
    cursor: crosshair;
}

/* Drag and Drop Game */
.game-area {
    height: 180px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: 30px;
}

#flower-pot-container {
    width: 140px;
    height: 140px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}

.pot-img {
    width: 100px;
    z-index: 5;
    pointer-events: none;
}

.flower-head {
    position: absolute;
    bottom: 60px;
    width: 120px;
    z-index: 3;
    opacity: 0;
    transform: scale(0) translateY(20px);
    transition: opacity 1s, transform 2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.flower-head.bloom {
    opacity: 1;
    transform: scale(1.6) translateY(-15px);
}

.game-tools {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
}

.draggable-wrapper {
    width: 70px; height: 70px;
    display: flex; justify-content: center; align-items: center;
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
    border: 2px dashed rgba(229, 115, 136, 0.5);
}

.draggable-tool {
    width: 50px;
    cursor: grab;
    touch-action: none; /* Crucial for pointer events drag */
    z-index: 10;
}

.draggable-tool:active {
    cursor: grabbing;
}

.draggable-tool.locked {
    filter: grayscale(100%);
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.pour-animation {
    animation: pour-tilt 2.5s ease-in-out forwards;
}

@keyframes pour-tilt {
    0% { transform: translate(-50%, 0) rotate(0); }
    15% { transform: translate(-80%, -10px) rotate(-30deg); }
    35% { transform: translate(-20%, -10px) rotate(-30deg); }
    55% { transform: translate(-80%, -10px) rotate(-30deg); }
    75% { transform: translate(-20%, -10px) rotate(-30deg); }
    90% { transform: translate(-80%, -10px) rotate(-30deg); }
    100% { transform: translate(-50%, 0) rotate(0); }
}

/* Modal POPUP */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    transform: scale(0.8);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-img {
    width: 120px;
    margin-bottom: 20px;
    border-radius: 10px;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
}

.btn-yes { background: #52b788; }
.btn-yes:hover { background: #40916c; transform: translateY(-2px); }

.btn-no { background: #e63946; transition: all 0.2s; }
.btn-no:hover { background: #d90429; transform: translateY(-2px); }

/* Jumpscare Mode */
.jumpscare-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: transparent;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.1s;
}

.jumpscare-overlay.active {
    opacity: 1;
    visibility: visible;
    animation: shake 0.5s infinite;
}

.jumpscare-bg-img {
    position: absolute;
    top: -10vh; /* Agar agak ke atas */
    left: 0; width: 100%; height: 100%;
    object-fit: contain; /* Lebih baik contain agar full characternya kelihatan kalau gif utuh */
    z-index: 1;
    opacity: 1;
    pointer-events: none; /* Biar tetap bisa klik tombol walau tertutup gif transparan */
}

.jumpscare-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: white;
}

@keyframes shake {
    0% { transform: translate(2px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(0px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(2px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(2px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

@media(max-width: 600px) {
    .glass-panel { padding: 35px 20px; }
    .cards-wrapper { gap: 10px; }
    .card { width: 95px; height: 140px; }
    .card-back p { font-size: 0.85rem; }
    .pin-box { width: 40px; height: 50px; font-size: 1.3rem; }
    .scratch-container { width: 250px; height: 250px; }
    .scratch-content h1 { font-size: 1.5rem; }
}
