:root {
    --sidebar-width: 28vw;
    --base-gap: 0.5vw;
    --news-bar-height: 6rem;
    --immersive-top-bar-height: 5.5rem;
    --immersive-top-bar-bg: rgba(0, 0, 0, 0.7);
    --immersive-top-bar-fontsize: 1.8rem;
    --immersive-bottom-bar-height: 5.5rem;
    --immersive-bottom-bar-bg: rgba(0, 0, 0, 0.7);
    --immersive-bottom-bar-fontsize: 1.8rem;
}

html {
    font-size: 1vw;
}

@keyframes gentleJitter {

    0%,
    100% {
        transform: translate(0, 0);
    }

    25% {
        transform: translate(-2px, 2px);
    }

    50% {
        transform: translate(2px, -2px);
    }

    75% {
        transform: translate(-2px, -2px);
    }
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    background-color: #000;
    color: #fff;
    font-family: 'Segoe UI', 'Microsoft JhengHei', 'Helvetica Neue', sans-serif;
    overflow: hidden;
    overflow-x: hidden !important;
    position: relative;
}

/* --- KTV Mode Active Isolation & Viewport Lock --- */
body.ktv-open {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* --- Performance Mode (For TV Boxes) --- */
body.performance-mode {
    text-shadow: none !important;
    box-shadow: none !important;
}

body.performance-mode * {
    box-shadow: none !important;
    text-shadow: none !important;
    backdrop-filter: none !important;
    filter: none !important;
}

body.performance-mode .sidebar,
body.performance-mode .news-ticker,
body.performance-mode .widget {
    will-change: transform;
    transform: translateZ(0);
}

body.performance-mode[data-crt-level]::before,
body.performance-mode[data-crt-level]::after {
    animation: none !important;
}

body.performance-mode .sidebar.jitter-enabled {
    animation: none !important;
}

.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    padding: var(--base-gap);
    box-sizing: border-box;
}

.main-content-area {
    display: flex;
    flex-grow: 1;
    gap: var(--base-gap);
    min-height: 0;
}

.main-video {
    flex-grow: 1;
    background-color: #111;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    min-width: 0;
}

.sidebar {
    flex-shrink: 0;
    flex-basis: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    gap: var(--base-gap);
    /* RESTORED */
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.news-ticker {
    flex-shrink: 0;
    height: var(--news-bar-height);
    margin-top: var(--base-gap);
    background-color: rgba(0, 0, 0, 0.7);
    overflow: hidden;
    white-space: nowrap;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.sidebar,
.news-ticker {
    transition: opacity 0.4s ease;
}

body.fullscreen-mode .sidebar,
body.fullscreen-mode .news-ticker {
    opacity: 0;
    pointer-events: none;
}

body.fullscreen-mode .main-video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    padding: 0;
    z-index: 10;
}

body.fullscreen-mode .dashboard-container {
    padding: 0;
}

body.immersive-mode-enabled.fullscreen-mode .news-ticker {
    display: none !important;
}

#youtube-player {
    width: 100%;
    height: 100%;
    border: none;
    object-fit: contain;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#youtube-player.aspect-auto {
    transform: none !important;
}

#youtube-player.aspect-4-3 {
    transform: scaleX(0.75) !important;
    transform-origin: center center !important;
}

#youtube-player.aspect-16-9 {
    transform: scaleX(1.3333) !important;
    transform-origin: center center !important;
}

#local-player {
    width: 100%;
    height: 100%;
    background-color: #000;
    display: none;
    object-fit: contain;
}

#local-player.aspect-4-3 {
    object-fit: fill !important;
    aspect-ratio: 4 / 3 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: auto !important;
}

#local-player.aspect-16-9 {
    object-fit: fill !important;
    aspect-ratio: 16 / 9 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    margin: auto !important;
}

#local-player.aspect-auto {
    object-fit: contain !important;
    aspect-ratio: auto !important;
    width: 100% !important;
    height: 100% !important;
}

#youtube-player.cover-mode,
#local-player.cover-mode {
    object-fit: cover;
}

.event-shield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    outline: none;
}

.sidebar.jitter-enabled {
    animation: gentleJitter 47s infinite linear;
}

/* RESTORED: Original Widget Padding */
.widget {
    background-color: #000;
    padding: 1.2rem;
    /* RESTORED */
    border-radius: 0.8rem;
    display: flex;
    flex-direction: column;
}

.time-weather-widget {
    text-align: right;
    padding: 1.2rem 1.2rem 0.5rem 1.2rem;
    cursor: pointer;
}

/* Sidebar Divider Line */
.sidebar-divider {
    height: 1px;
    background-color: #333;
    margin: 0 1rem;
    /* RESTORED */
    flex-shrink: 0;
}

/* --- Clock Styles --- */
.clock-style-classic {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
}

.clock-style-classic #clock {
    font-size: 2.8rem;
    font-weight: bold;
    letter-spacing: 0.2rem;
    line-height: 1.1;
}

.clock-style-classic #date {
    font-size: 1.2rem;
}

.clock-style-modern {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-end;
    gap: 1.5rem;
}

.clock-style-modern #clock {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1;
}

.clock-style-modern #date {
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    text-align: left;
    border-left: 2px solid #444;
    padding-left: 1rem;
    line-height: 1.3;
}

.clock-style-modern #date .weekday {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
}

.clock-style-modern #date .full-date {
    color: #aaa;
}

.clock-style-elegant {
    flex-direction: column;
    align-items: flex-end !important;
    justify-content: flex-end;
}

.clock-style-elegant #clock {
    font-size: 4rem;
    font-weight: 100;
    letter-spacing: 0.1rem;
    font-family: 'Segoe UI Light', sans-serif;
    line-height: 0.9;
    margin-bottom: 0.5rem;
}

.clock-style-elegant #date {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #aaa;
    padding-right: 0.2rem;
}

.clock-style-bold {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
}

.clock-style-bold #clock {
    background-color: #222;
    color: #00aaff;
    padding: 0.2rem 1.2rem;
    border-radius: 0.5rem;
    font-size: 3.2rem;
    font-weight: bold;
    letter-spacing: 0.1rem;
    border: 1px solid #333;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.clock-style-bold #date {
    font-size: 1.2rem;
    font-weight: 500;
    color: #ccc;
    padding-right: 0.5rem;
}

.clock-style-neon {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
}

.clock-style-neon #clock {
    font-size: 3.5rem;
    font-family: monospace;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 5px #00aaff;
    letter-spacing: 0.1rem;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.clock-style-neon #date {
    font-size: 1.1rem;
    font-family: monospace;
    color: #b3e5fc;
    text-shadow: 0 0 2px #00aaff;
    letter-spacing: 1px;
}

.clock-style-impact {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
}

.clock-style-impact #clock {
    font-size: 4.2rem;
    font-weight: 900;
    font-style: italic;
    letter-spacing: -0.1rem;
    line-height: 0.9;
    transform: skewX(-5deg);
    margin-right: 0.5rem;
    background: linear-gradient(to bottom, #fff 40%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.2rem;
}

.clock-style-impact #date {
    font-size: 1.3rem;
    font-weight: 700;
    font-style: italic;
    color: #ddd;
    transform: skewX(-5deg);
    margin-right: 0.5rem;
}

.clock-style-bubble {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
}

.clock-style-bubble #clock {
    font-size: 2.8rem;
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 0.2rem 1.5rem;
    border-radius: 50px;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.1;
}

.clock-style-bubble #date {
    font-size: 1.1rem;
    background-color: rgba(0, 0, 0, 0.3);
    padding: 0.3rem 1rem;
    border-radius: 20px;
    color: #ddd;
}

.clock-style-wide {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
}

.clock-style-wide #clock {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.8rem;
    margin-right: -0.8rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    line-height: 1.1;
}

.clock-style-wide #date {
    font-size: 1rem;
    letter-spacing: 0.4rem;
    margin-right: -0.4rem;
    color: #aaa;
    text-transform: uppercase;
    border-top: 1px solid #333;
    padding-top: 0.3rem;
    width: 100%;
    text-align: right;
}


/* Wrapper height */
#time-display-wrapper {
    position: relative;
    min-height: 5.2rem;
    width: 100%;
}

#local-time-container,
#international-clocks-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    transition: opacity 0.3s ease-in-out;
}

#local-time-container {
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
}

#international-clocks-container {
    justify-content: space-around;
}

.international-clock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.international-time {
    font-size: 2.6rem;
    font-weight: bold;
}

.international-date {
    font-size: 1.2rem;
    color: #aaa;
}

.international-city {
    font-size: 1.2rem;
    color: #ccc;
    margin-top: 0.2rem;
}

/* View Toggle Logic */
#international-clocks-container {
    opacity: 0;
    pointer-events: none;
}

.time-weather-widget.international-view #local-time-container {
    opacity: 0;
    pointer-events: none;
}

.time-weather-widget.international-view #international-clocks-container {
    opacity: 1;
    pointer-events: auto;
}

/* --- Weather Area Wrapper (Fix Layout Shift) --- */
#weather-area-wrapper {
    position: relative;
    margin-top: 0.8rem;
    min-height: 5rem;
    /* Fixed height to accommodate 2 lines of weather text (approx 4.5rem) + padding */
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Vertically center content */
}

#current-weather {
    font-size: 1.5rem;
    margin-top: 0;
    /* Margin handled by wrapper */
    line-height: 1.5;
}

/* --- Home Sensors Container --- */
#home-sensors-container {
    display: flex;
    justify-content: space-between;
    padding: 0;
    margin-top: 0;
    width: 100%;
}

.sensor-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 48%;
}

.sensor-label {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 0.2rem;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sensor-value {
    font-size: 1.5rem;
    /* Matched with weather font size */
    font-weight: bold;
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
    line-height: 1.2;
}

.sensor-unit {
    font-size: 1.1rem;
    color: #666;
    font-weight: normal;
}

.sensor-divider {
    width: 1px;
    height: 2.5rem;
    background-color: #333;
    align-self: center;
}

.gust-wind {
    font-weight: 500;
    color: #38bdf8;
}

/* MODIFIED: Stock Widget - Specific Fix for Space above "Last Update" */
.stock-widget {
    flex-grow: 1;
    min-height: 20vh;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    padding-top: 0 !important;
    /* FORCE REMOVE TOP PADDING */
    padding-bottom: 0;
}

.stock-widget.quotes-only {
    cursor: default;
}

.news-content {
    display: inline-block;
    padding-left: 100%;
    animation-name: marquee;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
    will-change: transform;
}

.news-item {
    margin-right: 5rem;
}


@keyframes marquee {
    0% {
        transform: translateX(0%);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* --- Sun Widget Styles (RESTORED to Normal but keeping it tidy) --- */
.sun-widget {
    background-color: #000;
    padding: 0.8rem 1rem;
    /* Moderately compact, better than ultra compact */
    border-radius: 0.8rem;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 0;
    min-height: auto;
    flex-shrink: 0;
}

.sun-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    /* RESTORED gap */
    font-size: 1.3rem;
    /* RESTORED font size */
    color: #ddd;
}

.sun-icon svg {
    width: 2.5rem;
    /* RESTORED icon size */
    height: 2.5rem;
    stroke: #ccc;
}

.sun-time {
    font-weight: bold;
    color: #fff;
    font-size: 1.5rem;
    /* RESTORED font size */
}

.sun-divider {
    width: 1px;
    height: 1.5rem;
    /* RESTORED height */
    background-color: #333;
}

#player-controls {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 70%;
    height: 6rem;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 1rem;
    z-index: 21;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

#player-controls.visible {
    opacity: 1;
    pointer-events: auto;
}

.control-button {
    width: 4rem;
    height: 4rem;
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    outline: 2px solid transparent;
    outline-offset: 3px;
    border-radius: 50%;
    transition: background-color 0.2s, transform 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.control-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.control-button:focus {
    outline-color: #00aaff;
    background-color: rgba(0, 170, 255, 0.3);
}

#play-pause-button .icon {
    width: 2.5rem;
    height: 2.5rem;
    fill: white;
}

#play-pause-button .icon.play .play-path {
    display: block;
}

#play-pause-button .icon.play .pause-path {
    display: none;
}

#play-pause-button .icon.pause .play-path {
    display: none;
}

#play-pause-button .icon.pause .pause-path {
    display: block;
}

.control-button svg {
    width: 2.5rem;
    height: 2.5rem;
    fill: white;
}

#time-display {
    font-size: 1.4rem;
    color: #ddd;
    white-space: nowrap;
}

#progress-bar {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 0.8rem;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 0.8rem;
    outline: none;
    cursor: pointer;
    position: relative;
}

#progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 2rem;
    height: 2rem;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
}

#progress-bar::-moz-range-thumb {
    width: 2rem;
    height: 2rem;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

#settings-button-area {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 12vw;
    height: 12vh;
    z-index: 1999;
}

#settings-button {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    width: 5rem;
    height: 5rem;
    background-color: #333;
    border: 2px solid #555;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2000;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path fill="white" d="m382-120-41-118q-19-8-37-18.5t-34-22.5l-117 49-99-171 99-74q-1-8-1-15.5t1-15.5l-99-74 99-171 117 49q16-12 34-22.5t37-18.5l41-118h196l41 118q19 8 37 18.5t34 22.5l117-49 99 171-99 74q1 8 1 15.5t-1 15.5l99 74-99 171-117-49q-16 12-34-22.5T578-238l-41 118H382Zm98-220q84 0 143-59t59-143q0-84-59-143t-143-59q-84 0-143 59t-59 143q0 84 59 143t143 59Z"/></svg>');
    background-size: 60%;
    background-position: center;
    background-repeat: no-repeat;
}

#settings-button-area:hover #settings-button {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* CRT 濾鏡基礎設定 */
body[data-crt-level]::before {
    content: '';
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: repeating-linear-gradient(rgba(0, 0, 0, 0.65) 0 1.5px, transparent 1.5px 3px);
    pointer-events: none !important;
    opacity: 0;
    z-index: 2147483646 !important;
    transition: opacity 0.3s;
}

body[data-crt-level]::after {
    content: '';
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none !important;
    z-index: 2147483647 !important;
    opacity: 0;
    transition: opacity 0.3s;
}

body[data-crt-level="off"]::before,
body[data-crt-level="off"]::after {
    display: none !important;
    opacity: 0 !important;
}

/* ... (CRT filters skipped for brevity) ... */
body[data-crt-level="low"] {
    filter: contrast(1.05) brightness(0.95) saturate(1.05);
}

body[data-crt-level="low"]::before {
    opacity: 0.35;
}

body[data-crt-level="medium"] {
    filter: contrast(1.1) brightness(0.92) saturate(1.08);
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.2);
}

body[data-crt-level="medium"]::before {
    opacity: 0.55;
}

body[data-crt-level="high"] {
    filter: contrast(1.2) brightness(0.9) saturate(1.2);
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.4);
}

body[data-crt-level="high"]::before {
    opacity: 0.75;
}

body[data-crt-level="high"] .dashboard-container {
    border-radius: 1%;
    transform: perspective(1000px) scale(0.99);
    box-shadow: 0 0 100px rgba(0, 255, 0, 0.05) inset, 0 0 50px rgba(0, 0, 255, 0.05) inset;
}

body[data-crt-level="bw"] {
    filter: grayscale(100%) contrast(1.2) brightness(1.1);
}

body[data-crt-level="bw"]::before {
    opacity: 0.15;
    background: repeating-linear-gradient(rgba(0, 0, 0, 0.3) 0 1px, transparent 1px 3px);
}

body[data-crt-level="green"] {
    filter: sepia(100%) hue-rotate(90deg) saturate(350%) contrast(1.1) brightness(0.9);
}

body[data-crt-level="green"]::before {
    opacity: 0.2;
}

body[data-crt-level="green"]::after {
    opacity: 0.2;
    background: radial-gradient(circle, rgba(0, 255, 0, 0) 60%, rgba(0, 50, 0, 0.6) 100%);
}

body[data-crt-level="amber"] {
    filter: sepia(100%) hue-rotate(-10deg) saturate(400%) contrast(1.1) brightness(0.95);
}

body[data-crt-level="amber"]::before {
    opacity: 0.15;
}

body[data-crt-level="amber"]::after {
    opacity: 0.15;
    background: radial-gradient(circle, rgba(255, 170, 0, 0) 60%, rgba(100, 50, 0, 0.6) 100%);
}

body[data-crt-level="blue_mono"] {
    filter: sepia(100%) hue-rotate(190deg) saturate(300%) contrast(1.2);
}

body[data-crt-level="blue_mono"]::before {
    opacity: 0.15;
}

body[data-crt-level="sepia"] {
    filter: sepia(0.7) contrast(1.1) brightness(0.9);
}

body[data-crt-level="sepia"]::before {
    opacity: 0.1;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect width="100%" height="100%" filter="url(%23noise)" opacity="0.1"/><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="1" stitchTiles="stitch"/></filter></svg>');
}

body[data-crt-level="vhs"] {
    filter: contrast(1.3) saturate(1.2) blur(0.5px) hue-rotate(-5deg);
}

body[data-crt-level="vhs"]::before {
    opacity: 0.1;
    background: repeating-linear-gradient(transparent 0, transparent 2px, rgba(255, 0, 0, 0.1) 3px, rgba(0, 255, 255, 0.1) 4px);
    animation: gentleJitter 0.2s infinite;
}

body[data-crt-level="cyber"] {
    filter: contrast(1.4) saturate(1.5) hue-rotate(180deg) invert(0.1);
}

body[data-crt-level="cyber"]::after {
    opacity: 0.2;
    background: linear-gradient(45deg, rgba(255, 0, 255, 0.2), rgba(0, 255, 255, 0.2));
}

body[data-crt-level="night_vision"] {
    filter: grayscale(100%) sepia(100%) hue-rotate(80deg) saturate(200%) brightness(1.2) contrast(1.5);
}

body[data-crt-level="night_vision"]::before {
    opacity: 0.3;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="1.5" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.5"/></svg>');
}

body[data-crt-level="night_vision"]::after {
    opacity: 0.6;
    background: radial-gradient(circle, transparent 40%, black 120%);
}

body[data-crt-level="dream"] {
    filter: blur(1px) brightness(1.1) contrast(0.9) saturate(1.3);
}

body[data-crt-level="dream"]::after {
    opacity: 0.3;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, rgba(255, 200, 200, 0.1) 100%);
}

body[data-crt-level="invert"] {
    filter: invert(100%) hue-rotate(180deg);
}

body[data-crt-level="high_contrast"] {
    filter: contrast(1.8) grayscale(100%);
}

body[data-crt-level="warm"] {
    filter: sepia(0.3) hue-rotate(-10deg) saturate(1.1);
}

body[data-crt-level="cool"] {
    filter: sepia(0.3) hue-rotate(170deg) saturate(0.9);
}

body[data-crt-level="technicolor"] {
    filter: contrast(1.3) saturate(1.8) sepia(0.1);
}

body[data-crt-level="cinematic"] {
    filter: contrast(1.1) saturate(0.8) brightness(0.9);
}

body[data-crt-level="cinematic"]::after {
    opacity: 1;
    background: linear-gradient(to bottom, black 0%, transparent 10%, transparent 90%, black 100%);
}

body[data-crt-level="matrix"] {
    filter: contrast(1.5) brightness(0.8) grayscale(100%) sepia(100%) hue-rotate(90deg) saturate(500%);
}

body[data-crt-level="gameboy"] {
    filter: contrast(1.2) brightness(1.1) grayscale(100%) sepia(100%) hue-rotate(60deg) saturate(200%);
}

body[data-crt-level="gameboy"]::before {
    opacity: 0.15;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.2) 3px);
}

body[data-crt-level="terminator"] {
    filter: contrast(1.4) grayscale(100%) sepia(100%) hue-rotate(-50deg) saturate(600%);
}

body[data-crt-level="glitch"] {
    filter: contrast(1.2) saturate(1.1);
}

body[data-crt-level="glitch"]::before {
    opacity: 0.2;
    background: repeating-linear-gradient(90deg, rgba(255, 0, 0, 0.1), transparent 2px, rgba(0, 255, 255, 0.1) 4px);
    animation: gentleJitter 0.1s infinite;
}

body[data-crt-level="glitch"]::after {
    opacity: 0.1;
    background: linear-gradient(transparent 50%, rgba(0, 0, 0, 0.5) 50%);
    background-size: 100% 4px;
}

body[data-crt-level="holodeck"] {
    filter: sepia(1) hue-rotate(190deg) saturate(250%) brightness(1.1) contrast(0.9);
}

body[data-crt-level="holodeck"]::before {
    opacity: 0.3;
    background: repeating-linear-gradient(0deg, rgba(0, 255, 255, 0.1) 0px, transparent 1px, transparent 10px);
}

body[data-crt-level="lcd_grid"] {
    filter: contrast(1.1) brightness(1.1);
}

body[data-crt-level="lcd_grid"]::before {
    opacity: 0.4;
    background: radial-gradient(circle, transparent 20%, black 130%), repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.1) 0, transparent 1px, transparent 3px), repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0, transparent 1px, transparent 3px);
    background-size: 100% 100%, 4px 4px, 4px 4px;
}

body[data-crt-level="bad_signal"] {
    filter: blur(0.5px) grayscale(0.5) contrast(1.5) brightness(0.8);
}

body[data-crt-level="bad_signal"]::before {
    opacity: 0.4;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.5"/></svg>');
    animation: gentleJitter 0.05s infinite;
}

body[data-crt-level="radioactive"] {
    filter: grayscale(100%) sepia(100%) hue-rotate(60deg) saturate(500%) contrast(1.2);
}

body[data-crt-level="radioactive"]::after {
    opacity: 0.3;
    background: radial-gradient(circle, rgba(100, 255, 0, 0.2), transparent 80%);
}

body[data-crt-level="underwater"] {
    filter: sepia(0.8) hue-rotate(170deg) saturate(200%) blur(1px);
}

body[data-crt-level="underwater"]::before {
    opacity: 0.2;
    background: radial-gradient(circle at 50% 0%, rgba(0, 100, 255, 0.4), transparent);
}

body[data-crt-level="heatmap"] {
    filter: invert(1) hue-rotate(180deg) contrast(1.5) saturate(2);
}

body[data-crt-level="xray"] {
    filter: grayscale(100%) invert(1) contrast(1.2);
}

body[data-crt-level="noir"] {
    filter: grayscale(100%) contrast(1.8) brightness(0.8);
}

body[data-crt-level="noir"]::after {
    opacity: 0.5;
    background: radial-gradient(circle, transparent 50%, black 100%);
}

body[data-crt-level="pop_art"] {
    filter: saturate(3) contrast(1.5) hue-rotate(45deg);
}

body[data-crt-level="vignette_heavy"] {
    filter: contrast(1.1);
}

body[data-crt-level="vignette_heavy"]::after {
    opacity: 0.8;
    background: radial-gradient(circle, transparent 30%, black 110%);
}

body[data-crt-level="scanlines_pure"] {
    filter: none;
}

body[data-crt-level="scanlines_pure"]::before {
    opacity: 0.75;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.85) 0px, rgba(0, 0, 0, 0.85) 1.5px, transparent 1.5px, transparent 3px);
}

/* --- 5 CRT 濾鏡補全 --- */
/* 0. 4K 超微細掃描線 (4K TV Ultra-Subtle Scanlines - 比輕度掃描線更低，專為 4K 超高解析度電視調校) */
body[data-crt-level="scanlines_4k"] {
    filter: contrast(1.02) brightness(1.01);
}
body[data-crt-level="scanlines_4k"]::before {
    opacity: 0.22;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.55) 0px, rgba(0, 0, 0, 0.55) 1px, transparent 1px, transparent 2.5px);
}

/* 1. 輕度掃描線 */
body[data-crt-level="scanlines_light"] {
    filter: contrast(1.05) brightness(1.02);
}
body[data-crt-level="scanlines_light"]::before {
    opacity: 0.52;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.72) 0px, rgba(0, 0, 0, 0.72) 1px, transparent 1px, transparent 3px);
}

/* 2. 重度掃描線 */
body[data-crt-level="scanlines_dark"] {
    filter: contrast(1.18) brightness(0.92) saturate(1.1);
}
body[data-crt-level="scanlines_dark"]::before {
    opacity: 0.85;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.95) 0px, rgba(0, 0, 0, 0.8) 1.5px, transparent 1.5px, transparent 3px);
}

/* 3. 交錯掃描 (480i Interlaced) */
body[data-crt-level="interlaced"] {
    filter: contrast(1.1) brightness(0.96);
}
body[data-crt-level="interlaced"]::before {
    opacity: 0.65;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.85) 0px, rgba(0, 0, 0, 0.85) 2px, transparent 2px, transparent 4px);
}
body[data-crt-level="interlaced"]::after {
    opacity: 0.25;
    background: radial-gradient(circle at center, transparent 60%, rgba(0, 0, 0, 0.5) 100%);
}

/* 4. 特麗霓虹 (Sony Trinitron) */
body[data-crt-level="trinitron"] {
    filter: contrast(1.15) brightness(1.05) saturate(1.25);
}
body[data-crt-level="trinitron"]::before {
    opacity: 0.5;
    background: repeating-linear-gradient(90deg, rgba(255, 0, 0, 0.12) 0px, rgba(0, 255, 0, 0.12) 1px, rgba(0, 0, 255, 0.12) 2px, transparent 3px);
}
body[data-crt-level="trinitron"]::after {
    opacity: 0.45;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.65) 0px, transparent 1px, transparent 2.5px);
}

/* 5. 陰影遮罩 (Shadow Mask CRT) */
body[data-crt-level="shadow_mask"] {
    filter: contrast(1.12) brightness(0.95) saturate(1.1);
}
body[data-crt-level="shadow_mask"]::before {
    opacity: 0.5;
    background: radial-gradient(rgba(0, 0, 0, 0.75) 15%, transparent 16%) 0 0, radial-gradient(rgba(0, 0, 0, 0.75) 15%, transparent 16%) 2px 2px;
    background-size: 4px 4px;
}
body[data-crt-level="shadow_mask"]::after {
    opacity: 0.5;
    background: radial-gradient(circle at center, transparent 65%, rgba(0, 0, 0, 0.65) 100%);
}

body[data-crt-level="rgb_split"] {
    text-shadow: -2px 0 red, 2px 0 blue;
}

body[data-crt-level="rgb_split"] .main-video {
    filter: drop-shadow(-3px 0 red) drop-shadow(3px 0 blue);
}

body[data-crt-level="soft_glow"] {
    filter: brightness(1.2) contrast(0.9) blur(0.5px) saturate(1.1);
}

body[data-crt-level="acid_trip"] {
    filter: hue-rotate(90deg) saturate(3) contrast(1.5) invert(0.1);
}

body[data-crt-level="red_alert"] {
    filter: sepia(1) hue-rotate(-50deg) saturate(4) contrast(1.2) brightness(0.8);
}

body[data-crt-level="red_alert"]::before {
    opacity: 0.2;
    background: repeating-linear-gradient(45deg, rgba(255, 0, 0, 0.1) 0, transparent 10px);
}

body[data-crt-level="golden_hour"] {
    filter: sepia(0.5) hue-rotate(-10deg) saturate(1.5) contrast(1.1) brightness(1.1);
}

body[data-crt-level="frost"] {
    filter: sepia(0.4) hue-rotate(180deg) saturate(0.8) brightness(1.2) contrast(0.9);
}

body[data-crt-level="frost"]::after {
    opacity: 0.3;
    background: radial-gradient(circle, white 10%, transparent 90%);
}

body[data-crt-level="comic_book"] {
    filter: contrast(1.8) saturate(1.5) brightness(1.1);
}

body[data-crt-level="comic_book"]::before {
    opacity: 0.3;
    background-image: radial-gradient(#000 15%, transparent 16%);
    background-size: 4px 4px;
}

body[data-crt-level="lofi_chill"] {
    filter: contrast(0.8) brightness(1.1) sepia(0.2) saturate(0.8);
}

body[data-crt-level="vaporwave"] {
    filter: contrast(1.1) brightness(1.1);
}

body[data-crt-level="vaporwave"]::after {
    opacity: 0.3;
    background: linear-gradient(to bottom, rgba(0, 255, 255, 0.2), rgba(255, 0, 255, 0.2));
    pointer-events: none;
}

body[data-crt-level="predator"] {
    filter: invert(1) hue-rotate(90deg) contrast(2);
}

body[data-crt-level="sin_city"] {
    filter: contrast(1.8) grayscale(100%);
}

body[data-crt-level="pencil"] {
    filter: grayscale(100%) contrast(3) brightness(1.5);
}

body[data-crt-level="blueprint"] {
    filter: grayscale(100%) sepia(1) hue-rotate(180deg) saturate(3) contrast(1.2) invert(1);
}

body[data-crt-level="blueprint"]::before {
    opacity: 0.2;
    background: linear-gradient(white 1px, transparent 1px), linear-gradient(90deg, white 1px, transparent 1px);
    background-size: 20px 20px;
}

body[data-crt-level="newspaper"] {
    filter: grayscale(100%) contrast(1.5) brightness(0.9) sepia(0.3);
}

body[data-crt-level="newspaper"]::before {
    opacity: 0.2;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.5" numOctaves="1" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.5"/></svg>');
}

body[data-crt-level="faded"] {
    filter: grayscale(0.6) contrast(0.8) brightness(1.2) blur(0.5px);
}

body[data-crt-level="1980s"] {
    filter: contrast(1.1) saturate(1.3) sepia(0.2) hue-rotate(-10deg);
}

body[data-crt-level="1990s"] {
    filter: contrast(0.9) saturate(0.8) brightness(1.1);
}

body[data-crt-level="bleach_bypass"] {
    filter: contrast(1.5) saturate(0.5) brightness(1.1);
}

body[data-crt-level="kodachrome"] {
    filter: contrast(1.4) saturate(1.4) sepia(0.2) hue-rotate(-10deg);
}

body[data-crt-level="cctv"] {
    filter: grayscale(0.8) contrast(1.2) brightness(1.1) blur(0.4px);
}

body[data-crt-level="cctv"]::before {
    opacity: 0.2;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.2) 0px, transparent 1px, transparent 1px);
}

body[data-crt-level="neon_noir"] {
    filter: contrast(1.5) saturate(1.8) hue-rotate(190deg) brightness(0.9);
}

body[data-crt-level="neon_noir"]::after {
    opacity: 0.4;
    background: linear-gradient(to bottom, rgba(255, 0, 255, 0.1), rgba(0, 0, 255, 0.1));
}

body[data-crt-level="phosphor"] {
    filter: contrast(1.2) brightness(1.1) drop-shadow(2px 0 0 rgba(0, 255, 0, 0.3));
}

body[data-crt-level="phosphor"]::before {
    opacity: 0.1;
    background: repeating-linear-gradient(0deg, rgba(0, 255, 0, 0.1), transparent 2px);
}

/* 複合視訊 Composite / NTSC / PAL (模擬類比訊號色度延遲、色邊滲透、彩虹斑與相位干擾) */
body[data-crt-level="composite_ntsc"] {
    filter: contrast(1.08) saturate(1.22) brightness(0.98) drop-shadow(1.8px 0 0 rgba(235, 60, 0, 0.35)) drop-shadow(-1.8px 0 0 rgba(0, 160, 255, 0.35)) blur(0.28px);
}
body[data-crt-level="composite_ntsc"]::before {
    opacity: 0.32;
    background: repeating-linear-gradient(90deg, rgba(255, 120, 0, 0.08) 0px, rgba(0, 180, 255, 0.08) 1.5px, transparent 3px), repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.6) 0px, transparent 1px, transparent 2.5px);
}
body[data-crt-level="composite_ntsc"]::after {
    opacity: 0.35;
    background: radial-gradient(circle at center, transparent 70%, rgba(10, 5, 0, 0.55) 100%);
}

/* 磷光餘輝殘影 (Ghosting / Afterglow / Phosphor Persistence - 模擬綠磷光/長餘輝衰減曳尾與夢幻輝光) */
body[data-crt-level="phosphor_ghosting"] {
    filter: contrast(1.14) brightness(1.1) saturate(1.2) drop-shadow(3px 0 4px rgba(0, 255, 136, 0.4)) drop-shadow(7px 0 9px rgba(0, 255, 136, 0.22)) drop-shadow(-2px 0 3px rgba(0, 220, 255, 0.2));
}
body[data-crt-level="phosphor_ghosting"]::before {
    opacity: 0.18;
    background: repeating-linear-gradient(0deg, rgba(0, 255, 136, 0.15) 0px, transparent 1px, transparent 2.5px);
}
body[data-crt-level="phosphor_ghosting"]::after {
    opacity: 0.28;
    background: radial-gradient(circle at center, rgba(0, 255, 136, 0.12) 0%, rgba(0, 180, 255, 0.04) 50%, transparent 80%);
}

/* --- UI Components --- */

#channel-display {
    position: fixed;
    top: 3vh;
    right: 2vw;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 1rem 2.5rem;
    font-size: 2.5rem;
    font-weight: bold;
    border-radius: 1rem;
    border: 2px solid #555;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

#channel-display.show {
    opacity: 1;
}

/* 當設定為「完全關閉」或「自動合併至 CRT OSD」時，強制徹底隱藏右上角黑底頻道提示，杜絕任何溢出或殘留 */
body.hide-top-right-osd #channel-display {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

#channel-switcher-area {
    position: fixed;
    left: 0;
    top: 0;
    width: 4vw;
    height: 100%;
    z-index: 2500;
}

#channel-switcher-menu {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) translateX(-100%);
    width: 25vw;
    background-color: rgba(0, 0, 0, 0.9);
    border: 1px solid #444;
    border-left: none;
    border-radius: 0 1rem 1rem 0;
    padding: 1rem 0;
    transition: transform 0.4s ease;
}

#channel-switcher-menu.is-open,
#channel-switcher-area.menu-visible #channel-switcher-menu {
    transform: translateY(-50%) translateX(0);
}

#channel-switcher-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.2rem 0.75rem 1.2rem;
    border-bottom: 1px solid #333;
    margin-bottom: 0.35rem;
}

.channel-switcher-title-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.channel-switcher-title {
    font-size: 1.15rem;
    font-weight: bold;
    color: #00aaff;
    letter-spacing: 0.5px;
    user-select: none;
}

.channel-switcher-stats-icon,
#open-stats-btn {
    display: inline-block;
    cursor: pointer;
    color: #64748b;
    opacity: 0.35;
    margin: 0;
    padding: 0;
    border: none !important;
    background: transparent !important;
    background-color: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    vertical-align: middle;
    transition: opacity 0.2s ease, color 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
}

.channel-switcher-stats-icon:hover,
#open-stats-btn:hover {
    opacity: 0.9;
    color: #38bdf8;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.channel-switcher-stats-icon:active,
#open-stats-btn:active {
    opacity: 1;
}

#channel-switcher-close-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid #666;
    color: #eee;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    outline: none;
    user-select: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

#channel-switcher-close-btn:hover,
#channel-switcher-close-btn:focus {
    background: #ff4444;
    border-color: #ff4444;
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.6);
}

#channel-switcher-close-btn:active {
    transform: scale(0.95);
}

#channel-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 80vh;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* RESTORED: Original Padding */
#channel-list li {
    padding: 0.4rem 1.2rem;
    font-size: 1.15rem;
    cursor: pointer;
    border-bottom: 1px solid #333;
}

#channel-list li.channel-nav-row {
    padding: 0 !important;
    background: transparent !important;
}

#channel-list li.channel-nav-row:hover {
    background: transparent !important;
}

#channel-list li:last-child {
    border-bottom: none;
}

#channel-list li:hover {
    background-color: #333;
}

/* TV Remote Focus State for Channel Switcher */
.channel-nav-item {
    outline: none !important;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, filter 0.15s ease;
}

.channel-nav-item:focus,
.channel-nav-item.tv-focused {
    outline: 2px solid #00aaff !important;
    outline-offset: -2px;
    box-shadow: inset 0 0 14px rgba(0, 170, 255, 0.7), 0 0 12px rgba(0, 170, 255, 0.6) !important;
    z-index: 10;
    filter: brightness(1.35);
}

#channel-list li.channel-nav-item:focus,
#channel-list li.channel-nav-item.tv-focused {
    outline: 2px solid #00aaff !important;
    outline-offset: -2px;
    background-color: #223344 !important;
    color: #fff !important;
    box-shadow: inset 0 0 12px rgba(0, 170, 255, 0.6) !important;
}

/* Specific Focus & Hover Glow for Row 1: 📺 IPTV台 | 🎤 KTV */
#channel-iptv-item:focus,
#channel-iptv-item.tv-focused {
    outline: 2px solid #00aaff !important;
    box-shadow: inset 0 0 14px rgba(0, 170, 255, 0.8), 0 0 12px rgba(0, 170, 255, 0.7) !important;
    background-color: #1a2744 !important;
}

#channel-ktv-item:focus,
#channel-ktv-item.tv-focused {
    outline: 2px solid #ff007f !important;
    box-shadow: inset 0 0 14px rgba(255, 0, 127, 0.8), 0 0 12px rgba(255, 0, 127, 0.7) !important;
    background-color: #55164d !important;
    color: #fff !important;
}

/* Specific Focus & Hover Glow for Row 2: 💰 財經 | 📈 股票 */
#open-finance-zone-btn:focus,
#open-finance-zone-btn.tv-focused {
    outline: 2px solid #00e5ff !important;
    box-shadow: inset 0 0 14px rgba(0, 229, 255, 0.8), 0 0 12px rgba(0, 229, 255, 0.7) !important;
    background-color: #2b3b55 !important;
}

#open-stock-analysis-btn:focus,
#open-stock-analysis-btn.tv-focused {
    outline: 2px solid #ffd700 !important;
    box-shadow: inset 0 0 14px rgba(255, 215, 0, 0.8), 0 0 12px rgba(255, 215, 0, 0.7) !important;
    background-color: #3b3a16 !important;
    color: #fff !important;
}

/* Specific Focus & Hover Glow for Row 3: 🎬 動畫專區 | 🎭 劇集專區 */
#open-anime-zone-btn {
    text-align: center;
    background-color: #2a0042;
    font-weight: bold;
}

#open-anime-zone-btn:hover {
    background-color: #4c007a;
}

#open-anime-zone-btn:focus,
#open-anime-zone-btn.tv-focused {
    outline: 2px solid #d946ef !important;
    box-shadow: inset 0 0 14px rgba(217, 70, 239, 0.8), 0 0 12px rgba(217, 70, 239, 0.7) !important;
    background-color: #4c007a !important;
}

#open-drama-zone-btn {
    text-align: center;
    background-color: #00421c;
    font-weight: bold;
}

#open-drama-zone-btn:hover {
    background-color: #007a32;
}

#open-drama-zone-btn:focus,
#open-drama-zone-btn.tv-focused {
    outline: 2px solid #00e676 !important;
    box-shadow: inset 0 0 14px rgba(0, 230, 118, 0.8), 0 0 12px rgba(0, 230, 118, 0.7) !important;
    background-color: #007a32 !important;
    color: #fff !important;
}

/* Specific Focus & Hover Glow for Row 4: 📁 本地專區 | 🌐 網播專區 */
#open-local-zone-btn {
    text-align: center;
    background-color: #4a2c00;
    font-weight: bold;
}

#open-local-zone-btn:hover {
    background-color: #8a5300;
}

#open-local-zone-btn:focus,
#open-local-zone-btn.tv-focused {
    outline: 2px solid #f59e0b !important;
    box-shadow: inset 0 0 14px rgba(245, 158, 11, 0.8), 0 0 12px rgba(245, 158, 11, 0.7) !important;
    background-color: #8a5300 !important;
}

#open-lan-zone-btn {
    text-align: center;
    background-color: #003c4a;
    font-weight: bold;
}

#open-lan-zone-btn:hover {
    background-color: #006880;
}

#open-lan-zone-btn:focus,
#open-lan-zone-btn.tv-focused {
    outline: 2px solid #00e5ff !important;
    box-shadow: inset 0 0 14px rgba(0, 229, 255, 0.8), 0 0 12px rgba(0, 229, 255, 0.7) !important;
    background-color: #006880 !important;
    color: #fff !important;
}

/* Specific Focus & Hover Glow for Row 5: 📻 AI電台 | 🎙️ 真人電台 */
#open-ai-radio-zone-btn:focus,
#open-ai-radio-zone-btn.tv-focused {
    outline: 2px solid #60a5fa !important;
    box-shadow: inset 0 0 14px rgba(96, 165, 250, 0.8), 0 0 12px rgba(96, 165, 250, 0.7) !important;
    background-color: #1a365d !important;
}

#open-live-radio-zone-btn:focus,
#open-live-radio-zone-btn.tv-focused {
    outline: 2px solid #38bdf8 !important;
    box-shadow: inset 0 0 14px rgba(56, 189, 248, 0.8), 0 0 12px rgba(56, 189, 248, 0.7) !important;
    background-color: #12435c !important;
    color: #fff !important;
}

/* Specific Focus & Hover Glow for Row 6: 📺 無縫電視台 | 🔖 動漫書籤 */
#open-seamless-tv-btn:focus,
#open-seamless-tv-btn.tv-focused {
    outline: 2px solid #38bdf8 !important;
    box-shadow: inset 0 0 14px rgba(56, 189, 248, 0.8), 0 0 12px rgba(56, 189, 248, 0.7) !important;
    background-color: #164e63 !important;
}

#open-xgcartoon-zone-btn:focus,
#open-xgcartoon-zone-btn.tv-focused {
    outline: 2px solid #ff5252 !important;
    box-shadow: inset 0 0 14px rgba(255, 82, 82, 0.8), 0 0 12px rgba(255, 82, 82, 0.7) !important;
    background-color: #4a1e1e !important;
    color: #fff !important;
}

/* Universal TV D-Pad Focus for Modal Windows (AI Radio, Live Radio, XGCartoon, Anime, etc.) */
.tv-modal-focused,
.tv-modal-focused:focus,
button.tv-modal-focused,
.radio-tab-btn.tv-modal-focused,
.live-radio-card.tv-modal-focused,
.live-radio-cat-tab.tv-modal-focused,
#radio-channel-list li.tv-modal-focused,
#xgcartoon-channel-list li.tv-modal-focused,
#anime-channel-list li.tv-modal-focused,
#drama-channel-list li.tv-modal-focused,
#local-channel-list li.tv-modal-focused,
#lan-channel-list li.tv-modal-focused,
.zone-close-button.tv-modal-focused {
    outline: 3px solid #00e5ff !important;
    outline-offset: 1px !important;
    box-shadow: 0 0 18px rgba(0, 229, 255, 0.85), inset 0 0 10px rgba(0, 229, 255, 0.45) !important;
    background-color: rgba(0, 229, 255, 0.18) !important;
    transform: scale(1.02) !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease, outline 0.15s ease !important;
    z-index: 25 !important;
}

#rss-feed-channel {
    background-color: #3b0000;
    font-weight: bold;
}

#rss-feed-channel:hover {
    background-color: #6d0000;
}

#channel-iptv-item {
    background: linear-gradient(135deg, #0e3b43 0%, #0d2836 100%);
    font-weight: bold;
    cursor: pointer;
    border-left: none;
}

#channel-iptv-item:hover {
    background: linear-gradient(135deg, #175d69 0%, #153f54 100%);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}



.stock-page {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 0 1rem;
    /* RESTORED */
    box-sizing: border-box;
}

.stock-page.active {
    display: block;
}

.stock-page::-webkit-scrollbar {
    display: none;
}

.stock-page {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* MODIFIED: Compact Last Update Time */
.last-update-time {
    text-align: center;
    color: grey;
    font-size: 1rem;
    /* RESTORED */
    padding: 0.2rem 0;
    /* RESTORED */
    border-bottom: 1px solid #222;
    margin-bottom: 0.4rem;
    /* RESTORED */
    /* NEW: Adjust top margin to be tight against the divider */
    margin-top: 0.5rem;
}

.stock-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    /* RESTORED */
    font-size: 1.2rem;
    /* RESTORED */
    border-bottom: 1px solid #222;
}

.stock-item:last-child {
    border-bottom: none;
}

.stock-symbol {
    font-weight: bold;
}

.stock-price {
    text-align: right;
}

.positive {
    color: #39FF14;
}

.negative {
    color: #ff0000;
}

.portfolio-header {
    font-size: 2.2rem;
    /* RESTORED */
    font-weight: bold;
    text-align: center;
    padding: 0.5rem 0;
    /* RESTORED */
    margin-bottom: 0.6rem;
    /* RESTORED */
    border-bottom: 1px solid #444;
}

.portfolio-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 1.6rem;
    /* RESTORED */
    padding: 0.5rem 0;
    /* RESTORED */
    border-bottom: 1px solid #222;
}

.portfolio-row:last-child {
    border-bottom: none;
}

.portfolio-label {
    color: #aaa;
}

.portfolio-value {
    font-weight: bold;
    text-align: right;
}

.portfolio-value .percent {
    font-size: 1.3rem;
    margin-left: 0.8rem;
    color: #ccc;
}

.fj-news-container {
    padding: 0 0.5rem;
}

.fj-news-item {
    display: flex;
    padding: 0.5rem 0;
    font-size: 1.1rem;
    border-bottom: 1px solid #222;
    line-height: 1.4;
}

.fj-news-item:last-child {
    border-bottom: none;
}

.fj-news-time {
    flex-shrink: 0;
    margin-right: 1rem;
    font-weight: bold;
    color: #aaa;
}

.fj-scroll-button {
    position: absolute;
    right: 0.8rem;
    width: 2.2rem;
    height: 2.2rem;
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, background-color 0.2s ease, transform 0.2s ease;
    backdrop-filter: blur(4px);
}

.stock-widget:hover .fj-scroll-button.visible,
.stock-widget.show-scroll .fj-scroll-button.visible {
    opacity: 0.7;
    pointer-events: auto;
}

.fj-scroll-button:hover {
    background-color: rgba(0, 170, 255, 0.7);
    border-color: #00aaff;
    opacity: 1 !important;
    transform: scale(1.1);
}

.fj-scroll-button svg {
    width: 1.2rem;
    height: 1.2rem;
    fill: #ffffff;
}

#fj-scroll-up {
    top: 3.2rem;
}

#fj-scroll-down {
    bottom: 1.2rem;
}

.daily-forecast-item,
.hourly-forecast-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 1.1rem;
    width: 30%;
}

.daily-forecast-day,
.hourly-forecast-time {
    font-weight: bold;
    color: #ccc;
}

.daily-forecast-icon,
.hourly-forecast-icon {
    font-size: 1.8rem;
    margin: 0.2rem 0;
}

.daily-forecast-temp,
.hourly-forecast-temp {
    font-size: 1rem;
}

/* Weather Forecast View Modes (Hourly, Daily, Radar) */
#weather-forecast-hourly,
#weather-forecast-daily {
    display: none;
}

#weather-forecast-container.hourly-view #weather-forecast-hourly {
    display: flex;
    justify-content: space-between;
}

#weather-forecast-container.daily-view #weather-forecast-daily {
    display: flex;
    justify-content: space-between;
}

#weather-forecast-container {
    position: relative;
    margin-top: 0.8rem;
    border-top: 1px solid #444;
    padding-top: 0.8rem;
}

/* Radar Container & Controls (Absolute Overlay over weather-forecast-container) */
#weather-forecast-radar {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0.8rem;
    overflow: hidden;
    background-color: #111;
    border: 1px solid #333;
    z-index: 10;
}

body.radar-mode-active #weather-forecast-radar {
    display: block;
}

/* Radar Mode Active: force daily forecast to render invisibly so container keeps full height */
body.radar-mode-active #weather-forecast-daily {
    display: flex !important;
    justify-content: space-between;
    visibility: hidden !important;
}

body.radar-mode-active #weather-forecast-hourly {
    display: none !important;
}

body.radar-mode-active .sun-widget-divider,
body.radar-mode-active #sun-widget {
    visibility: hidden !important;
}

#radar-map {
    width: 100%;
    height: 100%;
    background-color: #0b0e14;
}

#radar-map .leaflet-control-container {
    display: none !important;
}

#radar-controls {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    padding: 2px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 1001;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.radar-btn {
    background: none;
    border: none;
    color: #00aaff;
    font-weight: bold;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.radar-btn:hover {
    color: #fff;
    background: rgba(0, 170, 255, 0.3);
}

.radar-time {
    color: #ffcc00;
    font-size: 0.85rem;
    font-weight: bold;
    font-family: 'Consolas', 'Monaco', monospace;
    letter-spacing: 1px;
}

/* Weather Forecast Bus Station View (並排兩站，嚴禁換行，大字清晰排版) */
#weather-forecast-bus {
    display: none;
    position: absolute;
    top: 0.5rem;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0.8rem;
    overflow: hidden;
    background: rgba(8, 16, 26, 0.96);
    border: 1.5px solid rgba(105, 240, 174, 0.45);
    box-shadow: inset 0 0 25px rgba(0, 229, 255, 0.08);
    z-index: 10;
    box-sizing: border-box;
    padding: 2px 4px;
}

#weather-forecast-container.bus-view #weather-forecast-bus {
    display: flex;
    flex-direction: column;
}

#weather-forecast-container.bus-view #weather-forecast-daily {
    display: flex !important;
    justify-content: space-between;
    visibility: hidden !important;
}

#weather-forecast-container.bus-view #weather-forecast-hourly {
    display: none !important;
}

#weather-forecast-container.bus-view .sun-widget-divider,
#weather-forecast-container.bus-view #sun-widget {
    visibility: hidden !important;
}

.wf-bus-columns {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    width: 100%;
    height: 100%;
    gap: 0.45rem;
    align-items: stretch;
    box-sizing: border-box;
    overflow: hidden;
}

.wf-bus-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.wf-bus-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    white-space: nowrap !important;
    overflow: hidden;
    padding-bottom: 1px;
    margin-bottom: 2px;
    border-bottom: 1.5px solid rgba(105, 240, 174, 0.45);
    flex-shrink: 0;
}

.wf-bus-stop-key {
    color: #69f0ae;
    font-weight: 900;
    font-size: 0.88rem;
    font-family: Consolas, 'Segoe UI', monospace;
    letter-spacing: 0.5px;
    white-space: nowrap !important;
    text-shadow: 0 0 6px rgba(105, 240, 174, 0.3);
    line-height: 1.15;
}

.wf-bus-dist {
    color: #80deea;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: Consolas, 'Segoe UI', monospace;
    white-space: nowrap !important;
    line-height: 1.15;
}

.wf-bus-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-height: 0;
    justify-content: flex-start;
    overflow: hidden;
}

.wf-bus-item {
    display: flex;
    flex-direction: column;
    justify-content: center;
    white-space: nowrap !important;
    overflow: hidden;
    padding: 1px 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
    flex: 0 0 calc((100% - 4px) / 3);
    height: calc((100% - 4px) / 3);
    max-height: calc((100% - 4px) / 3);
    min-height: 28px !important;
    transition: background 0.2s;
}

.wf-bus-item:hover {
    background: rgba(255, 255, 255, 0.12);
}

.wf-bus-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    line-height: 1.1;
}

.wf-bus-rt {
    font-family: Consolas, 'Segoe UI', monospace;
    font-weight: 900;
    font-size: 0.78rem;
    color: #ffffff;
    flex-shrink: 0;
    white-space: nowrap !important;
    padding: 1px 5px;
    border-radius: 3px;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.25);
    line-height: 1.1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.wf-bus-rt.target {
    outline: 1.5px solid #ffd54f !important;
    box-shadow: 0 0 6px rgba(255, 213, 79, 0.6);
}

.wf-bus-time-group {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    white-space: nowrap !important;
    line-height: 1.1;
}

.wf-bus-sched-time {
    font-family: Consolas, monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: #b0bec5;
    line-height: 1.1;
}

.wf-bus-eta {
    font-family: Consolas, monospace;
    font-weight: 900;
    font-size: 0.78rem;
    color: #69f0ae;
    flex-shrink: 0;
    white-space: nowrap !important;
    line-height: 1.1;
}

.wf-bus-eta.urgent {
    color: #ffd54f;
    font-weight: 900;
    text-shadow: 0 0 6px rgba(255, 213, 79, 0.6);
}

.wf-bus-eta.arriving {
    color: #ff5252;
    font-weight: 900;
    animation: busArrivingPulse 1.5s infinite;
}

.wf-bus-dest {
    font-size: 0.65rem;
    font-weight: 500;
    color: #90a4ae;
    margin-top: 1px;
    line-height: 1.1;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    width: 100%;
    display: block !important;
    box-sizing: border-box;
    flex-shrink: 0 !important;
    min-height: 12px !important;
}

.wf-bus-divider {
    width: 1.5px;
    background: linear-gradient(to bottom, transparent, rgba(105, 240, 174, 0.4) 15%, rgba(105, 240, 174, 0.4) 85%, transparent);
    align-self: stretch;
    flex-shrink: 0;
}

.wf-bus-no-bus {
    color: #90a4ae;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: center;
    padding: 24px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
}

.wf-bus-empty {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #b0bec5;
    font-size: 0.92rem;
    font-weight: 600;
    gap: 6px;
    text-align: center;
    white-space: nowrap !important;
}

/* Settings Modal */
#settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 65vw;
    max-width: 950px;
    background-color: rgba(10, 10, 10, 0.95);
    border: 1px solid #555;
    border-radius: 1rem;
    z-index: 5000;
    padding: 2rem 5rem 2rem 2rem;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    transition: opacity 0.3s, transform 0.3s;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#settings-modal.hidden {
    opacity: 0;
    transform: translate(-50%, -45%);
    pointer-events: none;
}

.settings-scroll-button {
    position: absolute;
    right: 1.2rem;
    width: 3.2rem;
    height: 3.2rem;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    z-index: 5010;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #00aaff;
}

.settings-scroll-button:hover,
.settings-scroll-button:active {
    background-color: rgba(0, 170, 255, 0.3);
    border-color: #00aaff;
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.5);
    transform: scale(1.1);
}

.settings-scroll-button svg {
    width: 1.8rem;
    height: 1.8rem;
    fill: #00aaff;
    transition: fill 0.2s;
}

.settings-scroll-button:hover svg {
    fill: #ffffff;
}

#settings-scroll-up {
    top: 6rem;
}

#settings-scroll-down {
    bottom: 2.5rem;
}

#open-radio-zone-btn {
    text-align: center;
    background-color: #003366;
    font-weight: bold;
}

#open-radio-zone-btn:hover {
    background-color: #0055aa;
}

#anime-modal,
#drama-modal,
#local-modal,
#lan-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68vw;
    max-width: 1180px;
    background-color: rgba(14, 16, 22, 0.96);
    border: 2px solid #333d4d;
    border-radius: 1rem;
    z-index: 6000;
    padding: 1.4rem 2rem;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.7);
    transition: opacity 0.3s, transform 0.3s;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

#anime-modal.hidden,
#drama-modal.hidden,
#local-modal.hidden,
#lan-modal.hidden {
    opacity: 0;
    transform: translate(-50%, -45%);
    pointer-events: none;
}

#anime-title,
#drama-title,
#local-title,
#lan-title,
#radio-title {
    text-align: center;
    font-size: 2.2rem;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 1.2rem;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 1px;
}

/* --- Radio Station Mode Modal & Scroll Buttons --- */
#radio-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 75vw;
    max-width: 1050px;
    height: 85vh;
    max-height: 88vh;
    background-color: rgba(10, 15, 25, 0.96);
    border: 2px solid #00aaff;
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    box-shadow: 0 0 50px rgba(0, 170, 255, 0.35);
    z-index: 8500;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#radio-modal.hidden {
    display: none;
}

/* --- Live Radio (真人電台) Modal --- */
#live-radio-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 88vw;
    max-width: 980px;
    height: 82vh;
    max-height: 84vh;
    background-color: rgba(10, 16, 26, 0.96);
    border: 2px solid #00e5ff;
    border-radius: 1rem;
    padding: 1.1rem 1.4rem;
    box-shadow: 0 0 50px rgba(0, 229, 255, 0.35);
    z-index: 8500;
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    box-sizing: border-box;
}

#live-radio-modal.hidden {
    display: none !important;
}

.live-radio-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.7rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    gap: 8px;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
}

.live-radio-modal-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.live-radio-modal-subtitle {
    font-size: 0.82rem;
    color: #88a0bc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-radio-category-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-right: 36px;
}

.live-radio-cat-tab {
    padding: 4px 11px;
    border-radius: 6px;
    border: 1px solid #3a4b63;
    background: #141f30;
    color: #94a3b8;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.live-radio-cat-tab:hover {
    background: #1d2d46;
    color: #fff;
    border-color: #00e5ff;
}

.live-radio-cat-tab.active {
    background: #00aaff;
    color: #fff;
    border-color: #00e5ff;
    box-shadow: 0 0 12px rgba(0, 170, 255, 0.4);
}

.live-radio-station-grid {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden !important;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(130px, 1fr);
    gap: 10px;
    padding: 2px 4px 10px 2px;
    align-content: start;
    box-sizing: border-box;
    width: 100%;
}

@media (max-width: 980px) {
    .live-radio-station-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.live-radio-card {
    background: rgba(18, 26, 42, 0.92);
    border: 1.5px solid #293a52;
    border-radius: 10px;
    padding: 9px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-sizing: border-box;
    height: 100%;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
}

.live-radio-card:hover {
    transform: translateY(-2px);
    border-color: #00e5ff;
    background: rgba(24, 38, 62, 0.95);
    box-shadow: 0 6px 20px rgba(0, 229, 255, 0.25);
}

.live-radio-card.active-playing {
    border: 1.5px solid #00e5ff;
    background: linear-gradient(135deg, rgba(14, 42, 70, 0.95) 0%, rgba(20, 32, 54, 0.95) 100%);
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.4);
}

.live-radio-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    min-width: 0;
    width: 100%;
    gap: 6px;
    overflow: hidden;
}

.live-radio-card-badge {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    color: #fff;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    white-space: nowrap;
}

.live-radio-card-freq {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    text-align: right;
}

.live-radio-card-name {
    font-size: 1.02rem;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 4px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    width: 100%;
}

.live-radio-card-prog {
    font-size: 0.82rem;
    color: #38bdf8;
    background: rgba(0, 170, 255, 0.12);
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.live-radio-card-desc {
    font-size: 0.78rem;
    color: #94a3b8;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    width: 100%;
}

.live-radio-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    min-width: 0;
    width: 100%;
    gap: 6px;
}

/* Hide AI DJ top/bottom monologue banners when in Live Radio Mode */
#radio-host-screen.live-radio-mode #radio-host-top-banner,
#radio-host-screen.live-radio-mode #radio-host-bottom-banner {
    display: none !important;
}

/* Hide and disable settings button area ONLY during Live Radio FULLSCREEN mode to eliminate exit button interference */
body.live-radio-active.fullscreen-mode #settings-button-area,
body.fullscreen-mode:has(#radio-host-screen.live-radio-mode) #settings-button-area,
body.fullscreen-mode #radio-host-screen.live-radio-mode ~ #settings-button-area {
    display: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

body.live-radio-active.fullscreen-mode .main-video {
    z-index: 2050 !important;
}

/* --- Live Radio Top-Left Floating Station HUD (Matches AI Radio) --- */
.live-radio-top-banner {
    position: absolute;
    top: 22px;
    left: 24px;
    z-index: 2501;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 14px 0 10px;
    background: rgba(6, 12, 24, 0.94);
    border: 1.5px solid rgba(0, 229, 255, 0.45);
    border-radius: 7px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 15px rgba(0, 229, 255, 0.15);
    max-width: 65vw;
    box-sizing: border-box;
    backdrop-filter: blur(10px);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    cursor: pointer;
    user-select: none;
}

.live-radio-top-banner:hover {
    border-color: #00e5ff;
    box-shadow: 0 4px 24px rgba(0, 229, 255, 0.35);
}

.live-radio-top-banner.hidden {
    display: none !important;
}

.live-radio-top-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 59, 48, 0.2);
    border: 1px solid rgba(255, 59, 48, 0.6);
    color: #ff5252;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    white-space: nowrap;
    flex-shrink: 0;
}

.live-radio-top-station-box {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.live-radio-top-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-radio-top-freq {
    font-size: 0.8rem;
    color: #38bdf8;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Live Radio Bottom Broadcast Banner HUD (100% Focused on Program) --- */
.live-radio-banner {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    min-height: 60px;
    padding: 7px 18px;
    background: linear-gradient(180deg, rgba(8, 16, 28, 0.96) 0%, rgba(3, 7, 15, 0.99) 100%);
    border-top: 1.5px solid rgba(0, 229, 255, 0.6);
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    z-index: 2500;
    box-shadow: 0 -4px 28px rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.live-radio-banner.hidden {
    display: none !important;
}

.live-radio-station-badge {
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 800;
    color: #fff;
    background: #005596;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    flex-shrink: 0;
}

.live-radio-program-wrap {
    flex: 1 1 0% !important;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    width: auto !important;
    max-width: none !important;
    background: linear-gradient(90deg, rgba(0, 170, 255, 0.12) 0%, rgba(10, 25, 45, 0.7) 100%);
    border: 1.5px solid rgba(0, 229, 255, 0.4);
    border-radius: 8px;
    padding: 6px 14px;
    box-shadow: inset 0 0 16px rgba(0, 170, 255, 0.08);
}

.live-radio-program-live-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    box-sizing: border-box;
    padding: 0 12px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid #ef4444;
    color: #ef4444;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.live-radio-program-live-tag:hover {
    background: rgba(239, 68, 68, 0.35);
    border-color: #f87171;
    transform: scale(1.04);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}

.live-radio-pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
    animation: livePulse 1.4s infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

/* --- Live Radio Collapsed State & Right-Side Reopen Trigger --- */
body.live-radio-hud-collapsed #live-radio-top-banner,
body.live-radio-hud-collapsed .live-radio-top-banner,
#live-radio-top-banner.hud-collapsed {
    transform: translateY(-120px) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

body.live-radio-hud-collapsed #live-radio-banner,
body.live-radio-hud-collapsed .live-radio-banner,
#live-radio-banner.hud-collapsed {
    transform: translateY(160%) !important;
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
}

#live-radio-reopen-trigger.live-radio-reopen-trigger {
    position: absolute !important;
    right: 0 !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 45 !important;
    cursor: pointer !important;
    user-select: none !important;
    transition: opacity 0.25s ease, transform 0.25s ease;
    outline: none !important;
}

#live-radio-reopen-trigger.hidden {
    display: none !important;
}

.live-radio-reopen-arrow-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 46px;
    background: rgba(8, 16, 28, 0.85);
    border: 1.5px solid rgba(0, 229, 255, 0.5);
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: #00e5ff;
    box-shadow: -3px 0 12px rgba(0, 229, 255, 0.3), 0 2px 8px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    transition: all 0.2s ease;
    animation: reopenArrowPulse 2.5s infinite alternate;
}

.live-radio-reopen-arrow-tab:hover,
#live-radio-reopen-trigger:focus .live-radio-reopen-arrow-tab {
    background: rgba(0, 229, 255, 0.3);
    color: #ffffff;
    width: 24px;
    border-color: #00e5ff;
    box-shadow: -5px 0 20px rgba(0, 229, 255, 0.65);
}

.live-radio-reopen-arrow-tab svg {
    display: block;
    transition: transform 0.2s ease;
}

.live-radio-reopen-arrow-tab:hover svg {
    transform: translateX(-2px);
}

@keyframes reopenArrowPulse {
    0% {
        box-shadow: -2px 0 8px rgba(0, 229, 255, 0.2);
        border-color: rgba(0, 229, 255, 0.4);
    }
    100% {
        box-shadow: -4px 0 16px rgba(0, 229, 255, 0.6);
        border-color: rgba(0, 229, 255, 0.85);
    }
}

.live-radio-program-title-line {
    display: flex;
    align-items: center;
    min-width: 0;
    width: 100%;
}

.live-radio-program-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #00e5ff;
    letter-spacing: 0.4px;
    text-shadow: 0 0 14px rgba(0, 229, 255, 0.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    line-height: 1.22;
    width: 100%;
}

.live-radio-program-sub-line {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.86rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    width: 100%;
}

.live-radio-program-time {
    color: #38bdf8;
    font-weight: 700;
    flex-shrink: 0;
}

.live-radio-program-sep {
    color: #64748b;
    font-weight: bold;
    flex-shrink: 0;
}

.live-radio-program-desc {
    color: #cbd5e1;
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-radio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

.live-radio-ctrl-btn {
    height: 38px;
    box-sizing: border-box;
    background: rgba(18, 28, 48, 0.85);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: #e2e8f0;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

#live-radio-prev-btn,
#live-radio-next-btn {
    width: 38px;
    padding: 0;
}

.live-radio-ctrl-btn:hover,
.live-radio-ctrl-btn:focus {
    background: rgba(0, 229, 255, 0.22);
    border-color: #00e5ff;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.35);
}

.live-radio-ctrl-btn.play-btn {
    min-width: 44px;
    padding: 0 10px;
    background: rgba(0, 180, 255, 0.16);
    border: 1.2px solid rgba(0, 229, 255, 0.45);
    color: #00e5ff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.live-radio-ctrl-btn.play-btn:hover,
.live-radio-ctrl-btn.play-btn:focus,
.live-radio-ctrl-btn.play-btn.active {
    background: linear-gradient(180deg, rgba(0, 229, 255, 0.45) 0%, rgba(0, 130, 255, 0.65) 100%);
    border-color: #00e5ff;
    color: #ffffff;
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.6);
}

.live-radio-ctrl-btn.list-btn {
    background: rgba(20, 35, 60, 0.85);
    border-color: rgba(0, 229, 255, 0.3);
    padding: 0 14px;
}

.live-radio-ctrl-btn.close-btn {
    background: rgba(45, 20, 30, 0.85);
    border-color: rgba(239, 68, 68, 0.45);
    color: #ff7b7b;
    padding: 0 14px;
}

.live-radio-ctrl-btn.close-btn:hover,
.live-radio-ctrl-btn.close-btn:focus {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
    color: #fff;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
}

.radio-scroll-button {
    position: absolute;
    right: 1.2rem;
    width: 3.2rem;
    height: 3.2rem;
    background-color: rgba(0, 170, 255, 0.15);
    border: 1px solid rgba(0, 170, 255, 0.4);
    border-radius: 50%;
    cursor: pointer;
    z-index: 8510;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #00aaff;
}

.radio-scroll-button:hover,
.radio-scroll-button:active {
    background-color: rgba(0, 170, 255, 0.4);
    border-color: #00aaff;
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.7);
    transform: scale(1.1);
}

.radio-scroll-button svg {
    width: 1.8rem;
    height: 1.8rem;
    fill: #00aaff;
    transition: fill 0.2s;
}

.radio-scroll-button:hover svg {
    fill: #ffffff;
}

#radio-scroll-up {
    top: 5.5rem;
}

#radio-scroll-down {
    bottom: 1.5rem;
}

#radio-channel-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#anime-channel-list,
#drama-channel-list,
#local-channel-list,
#lan-channel-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
    box-sizing: border-box;
}

#anime-channel-list::-webkit-scrollbar,
#drama-channel-list::-webkit-scrollbar,
#local-channel-list::-webkit-scrollbar,
#lan-channel-list::-webkit-scrollbar {
    width: 8px;
}

#anime-channel-list::-webkit-scrollbar-thumb,
#drama-channel-list::-webkit-scrollbar-thumb,
#local-channel-list::-webkit-scrollbar-thumb,
#lan-channel-list::-webkit-scrollbar-thumb {
    background-color: #00aaff;
    border-radius: 4px;
}

#anime-channel-list::-webkit-scrollbar-track,
#drama-channel-list::-webkit-scrollbar-track,
#local-channel-list::-webkit-scrollbar-track,
#lan-channel-list::-webkit-scrollbar-track {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

#anime-channel-list li,
#drama-channel-list li,
#local-channel-list li,
#lan-channel-list li {
    position: relative;
    font-size: 1.35rem;
    font-weight: 600;
    height: 3.4rem;
    padding: 0 1rem;
    border-radius: 0.6rem;
    background-color: #1e1e24;
    border: 2px solid #3d3d4d;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap !important;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    user-select: none;
}

#anime-channel-list li:hover,
#drama-channel-list li:hover,
#local-channel-list li:hover,
#lan-channel-list li:hover,
#anime-channel-list li:focus,
#drama-channel-list li:focus,
#local-channel-list li:focus,
#lan-channel-list li:focus {
    background-color: #2b3342;
    border-color: #00aaff;
    transform: scale(1.02);
    box-shadow: 0 6px 18px rgba(0, 170, 255, 0.35);
    color: #ffffff;
    z-index: 2;
}

/* 走馬燈名稱：保持單行，如名稱太長則自動平滑滾動 */
.channel-title-text {
    display: inline-block;
    max-width: 100%;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    line-height: 1.2;
    will-change: transform;
}

li.has-marquee .channel-title-text {
    overflow: visible;
    text-overflow: clip;
    animation: channel-title-marquee var(--marquee-duration, 8s) ease-in-out infinite alternate;
}

@keyframes channel-title-marquee {

    0%,
    18% {
        transform: translateX(0%);
    }

    82%,
    100% {
        transform: translateX(var(--scroll-dist, -40%));
    }
}

#anime-channel-list li:only-child,
#drama-channel-list li:only-child,
#local-channel-list li:only-child,
#lan-channel-list li:only-child {
    grid-column: 1 / -1;
}

.zone-close-button {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    width: 3rem;
    height: 3rem;
    font-size: 2.5rem;
    color: #888;
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
    line-height: 1;
}

.zone-close-button:hover {
    color: #fff;
    background-color: #333;
}

#anime-pagination-controls,
#drama-pagination-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.2rem;
    flex-shrink: 0;
}

.anime-page-button,
.drama-page-button {
    padding: 0.6rem 1.4rem;
    font-size: 1.15rem;
    font-weight: bold;
    background-color: #252525;
    border: 2px solid #444;
    color: #ccc;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.anime-page-button:hover,
.drama-page-button:hover {
    background-color: #333;
    border-color: #00aaff;
    color: #fff;
}

.anime-page-button.active,
.drama-page-button.active {
    background-color: #007bff;
    border-color: #00aaff;
    color: #fff;
    cursor: default;
}

#local-modal-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #444;
    display: flex;
    gap: 1rem;
    flex-shrink: 0;
}

.local-action-button {
    flex-grow: 1;
    text-align: center;
    font-size: 1.4rem;
    padding: 1.2rem;
    border-radius: 0.5rem;
    background-color: #252525;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background-color 0.2s, transform 0.2s;
}

.local-action-button:hover {
    background-color: #007bff;
    color: white;
    transform: scale(1.02);
    border-color: #00aaff;
}

/* Stats Modal (Enhanced Style) */
#stats-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40vw;
    max-width: 500px;
    background-color: rgba(15, 15, 20, 0.95);
    /* Darker blue-black to match settings */
    border: 1px solid #444;
    border-radius: 1rem;
    z-index: 7000;
    padding: 2rem;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    transition: opacity 0.3s, transform 0.3s;
    backdrop-filter: blur(10px);
    /* Modern glass effect */
}

#stats-modal.hidden {
    opacity: 0;
    transform: translate(-50%, -45%);
    pointer-events: none;
}

.stats-content {
    display: flex;
    flex-direction: column;
    font-size: 1.4rem;
    color: #fff;
}

.stats-content h3 {
    text-align: center;
    color: #00aaff;
    margin: 0 0 1.5rem 0;
    border-bottom: 2px solid #333;
    padding-bottom: 1rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid #2a2a2a;
}

.stat-row:last-of-type {
    border-bottom: none;
}

.stat-label {
    color: #aaa;
    font-weight: normal;
    font-size: 1.2rem;
    font-family: 'Segoe UI', 'Microsoft JhengHei', sans-serif;
    /* Ensure standard font */
}

/* Use monospace font for values to look like data */
.stat-value {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.5);
}

.stat-close-hint {
    text-align: center;
    font-size: 1rem;
    color: #666;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #333;
}

.settings-title {
    text-align: center;
    font-size: 2.2rem;
    margin-top: 0;
    margin-bottom: 2rem;
    color: #fff;
    flex-shrink: 0;
}

#settings-content-wrapper {
    max-height: calc(85vh - 120px);
    overflow-y: auto !important;
    padding-right: 1rem;
    scroll-behavior: smooth;
}

#settings-content-wrapper::-webkit-scrollbar {
    width: 10px;
}

#settings-content-wrapper::-webkit-scrollbar-thumb {
    background-color: #00aaff;
    border-radius: 5px;
}

#settings-content-wrapper::-webkit-scrollbar-track {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
}

#settings-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* === NEW: Top Tab Navigation Styles === */
.settings-top-nav {
    display: flex;
    justify-content: space-around;
    background-color: #1a1a1a;
    border-radius: 0.8rem;
    margin-bottom: 2rem;
    padding: 0.5rem;
    border: 1px solid #333;
}

.settings-nav-item {
    flex-grow: 1;
    text-align: center;
    padding: 1rem;
    font-size: 1.6rem;
    color: #888;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.settings-nav-item .nav-icon {
    font-size: 2rem;
}

.settings-nav-item:hover {
    color: #ccc;
    background-color: rgba(255, 255, 255, 0.05);
}

.settings-nav-item.active {
    color: #fff;
    background-color: #252525;
    border-bottom: 3px solid #00aaff;
    font-weight: bold;
}

.settings-nav-item.focused {
    background-color: #333;
    border-color: #00aaff;
    color: #fff;
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* === NEW: Section Header Styles === */
.settings-section-header {
    font-size: 1.4rem;
    color: #00aaff;
    padding: 1rem 0.5rem 0.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #333;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.settings-tab-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #444;
}

.settings-tab-button {
    background-color: transparent;
    border: none;
    color: #aaa;
    font-size: 1.3rem;
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-bottom-color 0.2s;
}

.settings-tab-button:hover {
    color: #fff;
}

.settings-tab-button:focus,
.settings-tab-button.focused {
    color: #fff;
    outline: none;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
}

.settings-tab-button.active {
    color: #fff;
    font-weight: bold;
    border-bottom-color: #00aaff;
}

/* 特色濾鏡網格樣式 */
.settings-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 2rem;
    max-height: 60vh;
    overflow-y: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    box-sizing: border-box;
}

.settings-filter-grid::-webkit-scrollbar {
    display: none;
}

.filter-grid-item {
    background-color: #222;
    border: 2px solid #444;
    border-radius: 0.5rem;
    padding: 1.5rem;
    text-align: center;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-grid-item:hover {
    background-color: #333;
}

.filter-grid-item.focused {
    background-color: #333;
    border-color: #00aaff;
    transform: scale(1.03);
    box-shadow: 0 0 10px rgba(0, 170, 255, 0.3);
    z-index: 1;
}

.filter-grid-item.selected {
    background-color: #0055aa;
    border-color: #00aaff;
    color: white;
    font-weight: bold;
}

/* NEW: Explicit Filter Pagination Buttons */
.filter-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin: 1rem 0;
    padding: 1rem 0;
}

.filter-page-info {
    font-size: 2rem;
    font-weight: bold;
    color: #ccc;
}

.filter-nav-btn {
    background-color: #333;
    border: 2px solid #555;
    color: #fff;
    font-size: 1.4rem;
    padding: 0.8rem 2rem;
    border-radius: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-nav-btn:hover,
.filter-nav-btn.focused {
    background-color: #007bff;
    border-color: #00aaff;
    transform: scale(1.05);
}

.filter-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background-color: #222;
    border-color: #444;
}


.settings-category-item,
.settings-item,
.settings-back-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.4rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s, transform 0.2s;
    border: 2px solid transparent;
    cursor: pointer;
}

.settings-category-item:hover,
.settings-item:hover,
.settings-back-button:hover {
    background-color: #333;
    border-color: #00aaff;
    transform: scale(1.01);
}

.settings-back-button {
    justify-content: center;
    color: #a0a0a0;
    margin-top: 0.5rem;
}

.settings-label {
    color: #ddd;
    flex-shrink: 0;
    margin-right: 1rem;
}

.settings-value {
    font-weight: bold;
    color: #fff;
    display: flex;
    align-items: center;
}

.settings-value .arrows {
    color: #888;
    margin: 0 0.5rem;
}

.color-preview {
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid #555;
    border-radius: 0.3rem;
    margin-left: 1rem;
}

.settings-item input[type="range"] {
    flex-grow: 1;
    margin: 0 1rem;
    accent-color: #00aaff;
}

.settings-item .range-value {
    min-width: 50px;
    text-align: right;
}

.settings-item .input-group {
    display: flex;
    flex-direction: column;
    width: 50%;
    gap: 0.5rem;
}

.settings-item .input-group label {
    font-size: 1rem;
    color: #aaa;
    align-self: flex-start;
}

.settings-item input[type="text"],
.settings-item input[type="password"] {
    width: 100%;
    font-size: 1.2rem;
    padding: 0.5rem;
    background-color: #222;
    border: 1px solid #555;
    color: #fff;
    border-radius: 0.3rem;
    text-align: left;
}

.settings-stock-input-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.4rem;
    padding: 1rem;
    border-radius: 0.5rem;
    transition: background-color 0.2s, transform 0.2s;
    border: 2px solid transparent;
    cursor: pointer;
}

.settings-stock-input-row.focused,
.settings-stock-input-row:hover {
    background-color: #333;
    border-color: #00aaff;
    transform: scale(1.01);
}

.settings-stock-input-row .stock-labels {
    flex-shrink: 0;
    margin-right: 1rem;
    font-weight: bold;
    min-width: 5rem;
}

.settings-stock-input-row .input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-grow: 1;
    justify-content: flex-end;
}

.settings-stock-input-row .input-wrapper input {
    flex-basis: 30%;
    max-width: 7rem;
    text-align: center;
    font-size: 1.2rem;
    padding: 0.5rem;
    background-color: #222;
    border: 1px solid #555;
    color: #fff;
    border-radius: 0.3rem;
}

.settings-stock-input-row .input-wrapper .settings-value {
    flex-shrink: 0;
    flex-basis: 30%;
    max-width: 8rem;
}

.portfolio-inputs {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: flex-end;
    flex-grow: 1;
}

.portfolio-inputs label {
    font-size: 1.2rem;
    color: #aaa;
}

.portfolio-inputs input {
    width: 8rem;
    font-size: 1.2rem;
    padding: 0.5rem;
    background-color: #222;
    border: 1px solid #555;
    color: #fff;
    border-radius: 0.3rem;
    text-align: right;
}

.settings-actions-container {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #444;
}

.settings-action-item {
    flex-grow: 1;
    text-align: center;
    font-size: 1.4rem;
    padding: 1.2rem;
    border-radius: 0.5rem;
    background-color: #252525;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background-color 0.2s, transform 0.2s;
}

.settings-action-item.focused,
.settings-action-item:hover {
    background-color: #007bff;
    color: white;
    transform: scale(1.02);
    border-color: #00aaff;
}

#settings-close-button {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 3rem;
    height: 3rem;
    font-size: 2.5rem;
    color: #888;
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
}

#settings-close-button:hover {
    color: #fff;
    background-color: #333;
}

.settings-disclaimer {
    text-align: center;
    font-size: 1.1rem;
    color: #888;
    margin-top: 2rem;
    padding: 0 1rem;
    line-height: 1.5;
}

/* Alerts & Immersive Overlay (Always prioritized above all video/radio playback layers) */
#alert-container {
    position: absolute;
    top: var(--base-gap);
    left: var(--base-gap);
    width: calc(100vw - var(--sidebar-width) - 3 * var(--base-gap));
    height: calc(100vh - var(--news-bar-height) - 3 * var(--base-gap));
    overflow: hidden;
    contain: paint;
    pointer-events: none;
    z-index: 2147483640 !important;
}

body.fullscreen-mode #alert-container,
body.seamless-tv-open #alert-container,
body.seamless-tv-active #alert-container,
body:has(#seamless-tv-modal[style*="display: block"]) #alert-container,
body:has(.seamless-tv-container:not([style*="display: none"])) #alert-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    overflow: hidden !important;
    contain: paint !important;
    pointer-events: none !important;
    z-index: 2147483640 !important;
}

.alert-banner {
    position: absolute;
    left: 0;
    width: 100%;
    color: white;
    z-index: 2147483647 !important;
    display: flex;
    align-items: stretch;
    font-size: 2.2rem;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.2s ease, opacity 0.2s ease, visibility 0.6s;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    visibility: hidden;
}

.alert-banner.show {
    visibility: visible !important;
}

.alert-banner:hover {
    filter: brightness(1.12);
}

.alert-banner:active {
    filter: brightness(0.92);
}

#breaking-news-alert,
#economic-news-alert {
    top: 0;
    transform: translateY(-102%);
}

#earthquake-alert {
    bottom: 0;
    transform: translateY(102%);
}

body.fullscreen-mode .alert-banner,
body.seamless-tv-open .alert-banner,
body.seamless-tv-active .alert-banner,
body:has(#seamless-tv-modal[style*="display: block"]) .alert-banner,
body:has(.seamless-tv-container:not([style*="display: none"])) .alert-banner {
    position: absolute !important;
    top: 0 !important;
    bottom: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
    transform: translateY(-102%) !important;
    z-index: 2147483647 !important;
    pointer-events: auto !important;
}

body.fullscreen-mode #breaking-news-alert,
body.fullscreen-mode #economic-news-alert,
body.fullscreen-mode #ktv-cheer-alert,
body.seamless-tv-open #breaking-news-alert,
body.seamless-tv-open #economic-news-alert,
body.seamless-tv-open #ktv-cheer-alert,
body.seamless-tv-active #breaking-news-alert,
body.seamless-tv-active #economic-news-alert,
body.seamless-tv-active #ktv-cheer-alert,
body:has(#seamless-tv-modal[style*="display: block"]) #breaking-news-alert,
body:has(#seamless-tv-modal[style*="display: block"]) #economic-news-alert,
body:has(#seamless-tv-modal[style*="display: block"]) #ktv-cheer-alert,
body:has(.seamless-tv-container:not([style*="display: none"])) #breaking-news-alert,
body:has(.seamless-tv-container:not([style*="display: none"])) #economic-news-alert,
body:has(.seamless-tv-container:not([style*="display: none"])) #ktv-cheer-alert {
    top: 0 !important;
    bottom: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    transform: translateY(-102%) !important;
    z-index: 2147483647 !important;
}

body.fullscreen-mode #breaking-news-alert.show,
body.fullscreen-mode #economic-news-alert.show,
body.fullscreen-mode #ktv-cheer-alert.show,
body.seamless-tv-open #breaking-news-alert.show,
body.seamless-tv-open #economic-news-alert.show,
body.seamless-tv-open #ktv-cheer-alert.show,
body.seamless-tv-active #breaking-news-alert.show,
body.seamless-tv-active #economic-news-alert.show,
body.seamless-tv-active #ktv-cheer-alert.show,
body:has(#seamless-tv-modal[style*="display: block"]) #breaking-news-alert.show,
body:has(#seamless-tv-modal[style*="display: block"]) #economic-news-alert.show,
body:has(#seamless-tv-modal[style*="display: block"]) #ktv-cheer-alert.show,
body:has(.seamless-tv-container:not([style*="display: none"])) #breaking-news-alert.show,
body:has(.seamless-tv-container:not([style*="display: none"])) #economic-news-alert.show,
body:has(.seamless-tv-container:not([style*="display: none"])) #ktv-cheer-alert.show {
    top: 0 !important;
    bottom: auto !important;
    transform: translateY(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 2147483647 !important;
}

body:has(#breaking-news-alert.show) #channel-switcher-area,
body:has(#economic-news-alert.show) #channel-switcher-area,
body:has(#earthquake-alert.show) #channel-switcher-area,
body:has(#ktv-cheer-alert.show) #channel-switcher-area {
    pointer-events: none !important;
}

body.fullscreen-mode #earthquake-alert,
body.seamless-tv-open #earthquake-alert,
body.seamless-tv-active #earthquake-alert,
body:has(#seamless-tv-modal[style*="display: block"]) #earthquake-alert,
body:has(.seamless-tv-container:not([style*="display: none"])) #earthquake-alert {
    bottom: 0 !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    transform: translateY(102%) !important;
    z-index: 2147483647 !important;
}

body.fullscreen-mode #earthquake-alert.show,
body.seamless-tv-open #earthquake-alert.show,
body.seamless-tv-active #earthquake-alert.show,
body:has(#seamless-tv-modal[style*="display: block"]) #earthquake-alert.show,
body:has(.seamless-tv-container:not([style*="display: none"])) #earthquake-alert.show {
    bottom: 0 !important;
    top: auto !important;
    transform: translateY(0) !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 2147483647 !important;
}

.alert-title {
    background-color: #000;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.alert-content {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    flex-grow: 1;
    overflow: hidden;
}

#earthquake-alert {
    background-color: rgba(200, 0, 0, 0.9);
}

#earthquake-alert.show {
    transform: translateY(0);
}

#earthquake-alert .alert-title {
    animation: blink-animation 1.5s infinite;
}

@keyframes blink-animation {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.eq-mag {
    background-color: #ffc107;
    color: #000;
    padding: 0.8rem 1.2rem;
    margin-right: 1rem;
    border-radius: 6px;
    text-align: center;
}

.eq-mag-label {
    font-size: 1.8rem;
    display: block;
}

.eq-mag-value {
    font-size: 3rem;
    line-height: 1;
}

.eq-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 1.8rem;
}

.eq-place {
    font-size: 2rem;
}

.eq-time,
.eq-local-time {
    color: #ddd;
    font-size: 1.5rem;
}

#breaking-news-alert {
    background-color: rgba(10, 20, 80, 0.9);
}

#economic-news-alert {
    background-color: rgba(100, 80, 10, 0.9);
}

#ktv-cheer-alert {
    top: 0;
    transform: translateY(-102%);
    background: linear-gradient(90deg, rgba(35, 15, 60, 0.95) 0%, rgba(65, 20, 90, 0.95) 45%, rgba(20, 12, 45, 0.95) 100%);
    border-bottom: 3px solid #ff007f;
    box-shadow: 0 6px 25px rgba(255, 0, 127, 0.45);
}

.ktv-cheer-alert-title {
    background: linear-gradient(135deg, #ff007f 0%, #7928ca 100%) !important;
    color: #ffffff !important;
    font-weight: 900 !important;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

#ktv-cheer-alert.show {
    transform: translateY(0);
}

#breaking-news-alert.show,
#economic-news-alert.show {
    transform: translateY(0);
}

#news-alert-details,
#economic-news-alert-details,
#ktv-cheer-alert-details {
    flex-direction: row;
    align-items: center;
    width: 100%;
    overflow: hidden;
}

#news-alert-title-text,
#economic-news-alert-title-text,
#ktv-cheer-alert-title-text {
    font-size: 1.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

#ktv-cheer-alert-title-text {
    color: #00f0ff;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

#immersive-top-bar,
#immersive-bottom-bar {
    position: fixed;
    left: 0;
    width: 100%;
    z-index: 15;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
    color: #f0f0f0;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7);
}

#immersive-top-bar {
    top: 0;
    height: var(--immersive-top-bar-height);
    background-color: var(--immersive-top-bar-bg);
    font-size: var(--immersive-top-bar-fontsize);
    display: flex;
    align-items: center;
    padding: 0 2vw;
    font-weight: 500;
}

#immersive-bottom-bar {
    bottom: 0;
    height: var(--immersive-bottom-bar-height);
    background-color: var(--immersive-bottom-bar-bg);
    font-size: var(--immersive-bottom-bar-fontsize);
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
}

body.immersive-mode-enabled.fullscreen-mode #immersive-top-bar,
body.immersive-mode-enabled.fullscreen-mode #immersive-bottom-bar {
    opacity: 1;
    pointer-events: auto;
}

/* --- TV Static Canvas --- */
#tv-static-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 6;
    opacity: 0;
    transition: opacity 0.1s ease;
}

#tv-static-canvas.active {
    opacity: 0.95;
}

/* --- Retro CRT OSD Overlay --- */
/* --- Retro CRT OSD Overlay --- */
#retro-osd-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 7;
    padding: 1.2rem 1.6rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-family: 'Consolas', 'Courier New', monospace;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.4s ease;
    overflow: hidden; /* 防止子元素任何微小溢出 */
}

#retro-osd-overlay.visible {
    opacity: 1;
}

#retro-osd-overlay.green-theme {
    color: #00ff00;
    text-shadow: 0 0 8px rgba(0, 255, 0, 0.9), 0 0 15px rgba(0, 255, 0, 0.5);
}

#retro-osd-overlay.amber-theme {
    color: #ffb000;
    text-shadow: 0 0 8px rgba(255, 176, 0, 0.9), 0 0 15px rgba(255, 176, 0, 0.5);
}

#retro-osd-overlay.plain-green-theme {
    color: #00ff00;
    text-shadow: none;
}

#retro-osd-overlay.plain-amber-theme {
    color: #ffb000;
    text-shadow: none;
}

.retro-osd-top {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    font-size: 1.5rem;
    letter-spacing: 1px;
    background: rgba(0, 0, 0, 0.75);
    padding: 0.4rem 1rem;
    border-radius: 0.45rem;
    align-self: flex-start;
    border: 2px solid currentColor;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    max-width: 100%; /* 嚴格限制在容器寬度之內，永不超出 */
    box-sizing: border-box;
    min-width: 0;
}

#retro-osd-ch {
    font-size: 1.7rem;
    border-right: 2px solid currentColor;
    padding-right: 0.8rem;
    flex-shrink: 0;
    white-space: nowrap;
}

#retro-osd-name {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.retro-osd-bottom {
    align-self: flex-end;
    font-size: 1.2rem;
    letter-spacing: 2px;
    background: rgba(0, 0, 0, 0.75);
    padding: 0.35rem 0.85rem;
    border-radius: 0.45rem;
    border: 2px solid currentColor;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    flex-shrink: 0;
}

/* 全螢幕模式放大為震撼大字體 */
body.fullscreen-mode #retro-osd-overlay {
    padding: 2.5rem 3rem;
}

body.fullscreen-mode .retro-osd-top {
    font-size: 2.2rem;
    padding: 0.6rem 1.4rem;
    gap: 1.4rem;
    letter-spacing: 2px;
    border-radius: 0.5rem;
}

body.fullscreen-mode #retro-osd-ch {
    font-size: 2.6rem;
    padding-right: 1.2rem;
}

body.fullscreen-mode .retro-osd-bottom {
    font-size: 1.8rem;
    padding: 0.5rem 1.2rem;
    letter-spacing: 3px;
    border-radius: 0.5rem;
}

/* 窄視窗、手機或低解析度 TV Box 緊湊適配 */
@media (max-width: 768px), (max-height: 520px) {
    #retro-osd-overlay {
        padding: 0.6rem 0.8rem;
    }
    .retro-osd-top {
        font-size: 1.15rem;
        padding: 0.3rem 0.6rem;
        gap: 0.5rem;
        letter-spacing: 0.5px;
    }
    #retro-osd-ch {
        font-size: 1.25rem;
        padding-right: 0.5rem;
    }
    .retro-osd-bottom {
        font-size: 0.95rem;
        padding: 0.2rem 0.5rem;
        letter-spacing: 1px;
    }
}

.immersive-time-date,
.immersive-weather {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.immersive-weather-icon {
    font-size: 1.2em;
}

#stock-overlay {
    position: fixed;
    top: 1vh;
    right: 1vw;
    z-index: 990;
    display: flex;
    gap: 0.5rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#stock-overlay.vertical-layout {
    flex-direction: column;
    width: 14vw;
    max-width: 300px;
}

#stock-overlay.horizontal-layout {
    flex-direction: row;
    width: calc(12vw * 4 + 0.5rem * 3);
    /* RESTORED: Fixed width for 4 items */
    max-width: 70vw;
    align-items: flex-start;
    justify-content: flex-end;
}

#stock-overlay.single-box-layout {
    flex-direction: column;
    width: 14vw;
    max-width: 300px;
}

#stock-overlay.single-box-layout .stock-overlay-item {
    display: none;
}

#stock-overlay.single-box-layout .stock-overlay-item.active-slot {
    display: flex;
}

body.fullscreen-mode #stock-overlay {
    opacity: 1;
}

.stock-overlay-item {
    padding: 0.8rem 1rem;
    border-radius: 0.5rem;
    color: #fff;
    transition: background-color 0.3s, opacity 0.3s;
    display: none;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
    background-color: rgba(50, 50, 50, 0.7);
    min-height: 2.2rem;
}

.stock-overlay-item.visible {
    display: flex;
}

.stock-overlay-item.up {
    background-color: rgba(57, 255, 20, 0.7);
    /* Green */
    color: #000;
}

.stock-overlay-item.down {
    background-color: rgba(255, 0, 0, 0.7);
    /* Red */
}

.stock-overlay-symbol {
    font-weight: bold;
    font-size: 1.2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
    margin-right: 0.5rem;
    min-width: 3rem;
}

.stock-overlay-value-container {
    position: relative;
    height: 1.6rem;
    line-height: 1.6rem;
    overflow: hidden;
    font-size: 1.6rem;
    font-weight: bold;
    text-align: right;
    flex-grow: 1;
    min-width: 4rem;
}

.stock-price-content,
.stock-change-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    transition: transform 0.5s ease-in-out;
    white-space: nowrap;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.stock-change-content {
    transform: translateY(100%);
}

.stock-overlay-item.show-change .stock-price-content {
    transform: translateY(-100%);
}

.stock-overlay-item.show-change .stock-change-content {
    transform: translateY(0);
}

/* --- Finance Zone (TradingView Integration) --- */
#finance-zone-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(10, 15, 20, 0.95);
    /* Deep blue/black bg */
    backdrop-filter: blur(20px);
    z-index: 8000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
    padding: 2rem;
    box-sizing: border-box;
}

#finance-zone-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.finance-grid {
    display: grid;
    grid-template-columns: 60% 40%;
    gap: 1.5rem;
    width: 100%;
    height: 100%;
    max-width: 1800px;
    /* Prevent too wide on ultrawide */
}

.finance-heatmap-container,
.finance-watchlist-container {
    background-color: #111;
    border: 1px solid #333;
    border-radius: 0.8rem;
    overflow: hidden;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Ensure TradingView widgets take full height */
.tradingview-widget-container {
    width: 100% !important;
    height: 100% !important;
}

#tv-heatmap-embed,
#tv-overview-embed {
    width: 100%;
    height: 100%;
}

/* NEW: Exit Hint Style */
.finance-exit-hint {
    position: absolute;
    bottom: 1rem;
    left: 0;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.2rem;
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    z-index: 10;
}

/* NEW: Finance Action Button (Exit) */
.finance-action-btn {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background-color: #e60012;
    /* Red for Exit */
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 3rem;
    font-size: 1.5rem;
    font-weight: bold;
    border-radius: 0.5rem;
    cursor: pointer;
    z-index: 20;
    transition: all 0.2s;
    box-shadow: 0 0 15px rgba(230, 0, 18, 0.5);
}

.finance-action-btn:hover,
.finance-action-btn:focus {
    background-color: #ff3344;
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 0 25px rgba(255, 51, 68, 0.8);
    outline: none;
}

/* --- AI Analysis Styles (Hidden invisible trigger at top-right per user request) --- */
#ai-analysis-btn {
    position: fixed;
    top: 1rem;
    right: 1vw;
    width: 4.5rem;
    height: 4.5rem;
    background: transparent !important;
    border: none !important;
    border-radius: 0;
    box-shadow: none !important;
    z-index: 4000;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0 !important;
    pointer-events: auto !important;
}

#ai-analysis-btn:hover,
#ai-analysis-btn:active {
    opacity: 0.05 !important;
    background: transparent !important;
    border: none !important;
    transform: none !important;
}

#ai-analysis-btn svg {
    display: none !important;
}

/* ─── News & Finance Briefing Modal (長按 8 鍵) ─── */
#news-briefing-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 1550px;
    height: 86vh;
    max-height: 920px;
    background-color: rgba(9, 14, 28, 0.98);
    border: 1px solid rgba(0, 229, 255, 0.35);
    border-radius: 1.2rem;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    padding: 1.6rem 2.2rem;
    box-shadow: 0 0 100px rgba(0, 0, 0, 0.95), 0 0 40px rgba(0, 229, 255, 0.2);
    backdrop-filter: blur(25px);
    transition: opacity 0.3s, transform 0.3s;
    box-sizing: border-box;
}

#news-briefing-modal.hidden {
    opacity: 0;
    transform: translate(-50%, -45%);
    pointer-events: none;
}

/* ─── In-Screen PiP Broadcast Banner (畫面內快報條，非播放器) ─── */
#news-briefing-banner {
    position: fixed;
    top: 24px;
    left: 28px;
    z-index: 8950;
    display: flex;
    align-items: center;
    max-width: 520px;
    height: 40px;
    background: rgba(10, 15, 29, 0.88);
    border: 1px solid rgba(0, 229, 255, 0.35);
    border-left: 4px solid #00e5ff;
    border-radius: 6px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.65), 0 0 16px rgba(0, 229, 255, 0.2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    cursor: pointer;
    user-select: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s, box-shadow 0.2s, top 0.35s cubic-bezier(0.16, 1, 0.3, 1), max-width 0.3s ease, height 0.3s ease;
    box-sizing: border-box;
    padding: 0 8px 0 0;
    overflow: hidden;
}

#news-briefing-banner:hover {
    border-color: rgba(0, 229, 255, 0.7);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), 0 0 24px rgba(0, 229, 255, 0.35);
}

#news-briefing-banner.hidden {
    opacity: 0;
    transform: translateY(-16px) scale(0.96);
    pointer-events: none;
}

.briefing-pip-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(185, 28, 28, 0.95));
    color: #fff;
    padding: 0 10px;
    height: 100%;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.briefing-pip-badge .pip-dot {
    width: 7px;
    height: 7px;
    background-color: #fff;
    border-radius: 50%;
    animation: pipDotBlink 1.4s infinite ease-in-out;
}

@keyframes pipDotBlink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.75); }
}

.briefing-pip-body {
    display: flex;
    align-items: center;
    padding: 0 12px;
    flex: 1;
    min-width: 0;
}

.briefing-pip-text {
    font-size: 0.92rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.3px;
    font-weight: 500;
}

.briefing-pip-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.briefing-pip-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.15s;
    outline: none;
}

.briefing-pip-btn:hover,
.briefing-pip-btn:focus-visible {
    background: rgba(0, 229, 255, 0.25);
    border-color: #00e5ff;
    color: #fff;
    transform: scale(1.08);
}

.briefing-pip-btn.close:hover,
.briefing-pip-btn.close:focus-visible {
    background: rgba(239, 68, 68, 0.35);
    border-color: #ef4444;
    color: #fca5a5;
    transform: scale(1.08);
}

/* ─── 全螢幕模式自適應加大 (電視客廳遠距觀看) ─── */
body.fullscreen-mode #news-briefing-banner {
    top: 32px;
    left: 36px;
    height: 52px;
    max-width: 680px;
    border-radius: 8px;
    border-left-width: 5px;
    padding-right: 12px;
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.75), 0 0 24px rgba(0, 229, 255, 0.25);
}

body.fullscreen-mode #news-briefing-banner .briefing-pip-badge {
    padding: 0 14px;
    font-size: 0.96rem;
    letter-spacing: 1.5px;
}

body.fullscreen-mode #news-briefing-banner .briefing-pip-badge .pip-dot {
    width: 9px;
    height: 9px;
}

body.fullscreen-mode #news-briefing-banner .briefing-pip-body {
    padding: 0 14px;
}

body.fullscreen-mode #news-briefing-banner .briefing-pip-text {
    font-size: 1.08rem;
    font-weight: 600;
}

body.fullscreen-mode #news-briefing-banner .briefing-pip-actions {
    gap: 7px;
}

body.fullscreen-mode #news-briefing-banner .briefing-pip-btn {
    width: 36px;
    height: 36px;
    border-radius: 6px;
}

body.fullscreen-mode #news-briefing-banner .briefing-pip-btn svg {
    width: 18px;
    height: 18px;
}

/* ─── 沉浸模式自適應位置：自動避開頂部時間氣象頂欄 (#immersive-top-bar)，絕不遮蔽頂欄 ─── */
body.immersive-mode-enabled.fullscreen-mode #news-briefing-banner,
body.fullscreen-mode.immersive-mode-enabled #news-briefing-banner,
body.immersive-mode-enabled #immersive-top-bar:not([style*="display: none"]) ~ #news-briefing-banner {
    top: calc(var(--immersive-top-bar-height, 5.5rem) + 16px);
    left: max(32px, 2.5vw);
}

/* ─── 視窗或小螢幕自適應 ─── */
@media (max-width: 768px) {
    #news-briefing-banner {
        top: 14px;
        left: 12px;
        max-width: calc(100vw - 24px);
        height: 38px;
    }

    body.fullscreen-mode #news-briefing-banner {
        top: 20px;
        left: 14px;
        max-width: calc(100vw - 28px);
        height: 44px;
    }

    body.immersive-mode-enabled.fullscreen-mode #news-briefing-banner,
    body.fullscreen-mode.immersive-mode-enabled #news-briefing-banner {
        top: calc(var(--immersive-top-bar-height, 5.5rem) + 10px);
        left: 12px;
        max-width: calc(100vw - 24px);
    }
}

.news-briefing-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zone-minimize-button {
    width: 2.6rem;
    height: 2.6rem;
    font-size: 1.5rem;
    color: #888;
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: color 0.2s, background-color 0.2s;
    line-height: 1;
}

.zone-minimize-button:hover,
.zone-minimize-button:focus-visible {
    color: #00e5ff;
    background-color: rgba(0, 229, 255, 0.15);
}

.news-briefing-header-actions .zone-close-button {
    position: static;
    width: 2.6rem;
    height: 2.6rem;
}

.news-briefing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.8rem;
    margin-bottom: 1rem;
}

.news-briefing-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.news-briefing-icon {
    font-size: 2.2rem;
}

.news-briefing-title {
    font-size: 2.2rem;
    color: #00e5ff;
    margin: 0;
    letter-spacing: 1.5px;
    text-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.news-briefing-badge {
    background: rgba(0, 229, 255, 0.15);
    color: #00e5ff;
    border: 1px solid rgba(0, 229, 255, 0.3);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: bold;
}

.news-briefing-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding: 0 0.2rem;
    flex-wrap: wrap;
    gap: 10px;
}

.news-briefing-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    overflow-y: auto;
}

.news-briefing-summary-cards {
    display: flex;
    gap: 1.2rem;
}

.briefing-card {
    background: rgba(18, 26, 44, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.8rem;
    padding: 1.1rem 1.4rem;
    box-sizing: border-box;
}

#briefing-time-weather-card {
    flex: 0.9;
}

#briefing-finance-card {
    flex: 1.1;
}

.briefing-card-title {
    font-size: 1.15rem;
    font-weight: bold;
    color: #38bdf8;
    margin-bottom: 0.6rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.4rem;
}

.briefing-card-content {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #cbd5e1;
}

.briefing-script-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    background: rgba(13, 20, 36, 0.9);
    border-color: rgba(0, 229, 255, 0.25);
}

.briefing-script-content {
    flex: 1;
    overflow-y: auto;
    font-size: 1.25rem;
    line-height: 1.8;
    color: #f1f5f9;
    padding-right: 0.8rem;
    white-space: pre-wrap;
    letter-spacing: 0.5px;
}

.briefing-timestamp {
    font-size: 1rem;
    color: #94a3b8;
    font-family: monospace;
}

#ai-analysis-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92vw;
    max-width: 1650px;
    height: 88vh;
    max-height: 980px;
    background-color: rgba(10, 15, 26, 0.98);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 1.2rem;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    padding: 1.6rem 2rem;
    box-shadow: 0 0 100px rgba(0, 0, 0, 0.95), 0 0 30px rgba(99, 102, 241, 0.2);
    backdrop-filter: blur(20px);
    transition: opacity 0.3s, transform 0.3s;
    box-sizing: border-box;
}

#ai-analysis-modal.hidden {
    opacity: 0;
    transform: translate(-50%, -45%);
    pointer-events: none;
}

.ai-report-title {
    text-align: center;
    font-size: 2.2rem;
    color: #00aaff;
    margin: 0 0 0.8rem 0;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(0, 170, 255, 0.4);
}

.ai-report-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0 0.5rem;
}

.tts-controls {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.tts-config-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    padding: 3px 8px;
}

.tts-cfg-label {
    font-size: 0.92rem;
    color: #94a3b8;
    font-weight: 600;
}

.tts-select {
    background: transparent;
    color: #ffd700;
    border: none;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    outline: none;
    padding: 4px 6px;
}

.tts-select option {
    background: #0f172a;
    color: #fff;
}

.tts-btn {
    background-color: rgba(30, 41, 59, 0.9);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1.1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 600;
    transition: all 0.2s;
    outline: none;
}

.tts-btn:hover,
.tts-btn:focus {
    background-color: #00aaff;
    border-color: #00d2ff;
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.4);
    transform: scale(1.03);
}

.tts-status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.88rem;
    font-weight: 600;
    background: rgba(30, 41, 59, 0.8);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.tts-status-pill.speaking {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.4);
}

.tts-status-pill.generating {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}

.tts-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
}

.tts-status-pill.speaking .tts-dot {
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
    animation: ttsPulse 1.5s infinite;
}

.tts-status-pill.generating .tts-dot {
    background: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
    animation: ttsPulse 0.8s infinite;
}

@keyframes ttsPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.3); }
}

.report-timestamp {
    color: #94a3b8;
    font-size: 1rem;
    font-family: monospace;
}

/* Two-column Body Layout */
.ai-report-body {
    display: flex;
    gap: 20px;
    flex-grow: 1;
    min-height: 0;
    height: calc(100% - 95px);
    box-sizing: border-box;
}

/* Left Sidebar: Stock Navigation */
.ai-report-sidebar {
    width: 290px;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-sizing: border-box;
}

.ai-sidebar-group-title {
    font-size: 0.82rem;
    font-weight: bold;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 8px 4px 4px 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-sidebar-stock-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.7);
    border: 1.5px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    text-align: left;
    margin-bottom: 2px;
}

.ai-sidebar-stock-btn:hover,
.ai-sidebar-stock-btn:focus {
    background: rgba(51, 65, 85, 0.95);
    border-color: #00d2ff;
    transform: translateX(4px);
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.35);
}

.ai-sidebar-stock-btn.active {
    background: rgba(255, 215, 0, 0.15) !important;
    border-color: #ffd700 !important;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.45) !important;
}

.ai-sidebar-stock-btn.active .stock-btn-sym {
    color: #ffd700;
}

.stock-btn-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stock-btn-slot {
    font-size: 0.70rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
}

.stock-btn-sym {
    font-size: 1.15rem;
    font-weight: bold;
    color: #f8fafc;
    letter-spacing: 0.5px;
}

.stock-btn-name {
    font-size: 0.80rem;
    color: #94a3b8;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stock-btn-active-badge {
    font-size: 0.72rem;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255, 215, 0, 0.25);
    color: #ffd700;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Right Main Area: Comprehensive Stock Report */
.ai-report-content {
    flex-grow: 1;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-right: 8px;
    box-sizing: border-box;
}

.ai-report-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0, 170, 255, 0.08);
    border: 1px solid rgba(0, 170, 255, 0.25);
    border-radius: 8px;
    font-size: 0.95rem;
    color: #cbd5e1;
}

.ai-report-hero-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.ai-hero-sym-area {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.ai-hero-symbol {
    font-size: 2.6rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: 1px;
}

.ai-hero-name {
    font-size: 1.3rem;
    color: #94a3b8;
    font-weight: 500;
}

.ai-hero-score-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-hero-score-pill {
    font-size: 1.8rem;
    font-weight: 900;
    padding: 6px 18px;
    border-radius: 30px;
    color: #000;
}

.ai-hero-rating-text {
    font-size: 1.15rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

.ai-detail-section {
    background: rgba(20, 28, 48, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 16px 20px;
    box-sizing: border-box;
}

.ai-detail-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #00d2ff;
    font-size: 1.18rem;
    font-weight: 700;
    margin: 0 0 10px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-detail-section p {
    font-size: 1.08rem;
    line-height: 1.7;
    color: #e2e8f0;
    margin: 0;
}

.ai-detail-bullet {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 1.08rem;
    line-height: 1.7;
    color: #e2e8f0;
    margin-bottom: 8px;
}

.ai-detail-bullet:last-child {
    margin-bottom: 0;
}

.ai-bullet-dot {
    color: #00d2ff;
    font-weight: bold;
    user-select: none;
}

.ai-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.score-high {
    background-color: #00ff88;
}

.score-mid {
    background-color: #ffcc00;
}

.score-low {
    background-color: #ff4444;
    color: white;
}

/* --- AI Stock Real-Time Quote Banner & Pattern Button --- */
.ai-stock-quote-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.75) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 1px solid rgba(0, 210, 255, 0.25);
    border-radius: 12px;
    padding: 14px 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.quote-banner-left {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.quote-live-price {
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    font-family: monospace;
    letter-spacing: 0.5px;
}

.quote-live-change {
    font-size: 1.25rem;
    font-weight: 800;
    font-family: monospace;
}

.quote-live-change.up {
    color: #22c55e;
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}

.quote-live-change.down {
    color: #ef4444;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.quote-banner-ranges {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 0.95rem;
    color: #cbd5e1;
    flex-wrap: wrap;
}

.quote-range-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.quote-range-label {
    font-size: 0.78rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
}

.quote-range-val {
    font-weight: 700;
    color: #f1f5f9;
    font-family: monospace;
    font-size: 1.05rem;
}

.quote-btn-pattern {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    color: #fff;
    border: 1px solid rgba(56, 189, 248, 0.5);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
    outline: none;
}

.quote-btn-pattern:hover,
.quote-btn-pattern:focus {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.7);
    transform: scale(1.04);
}

/* --- Stock Pattern Modal (4K TV Adaptations) --- */
.intel-stock-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}

.intel-stock-pattern-modal-card {
    background: #0b1120;
    border: 1.5px solid rgba(56, 189, 248, 0.4);
    border-radius: 16px;
    width: 92vw;
    max-width: 1450px;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.9), 0 0 30px rgba(56, 189, 248, 0.2);
    overflow: hidden;
    animation: zoomInModal 0.2s ease-out;
}

.intel-stock-pattern-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 28px;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.intel-stock-pattern-modal-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: 0.5px;
}

.intel-stock-modal-close {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #94a3b8;
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.intel-stock-modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
    color: #fca5a5;
    transform: scale(1.05);
}

.intel-stock-pattern-modal-body {
    padding: 24px 28px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.intel-stock-pattern-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 20px;
    color: #94a3b8;
    font-size: 1.3rem;
}

/* ATR Card */
.sp-atr-card {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.14) 0%, rgba(30, 41, 59, 0.7) 100%);
    border: 1.5px solid rgba(245, 158, 11, 0.4);
    border-radius: 12px;
    padding: 16px 22px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.sp-atr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.sp-atr-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #fbbf24;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sp-atr-val {
    font-size: 1.5rem;
    font-weight: 900;
    color: #ffffff;
    font-family: monospace;
}

.sp-atr-pct {
    font-size: 1.05rem;
    color: #cbd5e1;
    font-weight: 700;
    margin-left: 6px;
}

.sp-atr-desc {
    font-size: 1.05rem;
    color: #cbd5e1;
    line-height: 1.6;
}

.sp-atr-desc b {
    color: #f8fafc;
    font-weight: 700;
}

/* Featured Dominant Pattern Card */
.sp-featured-card {
    background: rgba(15, 23, 42, 0.85);
    border: 1.5px solid rgba(34, 197, 94, 0.45);
    border-radius: 14px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
    position: relative;
}

.sp-featured-card.green {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.12) 0%, rgba(15, 23, 42, 0.9) 100%);
    border-color: rgba(34, 197, 94, 0.5);
}

.sp-featured-card.amber {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(15, 23, 42, 0.9) 100%);
    border-color: rgba(245, 158, 11, 0.45);
}

.sp-f-tag {
    font-size: 0.95rem;
    font-weight: 800;
    color: #22c55e;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sp-f-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.sp-f-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.45rem;
    font-weight: 800;
    color: #ffffff;
}

.sp-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.sp-status-dot.green { background: #22c55e; box-shadow: 0 0 10px #22c55e; }
.sp-status-dot.amber { background: #f59e0b; box-shadow: 0 0 10px #f59e0b; }

.sp-badge {
    font-size: 0.92rem;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 700;
}

.sp-badge.green {
    background: rgba(34, 197, 94, 0.2);
    border: 1px solid rgba(34, 197, 94, 0.5);
    color: #4ade80;
}

.sp-badge.amber {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: #fbbf24;
}

.sp-sentiment {
    font-size: 1.05rem;
    font-weight: 800;
    color: #4ade80;
}

/* Canvas Chart Container */
.sp-chart-container {
    background: #070d19;
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    margin: 14px 0 16px 0;
    padding: 14px 18px;
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.6);
}

.sp-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.05rem;
    font-weight: 700;
    color: #e2e8f0;
    margin-bottom: 10px;
}

.sp-pattern-canvas {
    width: 100%;
    height: 260px;
    min-height: 260px;
    display: block;
    border-radius: 6px;
}

.sp-chart-legend {
    display: flex;
    justify-content: center;
    gap: 28px;
    font-size: 0.98rem;
    color: #94a3b8;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sp-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.sp-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Textbook Schematic Box */
.sp-textbook-box {
    display: flex;
    gap: 16px;
    align-items: center;
    background: rgba(15, 23, 42, 0.75);
    padding: 14px 20px;
    border-radius: 10px;
    margin: 16px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sp-textbook-svg {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sp-textbook-content {
    flex: 1;
}

.sp-textbook-title {
    font-size: 1.12rem;
    font-weight: 800;
    color: #fbbf24;
    margin-bottom: 6px;
}

.sp-textbook-text {
    font-size: 1rem;
    color: #cbd5e1;
    line-height: 1.6;
}

.sp-f-features {
    font-size: 1.05rem;
    color: #cbd5e1;
    line-height: 1.6;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    border-left: 3.5px solid #22c55e;
    margin: 14px 0;
}

.sp-f-features b {
    color: #f8fafc;
}

/* Actionable Trade Blueprint Grid */
.sp-f-levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
}

.sp-lvl-box {
    background: rgba(15, 23, 42, 0.8);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px 14px;
    text-align: center;
}

.sp-lvl-box.breakout { border-color: rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.1); }
.sp-lvl-box.support { border-color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.1); }
.sp-lvl-box.target { border-color: rgba(56, 189, 248, 0.5); background: rgba(56, 189, 248, 0.1); }
.sp-lvl-box.rr { border-color: rgba(245, 158, 11, 0.5); background: rgba(245, 158, 11, 0.1); }

.sp-lvl-t {
    font-size: 0.88rem;
    color: #94a3b8;
    margin-bottom: 5px;
    font-weight: 700;
}

.sp-lvl-box.breakout .sp-lvl-t { color: #4ade80; }
.sp-lvl-box.support .sp-lvl-t { color: #f87171; }
.sp-lvl-box.target .sp-lvl-t { color: #38bdf8; }
.sp-lvl-box.rr .sp-lvl-t { color: #fbbf24; }

.sp-lvl-p {
    font-size: 1.35rem;
    font-weight: 900;
    color: #ffffff;
    font-family: monospace;
}

/* Section Title */
.sp-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 800;
    color: #f8fafc;
    margin: 28px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.1);
}

.sp-section-title i {
    color: #38bdf8;
    font-size: 1.25rem;
}

/* 7 Classic Patterns Grid & Cards (2 Columns on TV) */
.sp-patterns-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.sp-pattern-card {
    background: rgba(15, 23, 42, 0.8);
    border: 1.5px solid rgba(255, 255, 255, 0.09);
    border-radius: 10px;
    padding: 14px 18px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.sp-pattern-card.green {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(15, 23, 42, 0.85) 100%);
    border-color: rgba(34, 197, 94, 0.45);
}

.sp-pattern-card.amber {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(15, 23, 42, 0.85) 100%);
    border-color: rgba(245, 158, 11, 0.4);
}

.sp-pattern-card.gray {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(255, 255, 255, 0.07);
    opacity: 0.9;
}

.sp-p-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sp-p-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    white-space: nowrap;
}

.sp-dot {
    font-size: 0.95rem;
    line-height: 1;
}

.sp-sentiment-inline {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
    white-space: nowrap;
}

.sp-sentiment-inline.green {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.sp-sentiment-inline.amber {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.sp-p-right {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.sp-p-score {
    font-size: 0.95rem;
    color: #94a3b8;
    white-space: nowrap;
}

.sp-p-score b {
    font-size: 1.1rem;
    font-weight: 800;
}

.sp-p-score.green { color: #4ade80; }
.sp-p-score.amber { color: #fbbf24; }
.sp-p-score.gray { color: #94a3b8; }

.sp-p-svg {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 2px 5px;
}

.sp-p-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sp-p-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.98rem;
    line-height: 1.5;
}

.sp-p-lbl {
    color: #94a3b8;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
}

.sp-p-val {
    color: #cbd5e1;
    flex: 1;
}

.sp-p-row.invalid-reason {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid #ef4444;
    padding: 4px 10px;
    border-radius: 4px;
    margin-top: 4px;
}

.sp-p-row.invalid-reason .sp-p-lbl { color: #f87171; }
.sp-p-row.invalid-reason .sp-p-val { color: #fca5a5; }

.sp-p-levels-mini {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.08);
    font-size: 0.95rem;
    color: #94a3b8;
}

.sp-p-levels-mini span b {
    color: #f1f5f9;
    font-family: monospace;
}

.loading-spinner {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #aaa;
    font-size: 1.5rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.1);
    border-top: 5px solid #00aaff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* --- Voice Agent Button --- */
#voice-agent-btn {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    width: 5rem;
    height: 5rem;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    z-index: 4000;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

#voice-agent-btn:hover {
    background-color: rgba(30, 30, 30, 0.8);
    transform: scale(1.1);
    border-color: #00aaff;
}

#voice-agent-btn svg {
    width: 2.5rem;
    height: 2.5rem;
    pointer-events: none;
    z-index: 2;
}

/* Pulse Animation for Listening State */
#voice-agent-btn.listening {
    background-color: rgba(200, 0, 0, 0.8);
    border-color: #ff4444;
    animation: pulse-red 1.5s infinite;
}

#voice-agent-btn.speaking {
    background-color: rgba(0, 80, 200, 0.8);
    border-color: #00aaff;
    animation: pulse-blue 1.5s infinite;
}

.voice-ripple {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid transparent;
    pointer-events: none;
    z-index: 1;
}

#voice-agent-btn.listening .voice-ripple {
    animation: ripple 1.5s linear infinite;
    border-color: rgba(255, 0, 0, 0.5);
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(255, 0, 0, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 0, 0, 0);
    }
}

@keyframes pulse-blue {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 170, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(0, 170, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 170, 255, 0);
    }
}

@keyframes ripple {
    0% {
        width: 100%;
        height: 100%;
        opacity: 1;
    }

    100% {
        width: 200%;
        height: 200%;
        opacity: 0;
    }
}

/* --- West Melon Cartoon (XgCartoon) Modal --- */
#xgcartoon-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68vw;
    max-width: 960px;
    height: auto;
    max-height: 82vh;
    background-color: rgba(18, 18, 24, 0.96);
    border: 2px solid #ff6363;
    border-radius: 1rem;
    padding: 1.2rem 1.8rem;
    box-shadow: 0 0 50px rgba(255, 99, 99, 0.35);
    z-index: 8500;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
    overflow: hidden;
}

#xgcartoon-modal.hidden {
    display: none;
}

/* 隱藏捲動按鍵 (使用者要求不用卷軸及卷軸按鍵) */
.xgcartoon-scroll-button {
    display: none !important;
}

#xgcartoon-title {
    text-align: center;
    font-size: 1.8rem;
    font-weight: bold;
    margin-top: 0;
    margin-bottom: 0.8rem;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 1px;
}

#xgcartoon-channel-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    min-height: 0;
}

#xgcartoon-channel-list li {
    padding: 0.45rem 1rem;
    background: #1f1f28;
    border: 1px solid #333;
    margin-bottom: 0.3rem;
    border-radius: 0.5rem;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 2.6rem;
}

#xgcartoon-channel-list li:last-child {
    margin-bottom: 0;
}

#xgcartoon-channel-list li:hover {
    background: #2d2328;
    border-color: #ff6363;
    color: #fff;
    transform: scale(1.01);
}

.xgcartoon-episodes-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    overflow: hidden;
    padding: 4px;
    flex: 1 1 auto;
    box-sizing: border-box;
}

.xg-ep-btn {
    padding: 0.5rem 0.3rem;
    border-radius: 0.5rem;
    border: 1px solid #444;
    background: #1f1f28;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

.xg-ep-btn:hover {
    border-color: #ff6363;
    background: #2d2328;
    transform: scale(1.02);
}

.xg-ep-btn.last-played {
    border-color: #ff6363;
    background: rgba(255, 99, 99, 0.25);
    color: #ff6363;
    font-weight: bold;
}

/* 西瓜卡通分頁控制欄樣式 (固定於彈窗底部，永不被頂爆) */
.xgcartoon-pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 1px solid #333;
    flex-shrink: 0;
}

.xg-page-info-tag {
    padding: 0.4rem 1rem;
    font-size: 1.05rem;
    color: #ff8a8a;
    background: rgba(255, 99, 99, 0.1);
    border: 1px solid rgba(255, 99, 99, 0.3);
    border-radius: 0.5rem;
    font-weight: bold;
}

.xg-page-button {
    padding: 0.5rem 1.1rem;
    font-size: 1.05rem;
    font-weight: bold;
    background-color: #252525;
    border: 1.5px solid #444;
    color: #ccc;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.xg-page-button:hover:not(:disabled) {
    background-color: #333;
    border-color: #ff6363;
    color: #fff;
}

.xg-page-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: #333;
}

.xg-page-button.active {
    background-color: #ff6363;
    border-color: #ff6363;
    color: #fff;
    cursor: default;
}

/* --- West Melon Cartoon (XgCartoon) Iframe & TV Hint Styles --- */
#xgcartoon-iframe-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: #000;
    z-index: 10 !important;
    /* Higher than event-shield (z-index: 5) so mouse can click ad close button */
    pointer-events: auto !important;
}

#xgcartoon-iframe-player.xgcartoon-force-fullscreen,
.main-video.xgcartoon-force-fullscreen,
.main-video.xgcartoon-force-fullscreen #xgcartoon-player-wrapper,
.main-video.xgcartoon-force-fullscreen #xgcartoon-iframe-player {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    z-index: 99999 !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: #000 !important;
}

/* Floating TV HUD Toolbar for Web Player */
.xgcartoon-tv-bar {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(12, 18, 28, 0.94);
    border: 1px solid rgba(255, 99, 99, 0.45);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.85), 0 0 20px rgba(255, 99, 99, 0.25);
    backdrop-filter: blur(12px);
    border-radius: 6px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100000;
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    pointer-events: auto;
}

.xgcartoon-tv-bar.autohidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-24px);
    pointer-events: none;
}

.xgcartoon-tv-bar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.xgcartoon-tv-bar-badge {
    background: #ff6363;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
}

.xgcartoon-tv-bar-name {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.xgcartoon-tv-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.xgcartoon-tv-bar-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 4px;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.xgcartoon-tv-btn {
    background: #1e293b;
    border: 1px solid #334155;
    color: #f1f5f9;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.xgcartoon-tv-btn.icon-only {
    padding: 0;
    width: 28px;
    height: 28px;
    font-size: 12px;
}

.xgcartoon-tv-btn:hover,
.xgcartoon-tv-btn:focus {
    background: #38bdf8;
    border-color: #38bdf8;
    color: #0b1329;
    outline: none;
}

.xgcartoon-tv-btn.close:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

.xgcartoon-tv-hint {
    display: none !important;
}

.xg-ep-btn:hover {
    background: #ff6363 !important;
    color: #fff !important;
    border-color: #ff6363 !important;
    transform: scale(1.05);
}

/* XgCartoon Player Backdrop & Fallback Card (Prevents Black Screen) */
#xgcartoon-player-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #090d16;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.xgcartoon-backdrop-card {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #111827 0%, #030712 100%);
    padding: 32px;
    text-align: center;
    z-index: 11;
    transition: opacity 0.3s ease;
}

.xgcartoon-backdrop-card.xg-blocked {
    background: radial-gradient(circle at center, #1e111a 0%, #080307 100%);
}

.xg-spin-ring {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 99, 99, 0.2);
    border-top-color: #ff6363;
    border-radius: 50%;
    animation: xg-spin 0.9s linear infinite;
    margin-bottom: 20px;
}

.xgcartoon-backdrop-card.xg-blocked .xg-spin-ring {
    display: none;
}

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

.xg-backdrop-title {
    color: #f8fafc;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 10px;
}

.xg-backdrop-subtitle {
    color: #94a3b8;
    font-size: 14px;
    max-width: 580px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.xg-backdrop-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.xg-action-btn {
    background: #1e293b;
    color: #f1f5f9;
    border: 1px solid #334155;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.xg-action-btn:hover,
.xg-action-btn:focus {
    background: #334155;
    color: #fff;
    border-color: #64748b;
    outline: none;
    transform: translateY(-1px);
}

.xg-action-btn.primary {
    background: linear-gradient(135deg, #e11d48, #be123c);
    border-color: #e11d48;
    color: #fff;
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35);
}

.xg-action-btn.primary:hover {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    box-shadow: 0 6px 20px rgba(225, 29, 72, 0.5);
}

/* --- XgCartoon / YMVID External Link HUD (好過黑色畫面) --- */
.xgcartoon-external-hud {
    position: relative;
    max-width: 640px;
    width: 90%;
    margin: auto;
    padding: 32px 28px;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(8, 12, 22, 0.98));
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 8px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.75), inset 0 0 20px rgba(56, 189, 248, 0.05);
    text-align: center;
    z-index: 15;
    animation: xgHudFadeIn 0.35s ease-out;
}

@keyframes xgHudFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.xg-external-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(14, 165, 233, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: #38bdf8;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 6px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    text-transform: uppercase;
}

.xg-external-badge svg {
    flex-shrink: 0;
}

.xg-external-title {
    color: #f8fafc;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 8px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    word-break: break-word;
}

.xg-external-source {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 20px;
}

.xg-external-count {
    background: #1e293b;
    color: #cbd5e1;
    padding: 2px 8px;
    border-radius: 3px;
    border: 1px solid #334155;
    font-size: 11px;
}

.xg-external-desc {
    display: none !important;
}

.xg-external-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* --- Cartoon Source Badges (西瓜 🍉, 粤漫 粵, Anime1/MP4 A, 外部 🌐) --- */
.cartoon-src-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 4px;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
    user-select: none;
    box-sizing: border-box;
}

.cartoon-src-badge.xg {
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #f87171;
    font-size: 13px;
    padding: 1px 3px;
}

.cartoon-src-badge.ymvid {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.65);
    color: #fbbf24;
    font-family: inherit;
    font-size: 11.5px;
    letter-spacing: 0.5px;
}

.cartoon-src-badge.anime1 {
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.65);
    color: #60a5fa;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 11.5px;
    font-weight: 900;
}

.cartoon-src-badge.other {
    background: rgba(148, 163, 184, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.45);
    color: #94a3b8;
    font-size: 12px;
}

/* 內嵌廣告卡死緊急逃生橫幅 */
.xg-stuck-ad-banner {
    position: absolute;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(251, 191, 36, 0.5);
    border-radius: 6px;
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 30;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    pointer-events: auto;
    animation: xgBannerDrop 0.3s ease-out;
}

@keyframes xgBannerDrop {
    from {
        opacity: 0;
        transform: translate(-50%, -10px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.xg-stuck-ad-text {
    color: #f8fafc;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

/* ==========================================================================
   Flight Radar HUD Overlay (Non-blocking TV screen radar)
   ========================================================================== */
#flight-radar-overlay {
    position: absolute;
    inset: 0;
    z-index: 40;
    background-color: rgba(10, 15, 24, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
    border: 1px solid rgba(0, 229, 255, 0.3);
    box-shadow: inset 0 0 40px rgba(0, 229, 255, 0.15);
}

#flight-radar-overlay.active {
    opacity: 1;
}

#flight-radar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.6rem 0.25rem max(3.5vw, 42px);
    height: 3rem;
    min-height: 40px;
    box-sizing: border-box;
    background: linear-gradient(90deg, rgba(0, 25, 45, 0.98) 0%, rgba(5, 15, 30, 0.95) 100%);
    border-bottom: 1.5px solid rgba(0, 229, 255, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    z-index: 1200;
    white-space: nowrap !important;
    overflow: hidden;
    gap: 0.28rem;
}

#flight-radar-header * {
    white-space: nowrap !important;
}

.flight-radar-title-group {
    display: flex;
    align-items: center;
    gap: 0.28rem;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}

.flight-radar-city-btn {
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.35);
    border-radius: 6px;
    padding: 0.22rem 0.6rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 60 !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
    line-height: 1;
}

.flight-radar-city-btn * {
    pointer-events: none !important;
}

.flight-radar-city-btn:hover,
.flight-radar-city-btn:focus-visible {
    background: rgba(0, 229, 255, 0.25);
    border-color: #00e5ff;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
    transform: translateY(-1px);
}

.flight-radar-city-badge {
    background: rgba(0, 229, 255, 0.2);
    color: #e0f7fa;
    font-size: 0.85rem;
    font-weight: bold;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    border: 1px solid rgba(0, 229, 255, 0.4);
    letter-spacing: 0.5px;
}

.flight-radar-dropdown-arrow {
    color: #00e5ff;
    font-size: 0.65rem;
    transition: transform 0.25s ease;
    opacity: 0.85;
}

.flight-radar-city-btn.open .flight-radar-dropdown-arrow {
    transform: rotate(180deg);
}

/* ==========================================================================
   Flight Radar City Menu (HUD Floating Modal, 4K TV & Anti-Collision)
   ========================================================================== */
.flight-radar-city-menu {
    position: absolute;
    top: 3.3rem;
    left: max(5.2vw, 65px);
    width: 46rem;
    max-width: calc(100vw - max(6vw, 75px));
    max-height: calc(100vh - 4.5rem);
    background: rgba(6, 12, 22, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 2px solid rgba(0, 229, 255, 0.55) !important;
    border-radius: 0.8rem;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.95), 0 0 35px rgba(0, 229, 255, 0.3) !important;
    z-index: 99999 !important;
    pointer-events: auto !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: cityMenuSlideDown 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cityMenuSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.flight-radar-city-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.9rem;
    background: linear-gradient(90deg, rgba(0, 30, 55, 0.9) 0%, rgba(10, 20, 35, 0.85) 100%);
    border-bottom: 1px solid rgba(0, 229, 255, 0.25);
    flex-shrink: 0;
}

.flight-radar-city-menu-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.flight-radar-city-menu-icon {
    font-size: 1.15rem;
}

.flight-radar-city-menu-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #00e5ff;
    letter-spacing: 0.5px;
    text-shadow: 0 0 6px rgba(0, 229, 255, 0.4);
}

.flight-radar-city-menu-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #aaa;
    font-size: 0.9rem;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    outline: none;
}

.flight-radar-city-menu-close:hover,
.flight-radar-city-menu-close:focus {
    background: rgba(255, 60, 60, 0.8);
    border-color: #ff5252;
    color: #fff;
    transform: scale(1.1);
}

/* Category Tabs */
.flight-radar-city-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.45);
    border-bottom: 1px solid rgba(0, 229, 255, 0.2);
    padding: 0.35rem 0.6rem;
    gap: 0.35rem;
    overflow-x: auto;
    flex-shrink: 0;
}

.flight-radar-city-tab {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #b2ebf2;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    outline: none;
}

.flight-radar-city-tab:hover,
.flight-radar-city-tab:focus {
    background: rgba(0, 229, 255, 0.2);
    border-color: #00e5ff;
    color: #fff;
}

.flight-radar-city-tab.active {
    background: rgba(0, 229, 255, 0.3);
    border-color: #00e5ff;
    color: #00e5ff;
    font-weight: 800;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

/* City Grid */
.flight-radar-city-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
    gap: 0.45rem;
    padding: 0.8rem;
    overflow-y: auto;
    max-height: min(65vh, 480px);
    background: rgba(5, 10, 18, 0.7);
}

.flight-radar-city-grid::-webkit-scrollbar {
    width: 6px;
}

.flight-radar-city-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 229, 255, 0.3);
    border-radius: 3px;
}

.flight-radar-city-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(0, 229, 255, 0.18);
    border-radius: 6px;
    padding: 0.45rem 0.65rem;
    color: #e0f7fa;
    font-size: 0.84rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.15s ease;
    outline: none;
    text-align: left;
}

.flight-radar-city-item:hover,
.flight-radar-city-item:focus {
    background: rgba(0, 229, 255, 0.28);
    border-color: #00e5ff;
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.45);
    transform: scale(1.02);
}

.flight-radar-city-item.active {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.35), rgba(0, 150, 255, 0.3));
    border-color: #00e5ff;
    color: #fff;
    font-weight: 800;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
}

.flight-radar-city-item-name {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flight-radar-city-item-iata {
    font-family: Consolas, monospace;
    font-size: 0.75rem;
    color: #80deea;
    background: rgba(0, 0, 0, 0.35);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    border: 1px solid rgba(0, 229, 255, 0.25);
    margin-left: 0.3rem;
}

.flight-radar-city-item.active .flight-radar-city-item-iata {
    color: #00e5ff;
    border-color: #00e5ff;
    background: rgba(0, 229, 255, 0.2);
}

.flight-radar-icon {
    font-size: 1.15rem;
    line-height: 1;
    animation: radarPulse 2s infinite ease-in-out;
    flex-shrink: 0;
}

@keyframes radarPulse {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 2px #00e5ff);
    }

    50% {
        transform: scale(1.12);
        filter: drop-shadow(0 0 8px #00e5ff);
    }
}

.flight-radar-title {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #00e5ff;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
    line-height: 1;
    flex-shrink: 0;
}

.flight-radar-badge {
    background-color: rgba(0, 229, 255, 0.15);
    border: 1px solid #00e5ff;
    color: #e0f7fa;
    padding: 0.12rem 0.38rem;
    border-radius: 1rem;
    font-size: 0.78rem;
    font-weight: bold;
    font-family: Consolas, monospace;
    line-height: 1.2;
    flex-shrink: 0;
}

.flight-radar-status-group {
    display: flex;
    align-items: center;
    gap: 0.22rem;
    flex-shrink: 0;
}

.flight-trail-toggle {
    background: rgba(0, 229, 255, 0.15);
    border: 1px solid #00e5ff;
    color: #00e5ff;
    padding: 0.14rem 0.32rem;
    border-radius: 4px;
    font-size: 0.76rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    line-height: 1.2;
    flex-shrink: 0;
}

/* 響應式：寬度緊湊時智慧隱藏次要輔助文字，確保徽章與功能按鈕零碰撞、零重疊 */
@media (max-width: 1366px) {
    .flight-radar-hint {
        display: none !important;
    }
}
@media (max-width: 1180px) {
    .flight-radar-title {
        display: none !important;
    }
}
@media (max-width: 980px) {
    .flight-radar-time {
        display: none !important;
    }
    .flight-trail-toggle {
        padding: 0.12rem 0.26rem;
        font-size: 0.72rem;
    }
}

.flight-trail-toggle:hover {
    background: rgba(0, 229, 255, 0.35);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.flight-trail-toggle.off {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #888;
}

.flight-radar-time {
    color: #80deea;
    font-family: Consolas, monospace;
    font-size: 0.88rem;
    font-weight: bold;
    line-height: 1;
    flex-shrink: 0;
}

.flight-radar-hint {
    color: #aaa;
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.08);
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    line-height: 1.2;
    flex-shrink: 0;
}

.flight-close-button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    line-height: 1;
}

.flight-close-button:hover {
    background: rgba(255, 60, 60, 0.8);
    border-color: #ff5252;
    transform: scale(1.1);
}

@media (max-width: 1100px) {
    .flight-radar-hint {
        display: none !important;
    }
}

@media (max-width: 950px) {
    .flight-radar-time {
        display: none !important;
    }
}

@media (max-width: 820px) {
    .flight-radar-title {
        display: none !important;
    }
}

#flight-radar-map {
    flex-grow: 1;
    width: 100%;
    height: 100%;
    background-color: #050b14;
}

#flight-radar-map .leaflet-control-container {
    display: none !important;
}

/* 高科技深色雷達地圖濾鏡 (標準 OSM 轉為深色暗黑 HUD 風格) */
#flight-radar-map .leaflet-tile-pane {
    filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3);
}

/* 獨立降雨雷達、氣象連續熱力圖與即時衛星雲圖專用窗格 (保持真實全彩，不套用 OSM 暗黑反轉濾鏡) */
#flight-radar-map .leaflet-pane.leaflet-satellite-pane,
#flight-radar-map .leaflet-pane.leaflet-satellitePane-pane,
#flight-radar-map .leaflet-pane.leaflet-weatherRadarPane-pane,
#flight-radar-map .leaflet-pane.leaflet-weather-radar-pane,
#flight-radar-map .leaflet-pane.leaflet-weatherHeatPane-pane,
#flight-radar-map .leaflet-pane.weather-heat-pane {
    filter: none !important;
}

/* Continuous Weather Heatmap Legend HUD (TV: Bottom right baseline, cleanly to the left of D-Pad) */
.weather-heat-legend-hud {
    position: absolute;
    bottom: 1rem;
    right: calc(1rem + 146px);
    top: auto;
    left: auto;
    z-index: 990;
    background: rgba(10, 16, 26, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    padding: 5px 10px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.75);
    font-family: monospace, system-ui, sans-serif;
    pointer-events: auto;
    user-select: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.weather-heat-legend-title {
    font-size: 10.5px;
    font-weight: 700;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.weather-heat-legend-bar {
    width: 160px;
    height: 7px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.weather-heat-legend-bar.temp {
    background: linear-gradient(to right, #3b0764, #1e3a8a, #0284c7, #0ea5e9, #14b8a6, #22c55e, #eab308, #f97316, #ef4444, #9f1239);
}

.weather-heat-legend-bar.wind {
    background: linear-gradient(to right, rgba(6,182,212,0.25), #10b981, #84cc16, #f59e0b, #f97316, #ef4444, #d946ef, #ff0080);
}

.weather-heat-legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 8.5px;
    color: #94a3b8;
    font-weight: 600;
}

@media (max-width: 820px) {
    .weather-heat-legend-hud {
        bottom: calc(1rem + 95px);
        right: 1rem;
    }
}

/* 頂部氣象與衛星 Emoji 按鈕微調 (小巧省空間) */
#flight-radar-daynight-btn,
#flight-radar-weather-btn,
#flight-radar-temp-btn,
#flight-radar-wind-btn,
#flight-radar-satellite-btn,
#flight-radar-closures-btn,
#flight-radar-camera511-btn,
#flight-radar-events511-btn,
#flight-radar-311-btn {
    font-size: 0.88rem;
    padding: 0.14rem 0.32rem;
    line-height: 1.1;
}

#flight-radar-weather-btn:not(.off) {
    background: rgba(0, 229, 255, 0.25);
    border-color: #00e5ff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

#flight-radar-temp-btn:not(.off) {
    background: rgba(249, 115, 22, 0.25);
    border-color: #f97316;
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.6);
}

#flight-radar-wind-btn:not(.off) {
    background: rgba(16, 185, 129, 0.25);
    border-color: #10b981;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

#flight-radar-satellite-btn:not(.off) {
    background: rgba(179, 136, 255, 0.25);
    border-color: #b388ff;
    box-shadow: 0 0 10px rgba(179, 136, 255, 0.6);
}

/* Open-Meteo Weather Markers & Dark Popup (TV & Mobile) */
.weather-marker-container {
    background: transparent !important;
    border: none !important;
}

.weather-temp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2.5px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.25);
    white-space: nowrap;
    cursor: pointer;
    backdrop-filter: blur(4px);
    user-select: none;
    line-height: 1.15;
    transition: transform 0.15s ease;
}
.weather-temp-badge:hover {
    transform: scale(1.1);
}
.weather-temp-badge.freeze {
    background: rgba(14, 165, 233, 0.92);
    border-color: #38bdf8;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}
.weather-temp-badge.cool {
    background: rgba(20, 184, 166, 0.92);
    border-color: #2dd4bf;
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.5);
}
.weather-temp-badge.mild {
    background: rgba(34, 197, 94, 0.92);
    border-color: #4ade80;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}
.weather-temp-badge.warm {
    background: rgba(245, 158, 11, 0.92);
    border-color: #fbbf24;
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.6);
}
.weather-temp-badge.hot {
    background: rgba(239, 68, 68, 0.92);
    border-color: #f87171;
    box-shadow: 0 0 8px rgba(248, 113, 113, 0.7);
}

.weather-wind-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2.5px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #ffffff;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.25);
    white-space: nowrap;
    cursor: pointer;
    backdrop-filter: blur(4px);
    user-select: none;
    line-height: 1.15;
    transition: transform 0.15s ease;
}
.weather-wind-badge:hover {
    transform: scale(1.1);
}
.weather-wind-badge .wind-arrow {
    display: inline-block;
    font-size: 10px;
    line-height: 1;
    transform-origin: center center;
}
.weather-wind-badge.light {
    background: rgba(16, 185, 129, 0.92);
    border-color: #34d399;
}
.weather-wind-badge.moderate {
    background: rgba(234, 179, 8, 0.92);
    border-color: #fde047;
    color: #0f172a;
}
.weather-wind-badge.strong {
    background: rgba(249, 115, 22, 0.92);
    border-color: #fb923c;
}
.weather-wind-badge.gale {
    background: rgba(225, 29, 72, 0.95);
    border-color: #f43f5e;
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.7);
}

.weather-dark-popup .leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.95) !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    border-radius: 4px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(8px) !important;
    color: #f1f5f9 !important;
    padding: 6px !important;
}
.weather-dark-popup .leaflet-popup-content {
    margin: 4px 6px !important;
    line-height: 1.4 !important;
}
.weather-dark-popup .leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.95) !important;
}

/* Plane Marker & SVG (電視極致效能調優：移除 GPU Shader 濾鏡與圖層負擔) */
.flight-plane-marker {
    background: transparent !important;
    border: none !important;
    contain: layout style;
}

.flight-marker-inner {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 移除 will-change 與 transition，消除電視多重 GPU 圖層與旋轉過渡的過載 */
    transform: translateZ(0);
}

.flight-plane-svg {
    width: 26px;
    height: 26px;
    filter: none !important; /* 徹底消除常規客機的模糊濾鏡，零 GPU Shader 負擔 */
}

/* 常規客機、直升機、警務、救難、軍用等均使用 SVG 自帶高對比描邊，免除電視即時模糊運算 */
.flight-plane-svg.flight-heli-svg,
.flight-plane-svg.police-svg,
.flight-plane-svg.rescue-svg,
.flight-plane-svg.military-svg,
.flight-plane-svg.fire-svg,
.flight-plane-svg.ground-svg,
.flight-plane-svg.flight-ground-svg {
    filter: none !important;
}

/* 僅有極少數特級國家專機（空軍一號等）保留醒目金色/紅寶石發光光暈 (全空域僅 0~1 架，對電視零負擔) */
.flight-plane-svg.vip-potus-svg {
    filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.9)) !important;
}

.flight-plane-svg.vip-family-svg {
    filter: drop-shadow(0 0 6px rgba(255, 64, 129, 0.9)) !important;
}

.flight-plane-svg.vip-vpotus-svg {
    filter: drop-shadow(0 0 6px rgba(179, 136, 255, 0.9)) !important;
}

.flight-marker-label {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(5, 15, 25, 0.92);
    border: 1px solid rgba(0, 229, 255, 0.5);
    color: #fff;
    font-size: 0.72rem;
    font-weight: bold;
    font-family: Consolas, monospace;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    display: flex;
    gap: 3px;
    align-items: center;
}

/* 當縮小檢視全空域時 (Zoom <= 8，空域飛機多達上百架)，自動隱藏常規客機文字標籤，大幅減免 60% DOM 重排與繪製開銷 */
#flight-radar-map.radar-zoom-out .flight-plane-marker .flight-marker-label:not(.vip-potus-label):not(.vip-family-label):not(.vip-vpotus-label):not(.vip-potus):not(.vip-family):not(.vip-vpotus):not(.special):not(.military-label):not(.rescue-label):not(.police-label):not(.fire-label) {
    display: none !important;
}

/* 直升機專屬金色標籤 */
.flight-marker-label.heli-label {
    border-color: rgba(255, 179, 0, 0.85) !important;
    background: rgba(25, 18, 5, 0.92) !important;
}

/* 警務直升機標籤 */
.flight-marker-label.police-label {
    border-color: #2979ff !important;
    background: rgba(6, 18, 38, 0.94) !important;
    box-shadow: 0 0 8px rgba(41, 121, 255, 0.5) !important;
}

/* STARS 緊急救護標籤 */
.flight-marker-label.rescue-label {
    border-color: #ff1744 !important;
    background: rgba(36, 6, 12, 0.94) !important;
    box-shadow: 0 0 8px rgba(255, 23, 68, 0.5) !important;
}

/* 皇家空軍/美軍軍機專屬超鮮亮螢光綠標籤 (高對比黑底+粗體霓虹綠，徹底避免與背景混淆) */
.flight-marker-label.military-label {
    border: 1.5px solid #00ff66 !important;
    background: rgba(0, 20, 8, 0.96) !important;
    box-shadow: 0 0 14px rgba(0, 255, 102, 0.85), 0 2px 6px rgba(0, 0, 0, 0.95) !important;
}

.flight-marker-label.military-label .flight-callsign-text {
    color: #00ff66 !important;
    font-weight: 900 !important;
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.9);
}

.flight-marker-label.military-label .flight-alt-sub {
    color: #69f0ae !important;
    font-weight: 700 !important;
}

/* 野火撲救標籤 */
.flight-marker-label.fire-label {
    border-color: #ff9100 !important;
    background: rgba(32, 14, 4, 0.94) !important;
    box-shadow: 0 0 8px rgba(255, 145, 0, 0.5) !important;
}

/* 機場地面特勤/巡場車輛標籤 */
.flight-marker-label.ground-label {
    border-color: #ffb300 !important;
    background: rgba(26, 18, 0, 0.94) !important;
    box-shadow: 0 0 8px rgba(255, 179, 0, 0.5) !important;
}

.flight-marker-label.ground-label .flight-callsign-text {
    color: #ffd54f !important;
}

/* 總統座機標籤 (高貴黑金+立體光暈) */
.flight-marker-label.vip-potus-label {
    border: 1.5px solid #ffd700 !important;
    background: rgba(32, 26, 0, 0.96) !important;
    box-shadow: 0 0 14px rgba(255, 215, 0, 0.85), 0 2px 6px rgba(0, 0, 0, 0.95) !important;
}
.flight-marker-label.vip-potus-label .flight-callsign-text {
    color: #ffd700 !important;
    font-weight: 900 !important;
}

/* 第一家庭標籤 (優雅深粉紅寶石) */
.flight-marker-label.vip-family-label {
    border: 1.5px solid #ff4081 !important;
    background: rgba(38, 0, 16, 0.96) !important;
    box-shadow: 0 0 14px rgba(255, 64, 129, 0.85), 0 2px 6px rgba(0, 0, 0, 0.95) !important;
}
.flight-marker-label.vip-family-label .flight-callsign-text {
    color: #ff80ab !important;
    font-weight: 900 !important;
}

/* 副總統座機標籤 (尊貴亮紫金) */
.flight-marker-label.vip-vpotus-label {
    border: 1.5px solid #b388ff !important;
    background: rgba(24, 10, 40, 0.96) !important;
    box-shadow: 0 0 14px rgba(179, 136, 255, 0.85), 0 2px 6px rgba(0, 0, 0, 0.95) !important;
}
.flight-marker-label.vip-vpotus-label .flight-callsign-text {
    color: #d1c4e9 !important;
    font-weight: 900 !important;
}

.flight-ground-svg,
.ground-svg {
    filter: drop-shadow(0 0 5px #ffb300) drop-shadow(0 0 2px #000) !important;
}

.flight-special-tag {
    font-size: 0.8rem;
    margin-right: 1px;
    line-height: 1;
}

.flight-popup-special-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 9px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 0.82rem;
    font-weight: 700;
}

.flight-popup-special-banner span {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    display: inline-flex;
    align-items: center;
}

.flight-popup-special-banner strong {
    white-space: normal;
    word-break: break-word;
    flex: 1;
}

.flight-flag-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 2px;
    vertical-align: middle;
    flex-shrink: 0;
}

.flight-flag-svg,
.flight-flag-img {
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    vertical-align: middle;
    display: inline-block;
}

.flight-flag-emoji {
    font-size: 0.95rem;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.7));
}

.flight-flag-text {
    font-size: 0.65rem;
    font-weight: bold;
    color: #ffd54f;
}

.flight-heli-tag {
    font-size: 0.8rem;
    margin-right: 1px;
}

.flight-callsign-text {
    letter-spacing: 0.5px;
}

.flight-alt-sub {
    color: #ffeb3b;
    font-size: 0.68rem;
}

/* Popup Content */
.flight-custom-popup .leaflet-popup-content-wrapper {
    background: rgba(8, 18, 32, 0.96) !important;
    border: 1px solid #00e5ff !important;
    color: #fff !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 25px rgba(0, 229, 255, 0.45) !important;
    padding: 0 !important;
}

.flight-custom-popup .leaflet-popup-tip {
    background: #081220 !important;
}

.flight-popup-content {
    padding: 10px 14px;
    font-size: 0.95rem;
    min-width: 240px;
    max-width: 320px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft JhengHei", Consolas, monospace;
}

.flight-popup-callsign {
    font-size: 1.2rem;
    font-weight: bold;
    color: #00e5ff;
    border-bottom: 1px solid rgba(0, 229, 255, 0.3);
    padding-bottom: 5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.flight-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin: 4px 0;
    color: #b0bec5;
    font-size: 0.9rem;
}

.flight-popup-row strong {
    color: #fff;
    text-align: right;
    max-width: 70%;
    word-break: break-word;
    line-height: 1.3;
}

.flight-popup-model-row {
    align-items: flex-start;
}

.flight-popup-model-row strong {
    font-size: 0.92rem;
    color: #e0e7ff;
}

.flight-popup-route {
    background: rgba(0, 229, 255, 0.12);
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px dashed rgba(0, 229, 255, 0.4);
    margin: 8px 0 !important;
    align-items: center;
}

.route-highlight {
    color: #00e5ff !important;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 1px;
}

/* 飛機真機照片展示區塊 */
.flight-popup-photo-box {
    width: 100%;
    margin-bottom: 8px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.4);
    min-height: 75px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 229, 255, 0.2);
}

.flight-photo-wrapper {
    position: relative;
    width: 100%;
}

.flight-photo-img {
    width: 100%;
    max-height: 140px;
    object-fit: cover;
    display: block;
    border-radius: 5px;
}

.flight-photo-credit {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.2) 70%, transparent);
    color: #cfd8dc;
    font-size: 0.65rem;
    padding: 3px 6px;
    text-align: right;
    letter-spacing: 0.5px;
}

.flight-photo-placeholder {
    font-size: 0.8rem;
    color: #90a4ae;
    padding: 16px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.flight-photo-spinner {
    display: inline-block;
    animation: flight-spin 1.5s infinite linear;
}

@keyframes flight-spin {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-3px);
    }

    100% {
        transform: translateY(0);
    }
}

.flight-photo-fallback {
    width: 100%;
    height: 60px;
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.08), rgba(0, 0, 0, 0.5));
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 5px;
}

.fallback-icon {
    font-size: 1.5rem;
}

.fallback-model {
    font-size: 0.95rem;
    font-weight: bold;
    color: #00e5ff;
    letter-spacing: 0.5px;
    text-align: center;
    padding: 0 10px;
    line-height: 1.25;
}

/* 起飛/降落機場地圖圖釘 */
.flight-airport-marker-wrapper {
    background: transparent !important;
    border: none !important;
}

.flight-airport-pin {
    background: rgba(12, 22, 38, 0.94);
    border: 1.5px solid #ffd54f;
    border-radius: 12px;
    padding: 2px 8px;
    color: #ffd54f;
    font-size: 0.75rem;
    font-weight: bold;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    display: inline-block;
}

.flight-dest-pin {
    border-color: #00e5ff !important;
    color: #00e5ff !important;
}

/* ==========================================================================
   Flight Radar Floating Info Card (Bottom-Left HUD Panel)
   Leaves Bottom-Right D-PAD (at bottom: 1rem; right: 1rem) 100% Unobstructed
   ========================================================================== */
.flight-radar-info-panel {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    width: 330px;
    max-width: calc(100% - 240px);
    max-height: calc(100vh - 5.5rem);
    z-index: 1000;
    background: rgba(10, 20, 35, 0.88);
    border: 1.5px solid rgba(0, 229, 255, 0.45);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.75), 0 0 16px rgba(0, 229, 255, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #e0e7ff;
    font-size: 0.9rem;
    animation: fadeInSlideLeft 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

@keyframes fadeInSlideLeft {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.flight-radar-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.8rem;
    background: rgba(0, 229, 255, 0.08);
    border-bottom: 1px solid rgba(0, 229, 255, 0.25);
}

.flight-radar-info-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    color: #00e5ff;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.flight-radar-info-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    transition: all 0.2s;
}

.flight-radar-info-close-btn:hover {
    background: rgba(239, 68, 68, 0.8);
    border-color: #ef4444;
    color: #fff;
    transform: scale(1.1);
}

.flight-radar-info-body {
    padding: 0.75rem 0.85rem;
    overflow-y: auto;
    max-height: calc(100vh - 9.5rem);
}

.flight-radar-info-body::-webkit-scrollbar {
    width: 4px;
}
.flight-radar-info-body::-webkit-scrollbar-thumb {
    background: rgba(0, 229, 255, 0.4);
    border-radius: 4px;
}

/* ==========================================================================
   Flight Radar Navigation & Zoom Controls (Bottom-Right HUD Control Bar)
   ========================================================================== */
.flight-radar-nav-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    left: auto;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.45rem;
    background: rgba(8, 16, 28, 0.65);
    border: 1.5px solid rgba(0, 229, 255, 0.45);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(0, 229, 255, 0.18);
    user-select: none;
    -webkit-user-select: none;
    transition: all 0.25s ease;
    opacity: 0.9;
}

.flight-radar-nav-controls:hover {
    opacity: 1;
    background: rgba(8, 16, 28, 0.85);
    border-color: rgba(0, 229, 255, 0.75);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.75), 0 0 18px rgba(0, 229, 255, 0.35);
}

.flight-radar-dpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.flight-radar-dpad-middle {
    display: flex;
    align-items: center;
    gap: 2px;
}

.flight-radar-ctrl-btn {
    width: 1.25rem;
    height: 1.25rem;
    min-width: 26px;
    min-height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 229, 255, 0.14);
    border: 1px solid rgba(0, 229, 255, 0.35);
    color: #00e5ff;
    font-size: 0.7rem;
    font-weight: bold;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1;
    padding: 0;
    outline: none;
}

.flight-radar-ctrl-btn:hover,
.flight-radar-ctrl-btn:focus-visible {
    background: rgba(0, 229, 255, 0.4);
    border-color: #00e5ff;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
    transform: scale(1.08);
}

.flight-radar-ctrl-btn:active {
    background: rgba(0, 229, 255, 0.65);
    transform: scale(0.95);
}

.flight-radar-recenter-btn {
    font-size: 0.7rem;
    background: rgba(255, 213, 79, 0.14);
    border-color: rgba(255, 213, 79, 0.4);
    color: #ffd54f;
}

.flight-radar-recenter-btn:hover,
.flight-radar-recenter-btn:focus-visible {
    background: rgba(255, 213, 79, 0.4);
    border-color: #ffd54f;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(255, 213, 79, 0.6);
}

.flight-radar-ctrl-divider {
    width: 1px;
    height: 2.8rem;
    background: linear-gradient(to bottom, transparent, rgba(0, 229, 255, 0.4), transparent);
    margin: 0 2px;
}

.flight-radar-zoom-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.flight-radar-zoom-btn {
    font-size: 0.95rem;
    font-family: Consolas, monospace;
    font-weight: 800;
}

/* 當航空雷達或 KTV 模式開啟時，隱藏並禁用左側切台選單區與右下角設置按鈕區域以防遮擋/誤觸 */
body.flight-radar-active #settings-button-area,
body.flight-radar-active #channel-switcher-area,
body.flight-radar-active #channel-switcher-menu,
body.ktv-open #settings-button-area,
body.ktv-open #channel-switcher-area,
body.ktv-open #channel-switcher-menu,
html.ktv-open #settings-button-area,
html.ktv-open #channel-switcher-area,
html.ktv-open #channel-switcher-menu {
    display: none !important;
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(-50%) translateX(-100%) !important;
}

/* ==========================================================================
   Train Radar HUD & Markers (加拿大 / 曼尼托巴 Manitoba 火車實時追蹤圖層)
   ========================================================================== */
.flight-train-badge {
    background-color: rgba(255, 179, 0, 0.15) !important;
    border-color: #ffd54f !important;
    color: #fff8e1 !important;
}

.flight-train-btn {
    background: rgba(255, 179, 0, 0.15) !important;
    border-color: #ffd54f !important;
    color: #ffd54f !important;
}

.flight-train-btn:hover {
    background: rgba(255, 179, 0, 0.35) !important;
    box-shadow: 0 0 10px rgba(255, 213, 79, 0.6) !important;
}

.flight-train-btn.off {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: #888 !important;
}

/* Leaflet DivIcon Wrapper for Train */
.train-custom-leaflet-icon {
    background: transparent !important;
    border: none !important;
}

.flight-train-marker {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.train-marker-core {
    position: relative;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(10, 18, 30, 0.92);
    border: 2px solid #38bdf8;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
    transition: all 0.3s ease;
}

.train-marker-mb .train-marker-core {
    border-color: #ffd54f !important;
    box-shadow: 0 0 12px rgba(255, 213, 79, 0.85) !important;
    animation: trainPulseMB 2.2s infinite ease-in-out;
}

@keyframes trainPulseMB {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 8px rgba(255, 213, 79, 0.7);
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 18px rgba(255, 213, 79, 1);
    }
}

.train-icon-rotate {
    position: absolute;
    inset: -6px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    pointer-events: none;
    transition: transform 0.6s ease;
}

.train-arrow-svg {
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.9));
}

.train-emoji-icon {
    font-size: 0.95rem;
    line-height: 1;
    z-index: 2;
    transform: translateY(-1px);
}

.train-marker-label {
    position: absolute;
    top: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(6, 14, 24, 0.92);
    border: 1px solid rgba(56, 189, 248, 0.7);
    color: #e0f2fe;
    font-size: 0.72rem;
    font-weight: bold;
    font-family: Consolas, monospace;
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
    display: flex;
    gap: 3px;
    align-items: center;
    z-index: 10;
}

.train-marker-label.train-label-mb {
    border-color: rgba(255, 213, 79, 0.85);
    background: rgba(22, 16, 5, 0.94);
    color: #fff8e1;
}

.train-mb-tag {
    background: #ffd54f;
    color: #000;
    font-weight: 900;
    font-size: 0.6rem;
    padding: 0 3px;
    border-radius: 2px;
    line-height: 1.1;
    letter-spacing: -0.2px;
}

.train-no-text {
    letter-spacing: 0.3px;
}

.train-speed-sub {
    color: #69f0ae;
    font-size: 0.65rem;
}

/* Train Popup Styles */
.train-custom-popup .leaflet-popup-content-wrapper {
    border-color: #ffd54f !important;
    box-shadow: 0 4px 25px rgba(255, 213, 79, 0.4) !important;
}

.train-popup-content {
    min-width: 260px;
    max-width: 330px;
}

.train-status-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    margin-left: auto;
    white-space: nowrap;
}

.train-status-badge.on-time {
    background: rgba(0, 230, 118, 0.15);
    color: #69f0ae;
    border: 1px solid rgba(0, 230, 118, 0.4);
}

.train-status-badge.delayed-slight {
    background: rgba(255, 179, 0, 0.18);
    color: #ffd54f;
    border: 1px solid rgba(255, 179, 0, 0.45);
}

.train-status-badge.delayed-heavy {
    background: rgba(244, 67, 54, 0.2);
    color: #ff5252;
    border: 1px solid rgba(244, 67, 54, 0.5);
}

.train-next-station-row strong {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.train-eta-badge {
    background: rgba(0, 229, 255, 0.15);
    color: #00e5ff;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.72rem;
    font-family: Consolas, monospace;
}

.train-schedule-section {
    margin-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
    padding-top: 6px;
}

.train-schedule-title {
    font-size: 0.78rem;
    color: #90a4ae;
    margin-bottom: 4px;
    font-weight: 600;
}

.train-schedule-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 120px;
    overflow-y: auto;
}

.train-schedule-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    padding: 2px 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.04);
    color: #cfd8dc;
}

.train-schedule-item.train-mb-station {
    background: rgba(255, 213, 79, 0.14);
    color: #ffd54f;
    border-left: 2.5px solid #ffd54f;
    font-weight: 600;
}

.train-station-eta {
    font-family: Consolas, monospace;
    color: #80deea;
    font-size: 0.74rem;
}

/* ==========================================================================
   Winnipeg Transit Bus Radar HUD & Markers (溫尼伯巴士與站點雷達圖層)
   ========================================================================== */
.flight-bus-badge {
    background-color: rgba(0, 230, 118, 0.15) !important;
    border-color: #69f0ae !important;
    color: #e8f5e9 !important;
}

.flight-bus-btn {
    background: rgba(0, 230, 118, 0.15) !important;
    border-color: #69f0ae !important;
    color: #69f0ae !important;
}

.flight-bus-btn:hover {
    background: rgba(0, 230, 118, 0.35) !important;
    box-shadow: 0 0 10px rgba(105, 240, 174, 0.6) !important;
}

.flight-bus-btn.off {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: #888 !important;
}

/* Bus Leaflet DivIcon Wrappers */
.bus-custom-leaflet-icon,
.bus-vehicle-leaflet-icon {
    background: transparent !important;
    border: none !important;
}

/* 巴士站點標記 */
.flight-bus-stop-marker {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.bus-stop-pin {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(8, 20, 26, 0.92);
    border: 1.5px solid #69f0ae;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    box-shadow: 0 0 6px rgba(105, 240, 174, 0.5);
    transition: all 0.2s ease;
}

.flight-bus-stop-marker.urgent-stop .bus-stop-pin {
    border-color: #ffd54f !important;
    box-shadow: 0 0 10px rgba(255, 213, 79, 0.85) !important;
    animation: busStopPulse 2s infinite ease-in-out;
}

@keyframes busStopPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
        box-shadow: 0 0 14px rgba(255, 213, 79, 1);
    }
}

.bus-stop-label {
    position: absolute;
    top: 26px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(6, 16, 24, 0.94);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(105, 240, 174, 0.5);
    color: #e8f5e9;
    font-size: 0.68rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Consolas, monospace;
    padding: 2px 5px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    z-index: 50;
}

.stop-num {
    color: #69f0ae;
    font-weight: 800;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    line-height: 1.1;
}

.bus-eta-pills-row {
    display: flex;
    align-items: center;
    gap: 3px;
}

.bus-live-pill {
    display: inline-flex;
    align-items: center;
    gap: 2.5px;
    background: rgba(0, 229, 255, 0.15);
    border: 1px solid rgba(0, 229, 255, 0.4);
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 0.65rem;
    line-height: 1.2;
}

.bus-live-pill .pill-rt {
    font-weight: 800;
    color: #00e5ff;
}

.bus-live-pill .pill-time {
    color: #ffffff;
    font-weight: bold;
}

.bus-live-pill.urgent {
    background: rgba(255, 213, 79, 0.25);
    border-color: #ffd54f;
    box-shadow: 0 0 6px rgba(255, 213, 79, 0.4);
}

.bus-live-pill.urgent .pill-rt {
    color: #ffe082;
}

.bus-live-pill.urgent .pill-time {
    color: #ffeb3b;
    font-weight: 800;
}

.bus-live-pill.target {
    border-color: #ff9100;
    box-shadow: 0 0 5px rgba(255, 145, 0, 0.6);
}

.bus-pill-more {
    font-size: 0.6rem;
    color: #90a4ae;
    font-weight: bold;
    padding: 0 1px;
}

/* 巴士車輛標記 (Option 2 關注路線或接近中巴士) */
.flight-bus-vehicle-marker {
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.bus-vehicle-core {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(10, 20, 32, 0.95);
    border: 2px solid #00e5ff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.6);
}

.flight-bus-vehicle-marker.target-bus .bus-vehicle-core {
    border-color: #ffd54f !important;
    box-shadow: 0 0 12px rgba(255, 213, 79, 0.9) !important;
}

.bus-emoji {
    font-size: 0.9rem;
    line-height: 1;
}

.bus-vehicle-label {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(6, 14, 24, 0.92);
    border: 1px solid #00e5ff;
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    font-family: Consolas, monospace;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    display: flex;
    gap: 3px;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
    pointer-events: none;
    z-index: 10;
}

.bus-route-tag {
    color: #00e5ff;
}

.flight-bus-vehicle-marker.target-bus .bus-route-tag {
    color: #ffd54f !important;
}

.bus-eta-tag {
    color: #69f0ae;
    font-size: 0.65rem;
}

/* Bus Popup Styles */
.bus-custom-popup .leaflet-popup-content-wrapper {
    border-color: #69f0ae !important;
    box-shadow: 0 4px 25px rgba(105, 240, 174, 0.4) !important;
}

.bus-popup-content {
    min-width: 270px;
    max-width: 340px;
}

.stop-key-badge {
    font-size: 0.75rem;
    background: rgba(105, 240, 174, 0.2);
    color: #69f0ae;
    border: 1px solid rgba(105, 240, 174, 0.4);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: auto;
}

.target-flag-tag {
    font-size: 0.72rem;
    background: rgba(255, 213, 79, 0.2);
    color: #ffd54f;
    border: 1px solid rgba(255, 213, 79, 0.5);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: auto;
}

.bus-arrivals-section {
    margin-top: 8px;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
    padding-top: 6px;
}

.bus-arrivals-title {
    font-size: 0.8rem;
    color: #90a4ae;
    margin-bottom: 4px;
    font-weight: 600;
}

.bus-arrivals-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 190px;
    overflow-y: auto;
}

.bus-arrival-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.8rem;
}

.bus-arrival-row.target-route-row {
    background: rgba(255, 213, 79, 0.12);
    border-left: 2.5px solid #ffd54f;
}

.bus-route-badge {
    background: rgba(0, 229, 255, 0.2);
    border: 1px solid #00e5ff;
    color: #00e5ff;
    font-family: Consolas, monospace;
    font-weight: 800;
    font-size: 0.82rem;
    padding: 1px 5px;
    border-radius: 3px;
    min-width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.bus-route-badge.target-badge {
    background: rgba(255, 213, 79, 0.25);
    border-color: #ffd54f;
    color: #ffd54f;
}

.bus-dest-info {
    flex-grow: 1;
    overflow: hidden;
}

.bus-dest-name {
    font-weight: 600;
    color: #e0f2fe;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bus-dest-meta {
    font-size: 0.72rem;
    color: #90a4ae;
    display: flex;
    align-items: center;
    gap: 4px;
}

.bus-local-time {
    font-family: Consolas, monospace;
    color: #80deea;
}

.bus-cd-wrapper {
    flex-shrink: 0;
}

.bus-cd-badge {
    font-family: Consolas, monospace;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 3px;
    white-space: nowrap;
}

.bus-cd-badge.arriving {
    background: rgba(255, 82, 82, 0.25);
    border: 1px solid #ff5252;
    color: #ff5252;
    animation: busArrivingPulse 1.5s infinite;
}

@keyframes busArrivingPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.bus-cd-badge.imminent {
    background: rgba(255, 213, 79, 0.2);
    border: 1px solid #ffd54f;
    color: #ffd54f;
}

.bus-cd-badge.standard {
    background: rgba(0, 230, 118, 0.15);
    border: 1px solid #69f0ae;
    color: #69f0ae;
}

.bus-arrivals-empty {
    padding: 8px;
    color: #90a4ae;
    font-size: 0.8rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
}

/* Ensure touch tolerance and pointer cursor on interactive vector layers */
#flight-radar-map path.leaflet-interactive {
    cursor: pointer !important;
    touch-action: manipulation !important;
}

/* Road Closure Popup Styles (TV & Mobile S23U Responsive Single-Line Marquee) */
.road-closure-popup .leaflet-popup-content-wrapper {
    background: rgba(14, 18, 30, 0.96) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border: 1px solid rgba(255, 145, 0, 0.5) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.85), 0 0 20px rgba(255, 145, 0, 0.22) !important;
    color: #ffffff !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.road-closure-popup .leaflet-popup-content {
    margin: 10px 12px !important;
    width: auto !important;
    line-height: 1 !important;
}

.road-closure-card {
    min-width: 270px;
    max-width: 360px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei", sans-serif;
    user-select: none;
    box-sizing: border-box;
}

/* S23 Ultra & Mobile Screen Optimization */
@media (max-width: 500px) {
    .road-closure-card {
        min-width: 250px;
        max-width: 305px;
    }
}

.road-closure-popup .leaflet-popup-close-button {
    top: 6px !important;
    right: 8px !important;
    width: 26px !important;
    height: 26px !important;
    color: #b0bec5 !important;
    font-size: 20px !important;
    line-height: 24px !important;
    text-align: center !important;
    padding: 0 !important;
    z-index: 50 !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 50% !important;
    transition: all 0.2s ease !important;
}

.road-closure-popup .leaflet-popup-close-button:hover,
.road-closure-popup .leaflet-popup-close-button:active {
    color: #ffffff !important;
    background: rgba(244, 67, 54, 0.8) !important;
    transform: scale(1.1) !important;
}

.rc-header-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 7px;
    padding-right: 32px; /* 徹底杜絕遮蔽 X 關閉鍵 */
    height: 24px;
    line-height: 24px;
}

.rc-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.rc-badge.complete {
    background: #d50000;
    color: #ffffff;
    border: 1px solid #ff1744;
    box-shadow: 0 0 10px rgba(255, 23, 68, 0.45);
}

.rc-badge.partial {
    background: #e65100;
    color: #ffffff;
    border: 1px solid #ff9100;
    box-shadow: 0 0 10px rgba(255, 145, 0, 0.35);
}

.rc-item-row {
    display: flex;
    align-items: center;
    height: 24px;
    line-height: 24px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    width: 100%;
}

.rc-effect-multiline-row {
    display: flex;
    align-items: flex-start;
    height: auto;
    min-height: 26px;
    margin-bottom: 4px;
    white-space: normal;
    overflow: visible;
    width: 100%;
}

.rc-multiline-content {
    flex: 1;
    min-width: 0;
    white-space: normal;
    word-break: break-word;
    line-height: 1.35;
    font-size: 0.8rem;
    color: #e0e6ed;
    background: rgba(255, 255, 255, 0.06);
    padding: 4px 7px;
    border-radius: 4px;
    border-left: 2px solid #ff9100;
    max-height: 85px;
    overflow-y: auto;
    user-select: text;
}

.rc-multiline-content::-webkit-scrollbar {
    width: 4px;
}

.rc-multiline-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.rc-last-row {
    margin-bottom: 0;
}

.rc-item-label {
    flex-shrink: 0;
    width: 58px;
    font-size: 0.74rem;
    color: #90a4ae;
    font-weight: 600;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.rc-marquee-box {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    mask-image: linear-gradient(to right, black calc(100% - 10px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 10px), transparent 100%);
}

.rc-marquee-content {
    display: inline-block;
    white-space: nowrap;
    font-size: 0.82rem;
    color: #eceff1;
    will-change: transform;
}

.rc-road-name {
    color: #ffffff;
    font-weight: 700;
}

.rc-date-text {
    color: #ffd54f;
    font-weight: 600;
}

.rc-marquee-content.is-overflowing {
    animation: rcPingPongMarquee var(--marquee-dur, 8s) ease-in-out infinite;
}

@keyframes rcPingPongMarquee {
    0%, 20% {
        transform: translateX(0);
    }
    50%, 70% {
        transform: translateX(var(--marquee-dist, -50px));
    }
    90%, 100% {
        transform: translateX(0);
    }
}

.road-closure-popup .leaflet-popup-tip {
    background: rgba(14, 18, 30, 0.96) !important;
    border: 1px solid rgba(255, 145, 0, 0.5) !important;
}

/* ==========================================================================
   Wikipedia Knowledge Card HUD (TV Remote Projection Overlay)
   ========================================================================== */
#wiki-intel-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 68vw;
    max-width: 1300px;
    min-width: 580px;
    max-height: 82vh;
    background: linear-gradient(145deg, rgba(13, 19, 36, 0.97) 0%, rgba(18, 27, 50, 0.95) 100%);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1.5px solid rgba(0, 210, 255, 0.45);
    border-radius: 1.4rem;
    box-shadow: 0 35px 90px rgba(0, 0, 0, 0.92), 0 0 50px rgba(0, 210, 255, 0.25);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
}

#wiki-intel-card.hidden {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.95);
    pointer-events: none;
}

.wiki-intel-header {
    padding: 1.2rem 1.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.28);
}

.wiki-intel-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.45rem 1.2rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.18) 0%, rgba(37, 99, 235, 0.24) 100%);
    border: 1px solid rgba(0, 210, 255, 0.5);
    color: #00d2ff;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.2);
}

.wiki-intel-badge-icon {
    width: 1.4rem;
    height: 1.4rem;
}

.wiki-intel-close-btn {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.wiki-intel-close-btn:hover {
    background: rgba(239, 68, 68, 0.85);
    border-color: #ef4444;
    transform: scale(1.08);
    box-shadow: 0 0 18px rgba(239, 68, 68, 0.5);
}

.wiki-intel-body {
    display: flex;
    gap: 2.2rem;
    padding: 1.8rem 2.2rem;
    overflow: hidden;
    align-items: stretch;
}

.wiki-intel-media {
    flex-shrink: 0;
    width: 18vw;
    height: 18vw;
    min-width: 230px;
    min-height: 230px;
    max-width: 330px;
    max-height: 330px;
    border-radius: 1.2rem;
    overflow: hidden;
    background: radial-gradient(circle, rgba(15, 23, 42, 0.9) 0%, rgba(2, 6, 23, 1) 100%);
    border: 1.5px solid rgba(0, 210, 255, 0.35);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.wiki-intel-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.wiki-intel-no-img {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    color: #00d2ff;
    opacity: 0.85;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 2px;
}

.wiki-intel-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wiki-intel-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: #ffffff;
    margin: 0 0 0.5rem 0;
    line-height: 1.25;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    word-break: break-word;
}

.wiki-intel-desc {
    font-size: 1.3rem;
    font-weight: 600;
    color: #38bdf8;
    margin: 0 0 1.1rem 0;
    letter-spacing: 0.3px;
    word-break: break-word;
}

.wiki-intel-extract {
    font-size: 1.4rem;
    line-height: 1.72;
    color: #f1f5f9;
    overflow-y: auto;
    max-height: 40vh;
    padding-right: 1rem;
    word-break: break-word;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.wiki-intel-extract::-webkit-scrollbar {
    width: 7px;
}

.wiki-intel-extract::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
}

.wiki-intel-extract::-webkit-scrollbar-thumb {
    background: rgba(0, 210, 255, 0.4);
    border-radius: 4px;
}

.wiki-intel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2.2rem 1.2rem 2.2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.25);
    font-size: 1.15rem;
    color: #94a3b8;
}

.wiki-intel-source {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #cbd5e1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50%;
}

.wiki-intel-source-tag {
    font-family: serif;
    font-weight: 900;
    font-size: 1.1rem;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
}

.wiki-intel-hint {
    color: #64748b;
    font-size: 1.1rem;
    white-space: nowrap;
}

.wiki-intel-progress-track {
    position: relative;
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.wiki-intel-progress-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00d2ff 0%, #3b82f6 50%, #8b5cf6 100%);
    box-shadow: 0 0 12px rgba(0, 210, 255, 0.8);
    transition: width 0.1s linear;
}

/* ==========================================================================
   TV Media Intelligence Marquee Banner HUD (YouTube AI 情資走馬燈)
   ========================================================================== */
#media-intel-marquee-banner {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 4.4rem;
    background: linear-gradient(90deg, rgba(15, 23, 42, 0.96) 0%, rgba(26, 16, 60, 0.94) 50%, rgba(15, 23, 42, 0.96) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    border-top: 2px solid rgba(168, 85, 247, 0.7);
    border-radius: 0;
    box-shadow: 0 -6px 28px rgba(0, 0, 0, 0.88), 0 -2px 14px rgba(168, 85, 247, 0.4);
    z-index: 45;
    display: flex;
    align-items: stretch;
    padding: 0;
    margin: 0;
    overflow: hidden;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), bottom 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    box-sizing: border-box;
    cursor: pointer;
    user-select: none;
}

/* 沉浸式全螢幕模式：歌曲深度情資走馬燈必須浮在底部新聞走馬燈 (#immersive-bottom-bar) 之上，避免掉到走馬燈後方被遮蓋 */
body.immersive-mode-enabled.fullscreen-mode #media-intel-marquee-banner,
body.fullscreen-mode.immersive-mode-enabled #media-intel-marquee-banner {
    bottom: var(--immersive-bottom-bar-height, 5.5rem);
    border-bottom: 1px solid rgba(168, 85, 247, 0.35);
}

#media-intel-marquee-banner.hidden {
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
}

.media-marquee-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0 1.6rem;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.48) 0%, rgba(219, 39, 119, 0.48) 100%);
    border: none;
    border-right: 1.5px solid rgba(168, 85, 247, 0.7);
    border-radius: 0;
    color: #f472b6;
    font-weight: 700;
    font-size: 1.45rem;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.media-marquee-icon {
    font-size: 1.65rem;
}

.media-marquee-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    min-width: 0;
    mask-image: linear-gradient(90deg, black 0%, black 97%, transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, black 0%, black 97%, transparent 100%);
}

.media-marquee-track {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    width: max-content;
    will-change: transform;
}

.media-marquee-text {
    display: inline-block;
    white-space: nowrap;
    font-size: 1.6rem;
    font-weight: 650;
    color: #f8fafc;
    letter-spacing: 0.8px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95);
    padding-right: 5rem;
}

@keyframes mediaMarqueeContinuous {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

@keyframes mediaMarqueeScroll {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

#media-intel-marquee-banner:hover {
    filter: brightness(1.08);
}

#media-intel-marquee-banner:active {
    filter: brightness(0.92);
}

/* ==========================================================================
   Winnipeg 311 Citizen Service & Request Radar Layer Styles
   ========================================================================== */
.s311-marker-pin,
.s311-marker {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.75), 0 2px 6px rgba(0, 0, 0, 0.6);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
    backdrop-filter: blur(4px);
    border: 2px solid #ffffff;
    box-sizing: border-box;
}

.s311-marker-pin:hover,
.s311-marker:hover {
    transform: scale(1.35);
    z-index: 1000 !important;
}

.s311-marker-pin.s311-high,
.s311-marker.s311-high {
    background: radial-gradient(circle, #ff1744 0%, #b71c1c 100%);
    border-color: #ffffff;
    box-shadow: 0 0 14px rgba(255, 23, 68, 0.9), 0 2px 6px rgba(0, 0, 0, 0.8);
    animation: s311PulseRed 1.8s infinite ease-in-out;
}

.s311-marker-pin.s311-medium,
.s311-marker.s311-medium {
    background: radial-gradient(circle, #ff9100 0%, #e65100 100%);
    border-color: #ffffff;
    box-shadow: 0 0 12px rgba(255, 145, 0, 0.85), 0 2px 6px rgba(0, 0, 0, 0.8);
}

.s311-marker-pin.s311-normal,
.s311-marker.s311-normal {
    background: radial-gradient(circle, #00e5ff 0%, #00838f 100%);
    border-color: #ffffff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.8), 0 2px 6px rgba(0, 0, 0, 0.8);
}

/* 911 專屬標記樣式 (火警、車禍、緊急醫療) - 醒目純白高反差邊框 */
.s311-marker-pin.s911-fire,
.s311-marker.s911-fire {
    background: radial-gradient(circle, #ff1744 0%, #b71c1c 100%) !important;
    border-color: #ffffff !important;
    box-shadow: 0 0 16px rgba(255, 23, 68, 1), 0 2px 8px rgba(0, 0, 0, 0.9) !important;
    animation: s311PulseRed 1.5s infinite ease-in-out;
}

.s311-marker-pin.s911-crash,
.s311-marker.s911-crash {
    background: radial-gradient(circle, #ff9100 0%, #e65100 100%) !important;
    border-color: #ffffff !important;
    box-shadow: 0 0 14px rgba(255, 145, 0, 0.95), 0 2px 8px rgba(0, 0, 0, 0.9) !important;
}

.s311-marker-pin.s911-medical,
.s311-marker.s911-medical {
    background: radial-gradient(circle, #00e5ff 0%, #00838f 100%) !important;
    border-color: #ffffff !important;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.85), 0 2px 8px rgba(0, 0, 0, 0.9) !important;
}

.s311-marker-icon {
    font-size: 14px;
    line-height: 1;
    user-select: none;
    display: inline-block;
}

@keyframes s311PulseRed {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 23, 68, 0.8);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 23, 68, 1);
        transform: scale(1.15);
    }
}

/* 311 Floating Time Filter Bar (TV 端貼住雷達頂部按鈕列下方，預留安全間距防遮蔽最頂的bar) */
.service311-time-bar {
    position: absolute;
    top: max(3.8rem, 64px);
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100vw - 280px);
    background: rgba(11, 19, 32, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 8px;
    padding: 5px 9px;
    display: none;
    align-items: center;
    gap: 8px;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.75), 0 0 16px rgba(56, 189, 248, 0.15);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.service311-time-bar.collapsed {
    transform: translateX(-50%) translateY(-15px) scale(0.9);
    opacity: 0;
    pointer-events: none;
}

/* 311 Collapsed Floating Tab (TV 端貼住雷達頂部按鈕列下方，預留安全間距防遮蔽最頂的bar) */
.service311-pill-toggle {
    position: absolute;
    top: max(3.8rem, 64px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(11, 19, 32, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 9999px;
    padding: 4px 13px;
    display: none;
    align-items: center;
    gap: 6px;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.65), 0 0 12px rgba(56, 189, 248, 0.2);
    cursor: pointer;
    color: #e0f2fe;
    font-size: 0.76rem;
    font-weight: 700;
    user-select: none;
    transition: all 0.2s ease;
}

.service311-pill-toggle:hover {
    background: rgba(14, 165, 233, 0.25);
    border-color: #38bdf8;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.75), 0 0 16px rgba(56, 189, 248, 0.35);
    transform: translateX(-50%) translateY(2px);
}

.s311-bar-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.s311-bar-title {
    color: #38bdf8;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.4px;
}

.s311-count-badge {
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: #7dd3fc;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

/* 內嵌分段時間控制軌道 (Segmented Control Track) */
.s311-time-segmented-track {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    padding: 2px;
}

.s311-time-btn-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.s311-time-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #94a3b8;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.s311-time-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
}

.s311-time-btn.active {
    background: #0284c7;
    border-color: #38bdf8;
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.s311-filter-divider {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.16);
    margin: 0 2px;
}

.s311-filter-btn-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 獨立方形微圓角篩選標籤 (🚨 僅緊急 / ⚠️ 緊要 / 🟢 處理中) */
.s311-filter-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.s311-filter-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

/* 🚨 僅緊急 高亮樣式 */
.s311-filter-btn.btn-high.active {
    background: rgba(239, 68, 68, 0.25);
    border-color: #ef4444;
    color: #fca5a5;
    font-weight: 700;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}

/* ⚠️ 緊要 高亮樣式 */
.s311-filter-btn.btn-urgent.active {
    background: rgba(245, 158, 11, 0.25);
    border-color: #f59e0b;
    color: #fde68a;
    font-weight: 700;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* 🟢 處理中 (明確的開/關視覺對比) */
.s311-filter-btn.btn-open {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #94a3b8;
    transition: all 0.2s ease;
}
.s311-filter-btn.btn-open.active,
.s311-filter-btn.active.open-filter {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.5) 0%, rgba(5, 150, 105, 0.7) 100%) !important;
    border: 1px solid #34d399 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

/* 911 消防急救專用樣式 */
#flight-radar-311-btn.active-911,
.preview-layer-pill.active-911 {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.45) 0%, rgba(185, 28, 28, 0.75) 100%) !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 0 14px rgba(239, 68, 68, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

.service311-time-bar.mode-911 {
    border-color: rgba(239, 68, 68, 0.45) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 18px rgba(239, 68, 68, 0.22) !important;
}

.service311-pill-toggle.pill-911 {
    border-color: rgba(239, 68, 68, 0.45) !important;
    color: #fca5a5 !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.65), 0 0 12px rgba(239, 68, 68, 0.3) !important;
}

.s311-mode-switch-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #f1f5f9;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.s311-mode-switch-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.3);
    color: #ffffff;
}

.s311-filter-btn.btn-fire.active {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.45) 0%, rgba(185, 28, 28, 0.7) 100%) !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6) !important;
}

.s311-filter-btn.btn-crash.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.4) 0%, rgba(217, 119, 6, 0.7) 100%) !important;
    border-color: #f59e0b !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6) !important;
}

/* 收起按鈕 (微圓角方鍵) */
.s311-bar-action-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.18s ease;
    flex-shrink: 0;
    margin-left: 2px;
}

.s311-bar-action-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: #ef4444;
    color: #ffffff;
}

/* 311 Leaflet Popup Card (高科技微圓角卡片) */
.service311-popup .leaflet-popup-content-wrapper {
    background: rgba(11, 19, 32, 0.96) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border: 1px solid rgba(56, 189, 248, 0.35) !important;
    border-radius: 9px !important;
    color: #f1f5f9 !important;
    padding: 0 !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 20px rgba(56, 189, 248, 0.15) !important;
}

.service311-popup .leaflet-popup-content {
    margin: 0 !important;
    padding: 12px 14px !important;
    line-height: 1.4 !important;
}

.service311-popup .leaflet-popup-tip {
    background: rgba(11, 19, 32, 0.96) !important;
    border: 1px solid rgba(56, 189, 248, 0.35) !important;
}

/* 311 Popup 方形微圓角關閉按鈕 (絕不遮擋卡片頂部標記或文字) */
.service311-popup .leaflet-popup-close-button {
    top: 9px !important;
    right: 9px !important;
    width: 22px !important;
    height: 22px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #94a3b8 !important;
    font-size: 14px !important;
    line-height: 1 !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border-radius: 5px !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    z-index: 20 !important;
}

.service311-popup .leaflet-popup-close-button:hover {
    color: #ffffff !important;
    background: rgba(239, 68, 68, 0.4) !important;
    border-color: #ef4444 !important;
}

.service311-popup-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.s311-header-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding-bottom: 6px;
    padding-right: 32px !important; /* 為右上角關閉鍵留足安全空隙，絕不遮擋狀態標記 */
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.s311-header-badges {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.s311-priority-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.s311-priority-badge.s311-high {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.45);
}

.s311-priority-badge.s311-medium {
    background: rgba(245, 158, 11, 0.2);
    color: #fde68a;
    border: 1px solid rgba(245, 158, 11, 0.45);
}

.s311-priority-badge.s311-normal {
    background: rgba(56, 189, 248, 0.18);
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.s311-status-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
}

.s311-title-row {
    font-size: 0.98rem;
    font-weight: 700;
    color: #ffffff;
    line-height: 1.35;
    padding: 1px 0;
}

/* 規格表格式排版 (左欄固定寬度，右欄完全靠左對齊，告別參差不齊) */
.s311-spec-table {
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.s311-spec-row {
    display: grid;
    grid-template-columns: 82px 1fr;
    align-items: baseline;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    gap: 8px;
}

.s311-spec-row:last-child {
    border-bottom: none;
}

.s311-spec-lbl {
    color: #7dd3fc;
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.s311-spec-val {
    color: #f1f5f9;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left !important;
    word-break: break-word;
}

/* 隱藏電視版雷達頂部更新時鐘 */
#flight-radar-status,
.flight-radar-time {
    display: none !important;
}

/* ==========================================================================
   911 WFPS CAD Emergency Layer Styles (溫尼伯 911 消防救援與交通事故圖層)
   ========================================================================== */

/* 911 Mode Active Styles for TV HUD Buttons */
#flight-radar-311-btn.active-911,
.flight-radar-btn.active-911 {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(185, 28, 28, 0.98)) !important;
    color: #ffffff !important;
    border-color: #f87171 !important;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
}

/* 911 Mode Active Styles for Mobile Remote Preview Pills */
.preview-layer-pill.active-911 {
    background: linear-gradient(135deg, #ef4444, #b91c1c) !important;
    color: #ffffff !important;
    border-color: #f87171 !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6) !important;
}

/* 911 Mode Active Styles for Mobile Radar Card */
.radar-control-card.active-911 {
    border-color: #ef4444 !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.35) !important;
}
.radar-control-card.active-911 .radar-card-tag {
    background: rgba(239, 68, 68, 0.25) !important;
    color: #fca5a5 !important;
    border-color: rgba(239, 68, 68, 0.6) !important;
}

/* 911 Floating Time Filter Bar */
.service311-time-bar.mode-911,
#radar-preview-311-time-bar.mode-911 {
    border-color: rgba(239, 68, 68, 0.45) !important;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 18px rgba(239, 68, 68, 0.25) !important;
}

.service311-time-bar.mode-911 .s311-bar-title,
#radar-preview-311-time-bar.mode-911 .s311-bar-title {
    color: #fca5a5 !important;
}

/* Mode Switch Button (311 <-> 911) */
.s311-mode-switch-btn,
#preview-311-mode-switch-btn {
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 9999px;
    padding: 3px 9px;
    font-size: 0.74rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.s311-mode-switch-btn:hover,
#preview-311-mode-switch-btn:hover {
    background: rgba(239, 68, 68, 0.35);
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

/* 911 Filter Buttons */
.s311-filter-btn.btn-fire.active,
.preview-311-filter-pill.btn-fire.active {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #ffffff !important;
    border-color: #f87171 !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6) !important;
}

.s311-filter-btn.btn-crash.active,
.preview-311-filter-pill.btn-crash.active {
    background: linear-gradient(135deg, #f97316, #ea580c) !important;
    color: #ffffff !important;
    border-color: #fb923c !important;
    box-shadow: 0 0 12px rgba(249, 115, 22, 0.6) !important;
}

.s311-filter-btn.btn-active-cad.active,
.preview-311-filter-pill.btn-active-cad.active {
    background: linear-gradient(135deg, #e11d48, #be123c) !important;
    color: #ffffff !important;
    border-color: #fb7185 !important;
    box-shadow: 0 0 12px rgba(225, 29, 72, 0.6) !important;
}

/* 911 Status Badges */
.s311-status-badge.status-open {
    background: rgba(239, 68, 68, 0.25) !important;
    color: #fca5a5 !important;
    border-color: rgba(239, 68, 68, 0.55) !important;
}

.s311-status-badge.status-closed {
    background: rgba(148, 163, 184, 0.15) !important;
    color: #94a3b8 !important;
    border-color: rgba(148, 163, 184, 0.3) !important;
}

/* 911 Mobile Leaflet Marker Styling */
.s911-marker-pin {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.4);
}
.s911-marker-pin.s911-fire {
    background: #dc2626;
}
.s911-marker-pin.s911-crash {
    background: #ea580c;
}
.s911-marker-pin.s911-medical {
    background: #e11d48;
}

/* ==========================================================================
   Manitoba 511 CCTV Highway Camera Popup Styles (TV Dark Theme & Glassmorphism)
   ========================================================================== */
.camera-511-popup .leaflet-popup-content-wrapper {
    background: rgba(11, 19, 32, 0.96) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border: 1px solid rgba(0, 229, 255, 0.5) !important;
    border-radius: 12px !important;
    color: #f1f5f9 !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85), 0 0 24px rgba(0, 229, 255, 0.25) !important;
}

.camera-511-popup .leaflet-popup-content {
    margin: 10px 12px !important;
    padding: 0 !important;
    width: 300px !important;
    max-width: 340px !important;
    line-height: 1.2 !important;
    background: transparent !important;
    color: #ffffff !important;
}

.camera-511-popup .leaflet-popup-tip {
    background: rgba(11, 19, 32, 0.96) !important;
    border: 1px solid rgba(0, 229, 255, 0.5) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

.camera-511-popup .leaflet-popup-close-button {
    top: 8px !important;
    right: 8px !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #94a3b8 !important;
    font-size: 16px !important;
    line-height: 1 !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border-radius: 50% !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    z-index: 1000 !important;
    cursor: pointer !important;
}

.camera-511-popup .leaflet-popup-close-button:hover,
.camera-511-popup .leaflet-popup-close-button:active {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    transform: scale(1.1) !important;
}

.camera-popup-container {
    box-sizing: border-box;
    width: 100%;
}

.camera-img-box {
    background: #080d19 !important;
    border: 1px solid rgba(0, 229, 255, 0.25) !important;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8) !important;
}

.cam-view-btn {
    transition: all 0.15s ease !important;
}

.cam-view-btn:hover {
    background: rgba(0, 229, 255, 0.2) !important;
    border-color: rgba(0, 229, 255, 0.5) !important;
    color: #00e5ff !important;
}

/* ========================================================
   1990s TVB 經典無綫電視翡翠台「即將播放」與「間場」電視美學 (原版純淨藍天白雲 · Amber 琥珀金字)
   ======================================================== */
.tvb-sky-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: linear-gradient(180deg, #1263ab 0%, #2982cf 28%, #529ee0 55%, #9bc7ef 82%, #d8ecfa 100%);
    pointer-events: none;
    z-index: 1;
}

/* 柔和金色日照暈光 */
.tvb-sky-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    width: 60%;
    height: 55%;
    background: radial-gradient(ellipse at 50% 0%, rgba(255, 252, 235, 0.45) 0%, rgba(255, 255, 255, 0) 70%);
    pointer-events: none;
    z-index: 1;
}

.tvb-cloud-layer-1 {
    position: absolute;
    inset: 0;
    width: 200%;
    height: 100%;
    background-image:
        radial-gradient(ellipse 380px 190px at 20% 32%, rgba(255, 255, 255, 0.76) 0%, rgba(255, 255, 255, 0) 70%),
        radial-gradient(ellipse 460px 230px at 65% 50%, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0) 72%),
        radial-gradient(ellipse 320px 170px at 85% 28%, rgba(255, 255, 255, 0.62) 0%, rgba(255, 255, 255, 0) 70%),
        radial-gradient(ellipse 520px 260px at 42% 65%, rgba(255, 255, 255, 0.80) 0%, rgba(255, 255, 255, 0) 75%);
    background-repeat: repeat-x;
    background-size: 50% 100%;
    animation: tvbCloudFloat 52s linear infinite;
    opacity: 0.88;
    will-change: transform;
}

.tvb-cloud-layer-2 {
    position: absolute;
    inset: 0;
    width: 200%;
    height: 100%;
    background-image:
        radial-gradient(ellipse 580px 290px at 15% 72%, rgba(255, 255, 255, 0.90) 0%, rgba(255, 255, 255, 0) 65%),
        radial-gradient(ellipse 500px 250px at 52% 80%, rgba(255, 255, 255, 0.94) 0%, rgba(255, 255, 255, 0) 68%),
        radial-gradient(ellipse 620px 310px at 88% 76%, rgba(255, 255, 255, 0.88) 0%, rgba(255, 255, 255, 0) 65%);
    background-repeat: repeat-x;
    background-size: 50% 100%;
    animation: tvbCloudFloat 28s linear infinite;
    opacity: 0.94;
    will-change: transform;
}

@keyframes tvbCloudFloat {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

.tvb-scanlines {
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.12) 50%);
    background-size: 100% 3px;
    pointer-events: none;
    opacity: 0.38;
    z-index: 2;
}

.tvb-vignette {
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 clamp(60px, 12vw, 160px) rgba(0, 24, 72, 0.42);
    pointer-events: none;
    z-index: 3;
}

.tvb-weather-badge {
    position: absolute;
    top: clamp(14px, 3.5vw, 36px);
    left: clamp(14px, 3.8vw, 48px);
    display: flex;
    align-items: center;
    gap: clamp(4px, 1vw, 10px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-weight: 800;
    font-size: clamp(14px, 2.3vw, 28px);
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.7);
    letter-spacing: 0.06em;
    z-index: 30;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.tvb-clock-badge {
    position: absolute;
    top: clamp(14px, 3.5vw, 36px);
    right: clamp(14px, 3.8vw, 48px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-weight: 800;
    font-size: clamp(15px, 2.5vw, 30px);
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95), 0 0 8px rgba(0, 0, 0, 0.7);
    letter-spacing: 0.08em;
    font-variant-numeric: tabular-nums;
    z-index: 30;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.tvb-date-group {
    position: relative;
    z-index: 28;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 1.8vw, 20px);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    margin-top: -2vh;
}

.tvb-golden-text {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Segoe UI", system-ui, sans-serif;
    font-weight: 900;
    color: #f59e0b;
    background: linear-gradient(180deg, #fde68a 0%, #f59e0b 42%, #d97706 78%, #92400e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: 0 !important;
    letter-spacing: 0.08em;
    display: inline-block;
    text-align: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.95)) 
            drop-shadow(0 4px 12px rgba(2, 6, 23, 0.85)) 
            drop-shadow(0 0 16px rgba(245, 158, 11, 0.55));
}

.tvb-date-text {
    font-size: clamp(2.4rem, 6.2vw, 5.2rem);
    line-height: 1.15;
}

.tvb-weekday-text {
    font-size: clamp(2.4rem, 6.2vw, 5.2rem);
    line-height: 1.15;
}

.tvb-bottom-banner {
    position: absolute;
    bottom: clamp(16px, 4.5vw, 48px);
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1040px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 2.2vw, 24px);
    z-index: 28;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

.tvb-emblem {
    width: clamp(44px, 6.5vw, 80px);
    height: auto;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.75));
    transition: transform 0.3s ease, filter 0.3s ease;
}

#seamless-curtain-emblem-wrap,
#seamless-intermission-emblem-wrap,
#curtain-emblem-wrap,
#intermission-emblem-wrap,
#seamless-mobile-curtain-emblem-wrap,
#seamless-mobile-intermission-emblem-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.channel-emblem-ch1 {
    animation: ch1EmblemGlow 6s ease-in-out infinite alternate;
}
@keyframes ch1EmblemGlow {
    0%, 80% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(56, 189, 248, 0.3));
    }
    90% {
        filter: drop-shadow(0 4px 12px rgba(56, 189, 248, 0.75)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.55));
    }
    100% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(56, 189, 248, 0.3));
    }
}

.channel-emblem-ch2 {
    animation: ch2EmblemGlow 6s ease-in-out infinite alternate;
}
@keyframes ch2EmblemGlow {
    0%, 80% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(192, 132, 252, 0.3));
    }
    90% {
        filter: drop-shadow(0 4px 12px rgba(232, 121, 249, 0.75)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.55));
    }
    100% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(192, 132, 252, 0.3));
    }
}

.channel-emblem-ch3 {
    animation: ch3EmblemGlow 6s ease-in-out infinite alternate;
}
@keyframes ch3EmblemGlow {
    0%, 80% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(245, 158, 11, 0.3));
    }
    90% {
        filter: drop-shadow(0 4px 12px rgba(251, 191, 36, 0.75)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.55));
    }
    100% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(245, 158, 11, 0.3));
    }
}

.channel-emblem-ch4 {
    animation: ch4EmblemGlow 6s ease-in-out infinite alternate;
}
@keyframes ch4EmblemGlow {
    0%, 80% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(16, 185, 129, 0.35));
    }
    90% {
        filter: drop-shadow(0 4px 12px rgba(52, 211, 153, 0.8)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.6));
    }
    100% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(16, 185, 129, 0.35));
    }
}

.channel-emblem-ch5 {
    animation: ch5EmblemGlow 6s ease-in-out infinite alternate;
}
@keyframes ch5EmblemGlow {
    0%, 80% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(239, 68, 68, 0.35));
    }
    90% {
        filter: drop-shadow(0 4px 12px rgba(248, 113, 113, 0.8)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.6));
    }
    100% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(239, 68, 68, 0.35));
    }
}

.channel-emblem-ch6 {
    animation: ch6EmblemGlow 6s ease-in-out infinite alternate;
}
@keyframes ch6EmblemGlow {
    0%, 80% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(234, 179, 8, 0.35));
    }
    90% {
        filter: drop-shadow(0 4px 12px rgba(250, 204, 21, 0.8)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.6));
    }
    100% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(234, 179, 8, 0.35));
    }
}

.channel-emblem-ch7 {
    animation: ch7EmblemGlow 6s ease-in-out infinite alternate;
}
@keyframes ch7EmblemGlow {
    0%, 80% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(6, 182, 212, 0.35));
    }
    90% {
        filter: drop-shadow(0 4px 12px rgba(34, 211, 238, 0.8)) drop-shadow(0 0 14px rgba(255, 255, 255, 0.6));
    }
    100% {
        filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 4px rgba(6, 182, 212, 0.35));
    }
}

.tvb-program-title {
    font-size: clamp(1.3rem, 3.8vw, 3.2rem);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    word-break: break-word;
    white-space: normal;
    text-align: center;
    max-width: calc(100% - 90px);
}

.tvb-intermission-sub {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    font-size: clamp(14px, 1.8vw, 22px);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Segoe UI", system-ui, sans-serif;
    font-weight: 700;
    color: #f59e0b;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 0 10px rgba(245, 158, 11, 0.6);
    letter-spacing: 0.06em;
    margin-top: 6px;
}

.tvb-intermission-sub .tvb-cd-time {
    color: #f59e0b;
    font-weight: 800;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
}

.tvb-intermission-sub .tvb-cd-highlight {
    color: #f59e0b;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 12px rgba(245, 158, 11, 0.85), 0 2px 4px rgba(0, 0, 0, 0.95);
    letter-spacing: 0.05em;
}

.tvb-curtain-progress-edge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.25);
    z-index: 35;
    overflow: hidden;
}

.tvb-curtain-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    box-shadow: 0 0 8px #f59e0b;
    transition: width 9s linear;
}

@media (max-width: 680px) {
    .tvb-weather-badge {
        top: 10px;
        left: 12px;
        font-size: 13px;
        gap: 4px;
    }
    .tvb-clock-badge {
        top: 10px;
        right: 12px;
        font-size: 14px;
    }
    .tvb-date-group {
        gap: 2px;
        margin-top: -6px;
    }
    .tvb-date-text,
    .tvb-weekday-text {
        font-size: clamp(1.6rem, 5.8vw, 2.4rem);
        line-height: 1.15;
    }
    .tvb-bottom-banner {
        bottom: 12px;
        gap: 8px;
        width: 94%;
    }
    .tvb-emblem {
        width: 34px;
    }
    .tvb-program-title {
        font-size: clamp(1rem, 3.8vw, 1.35rem);
        max-width: calc(100% - 46px);
    }
    .tvb-golden-text {
        -webkit-text-stroke: 0 !important;
        letter-spacing: 0.05em;
        filter: drop-shadow(0 1.5px 3.5px rgba(0, 0, 0, 0.88))
                drop-shadow(0 0 8px rgba(245, 158, 11, 0.5)) !important;
    }
    .tvb-intermission-sub {
        font-size: 11px;
        margin-top: 2px;
    }
}

@media (min-width: 2560px) {
    .tvb-weather-badge {
        font-size: 38px;
        top: 48px;
        left: 64px;
    }
    .tvb-clock-badge {
        font-size: 42px;
        top: 48px;
        right: 64px;
    }
    .tvb-date-text,
    .tvb-weekday-text {
        font-size: 6.8rem;
    }
    .tvb-emblem {
        width: 108px;
    }
    .tvb-program-title {
        font-size: 4.2rem;
    }
    .tvb-intermission-sub {
        font-size: 24px;
    }
}

/* ==========================================================================
   TV Native Hotkey Guide Modal (電視快捷鍵指南)
   ========================================================================== */
#tv-hotkeys-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 82vw;
    max-width: 1100px;
    max-height: 88vh;
    background: linear-gradient(135deg, rgba(16, 20, 28, 0.98) 0%, rgba(9, 13, 20, 0.99) 100%);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-top: 3px solid #00f2fe;
    border-radius: 4px;
    z-index: 99999;
    padding: 1.4rem 1.8rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.92);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    color: #e2e8f0;
}

#tv-hotkeys-modal.hidden {
    opacity: 0;
    transform: translate(-50%, -46%);
    pointer-events: none;
}

.tv-hotkeys-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 0.8rem;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

#tv-hotkeys-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin: 0;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    letter-spacing: 0.03em;
}

.tv-hotkeys-scroll-body {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    padding-right: 0.5rem;
}

.tv-hotkeys-scroll-body::-webkit-scrollbar {
    width: 6px;
}
.tv-hotkeys-scroll-body::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.4);
    border-radius: 3px;
}

.tv-hotkey-card {
    background: rgba(22, 28, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.tv-hotkey-card.border-seamless {
    background: linear-gradient(135deg, rgba(14, 34, 61, 0.7) 0%, rgba(8, 20, 36, 0.85) 100%);
    border-color: rgba(56, 189, 248, 0.5);
    border-left: 3px solid #00f2fe;
}

.tv-hotkey-card.border-ktv {
    background: linear-gradient(135deg, rgba(46, 16, 36, 0.7) 0%, rgba(20, 8, 18, 0.85) 100%);
    border-color: rgba(255, 0, 127, 0.45);
    border-left: 3px solid #ff007f;
}

.tv-hotkey-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 0.45rem;
}

.tv-hotkey-card-subtitle {
    font-size: 0.75rem;
    font-weight: 500;
    color: #94a3b8;
}

.tv-hotkey-card-badge {
    font-size: 0.72rem;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    font-weight: 700;
}

.badge-seamless {
    background: rgba(56, 189, 248, 0.25);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.badge-ktv {
    background: rgba(255, 0, 127, 0.25);
    color: #ff66b2;
    border: 1px solid rgba(255, 0, 127, 0.4);
}

.tv-hotkey-grid {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.tv-hotkey-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    padding: 0.2rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.tv-hotkey-row:last-child {
    border-bottom: none;
}

.tv-hotkey-highlight-row {
    background: rgba(234, 179, 8, 0.12);
    border-radius: 3px;
    padding: 0.25rem 0.4rem;
    border-bottom: none;
}

.tv-hotkey-key {
    background: #2a3444;
    color: #ffffff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
    font-weight: 800;
    padding: 0.2rem 0.55rem;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.tv-hotkey-key.key-blue {
    background: #0284c7;
    color: #ffffff;
}

.tv-hotkey-key.key-cyan {
    background: #00f2fe;
    color: #000000;
}

.tv-hotkey-key.key-gold {
    background: #eab308;
    color: #000000;
}

.tv-hotkey-key.key-red {
    background: #ef4444;
    color: #ffffff;
}

.tv-hotkey-key.key-green {
    background: #10b981;
    color: #ffffff;
}

.tv-hotkey-key.key-purple {
    background: #a855f7;
    color: #ffffff;
}

.tv-hotkey-key.key-magenta {
    background: #ff007f;
    color: #ffffff;
}

.tv-hotkey-desc {
    font-size: 0.88rem;
    color: #cbd5e1;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-cyan { color: #38bdf8; }
.text-seamless { color: #38bdf8; }
.text-ktv { color: #ff007f; }
.text-green { color: #10b981; }
.text-red { color: #f87171; }
.text-gold { color: #facc15; }

.tv-hotkeys-footer {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin-top: 0.8rem;
    flex-shrink: 0;
}

.tv-hotkeys-close-action {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.55rem 2rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.tv-hotkeys-close-action:hover {
    background: #334155;
    border-color: #38bdf8;
}

