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

/* ── Base ────────────────────────────────────────────────── */
body {
    font-family: 'Special Elite', cursive;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d1117 0%, #1a1a2e 45%, #2c1400 100%);
    overflow-x: hidden;
    position: relative;
}

body.scrollable {
    overflow-y: auto;
    align-items: flex-start;
    padding: 30px 0;
}

/* ── Bokeh background ────────────────────────────────────── */
.bokeh-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bokeh {
    position: absolute;
    border-radius: 50%;
    filter: blur(8px);
    animation: bokehFloat linear infinite;
    opacity: 0;
}

@keyframes bokehFloat {
    0%   { opacity: 0; transform: translateY(100vh) scale(1); }
    10%  { opacity: 0.5; }
    90%  { opacity: 0.5; }
    100% { opacity: 0; transform: translateY(-100px) scale(1.5); }
}

/* ── Ambient glows ───────────────────────────────────────── */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}

.glow1 {
    width: 420px; height: 420px;
    background: radial-gradient(circle, #ff8c42 0%, transparent 70%);
    bottom: -150px; right: -100px;
    opacity: 0.22;
    animation: glowPulse 8s ease-in-out infinite;
}

.glow2 {
    width: 300px; height: 300px;
    background: radial-gradient(circle, #a1c4fd 0%, transparent 70%);
    top: -100px; left: -100px;
    opacity: 0.18;
    animation: glowPulse 12s ease-in-out infinite reverse;
}

.glow3 {
    width: 260px; height: 260px;
    background: radial-gradient(circle, #ffd580 0%, transparent 70%);
    top: calc(50% - 130px);
    left: calc(50% - 130px);
    animation: glowPulse3 10s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.15; transform: scale(1); }
    50%       { opacity: 0.28; transform: scale(1.15); }
}

@keyframes glowPulse3 {
    0%, 100% { opacity: 0.12; }
    50%       { opacity: 0.25; }
}

/* ── Music toggle ────────────────────────────────────────── */
.music-toggle {
    position: fixed;
    top: 12px; right: 12px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 36px; height: 36px;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.music-toggle.visible   { opacity: 1; pointer-events: auto; }
.music-toggle:hover     { background: rgba(255, 255, 255, 0.22); transform: scale(1.1); }
.music-toggle:active    { transform: scale(0.95); }

/* ── Container & scenes ──────────────────────────────────── */
.container {
    position: relative;
    z-index: 10;
    width: 90%;
    max-width: 500px;
}

.scene { display: none; }
.scene.active {
    display: block;
    animation: fadeIn 0.8s ease;
}

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

/* ── PIN lock screen ─────────────────────────────────────── */
.pin-screen {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    padding: 50px 20px;
}

.pin-icon {
    font-size: 2.8rem;
    opacity: 0.85;
}

.pin-title {
    font-family: 'Shadows Into Light', cursive;
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.65);
    letter-spacing: 6px;
    text-transform: uppercase;
}

.pin-dots {
    display: flex;
    gap: 22px;
    margin: 6px 0;
}

.pin-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.45);
    transition: all 0.2s ease;
}

.pin-dot.filled {
    background: white;
    border-color: white;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.pin-dot.checking {
    animation: dotPulse 0.8s ease-in-out infinite;
}

@keyframes dotPulse {
    0%, 100% { opacity: 0.4; transform: scale(0.85); }
    50%       { opacity: 1;   transform: scale(1.1); }
}

.pin-status {
    font-size: 0.88rem;
    color: #ff8080;
    opacity: 0;
    transition: opacity 0.3s;
    height: 18px;
    font-style: italic;
}

.pin-status.visible    { opacity: 1; color: #ff8080; }
.pin-status.locked-out { color: #ffb347; }

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    max-width: 260px;
    width: 100%;
}

.pin-key {
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-family: 'Special Elite', cursive;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pin-key:hover   { background: rgba(255, 255, 255, 0.18); }
.pin-key:active  { background: rgba(255, 255, 255, 0.32); transform: scale(0.92); }
.pin-key.disabled { opacity: 0.3; pointer-events: none; }

.pin-key-empty {
    background: transparent;
    border-color: transparent;
    cursor: default;
    pointer-events: none;
}

.pin-key-del { font-size: 1.2rem; }

.pin-shake { animation: pinShake 0.45s ease; }

@keyframes pinShake {
    0%, 100% { transform: translateX(0); }
    15%       { transform: translateX(-10px); }
    35%       { transform: translateX(10px); }
    55%       { transform: translateX(-7px); }
    75%       { transform: translateX(7px); }
    90%       { transform: translateX(-3px); }
}

/* ── Welcome screen ──────────────────────────────────────── */
.welcome-screen {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px 20px;
}

.welcome-emoji {
    font-size: 5rem;
    animation: floatEmoji 3s ease-in-out infinite;
}

@keyframes floatEmoji {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-12px); }
}

.welcome-text {
    font-family: 'Shadows Into Light', cursive;
    font-size: 2.2rem;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.welcome-subtext {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 6px;
}

.start-btn {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.35);
    color: white;
    padding: 16px 40px;
    border-radius: 50px;
    font-family: 'Shadows Into Light', cursive;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: btnGlow 2.5s ease-in-out infinite;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.start-btn:hover  { background: rgba(255, 255, 255, 0.22); transform: scale(1.05); }
.start-btn:active { transform: scale(0.97); }

@keyframes btnGlow {
    0%, 100% { box-shadow: 0 0 15px rgba(255, 200, 80, 0.1); }
    50%       { box-shadow: 0 0 35px rgba(255, 200, 80, 0.3); }
}

/* ── Envelope ────────────────────────────────────────────── */
.envelope-container { text-align: center; perspective: 1000px; }

.envelope {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 1.6;
    background: linear-gradient(135deg, #d4a574 0%, #c69963 100%);
    border-radius: 8px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(212, 165, 116, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.envelope:hover { transform: translateY(-8px); }

.envelope::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background:
        linear-gradient(45deg,  transparent 48%, rgba(0,0,0,0.08) 50%, transparent 52%),
        linear-gradient(-45deg, transparent 48%, rgba(0,0,0,0.08) 50%, transparent 52%);
    border-radius: 8px;
}

.wax-seal {
    width: 120px; height: 120px;
    background: radial-gradient(circle, #8b0000 0%, #5c0000 100%);
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4), inset 0 -4px 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    z-index: 2;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.wax-seal:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(139,0,0,0.5), inset 0 -4px 8px rgba(0,0,0,0.3);
}

.wax-seal::before {
    content: '💚';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
}

.wax-seal.breaking { animation: sealBreak 0.6s forwards; }

@keyframes sealBreak {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.1); }
    100% { transform: scale(0) rotate(180deg); opacity: 0; }
}

.tap-hint {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.1rem;
    margin-top: 30px;
    animation: pulseOpacity 2s ease-in-out infinite;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

@keyframes pulseOpacity {
    0%, 100% { opacity: 0.45; }
    50%       { opacity: 1; }
}

/* ── Letter pages ────────────────────────────────────────── */
.letter-container {
    position: relative;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
}

.letter-page {
    background: linear-gradient(to bottom, #f4e8d0 0%, #e8dcc8 100%);
    padding: 40px 30px;
    border-radius: 4px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(244, 232, 208, 0.2),
        inset 0 0 80px rgba(194, 154, 108, 0.15);
    position: relative;
    min-height: 520px;
    transform-style: preserve-3d;
}

.letter-page::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 27px,
        rgba(139, 111, 71, 0.07) 28px
    );
    pointer-events: none;
    border-radius: 4px;
}

.letter-page::after {
    content: '';
    position: absolute;
    bottom: 40px; right: 40px;
    width: 80px; height: 80px;
    background: radial-gradient(circle, rgba(139, 90, 43, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.page-content { position: relative; z-index: 1; }

.chapter-label {
    font-family: 'Special Elite', cursive;
    font-size: 0.68rem;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: #a0846a;
    margin-bottom: 4px;
}

.chapter-title {
    font-family: 'Dawning of a New Day', cursive;
    font-size: 2rem;
    color: #2c1810;
    margin-bottom: 22px;
    line-height: 1.2;
}

.date-line {
    font-size: 0.85rem;
    color: #6a5040;
    margin-bottom: 18px;
    text-align: right;
    font-style: italic;
}

.letter-text {
    font-size: 1.05rem;
    line-height: 2.1;
    color: #3a2a1a;
    margin: 14px 0;
}

/* ── Polaroid photo ──────────────────────────────────────── */
.polaroid-wrap {
    display: flex;
    justify-content: center;
    margin: 18px 0 10px;
}

.polaroid {
    background: #fff;
    padding: 8px 8px 26px;
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.22),
        0 2px 6px rgba(0, 0, 0, 0.12);
    transform: rotate(2.5deg);
    max-width: 155px;
    flex-shrink: 0;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.polaroid:hover {
    transform: rotate(2.5deg) scale(1.06);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.polaroid:active { transform: rotate(2.5deg) scale(0.97); }

.polaroid img {
    width: 100%;
    display: block;
    image-orientation: from-image;
}

.polaroid-caption {
    text-align: center;
    font-family: 'Shadows Into Light', cursive;
    font-size: 0.82rem;
    color: #5a4a42;
    margin-top: 5px;
    line-height: 1.3;
}

/* ── Lightbox ────────────────────────────────────────────── */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.93);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox.open {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.lightbox img {
    max-width: 96vw;
    max-height: 96vh;
    object-fit: contain;
    image-orientation: from-image;
    border-radius: 2px;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
}

.lightbox-close {
    position: absolute;
    top: 16px; right: 16px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.8rem;
    line-height: 1;
    pointer-events: none;
}

/* ── Chapter decorations ─────────────────────────────────── */
.goose-deco {
    text-align: center;
    font-size: 2.4rem;
    margin: 10px 0 18px;
}

.mountain-deco {
    font-size: 2.2rem;
    margin: 10px 0 20px;
    opacity: 0.75;
}

/* ── Question page ───────────────────────────────────────── */
.question-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.main-question {
    font-family: 'Shadows Into Light', cursive;
    font-size: 1.9rem;
    color: #2c1810;
    margin: 10px 0 30px;
    line-height: 1.75;
}

.options {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
}

.option {
    font-family: 'Shadows Into Light', cursive;
    font-size: 1.7rem;
    padding: 14px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.option.yes {
    color: #2c1810;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px dashed #8b6f47;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.3);
}

.option.yes:hover  { background: rgba(139, 111, 71, 0.15); transform: scale(1.04); }
.option.yes:active { transform: scale(0.98); }

.option.no {
    color: #8b0000;
    text-decoration: line-through;
    text-decoration-thickness: 3px;
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Final page ──────────────────────────────────────────── */
.final-message { min-height: auto; }

.signature {
    font-family: 'Dawning of a New Day', cursive;
    font-size: 2rem;
    color: #2c1810;
    margin-top: 40px;
    text-align: right;
    padding-bottom: 20px;
}

/* ── Page navigation ─────────────────────────────────────── */
.page-nav {
    background: rgba(139, 111, 71, 0.35);
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1rem;
    color: #3a2a1a;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
    border: 1px dashed #8b6f47;
    font-weight: 600;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.page-nav:hover  { background: rgba(139, 111, 71, 0.55); transform: scale(1.05); }
.page-nav:active { transform: scale(0.98); }

/* ── Page flip animations ────────────────────────────────── */
.letter-page.flip-out { animation: pageFlip 0.8s forwards; }

@keyframes pageFlip {
    0%   { transform: rotateY(0deg); opacity: 1; }
    100% { transform: rotateY(-180deg); opacity: 0; }
}

.letter-page.flip-in { animation: pageFlipIn 0.8s forwards; }

@keyframes pageFlipIn {
    0%   { transform: rotateY(180deg); opacity: 0; }
    100% { transform: rotateY(0deg); opacity: 1; }
}

/* ── Confetti ────────────────────────────────────────────── */
.confetti-heart {
    position: fixed;
    font-size: 22px;
    pointer-events: none;
    z-index: 1000;
    animation: heartFall 4s linear forwards;
}

@keyframes heartFall {
    to { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
    .letter-page      { padding: 28px 18px; min-height: 460px; }
    .chapter-title    { font-size: 1.7rem; }
    .main-question    { font-size: 1.55rem; }
    .option           { font-size: 1.4rem; }
    .letter-text      { font-size: 1rem; line-height: 1.9; }
    .welcome-emoji    { font-size: 4rem; }
    .welcome-text     { font-size: 1.8rem; }
    .start-btn        { font-size: 1.3rem; padding: 14px 32px; }
    .wax-seal         { width: 100px; height: 100px; }
    .wax-seal::before { font-size: 40px; }
    .music-toggle     { top: 8px; right: 8px; width: 32px; height: 32px; font-size: 14px; }
    .pin-pad          { max-width: 230px; gap: 12px; }
    .pin-key          { font-size: 1.3rem; }
    .polaroid         { max-width: 130px; }
}
