:root {
    --primary-color: #ff8fa3;
    --primary-dark: #ff4d6d;
    --primary-light: #ffccd5;
    --bg-color: #fff0f3;
    --text-color: #590d22;
    --white: #ffffff;
    --gray-light: #f8f9fa;
    --gray: #ced4da;
}

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

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #ffe5ec; /* Desktop background */
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--text-color);
}

.app-container {
    width: 100%;
    max-width: 480px;
    height: 100vh; /* fallback */
    height: 100dvh;
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(255, 77, 109, 0.15);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 1;
    background-color: var(--bg-color);
}

.screen.main-active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
}

.screen.scrollable {
    justify-content: flex-start;
    overflow-y: auto;
    padding-top: 3rem;
    padding-bottom: 3rem;
}

/* Typography */
h1 { font-size: 1.8rem; line-height: 1.4; margin-bottom: 1rem; color: var(--primary-dark); font-weight: 700; }
h2 { font-size: 1.4rem; line-height: 1.5; margin-bottom: 1.5rem; color: var(--text-color); font-weight: 700; }
p { font-size: 1rem; line-height: 1.6; color: #666; }

/* Buttons */
.btn {
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 320px;
    margin: 0.5rem auto;
    font-family: 'Noto Sans KR', sans-serif;
}

.primary-btn {
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: 0 6px 15px rgba(255, 143, 163, 0.4);
    margin-top: 2rem;
}

.primary-btn:active {
    transform: scale(0.96);
    box-shadow: 0 2px 8px rgba(255, 143, 163, 0.4);
}

.option-btn {
    background-color: var(--white);
    color: var(--primary-dark);
    border: 2px solid var(--primary-light);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    text-align: left;
    padding: 1.2rem;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
}

.option-btn:active {
    background-color: var(--primary-light);
    transform: scale(0.98);
}

/* Animations */
.bounce { animation: bounce 2s infinite; }
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-20px); }
    60% { transform: translateY(-10px); }
}

.bounce-in {
    animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}
@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 1; }
    70% { transform: scale(0.9); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.pulse-btn {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 143, 163, 0.7); }
    70% { transform: scale(1.03); box-shadow: 0 0 0 10px rgba(255, 143, 163, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 143, 163, 0); }
}

.slide-up {
    animation: slideUp 0.8s ease forwards;
}
@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Progress Header */
.header-progress {
    position: absolute;
    top: 2rem;
    left: 0;
    width: 100%;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar-container {
    flex-grow: 1;
    height: 8px;
    background-color: var(--primary-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.4s ease-out;
    border-radius: 4px;
}

.question-count-text {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 0.9rem;
}

/* Question Content */
.question-content {
    width: 100%;
    margin-top: 2rem;
    transition: opacity 0.3s ease;
}

.q-title {
    text-align: left;
    margin-bottom: 2rem;
    line-height: 1.4;
    word-break: keep-all;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* Loading Screen */
.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid var(--primary-light);
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 2rem;
}

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.loading-bar-wrapper {
    width: 100%;
    height: 16px;
    background-color: var(--primary-light);
    border-radius: 8px;
    margin: 2rem 0 0.5rem;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    background-color: var(--primary-color);
    width: 0%;
    transition: width 0.1s linear;
}

.loading-percent {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.loading-msg {
    font-size: 0.9rem;
    color: #888;
}

/* Blackout Screen */
.blackout-bg {
    background-color: #000 !important;
    transition: opacity 1.5s ease;
}

/* Result Screen */
.result-screen {
    background-color: var(--bg-color);
}

.result-header {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    transition: opacity 1s ease;
    z-index: 2;
}

.fade-in-text {
    font-size: 1.6rem;
    color: var(--primary-dark);
    opacity: 0;
    animation: fadeIn 1.5s forwards;
}

.surprise-content {
    width: 100%;
    display: none; /* hidden initially via JS */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3;
    opacity: 0;
    transition: opacity 1s ease;
}

.highlight-text {
    font-size: 1.8rem;
    color: var(--primary-dark);
    margin-bottom: 1.5rem;
    word-break: keep-all;
}

.photo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 2rem;
    width: 100%;
    padding: 10px;
}

.polaroid {
    background: #fff;
    padding: 8px 8px 24px 8px; /* 폴라로이드 감성 하단 여백 */
    box-shadow: 0 4px 12px rgba(255, 77, 109, 0.15); /* 부드러운 핑크빛 그림자 */
    border-radius: 4px;
    transform: rotate(-3deg);
    transition: transform 0.3s ease, z-index 0.3s ease;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.polaroid:nth-child(even) {
    transform: rotate(4deg);
}

.polaroid:hover, .polaroid:active {
    transform: scale(1.08) rotate(0deg);
    z-index: 10;
}

.polaroid-img {
    width: 100%;
    aspect-ratio: 1 / 1; /* 정사각형 비율로 꽉 차게 */
    overflow: hidden;
    border-radius: 2px;
    background-color: #f1f3f5;
}

.polaroid-img img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 중앙을 기준으로 꽉 차게 자름 */
    object-position: center;
    display: block;
}

.ending-message {
    color: var(--text-color);
    font-weight: 500;
    margin-bottom: 2rem;
    font-size: 1.1rem;
    word-break: keep-all;
}

/* Letter Screen */
.letter-content {
    background-color: var(--white);
    padding: 2.5rem 2rem;
    border-radius: 20px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(255, 77, 109, 0.1);
    text-align: left;
    position: relative;
}

.letter-content::before {
    content: "💌";
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5rem;
    background: var(--bg-color);
    border-radius: 50%;
    padding: 5px;
}

.letter-content h2 {
    color: var(--primary-dark);
    border-bottom: 2px dashed var(--primary-light);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.letter-body {
    min-height: 200px;
    line-height: 1.8;
    color: #444;
}

.letter-footer {
    text-align: right;
    margin-top: 2rem;
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1.1rem;
}

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