/* 娛樂區影片。卡片外框用 qto-card-ui；這裡排清單、復古拉門電視與全螢幕播放。 */

#avatarVideoRoot[hidden],
#avatarVideoPlayer[hidden] {
    display: none !important;
}

#avatarVideoRoot:not([hidden]) {
    position: relative;
    z-index: 4;
    width: 100%;
    max-height: min(62vh, 520px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 8px 10px;
    box-sizing: border-box;
}

/* —— 復古木頭落地電視 —— */
.ent-tv {
    --ent-tv-wood: #6b3f24;
    --ent-tv-wood-deep: #3e2414;
    --ent-tv-wood-mid: #8a5533;
    --ent-tv-wood-lite: #a86b42;
    --ent-tv-metal: #c5b48a;
    --ent-tv-metal-shine: #f0e6c8;
    --ent-tv-open-ms: 820ms;
    --ent-tv-close-ms: 820ms;
    width: min(100%, 420px);
    margin: 0 auto;
}

.ent-tv__stage {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.ent-tv__side {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    padding: 28px 0 40px;
    flex: 0 0 auto;
}

.ent-tv__knob {
    position: relative;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ent-tv__knob-face {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 28%, var(--ent-tv-metal-shine) 0%, var(--ent-tv-metal) 38%, #8a7a52 72%, #5a4e32 100%);
    box-shadow:
        inset 0 2px 3px rgba(255, 255, 255, 0.55),
        inset 0 -3px 5px rgba(40, 28, 10, 0.55),
        0 2px 0 #2a1c0e,
        0 4px 8px rgba(0, 0, 0, 0.45);
    transition: transform 80ms ease, box-shadow 80ms ease;
}

.ent-tv__knob-mark {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 3px;
    height: 10px;
    margin-left: -1.5px;
    border-radius: 1px;
    background: linear-gradient(180deg, #fff8e0, #6a5a38);
    box-shadow: 0 0 1px rgba(255, 255, 255, 0.7);
    pointer-events: none;
}

.ent-tv__knob:active .ent-tv__knob-face {
    transform: translateY(2px) scale(0.96);
    box-shadow:
        inset 0 3px 6px rgba(40, 28, 10, 0.65),
        0 1px 0 #2a1c0e,
        0 2px 4px rgba(0, 0, 0, 0.35);
}

.ent-tv__cabinet {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    padding: 10px 12px 0;
    border-radius: 10px 10px 6px 6px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.14), transparent 42%),
        linear-gradient(180deg, var(--ent-tv-wood-lite) 0%, var(--ent-tv-wood) 45%, var(--ent-tv-wood-deep) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 230, 190, 0.35),
        inset 0 -2px 6px rgba(20, 10, 4, 0.45),
        0 10px 22px rgba(0, 0, 0, 0.45),
        0 2px 0 rgba(255, 220, 170, 0.12);
}

.ent-tv__wood-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.ent-tv__top-rail {
    height: 10px;
    margin: 0 4px 8px;
    border-radius: 4px;
    background:
        linear-gradient(180deg, #c08958, var(--ent-tv-wood-deep));
    box-shadow:
        inset 0 1px 0 rgba(255, 230, 190, 0.4),
        0 2px 3px rgba(0, 0, 0, 0.35);
}

.ent-tv__bezel {
    padding: 10px;
    border-radius: 8px;
    background:
        linear-gradient(180deg, #4a2c18, #2a160c 60%, #1a0e08);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.65),
        inset 0 -1px 0 rgba(255, 210, 160, 0.12),
        0 1px 0 rgba(255, 220, 170, 0.15);
}

.ent-tv__screen-well {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 12px;
    background: #0a0c10;
    box-shadow:
        inset 0 0 0 3px #1a120c,
        inset 0 0 18px rgba(0, 0, 0, 0.85);
}

.ent-tv__crt {
    position: absolute;
    inset: 6px;
    overflow: hidden;
    border-radius: 18px / 22px;
    background:
        radial-gradient(ellipse at center, #1a2230 0%, #0b1018 70%, #05070c 100%);
    transform-origin: center center;
    transition: transform var(--ent-tv-close-ms) ease, filter var(--ent-tv-close-ms) ease, opacity 200ms ease;
}

.ent-tv__snow {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 1px, rgba(255, 255, 255, 0.04) 1px, rgba(255, 255, 255, 0.04) 2px),
        radial-gradient(circle, rgba(255, 255, 255, 0.35) 0.5px, transparent 0.6px);
    background-size: 100% 4px, 3px 3px;
    mix-blend-mode: screen;
}

.ent-tv__scan {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    opacity: 0.12;
    background: repeating-linear-gradient(
        180deg,
        transparent 0,
        transparent 2px,
        rgba(0, 0, 0, 0.35) 2px,
        rgba(0, 0, 0, 0.35) 3px
    );
}

.ent-tv__glass {
    position: absolute;
    inset: 0;
    z-index: 4;
    pointer-events: none;
    border-radius: inherit;
    background:
        radial-gradient(ellipse 70% 45% at 30% 18%, rgba(255, 255, 255, 0.22), transparent 55%),
        radial-gradient(ellipse 50% 40% at 78% 80%, rgba(120, 180, 255, 0.08), transparent 60%);
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.35);
}

.ent-tv .ent-video__stack {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
    box-sizing: border-box;
    background: rgba(10, 14, 20, 0.92);
    color: var(--cm-ivory, #f4f6f8);
}

.ent-tv .ent-video__stack[hidden] {
    display: none !important;
}

.ent-tv__door {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    z-index: 5;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--ent-tv-open-ms) cubic-bezier(0.33, 0.1, 0.25, 1);
    box-shadow:
        inset 0 1px 0 rgba(255, 230, 190, 0.25),
        inset 0 -2px 6px rgba(20, 10, 4, 0.4);
}

.ent-tv__door--left {
    left: 0;
    transform-origin: left center;
    border-right: 1px solid rgba(30, 16, 8, 0.55);
}

.ent-tv__door--right {
    right: 0;
    transform-origin: right center;
    border-left: 1px solid rgba(30, 16, 8, 0.55);
}

.ent-tv__door-svg {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.ent-tv__handle {
    position: absolute;
    top: 50%;
    width: 10px;
    height: 28px;
    margin-top: -14px;
    border-radius: 3px;
    background:
        linear-gradient(90deg, #e8d7a8, #9a8450 45%, #6a5830 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.55),
        inset 0 -1px 2px rgba(40, 28, 10, 0.5),
        0 2px 3px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.ent-tv__handle--left { right: 10px; }
.ent-tv__handle--right { left: 10px; }

.ent-tv__door:active {
    filter: brightness(0.92);
}

.ent-tv__door:active .ent-tv__handle {
    transform: translateY(1px);
}

/* 門狀態 */
.ent-tv[data-ent-tv-state="open"] .ent-tv__door--left,
.ent-tv[data-ent-tv-state="opening"] .ent-tv__door--left {
    transform: translateX(-102%);
}

.ent-tv[data-ent-tv-state="open"] .ent-tv__door--right,
.ent-tv[data-ent-tv-state="opening"] .ent-tv__door--right {
    transform: translateX(102%);
}

.ent-tv[data-ent-tv-state="open"] .ent-tv__door,
.ent-tv[data-ent-tv-state="opening"] .ent-tv__door {
    pointer-events: none;
}

.ent-tv[data-ent-tv-state="opening"] .ent-tv__snow {
    opacity: 0.85;
    animation: ent-tv-snow-flicker 0.45s steps(3, end) 0.2s 1;
}

.ent-tv[data-ent-tv-state="open"] .ent-tv__snow {
    opacity: 0;
}

.ent-tv[data-ent-tv-state="closing"] .ent-tv__crt {
    animation: ent-tv-crt-off var(--ent-tv-close-ms) ease forwards;
}

.ent-tv[data-ent-tv-state="closing"] .ent-tv__door--left,
.ent-tv[data-ent-tv-state="closing"] .ent-tv__door--right {
    transform: translateX(0);
}

.ent-tv[data-ent-tv-state="closed"] .ent-tv__door--left,
.ent-tv[data-ent-tv-state="closed"] .ent-tv__door--right {
    transform: translateX(0);
}

@keyframes ent-tv-snow-flicker {
    0% { opacity: 0.95; filter: contrast(1.4); }
    40% { opacity: 0.35; }
    70% { opacity: 0.9; }
    100% { opacity: 0.15; }
}

@keyframes ent-tv-crt-off {
    0% { transform: scale(1); filter: brightness(1); opacity: 1; }
    45% { transform: scaleY(0.04) scaleX(1.05); filter: brightness(2.4); opacity: 1; }
    75% { transform: scaleY(0.02) scaleX(0.12); filter: brightness(3); opacity: 1; }
    100% { transform: scale(0); filter: brightness(4); opacity: 0; }
}

.ent-tv__grille {
    margin: 8px 4px 0;
    height: 36px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 1px 0 rgba(255, 220, 170, 0.12);
}

.ent-tv__grille svg {
    display: block;
    width: 100%;
    height: 100%;
}

.ent-tv__legs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    padding: 8px 18px 0;
    min-height: 28px;
}

.ent-tv__leg {
    display: block;
    width: 10px;
    height: 22px;
    margin: 0 auto;
    border-radius: 2px 2px 1px 1px;
    background:
        linear-gradient(90deg, #5a341c, #8a5533 40%, #3e2414);
    box-shadow:
        inset 1px 0 0 rgba(255, 220, 170, 0.25),
        0 4px 6px rgba(0, 0, 0, 0.4);
}

.ent-tv__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 12px;
    margin-top: 10px;
}

.ent-tv__opt {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 4px;
    font: inherit;
    font-size: 14px;
    color: var(--cm-ivory, #f4f6f8);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.ent-tv__opt input {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: #8a5533;
}

/* 減少動態效果：門直接開合、無雪花／熄滅動畫 */
@media (prefers-reduced-motion: reduce) {
    .ent-tv {
        --ent-tv-open-ms: 1ms;
        --ent-tv-close-ms: 1ms;
    }

    .ent-tv__door,
    .ent-tv__crt {
        transition: none !important;
        animation: none !important;
    }

    .ent-tv[data-ent-tv-state="opening"] .ent-tv__snow {
        animation: none !important;
        opacity: 0;
    }
}

.ent-video__item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ent-video__title {
    flex: 1 1 100%;
    margin: 0;
    font-size: inherit;
    font-weight: 700;
    line-height: 1.35;
}

.ent-video__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    flex: 1 1 auto;
    margin: 0;
    color: var(--cm-muted, #c8d0d8);
    font-size: 0.85em;
    line-height: 1.35;
}

.ent-video__publisher {
    font-weight: 700;
    color: var(--cm-ivory, #f4f6f8);
}

.ent-video__disclaimer {
    margin: 0 0 8px;
    font-size: 0.78em;
    font-weight: 500;
    line-height: 1.45;
    color: var(--cm-muted, #c8d0d8);
}

.ent-video__empty,
.ent-video__fallback {
    margin: 0 0 8px;
    line-height: 1.45;
}

.ent-video__official {
    color: var(--cm-ivory, #f4f6f8);
    font-weight: 700;
}

/* 全螢幕播放卡：關閉鈕在最上方。 */
.ent-video__screen {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px));
    background: rgba(8, 10, 14, 0.94);
}

.ent-video__screen-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 12px;
    border: none;
    border-radius: 14px;
    background: rgba(28, 32, 38, 0.92);
}

.ent-video__screen-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ent-video__screen-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.ent-video__screen-publisher,
.ent-video__screen-title {
    margin: 0;
    line-height: 1.35;
}

.ent-video__screen-publisher {
    font-weight: 700;
}

.ent-video__screen-title {
    font-size: inherit;
    font-weight: 700;
}

.ent-video__frame-shell {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 12px;
    overflow: hidden;
    background: var(--cm-night, #121418);
    box-shadow:
        inset 0 0 0 2px #1a120c,
        inset 0 0 20px rgba(0, 0, 0, 0.45);
}

.ent-video__frame {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    background: var(--cm-night, #121418);
}

.ent-video__frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* 很淡的掃描線與弧面反光，不擋操作 */
.ent-video__crt-fx,
.ent-video__crt-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
}

.ent-video__crt-fx {
    opacity: 0.08;
    background: repeating-linear-gradient(
        180deg,
        transparent 0,
        transparent 2px,
        rgba(0, 0, 0, 0.45) 2px,
        rgba(0, 0, 0, 0.45) 3px
    );
    mix-blend-mode: multiply;
}

.ent-video__crt-glow {
    border-radius: inherit;
    background:
        radial-gradient(ellipse 65% 40% at 28% 16%, rgba(255, 255, 255, 0.16), transparent 55%);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.25);
}

/* 現有字級、邊框貼字、半透明深灰、無邊線、至少 44pt。 */
#avatarHome .ent-video button,
#avatarVideoRoot .ent-video__play,
#avatarVideoRoot .ent-video__close,
#avatarVideoRoot .ent-video__fullscreen,
#avatarVideoRoot .ent-tv__power {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--bm-ios-chip-tap, 44px) !important;
    min-width: var(--bm-ios-chip-tap, 44px);
    padding: var(--bm-ios-chip-pad, 4px 10px) !important;
    margin: 0;
    border: none !important;
    border-radius: var(--bm-ios-chip-radius, 10px);
    background: var(--bm-ios-chip-bg, rgba(60, 60, 67, 0.6)) !important;
    -webkit-backdrop-filter: var(--bm-ios-chip-blur, blur(12px));
    backdrop-filter: var(--bm-ios-chip-blur, blur(12px));
    color: var(--bm-ios-chip-ink, #F4F6F8) !important;
    -webkit-text-fill-color: var(--bm-ios-chip-ink, #F4F6F8);
    font: inherit;
    font-size: 14px !important;
    font-weight: 600;
    line-height: 1.2;
    box-shadow: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#avatarVideoRoot .ent-tv__door {
    background: transparent !important;
    border-radius: 0;
    min-width: 0;
    color: transparent !important;
    -webkit-text-fill-color: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#avatarVideoRoot .ent-tv__knob {
    background: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
}
