.wavecx-wrapper {
    position: relative;
    cursor: pointer;
    background-color: #f9f9f9;
    overflow: hidden;
    aspect-ratio: 1 / .7; 
    border-radius: 20px;
    width: 100%;
    max-width: 500px; 
    margin: 0 auto;
    transition: all 0.3s ease-in-out;
}

@media (min-width: 655px) {
    .wavecx-wrapper:not(.is-playing) {
        aspect-ratio: 1.38 / .96;
    }
}

.wavecx-wrapper.is-playing {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    background-color: rgba(10, 10, 10, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    margin: 0;
    box-sizing: border-box;
    padding: 20px;
    animation: wavecxFadeIn 0.3s ease-out forwards;
    cursor: default;
}

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

body.wavecx-body-lock {
    overflow: hidden !important;
}

/* Reset Button: Starts in Upper Right */
.wavecx_reset_btn {
    display: none; 
    position: fixed;
    top: 25px;
    right: 25px;
    background: rgba(184, 134, 11, 0.95);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-family: Arial, sans-serif;
    font-size: 20px;
    font-weight: bold;
    z-index: 1000000;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: all 0.3s ease-in-out, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wavecx_reset_btn:hover {
    background: rgb(184, 134, 11);
    transform: scale(1.1);
}

.is-playing .wavecx_reset_btn {
    display: flex;
}

/* Move to center when finished class is added */
.wavecx_reset_btn.is-finished {
    position: fixed;
    top: 50%;
    right: auto;
    left: 50%;
    transform: translate(-50%, -50%); 
    width: 80px;
    height: 80px;
    font-size: 32px;
}

.wavecx_thumb {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    object-fit: cover;
    z-index: 2;
}

.wavecx_play_overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    pointer-events: none;
}

.is-playing .wavecx_thumb, 
.is-playing .wavecx_play_overlay { 
    display: none; 
}

.wavecx-wrapper iframe {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    border: none;
}

/* Placeholder container: dynamically respects aspect-ratio even under height-constrained viewports */
.wavecx-wrapper.is-playing > div[id$="_placeholder"] {
    width: 100%;
    height: auto;
    max-height: min(86vh, calc(100vh - 160px));
    max-width: min(1400px, calc(100vw - 160px), calc(min(86vh, calc(100vh - 160px)) * 16 / 9));
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.wavecx-wrapper.is-playing iframe {
    position: relative;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 12px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.8);
    display: block;
    background-color: #000;
}

@media (max-width: 768px) {
    .wavecx-wrapper.is-playing {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        padding: 0;
        align-items: flex-start;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .wavecx-wrapper.is-playing > div[id$="_placeholder"] {
        width: 100%;
        height: 100%;
        min-height: 760px;
        max-width: 100vw;
        max-height: 100%;
        aspect-ratio: auto;
    }
    .wavecx-wrapper.is-playing iframe {
        border-radius: 0;
        box-shadow: none;
    }
    .is-playing .wavecx_reset_btn {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        font-size: 14px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
}
