* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none;
}

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    overflow-x: hidden;
    font-family: 'Times New Roman', Times, serif;
    position: relative;
    cursor: default;
    transition: background 1s ease;
}

body.card-visible {
    background: linear-gradient(135deg, #ffccd5 0%, #b5e6ff 100%);
    overflow-y: auto;
}

.envelope-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: 10000;
    transition: opacity 0.8s ease;
}

.envelope-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.envelope-container {
    position: relative;
    perspective: 1000px;
    width: 100%;
    max-width: 500px;
    padding: 20px;
}

.envelope {
    position: relative;
    width: 320px;
    height: 220px;
    margin: 0 auto;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.envelope.opening {
    transform: rotateY(180deg) scale(0.9);
}

.envelope-front, .envelope-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    overflow: hidden;
}

.envelope-front {
    background: linear-gradient(135deg, #ff4081, #7C4DFF);
    transform-style: preserve-3d;
    box-shadow: 
        0 20px 50px rgba(255, 64, 129, 0.4),
        0 10px 30px rgba(124, 77, 255, 0.3),
        inset 0 -2px 10px rgba(0, 0, 0, 0.2);
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(135deg, #ff4081, #ff6b9d);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    transform-origin: top center;
    transition: transform 0.5s ease;
    z-index: 2;
}

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

.envelope-body {
    position: absolute;
    top: 40%;
    left: 0;
    width: 100%;
    height: 60%;
    background: linear-gradient(135deg, #7C4DFF, #40C4FF);
    border-radius: 0 0 10px 10px;
    padding: 20px;
}

.envelope-design {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 5px;
    pointer-events: none;
}

.stamp {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 60px;
    height: 60px;
    background: #FFD700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    border: 2px solid white;
}

.stamp-text {
    font-size: 24px;
}

.to-label {
    position: absolute;
    bottom: 20px;
    left: 20px;
    color: white;
    font-family: 'Times New Roman', Times, serif;
}

.label-text {
    font-size: 16px;
    opacity: 0.9;
    margin-bottom: 5px;
    font-weight: bold;
}

.name-highlight {
    font-size: 32px;
    font-weight: bold;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4);
    color: #FFD700;
}

.envelope-back {
    background: linear-gradient(135deg, #40C4FF, #7C4DFF);
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 20px 50px rgba(64, 196, 255, 0.4),
        0 10px 30px rgba(124, 77, 255, 0.3);
}

.envelope-message {
    text-align: center;
    color: white;
    padding: 20px;
}

.message-icon {
    font-size: 45px;
    margin-bottom: 10px;
}

.message-text {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 5px;
    text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.3);
}

.message-hint {
    font-size: 28px;
}

.open-instruction {
    margin-top: 40px;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
}

.instruction-text {
    font-size: 18px;
    margin-bottom: 10px;
    font-weight: bold;
}

.card-content-wrapper {
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.8s ease, transform 0.8s ease;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.card-content-wrapper.visible {
    opacity: 1;
    transform: scale(1);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
}

.card {
    background: rgba(255, 255, 255, 0.97);
    border-radius: 35px;
    padding: 45px;
    margin: 20px auto;
    box-shadow: 
        0 25px 70px rgba(255, 64, 129, 0.3),
        0 15px 35px rgba(124, 77, 255, 0.2),
        inset 0 2px 15px rgba(255, 255, 255, 0.8);
    border: 6px solid;
    border-image: linear-gradient(45deg, #ff4081, #7C4DFF, #40C4FF) 1;
    position: relative;
    overflow: hidden;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 0.3s forwards;
}

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

.header {
    text-align: center;
    margin-bottom: 45px;
}

.title {
    font-family: 'Times New Roman', Times, serif;
    font-size: 4.5em;
    background: linear-gradient(45deg, #ff4081, #7C4DFF, #40C4FF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 25px 0;
    text-shadow: 3px 3px 15px rgba(255, 64, 129, 0.2);
    font-weight: bold;
}

.hearts {
    display: flex;
    justify-content: center;
    gap: 35px;
    margin: 25px 0;
}

.heart {
    font-size: 3.5em;
    filter: drop-shadow(0 5px 12px rgba(255, 64, 129, 0.4));
    animation: heartMoveSync 2s infinite ease-in-out;
}

@keyframes heartMoveSync {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-15px) scale(1.2); }
    50% { transform: translateY(0) scale(1); }
    75% { transform: translateY(-15px) scale(1.2); }
}

.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 55px;
    align-items: center;
    justify-content: center;
    margin: 45px 0;
}

.cake-section {
    flex: 1;
    min-width: 320px;
    text-align: center;
}

.cake {
    width: 270px;
    height: 240px;
    margin: 0 auto 35px;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.cake:hover {
    transform: scale(1.03);
}

.cake-layer {
    position: absolute;
    border-radius: 18px;
    box-shadow: 
        0 10px 25px rgba(0,0,0,0.2),
        inset 0 -6px 12px rgba(0,0,0,0.15);
}

.cake-layer.bottom {
    width: 240px;
    height: 90px;
    background: linear-gradient(45deg, #ff6b9d, #ff4081);
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1;
}

.cake-layer.middle {
    width: 200px;
    height: 80px;
    background: linear-gradient(45deg, #ff9ebb, #ff6b9d);
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.cake-layer.top {
    width: 160px;
    height: 70px;
    background: linear-gradient(45deg, #ffccd5, #ff9ebb);
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50% 50% 25% 25%;
    z-index: 3;
}

.candle {
    position: absolute;
    bottom: 150px; 
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
}

.candle-stick {
    width: 18px;
    height: 45px; 
    background: linear-gradient(to bottom, #FFD700, #FF9800);
    border-radius: 9px 9px 0 0; 
    margin: 0 auto;
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
    position: relative;
    top: -12px; 
}

.flame {
    width: 30px;
    height: 40px;
    background: radial-gradient(circle, #FFEB3B 0%, #FF9800 70%, transparent 90%);
    border-radius: 50% 50% 25% 25%;
    margin: 0 auto;
    opacity: 0;
    filter: blur(2px);
    position: absolute;
    top: -40px; /* ИСПРАВЛЕНО: поднял огонь выше */
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
}

.flame.lit {
    opacity: 1;
    animation: flameFlicker 0.6s infinite alternate;
}

@keyframes flameFlicker {
    0% { transform: translateX(-50%) scale(1) rotate(-8deg); }
    100% { transform: translateX(-50%) scale(1.4) rotate(8deg); }
}

.slider-controls {
    margin-top: 10px;
}

.slider-group {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 25px;
    border: 3px solid #40C4FF;
    margin-bottom: 15px;
}

.slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.slider-group label {
    font-weight: bold;
    color: #7C4DFF;
    font-size: 1.3em;
    flex-grow: 1;
    margin-left: 12px;
}

.slider-value {
    font-weight: bold;
    color: #FF4081;
    font-size: 1.3em;
    min-width: 70px;
    text-align: right;
}

.range-slider {
    width: 100%;
    height: 30px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #40C4FF, #7C4DFF);
    border-radius: 20px;
    outline: none;
    cursor: pointer;
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.4),
        0 0 0 4px #FFD700;
    border: 3px solid white;
}

.cake-hint {
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 20px;
    border-radius: 15px;
    border: 2px solid #FFD700;
    text-align: center;
    font-size: 0.9em;
    color: #7C4DFF;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    animation: hintPulse 2s infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; }
}

.hint-icon {
    font-size: 1.2em;
    animation: hintBounce 1s infinite;
}

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

.hint-text {
    font-weight: 500;
}

.message-section {
    flex: 1;
    min-width: 320px;
}

.greeting-message {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 240, 245, 0.95));
    padding: 35px;
    border-radius: 30px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    border: 3px dashed #ff4081;
}

.greeting-message h2 {
    color: #7C4DFF;
    margin-bottom: 25px;
    font-size: 2.5em;
    font-weight: bold;
}

.highlight {
    color: #FF4081;
    font-weight: bold;
    text-shadow: 2px 2px 6px rgba(255, 64, 129, 0.3);
}

.wish {
    font-size: 1.5em;
    line-height: 1.9;
    color: #333;
    text-align: center;
    font-weight: 500;
}

.particle {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
}

.confetti-piece {
    width: 15px;
    height: 15px;
    border-radius: 4px;
}

.heart-particle {
    font-size: 2em;
    filter: drop-shadow(0 0 15px rgba(255, 0, 100, 0.9));
}

.sparkle-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.firework-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.spiral-particle {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.rainbow-particle {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.lightning-particle {
    width: 8px;
    height: 35px;
    border-radius: 4px;
}

.message-popup {
    position: fixed;
    top: -100px;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(255, 255, 255, 0.97);
    padding: 20px 40px;
    border-radius: 60px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    z-index: 10001;
    font-weight: bold;
    color: #7C4DFF;
    border: 4px solid #FF4081;
    font-family: 'Times New Roman', Times, serif;
    text-align: center;
    max-width: 90%;
    font-size: 1.3em;
    white-space: nowrap;
}


@media (max-width: 768px) {
    .message-popup {
        white-space: normal;
        max-width: 85%;
        padding: 15px 25px;
        font-size: 1.1em;
    }
}
.flash-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
    pointer-events: none;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .card {
        padding: 25px 20px;
        margin: 10px;
    }
    
    .title {
        font-size: 2.8em;
    }
    
    .main-content {
        flex-direction: column;
        gap: 30px;
    }
    
    .envelope {
        width: 280px;
        height: 190px;
    }
    
    .name-highlight {
        font-size: 28px;
    }
    
    .heart {
        font-size: 2.5em;
    }
    
    .cake-hint {
        padding: 10px 15px;
        font-size: 0.85em;
    }
    
    .greeting-message h2 {
        font-size: 2em;
    }
    
    .wish {
        font-size: 1.3em;
    }
    
    .cake {
        width: 240px;
        height: 210px;
    }
    
    .cake-layer.bottom {
        width: 210px;
        height: 80px;
    }
    
    .cake-layer.middle {
        width: 170px;
        height: 70px;
        bottom: 70px;
    }
    
    .cake-layer.top {
        width: 130px;
        height: 60px;
        bottom: 130px;
    }
    
    .candle {
        bottom: 130px;
    }
    
    .candle-stick {
        height: 40px;
    }
}