/* Modern Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-bg-top: #fff0f3;
    --color-bg-bot: #ffe5ec;
    --color-red: #E63946;
    --color-pink: #FFCDB2;
    --color-text: #1D3557;
    --color-trace-off: #cbd5e1;
    --color-trace-on: #E63946;
    --color-led-off: #cbd5e1;
    --color-led-on: #E63946;
    --color-accent-blue: #2774AE;
}

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(to bottom, var(--color-bg-top), var(--color-bg-bot));
    color: var(--color-text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    /* Allow scroll for smaller screens */
}

.container {
    text-align: center;
    padding: 3rem 2rem;
    max-width: 600px;
    width: 90%;
    animation: fadeIn 1.5s ease-out;
    position: relative;
    z-index: 10;
    /* Clean, soft card */
    background: rgba(255, 255, 255, 0.85);
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(230, 57, 70, 0.15);
    backdrop-filter: blur(10px);
}

/* Background Hearts */
.bg-hearts {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.heart {
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(255, 182, 193, 0.4);
    transform: rotate(45deg);
    animation: floatHeart 15s linear infinite;
    bottom: -10vh;
}

.heart::before,
.heart::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: inherit;
    border-radius: 50%;
}

.heart::before {
    top: -10px;
    left: 0;
}

.heart::after {
    left: -10px;
    top: 0;
}

.heart:nth-child(1) {
    left: 10%;
    width: 30px;
    height: 30px;
    animation-duration: 12s;
    animation-delay: 0s;
}

.heart:nth-child(1)::before,
.heart:nth-child(1)::after {
    width: 30px;
    height: 30px;
    top: -15px;
    left: 0;
}

.heart:nth-child(1)::after {
    left: -15px;
    top: 0;
}

.heart:nth-child(2) {
    left: 30%;
    width: 15px;
    height: 15px;
    animation-duration: 18s;
    animation-delay: 2s;
    background: rgba(230, 57, 70, 0.1);
}

.heart:nth-child(2)::before,
.heart:nth-child(2)::after {
    width: 15px;
    height: 15px;
    top: -7.5px;
    left: 0;
}

.heart:nth-child(2)::after {
    left: -7.5px;
    top: 0;
}

.heart:nth-child(3) {
    left: 70%;
    width: 40px;
    height: 40px;
    animation-duration: 20s;
    animation-delay: 5s;
}

.heart:nth-child(3)::before,
.heart:nth-child(3)::after {
    width: 40px;
    height: 40px;
    top: -20px;
    left: 0;
}

.heart:nth-child(3)::after {
    left: -20px;
    top: 0;
}

.heart:nth-child(4) {
    left: 90%;
    width: 25px;
    height: 25px;
    animation-duration: 15s;
    animation-delay: 1s;
    background: rgba(230, 57, 70, 0.15);
}

.heart:nth-child(4)::before,
.heart:nth-child(4)::after {
    width: 25px;
    height: 25px;
    top: -12.5px;
    left: 0;
}

.heart:nth-child(4)::after {
    left: -12.5px;
    top: 0;
}

@keyframes floatHeart {
    0% {
        transform: translateY(0) rotate(45deg);
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    100% {
        transform: translateY(-120vh) rotate(45deg);
        opacity: 0;
    }
}

/* Header */
.header h1 {
    font-family: 'Great Vibes', cursive;
    font-weight: 400;
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
    color: var(--color-red);
    line-height: 1.2;
    text-shadow: 2px 2px 4px rgba(230, 57, 70, 0.1);
}

.subtitle {
    font-weight: 300;
    font-size: 1.2rem;
    color: #64748b;
    margin-bottom: 2rem;
}

.university-badge {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-accent-blue);
    background: rgba(39, 116, 174, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Heart Photo Frame */
.heart-photo-container {
    position: relative;
    margin: 2rem auto;
    width: 250px;
    height: 250px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.heart-photo-container:hover {
    transform: scale(1.05) rotate(3deg);
}

.heart-shape {
    width: 100%;
    height: 100%;
    background-color: #ffe5ec;
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path d='M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z'/></svg>") no-repeat center / contain;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path d='M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z'/></svg>") no-repeat center / contain;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    animation: heartbeat 2s infinite ease-in-out;
}

/* Photo inside the heart */
.heart-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Placeholder fallback color */
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
}

.pulsing {
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
        filter: drop-shadow(0px 0px 10px rgba(230, 57, 70, 0.3));
    }

    15% {
        transform: scale(1.05);
        filter: drop-shadow(0px 0px 20px rgba(230, 57, 70, 0.5));
    }

    30% {
        transform: scale(1);
        filter: drop-shadow(0px 0px 10px rgba(230, 57, 70, 0.3));
    }

    45% {
        transform: scale(1.02);
        filter: drop-shadow(0px 0px 15px rgba(230, 57, 70, 0.4));
    }

    60% {
        transform: scale(1);
        filter: drop-shadow(0px 0px 10px rgba(230, 57, 70, 0.3));
    }

    100% {
        transform: scale(1);
        filter: drop-shadow(0px 0px 10px rgba(230, 57, 70, 0.3));
    }
}

/* Question & Buttons */
.proposal {
    margin-top: 3rem;
    transition: opacity 0.5s ease;
}

.question {
    font-family: 'Great Vibes', cursive;
    font-size: 2.8rem;
    margin-bottom: 2.5rem;
    font-weight: 400;
    color: var(--color-text);
}

.buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

@media (min-width: 400px) {
    .buttons {
        flex-direction: row;
        justify-content: center;
    }
}

.btn {
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Bouncy feel */
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-red), #ff5d6e);
    /* energetic gradient */
    color: white;
    box-shadow: 0 4px 15px rgba(230, 57, 70, 0.4);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(230, 57, 70, 0.5);
}

.btn-secondary {
    background-color: white;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background-color: #f1f5f9;
}

/* Screen Management */
.hidden {
    display: none !important;
}

/* Photo Frame */
.photo-frame {
    background: white;
    padding: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    transform: rotate(-3deg);
    margin: 2rem auto;
    width: 100%;
    max-width: 300px;
    /* Polaroid size */
}

.photo-placeholder {
    width: 100%;
    height: 300px;
    background: #f1f5f9;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-style: italic;
    border: 2px dashed #cbd5e1;
}

/* Date Ticket Design */
.ticket {
    background: white;
    width: 300px;
    margin: 2rem auto;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    color: var(--color-text);
    text-align: left;
}

.ticket-header {
    background: var(--color-red);
    color: white;
    padding: 1rem;
    text-align: center;
    border-bottom: 2px dashed white;
    position: relative;
}

.ticket-header h3 {
    margin: 0;
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.ticket-header::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 20px;
    background: radial-gradient(circle, transparent 70%, white 70%);
    background-size: 20px 20px;
    background-position: center bottom;
    opacity: 0.5;
    /* Subtle rip effect */
}

.ticket-body {
    padding: 1.5rem;
}

.ticket-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.ticket-label {
    color: #94a3b8;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 0.25rem;
}

.ticket-value {
    font-weight: 600;
    font-size: 1.1rem;
}

.ticket-footer {
    padding: 1rem;
    background: #f8fafc;
    text-align: center;
    border-top: 1px dashed #e2e8f0;
}

.barcode {
    font-family: 'libre barcode 39 text', cursive;
    /* Fallback or import if possible, otherwise use stripes */
    height: 30px;
    width: 80%;
    margin: 0 auto;
    background: repeating-linear-gradient(90deg,
            #333,
            #333 2px,
            transparent 2px,
            transparent 4px);
}

.success-text {
    font-size: 1.2rem;
    margin-top: 2rem;
    color: var(--color-text);
}

/* No Screen - Error Theme */
.error-title {
    color: var(--color-red);
    font-family: 'Courier New', monospace;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.error-text {
    font-family: 'Courier New', monospace;
    margin-bottom: 2rem;
    color: #64748b;
}

.circuit-broken {
    font-size: 5rem;
    margin: 2rem 0;
    animation: shake 0.5s infinite;
}

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

    50% {
        transform: translate(-1px, 2px) rotate(-1deg);
    }

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

/* Animation utilities */
section {
    animation: fadeIn 0.8s ease-out;
}

/* Utility to ensure the 'No' button moves smoothly */
.btn-avoid {
    position: absolute;
    transition: all 0.2s ease;
}

/* Music Control */
.music-control {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s ease;

    /* Heart Shape Match */
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path d='M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z'/></svg>") no-repeat center / 85%;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'><path d='M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z'/></svg>") no-repeat center / 85%;

    /* Shadow for masked element */
    filter: drop-shadow(0 4px 10px rgba(230, 57, 70, 0.4));
}

.music-control:hover {
    transform: scale(1.1) rotate(5deg);
    background: linear-gradient(135deg, #ff758c 0%, #ff7eb3 100%);
    /* Darker pink on hover */
}

.icon-music {
    font-size: 1.5rem;
    color: #d63384;
    padding-top: 5px;
    /* Visually center in heart */
}

.music-control:hover .icon-music {
    color: white;
}