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

body {
    font-family: 'Caveat', cursive;
    background: #f5f5f5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 400px;
    perspective: 1000px;
}

/* Enhanced Envelope Styles */
.envelope-wrapper {
    width: 100%;
    aspect-ratio: 1.5/1;
    perspective: 1000px;
    cursor: pointer;
    margin-bottom: 50px;
}

.envelope {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.8s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;  /* Remove tap highlight on mobile */
    touch-action: manipulation;  /* Optimize for touch */
}

.envelope.open {
    transform: rotateX(20deg);
}

.envelope-front {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #e74c3c;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transform-style: preserve-3d;
    z-index: 3;
}

.envelope-content {
    text-align: center;
    color: white;
    font-size: 2rem;
    z-index: 4;
}

.tap-hint {
    font-size: 1rem;
    opacity: 0.8;
    margin-top: 10px;
}

.envelope-back {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #c0392b;
    border-radius: 10px;
    backface-visibility: hidden;
    transform: translateZ(-1px);
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: #c0392b;
    clip-path: polygon(0 0, 50% 50%, 100% 0);
    transform-origin: top;
    transition: transform 0.8s ease;
    z-index: 4;
}

.envelope.open .envelope-flap {
    transform: rotateX(180deg);
}

.side-flap-left, .side-flap-right {
    position: absolute;
    width: 50%;
    height: 80%;
    bottom: 0;
    background: #d35400;
    z-index: 2;
    transition: transform 0.6s ease;
}

.side-flap-left {
    left: 0;
    transform-origin: left;
    clip-path: polygon(0 0, 100% 20%, 100% 100%, 0 100%);
}

.side-flap-right {
    right: 0;
    transform-origin: right;
    clip-path: polygon(0 20%, 100% 0, 100% 100%, 0 100%);
}

.envelope.open .side-flap-left {
    transform: rotateY(-120deg);
}

.envelope.open .side-flap-right {
    transform: rotateY(120deg);
}

.bottom-flap {
    position: absolute;
    width: 100%;
    height: 80%;
    bottom: 0;
    background: #e67e22;
    z-index: 1;
    clip-path: polygon(0 20%, 50% 0, 100% 20%, 100% 100%, 0 100%);
}

/* Napkin Styles */
.napkin {
    background: white;
    padding: 20px;
    border-radius: 2px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transform: rotate(-2deg);
    position: relative;
    transition: all 0.5s ease;
    opacity: 0;
    transform: translateY(20px) rotate(-2deg);
    margin-top: -100px;
}

.napkin.hidden {
    display: none;
}

.napkin:not(.hidden) {
    opacity: 1;
    transform: translateY(0) rotate(-2deg);
}

.napkin.unfolded .folded-paper {
    transform: translateY(-50px) scale(1);
}

.napkin.unfolded .paper-fold.top {
    transform: rotateX(180deg);
}

.napkin.unfolded .paper-fold.bottom {
    transform: rotateX(-180deg);
}

/* Folded Paper Styles */
.folded-paper {
    width: 100%;
    position: relative;
    transform-origin: center;
    transform: translateY(0) scale(0.9);
    transition: transform 0.8s ease;
    perspective: 1000px;
}

.paper-content {
    width: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.paper-content.flipped {
    transform: rotateY(180deg);
}

.paper-content.flipped .question-text,
.paper-content.flipped .question-text-back {
    /* The parent's transform is sufficient */
}

.paper-fold {
    position: relative;
    width: 100%;
    background: white;
    transition: transform 0.8s ease;
    transform-origin: top;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.paper-fold.middle {
    background: white;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 300px;
    padding: 30px;
    position: relative;
    transform-style: preserve-3d;
}

.question-text, .question-text-back {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    background: white;
    padding: 30px;
}

.question-text {
    transform: rotateY(0deg);
}

.question-text-back {
    transform: rotateY(180deg);
}

.paper-fold.bottom {
    height: 20px;
    transform: rotateX(0deg);
    transform-origin: bottom;
    z-index: 0;
}

.intro {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #e74c3c;
}

.transition-message {
    font-size: 1.2rem;
    line-height: 1.4;
    margin-bottom: 20px;
    color: #333;
}

.main-question {
    font-size: 2rem;
    margin-bottom: 30px;
    color: #e74c3c;
    font-weight: bold;
}

.checkbox-area {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
}

.next-btn, .yes-btn {
    padding: 10px 30px;
    font-size: 1.5rem;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Caveat', cursive;
    transition: all 0.3s ease;
}

.no-btn {
    padding: 6px 15px;
    font-size: 0.9rem;
    background: #95a5a6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Caveat', cursive;
    transition: all 0.3s ease;
    opacity: 0.7;
    margin-left: -5px;
    vertical-align: middle;
}

.next-btn:hover, .yes-btn:hover {
    background: #c0392b;
    transform: scale(1.05);
}

.no-btn:hover {
    background: #7f8c8d;
    transform: scale(0.95);
    opacity: 0.9;
}

/* Napkin Styles */
.napkin::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(45deg, transparent 48%, #f8f8f8 49%, #f8f8f8 51%, transparent 52%),
        linear-gradient(-45deg, transparent 48%, #f8f8f8 49%, #f8f8f8 51%, transparent 52%);
    background-size: 20px 20px;
    opacity: 0.5;
    pointer-events: none;
}

.napkin-content {
    padding: 20px;
    transform: rotate(2deg);
}

.yes-btn {
    font-size: 2.5rem;
    padding: 15px 40px;
    background: linear-gradient(45deg, #e74c3c, #ff7675);
    color: white;
    border: none;
    border-radius: 30px;
    transform-origin: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.2);
    position: relative;
    overflow: hidden;
    font-family: 'Caveat', cursive;
    cursor: pointer;
}

.yes-btn::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transform: rotate(45deg);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%) rotate(45deg);
    }
    100% {
        transform: translateX(100%) rotate(45deg);
    }
}

.yes-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(231, 76, 60, 0.4);
}

.no-btn {
    font-size: 0.9rem;
    opacity: 0.6;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-family: 'Caveat', cursive;
    position: relative;
    transition: all 0.3s ease;
}

.no-btn::before {
    content: '🔥';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
    opacity: 0;
    transition: all 0.3s ease;
}

.no-btn:hover::before {
    opacity: 1;
    bottom: -5px;
}

.next-btn {
    font-family: 'Caveat', cursive;
    font-size: 1.5rem;
    background: linear-gradient(45deg, #e74c3c, #ff7675);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 8px 25px;
    margin-top: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.2);
}

.next-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.3);
}

.transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(45deg, #ff7675, #e74c3c);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    text-align: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    z-index: 2;
}

.transition.active {
    opacity: 1;
    pointer-events: all;
}

.transition-content {
    max-width: 600px;
    margin: 0 auto;
    color: white;
    font-family: 'Caveat', cursive;
}

.transition p {
    font-size: 1.5em;
    margin: 20px 0;
    line-height: 1.6;
}

.transition-message {
    font-size: 1.6rem;
    margin: 2rem 0;
    line-height: 1.5;
    color: #e74c3c;
    opacity: 0;
    animation: fadeIn 1s ease forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.celebration {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: #fff;
    z-index: 1000;
    text-align: center;
}

.celebration-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
}

.celebration-content h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: #e74c3c;
}

.celebration-content p {
    font-size: 1.8rem;
    margin-bottom: 30px;
    line-height: 1.4;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

#gameCanvas {
    display: block;
    margin: 10px auto;
    background: black;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    max-width: 100%;
}

.touch-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    max-width: 150px;
    margin: 5px auto;
}

.horizontal-controls {
    display: flex;
    gap: 10px;
    margin: 5px 0;
}

.control-btn {
    font-size: 18px;
    padding: 5px 15px;
    background: #e74c3c;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    min-width: 40px;
}

.control-btn:hover {
    background: #c0392b;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .envelope-content {
        font-size: 1.6rem;
    }
    
    .napkin {
        padding: 10px;
    }
    
    .intro {
        font-size: 1.5rem;
    }
    
    .main-question {
        font-size: 1.8rem;
    }
    
    .checkbox-area {
        gap: 2rem;
    }
    
    .yes-btn, .no-btn {
        font-size: 1.3rem;
    }
}

.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding-top: 20px;
}
