/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    position: relative; /* Make body the positioning context for absolute children */
}

/* Page container holds just the media */
.page-container {
    max-width: 100vw;
    max-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Media container for video/image */
.media-container {
    max-width: 100%;
    max-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

img, video {
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
    display: block;
}

/* Caption styles - positioned relative to body */
.caption {
    position: absolute;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    z-index: 10;
    transition: opacity 0.3s ease;
}

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

.caption-text {
    display: block;
    padding-right: 20px; /* Space for close button */
}

.close-btn {
    display: none; /* Hidden by default, shown on mobile */
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 20px;
    height: 20px;
    line-height: 1;
    padding: 0;
}

/* Created by styles - positioned relative to body */
.created-by {
    position: absolute;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    font-size: 14px;
    z-index: 10;
}

.created-by a {
    color: white;
    text-decoration: none;
}

.created-by a:hover {
    text-decoration: underline;
}

/* Desktop (default) */
.caption {
    top: 20px;
    left: 20px;
    max-width: 40%;
}

.created-by {
    bottom: 20px;
    right: 20px;
}

/* Tablet (portrait) */
@media (max-width: 1024px) and (min-width: 768px) {
    .caption {
        top: 15px;
        left: 15px;
        max-width: 50%;
        font-size: 13px;
    }

    .created-by {
        bottom: 15px;
        right: 15px;
        font-size: 13px;
    }
}

/* Tablet (landscape) */
@media (max-width: 1024px) and (orientation: landscape) {
    .caption {
        max-width: 35%;
        top: 15px;
        left: 15px;
    }
}

/* Mobile (all) - Modified for iPhone safe areas */
@media (max-width: 767px) {
    .caption {
        top: max(10px, env(safe-area-inset-top, 10px) + 10px); /* Extra space for iPhone notch */
        left: 10px;
        right: 10px;
        max-width: none;
        font-size: 12px;
        padding: 8px 10px;
    }

    /* Show close button on mobile */
    .close-btn {
        display: block;
    }

    .created-by {
        bottom: max(10px, env(safe-area-inset-bottom, 10px) + 10px); /* Extra space for iPhone home indicator */
        right: 10px;
        font-size: 12px;
        padding: 8px 10px;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .caption {
        top: max(5px, env(safe-area-inset-top, 5px) + 15px); /* Even more space on very small screens */
        left: 5px;
        right: 5px;
        font-size: 11px;
        padding: 6px 8px;
    }

    .created-by {
        bottom: max(5px, env(safe-area-inset-bottom, 5px) + 15px);
        right: 5px;
        font-size: 11px;
        padding: 5px 8px;
    }
}

/* Extra small screens */
@media (max-width: 360px) {
    .caption {
        top: max(5px, env(safe-area-inset-top, 5px) + 20px);
    }

    .created-by {
        bottom: max(5px, env(safe-area-inset-bottom, 5px) + 20px);
    }
}