:root {
    --primary-color: #ff00cc;
    /* Neon Pink */
    --secondary-color: #333399;
    /* Deep Blue/Purple */
    --accent-color: #00ffff;
    /* Cyan */
    --text-color: #ffffff;
    --bg-gradient: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

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

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    /* Prevent scrollbar from background blobs if we add them */
}

/* Background Blobs for extra depth */
body::before,
body::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
}

body::before {
    width: 400px;
    height: 400px;
    background: var(--primary-color);
    top: -100px;
    left: -100px;
    opacity: 0.4;
}

body::after {
    width: 300px;
    height: 300px;
    background: var(--accent-color);
    bottom: -50px;
    right: -50px;
    opacity: 0.3;
}

.container {
    width: 90%;
    max-width: 900px;
    text-align: center;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

header h1 {
    font-family: 'Fredoka', sans-serif;
    font-size: 3rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color);
    letter-spacing: 2px;
}

header p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 3rem;
    font-size: 1.1rem;
    font-weight: 300;
}

.joke-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 3rem;
    box-shadow: var(--glass-shadow);
    margin-bottom: 3rem;
    height: fit-content;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Media Flip Container */
.media-flip-container {
    width: 100%;
    max-width: 500px;
    /* Limit width for better appearance */
    margin: 0 auto 2rem auto;
    perspective: 1000px;
    position: relative;
    /* Ensure height is determined by content */
}

.media-flip-inner {
    position: relative;
    width: 100%;
    height: auto;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.media-flip-container.flipped .media-flip-inner {
    transform: rotateY(180deg);
}

.media-front,
.media-back {
    width: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.media-front {
    z-index: 2;
    transform: rotateY(0deg);
}

.media-back {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotateY(180deg);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    /* Background for video container */
    border-radius: 20px;
    /* Match image border radius */
}

/* Rotation Button */
.rotation-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    z-index: 10;
}

.rotation-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.1) rotate(180deg);
}

/* Video Styling */
.video-container {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 20px;
    overflow: hidden;
}

.joke-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 20px;
}

/* Adjust image container to match */
.image-container {
    display: none;
    /* Controlled by JS */
    margin-bottom: 0;
    /* Remove bottom margin as it's handled by container */
    position: relative;
}

.joke-image {
    /* Existing styles... */
    display: block;
    /* Ensure it takes up space */
}

.joke-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.joke-content h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--accent-color);
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
    word-wrap: break-word;
}

.joke-content p {
    font-size: 1.2rem;
    line-height: 1.6;
    color: var(--text-color);
    white-space: pre-wrap;
    font-weight: 400;
}

.image-container {
    display: none;
    margin-bottom: 2rem;
    text-align: center;
}

.joke-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.2);
    image-rendering: pixelated;
    transition: transform 0.3s ease;
    max-width: 100%;
}

.joke-image:hover {
    transform: scale(1.03) rotate(1deg);
}

.humor-btn {
    background: linear-gradient(90deg, var(--primary-color), #ff5e62);
    color: white;
    border: none;
    padding: 1.2rem 3.5rem;
    font-size: 1.3rem;
    font-family: 'Fredoka', sans-serif;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(255, 0, 204, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.humor-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 0, 204, 0.7);
    filter: brightness(1.1);
}

.humor-btn:active {
    transform: scale(0.98);
}

.btn-icon {
    font-size: 1.5rem;
}

.voting-container {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 2rem;
}

.vote-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Nunito', sans-serif;
    font-weight: bold;
    color: var(--text-color);
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.vote-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-3px);
}

.vote-btn.upvote:hover {
    border-color: #2ecc71;
    color: #2ecc71;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.3);
}

.vote-btn.downvote:hover {
    border-color: #e74c3c;
    color: #e74c3c;
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.3);
}

.vote-btn.share-btn:hover,
.vote-btn.facebook-share-btn:hover,
.vote-btn.twitter-share-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.vote-icon {
    font-size: 1.2rem;
}

footer {
    margin-top: 3rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Loading animation */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
        width: 95%;
    }

    header h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
        margin-bottom: 2rem;
    }

    .joke-card {
        padding: 1.5rem;
        display: flex;
        flex-direction: column;
    }

    .joke-content h2 {
        font-size: 1.3rem;
    }

    .joke-content p {
        font-size: 1.1rem;
    }

    .joke-image {
        width: 100%;
        max-width: 280px;
        margin: 0 auto 1rem auto;
    }

    .humor-btn {
        width: 100%;
        justify-content: center;
        padding: 1rem 2rem;
        font-size: 1.1rem;
    }

    .voting-container {
        gap: 15px;
        flex-wrap: wrap;
    }

    .vote-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* Feedback Button - Corner */
.feedback-btn-corner {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.feedback-btn-corner:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

.modal-content {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    margin: 10% auto;
    padding: 2.5rem;
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--glass-shadow);
    position: relative;
}

.modal-content h2 {
    color: var(--accent-color);
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

.modal-content p {
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 1.5rem;
}

.close-modal {
    color: rgba(255, 255, 255, 0.6);
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: var(--text-color);
}

#feedback-text {
    width: 100%;
    min-height: 120px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem;
    color: var(--text-color);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    resize: vertical;
    margin-bottom: 1.5rem;
}

#feedback-text:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
}

.small-btn {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.1rem;
}