#vr-container,
.vr180-container {
    position: relative;
    display: inline-block;
    width: 100%;
    overflow: hidden;
}

video {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
}

#vr180-playBtn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.55);
    border: 2px solid rgba(255, 255, 255, 0.75);
    border-radius: 14px;
    cursor: pointer;
    padding: 14px 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #fff;
    transition: opacity 0.3s ease, transform 0.2s ease, background 0.2s ease;
    z-index: 10;
    min-width: 100px;
}

#vr180-playBtn:hover {
    transform: translate(-50%, -50%) scale(1.07);
    background: rgba(0, 0, 0, 0.75);
}

#vr180-playBtn:active {
    transform: translate(-50%, -50%) scale(0.96);
}

#vr180-playBtn.hidden {
    opacity: 0;
    pointer-events: none;
}

#vr180-playBtn svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

#vr180-playBtn-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
}

/* 2D Video Controls Panel */
#vr180-panel {
    position: absolute;
    /* env() keeps the panel above the iOS home indicator; 0px fallback for non-iOS. */
    bottom: calc(10% + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    padding: 20px;
    border-radius: 30px;
    background: rgba(0, 0, 0, 0.70);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
}

#vr180-panel.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#vr180-status {
    margin: 0 12px 12px 12px;
}

#vr180-video-title {
    text-align: center;
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 500;
}

#vr180-current-time,
#vr180-total-time {
    margin: 0;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

#vr180-progress {
    display: grid;
    grid-template-columns: min-content 1fr min-content;
    grid-gap: 8px;
    align-items: center;
}

#vr180-bar {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #666;
    cursor: pointer;
    position: relative;
}

#vr180-played {
    border-radius: 2px;
    background: #fff;
    height: 4px;
    width: 0%;
    transition: width 0.1s ease;
}

#vr180-controls-row {
    display: flex;
    align-items: center;
}

#vr180-controls {
    display: grid;
    grid-template-areas: "full lflex nav rflex qual mute";
    grid-template-columns: 44px 1fr 156px 1fr 44px 44px;
    flex: 1;
    height: 44px;
}

#vr180-panel button {
    cursor: pointer;
    border: none;
    background-color: transparent;
}

#vr180-fullscreen {
    grid-area: full;
    width: 44px;
    height: 44px;
    background-image: url(../images/fullscreen.png);
    background-size: 44px 44px;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.15s ease-in-out;
}

#vr180-fullscreen:hover {
    background-image: url(../images/fullscreen-hover.png);
}

#vr180-mute-wrap {
    grid-area: mute;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#vr180-mute {
    width: 44px;
    height: 44px;
    background-image: url(../images/mute.png);
    background-size: 44px 44px;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.15s ease-in-out;
}

#vr180-volume-popup {
    position: absolute;
    bottom: 52px;
    right: 0;
    background: rgba(10, 10, 10, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 10px 14px;
    z-index: 200;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

#vr180-volume-slider {
    width: 90px;
    accent-color: #fff;
    cursor: pointer;
    display: block;
}

#vr180-mute:hover {
    background-image: url(../images/mute-hover.png);
}

#vr180-mute.muted {
    background-image: url(../images/mute.png);
}

#vr180-mute.muted:hover {
    background-image: url(../images/mute-hover.png);
}

#vr180-mute.unmuted {
    background-image: url(../images/unmute.png);
}

#vr180-mute.unmuted:hover {
    background-image: url(../images/unmute-hover.png);
}

#vr180-vr {
    width: 44px;
    height: 44px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

#vr180-vr:hover {
    opacity: 1;
}

#vr180-vr svg {
    width: 22px;
    height: 22px;
}

#vr180-nav {
    grid-area: nav;
    display: grid;
    grid-template-columns: 44px 44px 44px;
    grid-gap: 12px;
    height: 44px;
}

#vr180-back {
    width: 44px;
    height: 44px;
    background-image: url(../images/back.png);
    background-size: 44px 44px;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.15s ease-in-out;
}

#vr180-back:hover {
    background-image: url(../images/back-hover.png);
}

#vr180-play2 {
    width: 44px;
    height: 44px;
    background-image: url(../images/play2.png);
    background-size: 44px 44px;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.15s ease-in-out;
}

#vr180-play2:hover {
    background-image: url(../images/play2-hover.png);
}

#vr180-play2.paused {
    background-image: url(../images/play2.png);
}

#vr180-play2.paused:hover {
    background-image: url(../images/play2-hover.png);
}

#vr180-play2.playing {
    background-image: url(../images/pause.png);
}

#vr180-play2.playing:hover {
    background-image: url(../images/pause-hover.png);
}

#vr180-forward {
    width: 44px;
    height: 44px;
    background-image: url(../images/forward.png);
    background-size: 44px 44px;
    background-repeat: no-repeat;
    background-position: center;
    transition: background-image 0.15s ease-in-out;
}

#vr180-forward:hover {
    background-image: url(../images/forward-hover.png);
}

/* Quality picker inside #vr180-panel */
#vr180-quality-wrap {
    grid-area: qual;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#vr180-quality {
    width: 44px;
    height: 44px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

#vr180-quality:hover {
    opacity: 1;
}

#vr180-quality svg {
    width: 28px;
    height: 28px;
}

#vr180-quality-menu {
    position: absolute;
    bottom: 52px;
    right: 0;
    background: rgba(10, 10, 10, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 4px 0;
    min-width: 100px;
    z-index: 200;
    backdrop-filter: blur(4px);
}

#vr180-quality-menu button {
    display: block;
    width: 100%;
    padding: 9px 16px;
    color: #e0e0e0;
    text-align: left;
    font-size: 13px;
    border-radius: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.1s ease;
}

#vr180-quality-menu button:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

#vr180-quality-menu button.active {
    color: #fff;
    font-weight: bold;
}

/* ---- Mobile responsive ---- */
@media (max-width: 600px) {
    #vr180-panel {
        width: 92%;
        padding: 12px 14px;
        border-radius: 20px;
        bottom: calc(6% + env(safe-area-inset-bottom, 0px));
    }

    /* On small screens the desktop grid overflows — collapse flex columns. */
    #vr180-controls {
        grid-template-areas: "full lflex nav rflex qual mute";
        grid-template-columns: 44px 1fr auto 1fr 44px 44px;
    }

    #vr180-playBtn {
        padding: 10px 18px;
        min-width: 80px;
    }

    #vr180-playBtn svg {
        width: 32px;
        height: 32px;
    }
}

/* ---- iOS Pseudo-Fullscreen ---- */
/* Applied via JS on browsers that lack Element.requestFullscreen (Safari/iOS).
   !important is required to override the inline max-height set by PHP. */
.vr180-pseudo-fullscreen {
    position: fixed !important;
    top: env(safe-area-inset-top, 0px) !important;
    left: 0 !important;
    width: 100dvw !important;
    height: 100dvh !important; /* dvh tracks the visible viewport, handles Safari's sliding address bar */
    max-height: none !important;
    z-index: 9999 !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

/* Fallback for Safari < 15.4 that doesn't support dvh */
@supports not (height: 100dvh) {
    .vr180-pseudo-fullscreen {
        height: 100vh !important;
    }
}

/* Fullscreen button icon state — rotate to signal "exit fullscreen" */
#vr180-fullscreen.is-fullscreen {
    transform: rotate(180deg);
}