/* ========================
   RESET & BASE STYLES
   ======================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --tertiary-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.18);
    --text-primary: #ffffff;
    --text-secondary: #f0f0f0;
    --shadow-soft: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    --shadow-glow: 0 0 40px rgba(102, 126, 234, 0.6);
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ========================
   THREE.JS BACKGROUND CANVAS
   ======================== */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* ========================
   LOADING SCREEN
   ======================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease;
}

.loader-content {
    text-align: center;
    padding: 2rem;
}

.loader-content h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    background: linear-gradient(45deg, #f093fb, #f5576c, #4facfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s infinite;
}

.loader-bar {
    width: 300px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto 1rem;
}

.loader-progress {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea, #764ba2, #f093fb);
    border-radius: 10px;
    transition: width 0.3s ease;
}

.loader-text {
    font-size: 1rem;
    color: var(--text-secondary);
}

@keyframes shimmer {

    0%,
    100% {
        filter: hue-rotate(0deg);
    }

    50% {
        filter: hue-rotate(45deg);
    }
}

/* ========================
   STAGE CONTAINER
   ======================== */
.stage {
    display: none;
    min-height: 100vh;
    width: 100%;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.stage.active {
    display: flex;
    opacity: 1;
}

.stage-content {
    width: 100%;
    max-width: 1400px;
    text-align: center;
}

/* ========================
   BUTTONS
   ======================== */
.continue-btn,
.choice-btn {
    padding: 1rem 3rem;
    font-size: 1.2rem;
    font-weight: 600;
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 2px solid var(--glass-border);
    border-radius: 15px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow-soft);
    transition: all 0.3s ease;
    margin: 1rem;
}

.continue-btn:hover,
.choice-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-glow);
    background: rgba(255, 255, 255, 0.2);
}

.continue-btn:active,
.choice-btn:active {
    transform: translateY(0) scale(0.98);
}

.hidden {
    display: none !important;
}

/* ========================
   STAGE 1: WELCOME
   ======================== */
.intro-video {
    width: 80%;
    max-width: 600px;
    border-radius: 20px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-soft);
}

.welcome-text {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
}

/* ========================
   STAGE 2: APOLOGY
   ======================== */
.scrollable-content {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    max-height: 70vh;
    overflow-y: auto;
    padding: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    margin-bottom: 2rem;
}

/* Hide scrollbar but keep functionality */
.scrollable-content::-webkit-scrollbar {
    display: none;
}

.scrollable-content {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.side-images {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex-shrink: 0;
}

.photo-frame {
    width: 200px;
    height: 250px;
    object-fit: cover;
    border-radius: 15px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    transform: rotate(-2deg);
    transition: all 0.3s ease;
}

.photo-frame:nth-child(even) {
    transform: rotate(2deg);
}

.photo-frame:hover {
    transform: rotate(0deg) scale(1.05);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.text-content {
    flex: 1;
    text-align: left;
}

.text-content h2 {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.apology-text p,
.letter-text p {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    text-align: justify;
}

.big-sorry {
    font-size: 2rem !important;
    font-weight: bold;
    text-align: center !important;
    color: #f5576c;
    text-shadow: 2px 2px 10px rgba(245, 87, 108, 0.5);
}

.timer-container {
    margin: 1rem 0;
    font-size: 1.2rem;
    color: #f093fb;
}

#timer-count {
    font-weight: bold;
    font-size: 1.5rem;
}

/* ========================
   STAGE 3: MEMORY GAME
   ======================== */
.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    max-height: 65vh;
    padding: 1rem 0;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(5, 100px);
    grid-template-rows: repeat(5, 100px);
    gap: 12px;
    margin: 0 auto;
}

.game-card {
    width: 100px !important;
    height: 100px !important;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: 15px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    transform-style: preserve-3d;
}

.game-card:hover:not(.matched):not(.locked) {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

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

.game-card.flipped .card-front {
    transform: rotateY(0deg);
}

.game-card.matched {
    opacity: 0.3;
    pointer-events: none;
}

.game-card.locked {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    animation: pulse 2s infinite;
}

.card-back,
.card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    transition: transform 0.6s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: rotateY(0deg);
}

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

.card-front img,
.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 13px;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    }

    50% {
        box-shadow: 0 0 40px rgba(255, 215, 0, 0.8);
    }
}

.code-input-container {
    margin-top: 2rem;
    padding: 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

#code-input {
    padding: 1rem 2rem;
    font-size: 1.5rem;
    border-radius: 10px;
    border: 2px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    text-align: center;
    margin: 1rem;
}

#submit-code {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#submit-code:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

/* ========================
   STAGE 4: NAUGHTY CHECK
   ======================== */
.naughty-video {
    width: 80%;
    max-width: 600px;
    border-radius: 20px;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-soft);
}

.naughty-question {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
}

.naughty-buttons,
.final-buttons {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ========================
   STAGE 5: TRANSITION
   ======================== */
#transition-stage h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    animation: fadeInUp 1s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================
   STAGE 7: FINAL QUESTION
   ======================== */
.final-question {
    font-size: 3.5rem;
    margin-bottom: 3rem;
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: heartbeat 2s infinite;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    10%,
    30% {
        transform: scale(1.05);
    }

    20%,
    40% {
        transform: scale(1);
    }
}

.potato-container {
    margin-top: 2rem;
}

.potato-image {
    width: 300px;
    border-radius: 20px;
    margin-bottom: 1rem;
}

.potato-text {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #f5576c;
}

/* ========================
   STAGE 8: CELEBRATION
   ======================== */
.fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.celebration-title {
    font-size: 4rem;
    margin-bottom: 2rem;
    position: relative;
    z-index: 2;
    animation: rainbow 3s infinite, bounce 1s infinite;
}

.celebration-message {
    font-size: 1.5rem;
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    line-height: 1.8;
}

@keyframes rainbow {
    0% {
        color: #ff0000;
    }

    16% {
        color: #ff7f00;
    }

    33% {
        color: #ffff00;
    }

    50% {
        color: #00ff00;
    }

    66% {
        color: #0000ff;
    }

    83% {
        color: #8b00ff;
    }

    100% {
        color: #ff0000;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* ========================
   POPUP MODAL
   ======================== */
.popup-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.popup-content {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 3rem;
    border-radius: 20px;
    border: 2px solid var(--glass-border);
    box-shadow: var(--shadow-soft);
    text-align: center;
    max-width: 500px;
}

.popup-content p {
    font-size: 1.3rem;
    margin-bottom: 2rem;
    line-height: 1.6;
}

#popup-close {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#popup-close:hover {
    transform: scale(1.05);
}

/* ========================
   RESPONSIVE DESIGN
   ======================== */
@media (max-width: 1024px) {
    .scrollable-content {
        flex-direction: column;
    }

    .side-images {
        flex-direction: row;
        justify-content: center;
    }

    .photo-frame {
        width: 150px;
        height: 200px;
    }

    .game-grid {
        grid-template-columns: repeat(5, 90px);
        grid-template-rows: repeat(5, 90px);
        gap: 10px;
    }

    .game-card {
        width: 90px;
        height: 90px;
    }
}

@media (max-width: 768px) {

    .welcome-text,
    .naughty-question {
        font-size: 1.8rem;
    }

    .final-question {
        font-size: 2.5rem;
    }

    .celebration-title {
        font-size: 2.5rem;
    }

    .text-content h2 {
        font-size: 2rem;
    }

    .apology-text p,
    .letter-text p {
        font-size: 1rem;
    }

    .game-grid {
        grid-template-columns: repeat(5, 60px);
        grid-template-rows: repeat(5, 60px);
        gap: 8px;
    }

    .game-card {
        width: 60px;
        height: 60px;
    }

    .photo-frame {
        width: 120px;
        height: 160px;
    }
}