:root {
    --bfm-accent: #D41515;
    --bfm-bg: #161616;
    --bfm-text: #FFFFFF;
    --bfm-muted: rgba(255, 255, 255, 0.72);
    --bfm-control-bg: rgba(22, 22, 22, 0.92);
}

/* Warstwa zewnętrzna modala. */
.bfm-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    box-sizing: border-box;
    padding: 64px;
    overflow: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    color: var(--bfm-text);
}

.bfm-modal::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.bfm-modal.is-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.bfm-modal__backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.20);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}


.bfm-modal__close {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 3;
    width: 44px;
    height: 44px;
    box-sizing: border-box;
    margin: 0;
    padding: 10px;
    border: 0;
    border-radius: 50%;
    background: rgba(22, 22, 22, 0.72);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    appearance: none;
    transition:
        background 160ms ease,
        transform 160ms ease;
}

.bfm-modal__close:hover,
.bfm-modal__close:focus-visible {
    background: rgba(22, 22, 22, 0.94);
    outline: none;
    transform: scale(1.04);
}

.bfm-modal__close img {
    display: block;
    width: 24px;
    height: 24px;
    color: currentColor;
    object-fit: contain;
}

/* Panel modala. */
.bfm-modal__panel {
    position: relative;
    z-index: 1;
    width: auto;
    max-width: calc(100vw - 128px);
    max-height: calc(100dvh - 128px);
    box-sizing: border-box;
    padding: 64px;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    border: 1px solid rgba(0, 0, 0, 0.72);
    border-radius: 16px;
    background:
        linear-gradient(
            314deg,
            rgba(0, 0, 0, 0.20) 0%,
            rgba(75, 75, 75, 0.20) 100%
        ),
        var(--bfm-bg);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
    display: flex;
    flex-direction: column;
    align-items: center;
}


.bfm-modal__panel::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.bfm-modal__title {
    margin: 0 0 32px;
    color: #fff;
    text-align: center;
    font-family: inherit;
    font-size: clamp(40px, 4.4vw, 68px);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.02em;
}


.bfm-version-picker {
    width: 720px;
    max-width: 100%;
    box-sizing: border-box;
}

.bfm-version-picker__prompt {
    margin: 0 0 20px;
    color: rgba(255, 255, 255, 0.72);
    text-align: center;
    font-size: 17px;
}

.bfm-version-picker__options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.bfm-version-card {
    min-height: 132px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.035);
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    text-align: left;
    font: inherit;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.bfm-version-card:hover,
.bfm-version-card:focus-visible {
    border-color: var(--bfm-accent);
    background: rgba(212, 21, 21, 0.08);
    outline: none;
    transform: translateY(-2px);
}

.bfm-version-card__title {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.15;
}

.bfm-version-card__duration {
    margin-top: 20px;
    color: rgba(255, 255, 255, 0.62);
    font-size: 15px;
}

.bfm-playback {
    width: 100%;
}

.bfm-modal [hidden] {
    display: none !important;
}

/* Kontener odtwarzacza. */
.bfm-player {
    position: relative;
    width: 100%;
    max-width: 1320px;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid #000;
    border-radius: 8px;
    background: #000;
    box-sizing: border-box;
}

.bfm-player__video {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    border-radius: 8px 8px 0 0;
    background: #000;
    object-fit: contain;
    cursor: pointer;
}


.bfm-player__freeze,
.bfm-player__loading {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 12;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px 8px 0 0;
    pointer-events: none;
}

.bfm-player__freeze {
    display: block;
    height: auto;
    opacity: 0;
    object-fit: cover;
    background: #000;
    transition: opacity 120ms ease;
}

.bfm-player--freeze-visible .bfm-player__freeze {
    opacity: 1;
}

.bfm-player__loading {
    z-index: 14;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    background: rgba(0, 0, 0, 0.08);
    transition: opacity 140ms ease;
}

.bfm-player--buffering .bfm-player__loading {
    opacity: 1;
}

.bfm-player__spinner {
    width: 42px;
    height: 42px;
    box-sizing: border-box;
    border: 4px solid rgba(255, 255, 255, 0.30);
    border-top-color: var(--bfm-accent);
    border-radius: 50%;
    animation: bfm-spin 720ms linear infinite;
}

@keyframes bfm-spin {
    to {
        transform: rotate(360deg);
    }
}

.bfm-player__controls {
    min-height: 56px;
    display: grid;
    grid-template-columns: auto auto minmax(100px, 1fr) auto auto auto;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    box-sizing: border-box;
    background: var(--bfm-control-bg);
}

.bfm-control {
    width: 32px;
    height: 32px;
    padding: 5px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bfm-control:hover,
.bfm-control:focus-visible {
    background: rgba(255, 255, 255, 0.10);
    outline: none;
}

.bfm-control img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.bfm-player__time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    color: var(--bfm-muted);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.bfm-player__progress {
    --bfm-progress: 0%;
    width: 100%;
    height: 22px;
    margin: 0;
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
}

.bfm-player__progress::-webkit-slider-runnable-track {
    height: 5px;
    border-radius: 999px;
    background:
        linear-gradient(
            to right,
            var(--bfm-accent) 0,
            var(--bfm-accent) var(--bfm-progress),
            rgba(255, 255, 255, 0.72) var(--bfm-progress),
            rgba(255, 255, 255, 0.72) 100%
        );
}

.bfm-player__progress::-moz-range-track {
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
}

.bfm-player__progress::-moz-range-progress {
    height: 5px;
    border-radius: 999px;
    background: var(--bfm-accent);
}

.bfm-player__progress::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
    margin-top: -7.5px;
    border: 0;
    border-radius: 50%;
    appearance: none;
    -webkit-appearance: none;
    background: var(--bfm-accent);
}

.bfm-player__progress::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: 0;
    border-radius: 50%;
    background: var(--bfm-accent);
}

.bfm-player__settings-wrap {
    position: relative;
}

.bfm-player__settings-menu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    z-index: 20;
    width: 180px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(22, 22, 22, 0.98);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.bfm-player__settings-title {
    padding: 6px 8px 9px;
    color: rgba(255, 255, 255, 0.58);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.bfm-player__quality-list {
    display: grid;
    gap: 2px;
}

.bfm-quality {
    width: 100%;
    padding: 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    text-align: left;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

button.bfm-quality:hover,
button.bfm-quality:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

.bfm-quality.is-active {
    color: var(--bfm-accent);
}

.bfm-quality--native {
    display: block;
    cursor: default;
}

.bfm-player__message {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    max-width: 80%;
    margin: 0;
    padding: 12px 16px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    text-align: center;
}

.bfm-modal__back {
    margin-top: 32px;
    min-height: 52px;
    padding: 0 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 4px;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 16px;
    cursor: pointer;
}

.bfm-modal__back:hover,
.bfm-modal__back:focus-visible {
    background: rgba(255, 255, 255, 0.08);
    outline: none;
}

.bfm-modal__back img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

/* Tryb pełnoekranowy. */
.bfm-player:fullscreen,
.bfm-player:-webkit-full-screen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none;
    border: 0;
    border-radius: 0;
    background: #000;
}

.bfm-player:fullscreen .bfm-player__video,
.bfm-player:-webkit-full-screen .bfm-player__video {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
    object-fit: contain;
}


.bfm-player:fullscreen .bfm-player__freeze,
.bfm-player:fullscreen .bfm-player__loading,
.bfm-player:-webkit-full-screen .bfm-player__freeze,
.bfm-player:-webkit-full-screen .bfm-player__loading {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
}

.bfm-player:fullscreen .bfm-player__controls,
.bfm-player:-webkit-full-screen .bfm-player__controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    min-height: 68px;
    padding: 12px 24px 10px;
    background:
        linear-gradient(
            to top,
            rgba(0, 0, 0, 0.88) 0%,
            rgba(0, 0, 0, 0.58) 62%,
            rgba(0, 0, 0, 0) 100%
        );
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 180ms ease,
        transform 180ms ease;
}

.bfm-player:fullscreen.bfm-player--controls-hidden .bfm-player__controls,
.bfm-player:-webkit-full-screen.bfm-player--controls-hidden .bfm-player__controls {
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .bfm-player:fullscreen.bfm-player--controls-hidden,
    .bfm-player:-webkit-full-screen.bfm-player--controls-hidden {
        cursor: none;
    }
}

@media (max-width: 1024px) {
    .bfm-modal {
        padding: 24px;
    }

    .bfm-modal__panel {
        width: auto;
        max-width: calc(100vw - 48px);
        max-height: calc(100dvh - 48px);
        padding: 40px 32px;
    }

    .bfm-modal__title {
        font-size: clamp(36px, 6vw, 56px);
    }

    .bfm-player__video {
        height: auto;
    }
}

@media (max-width: 720px) {
    .bfm-modal__close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        padding: 8px;
    }

    .bfm-modal {
        padding: 12px;
    }

    .bfm-modal__panel {
        width: 100%;
        max-width: none;
        max-height: calc(100dvh - 24px);
        padding: 28px 16px;
        border-radius: 12px;
    }

    .bfm-modal__title {
        margin-bottom: 24px;
        font-size: clamp(30px, 10vw, 42px);
    }

    .bfm-version-picker__options {
        grid-template-columns: 1fr;
    }

    .bfm-version-card {
        min-height: 104px;
        padding: 20px;
    }

    .bfm-version-card__title {
        font-size: 21px;
    }

    .bfm-player {
        border-radius: 8px;
    }

    .bfm-player__video {
        height: auto;
        border-radius: 8px 8px 0 0;
    }

    .bfm-player__controls {
        min-height: 52px;
        grid-template-columns: auto auto minmax(60px, 1fr) auto auto auto;
        gap: 6px;
        padding: 0 8px;
    }

    .bfm-player__time {
        font-size: 12px;
    }

    .bfm-control {
        width: 30px;
        height: 30px;
        padding: 5px;
    }

    .bfm-player__progress::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
        margin-top: -6.5px;
    }

    .bfm-player__progress::-moz-range-thumb {
        width: 18px;
        height: 18px;
    }

    .bfm-player__spinner {
        width: 34px;
        height: 34px;
        border-width: 3px;
    }

    .bfm-modal__back {
        margin-top: 24px;
    }

    .bfm-player:fullscreen .bfm-player__controls,
    .bfm-player:-webkit-full-screen .bfm-player__controls {
        min-height: 60px;
        padding: 8px 10px;
    }
}

@media (max-width: 520px) {
    .bfm-player__controls {
        grid-template-columns: auto minmax(60px, 1fr) auto auto auto;
    }

    .bfm-player__time {
        display: none;
    }
}
