/* =====================================================================
 * 即時開票 - 群組即時票數頁（電視版面）
 * ---------------------------------------------------------------------
 * - 以 1920 × 1080 舞台設計，由 vote.js 依視窗大小等比例縮放（--tv-scale）
 * - 候選人固定左、右兩位，開票所固定三所
 * - 左、右候選人代表色於下方 :root 調整
 * - 電視播放效能：沒有常駐動畫（含 LIVE 閃爍）、進場動畫、光束滑過特效與底部跑馬燈；
 *   新增特效請以 transform / opacity 製作，避免以 box-shadow、filter、background-position、left 等需要重繪的屬性做動畫
 * ===================================================================== */
:root {
    /* 左側候選人 */
    --tv-left: #1d4ed8;
    --tv-left-2: #3b82f6;
    --tv-left-deep: #1e3a8a;
    --tv-left-soft: #e8f0ff;
    --tv-left-shadow: rgba(29, 78, 216, 0.28);
    /* 右側候選人 */
    --tv-right: #ea580c;
    --tv-right-2: #fb923c;
    --tv-right-deep: #9a3412;
    --tv-right-soft: #fff0e6;
    --tv-right-shadow: rgba(234, 88, 12, 0.28);
    /* 共用 */
    --tv-ink: #0f172a;
    --tv-muted: #64748b;
    --tv-line: #e2e8f0;
    --tv-track: #e8edf4;
    --tv-gold: #f59e0b;
    --tv-gold-2: #fbbf24;
    --tv-live: #ef4444;
    --tv-ok: #16a34a;
    --tv-card-shadow: 0 2px 4px rgba(15, 23, 42, 0.04), 0 18px 40px rgba(15, 23, 42, 0.08);
    /* 各開票所框框：淺灰底、深灰邊線 */
    --tv-box-bg: #f3f4f6;
    --tv-box-border: #4b5563;
    --tv-box-divider: #d1d5db;
    --tv-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --vote-odometer-height: 1.1em;
}

.is-left {
    --side: var(--tv-left);
    --side-2: var(--tv-left-2);
    --side-deep: var(--tv-left-deep);
    --side-soft: var(--tv-left-soft);
    --side-shadow: var(--tv-left-shadow);
}

.is-right {
    --side: var(--tv-right);
    --side-2: var(--tv-right-2);
    --side-deep: var(--tv-right-deep);
    --side-soft: var(--tv-right-soft);
    --side-shadow: var(--tv-right-shadow);
}

/* ===== 舞台與縮放 ===== */
body.vote-tv-body {
    height: 100vh;
    overflow: hidden;
    background: #ffffff; /* 視窗比例非 16:9 時，舞台四周留邊同為白色 */
}

body.vote-tv-body.is-idle {
    cursor: none;
}

.tv-viewport {
    position: fixed;
    inset: 0;
    overflow: hidden;
}

.tv-stage {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1920px;
    height: 1080px;
    overflow: hidden;
    background: #ffffff;
    color: var(--tv-ink);
    transform: translate(-50%, -50%) scale(var(--tv-scale, 1));
    transform-origin: center center;
}

/* ===== 頁首 ===== */
.tv-topbar {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    align-items: center;
    gap: 28px;
    height: 108px;
    padding: 0 56px;
}

.tv-live {
    display: flex;
    flex: 0 0 auto;
    align-items: stretch;
    height: 52px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: var(--tv-card-shadow);
    overflow: hidden;
}

.tv-live-tag {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    background: var(--tv-live);
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0.1em;
}

.tv-live-tag::before {
    content: "";
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffffff;
}

.tv-live .vote-live-text {
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 24px;
    font-weight: 800;
}

.tv-live[data-state="error"] .tv-live-tag {
    background: #94a3b8;
}

.tv-live[data-state="error"] .vote-live-text {
    color: var(--tv-live);
}

.tv-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-size: 52px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-clock {
    flex: 0 0 auto;
    text-align: right;
}

.tv-clock-time {
    font-size: 46px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.tv-clock-date {
    margin-top: 6px;
    color: var(--tv-muted);
    font-size: 19px;
    font-weight: 600;
}

/* 頁首下方的雙色線 */
.tv-topbar-line {
    position: absolute;
    right: 56px;
    bottom: 0;
    left: 56px;
    height: 5px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--tv-left-deep), var(--tv-left-2) 46%, var(--tv-right-2) 54%, var(--tv-right-deep));
}

/* ===== 候選人對決 ===== */
.tv-match {
    position: absolute;
    top: 132px;
    right: 56px;
    left: 56px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px minmax(0, 1fr);
    gap: 24px;
    height: 412px;
}

.tv-candidate {
    display: flex;
    align-items: center;
    gap: 28px;
    min-width: 0;
}

.tv-candidate.is-right {
    flex-direction: row-reverse;
}

/* 照片框 */
.tv-candidate-photo {
    position: relative;
    flex: 0 0 290px;
    height: 396px;
    border: 6px solid #ffffff;
    border-radius: 30px;
    background: linear-gradient(160deg, var(--side-2) 0%, var(--side) 55%, var(--side-deep) 100%);
    box-shadow: 0 0 0 3px var(--side), 0 26px 50px var(--side-shadow);
    overflow: hidden;
}

.tv-candidate-photo::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.07) 0 18px, transparent 18px 36px);
    pointer-events: none;
}

.tv-candidate-photo img {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.tv-candidate-initial {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #ffffff;
    font-size: 190px;
    font-weight: 900;
    text-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

/* 票數更新時照片閃光 */
.tv-candidate-photo::after {
    content: "";
    position: absolute;
    inset: 0;
    background: #ffffff;
    opacity: 0;
    pointer-events: none;
}

.tv-candidate.is-updated .tv-candidate-photo::after {
    animation: tv-photo-flash 1.2s ease-out;
}

@keyframes tv-photo-flash {
    0% {
        opacity: 0.55;
    }

    100% {
        opacity: 0;
    }
}

/* 領先標示 */
.tv-candidate-badge {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 1;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 18px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--tv-gold-2), var(--tv-gold));
    color: #ffffff;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 0.08em;
    box-shadow: 0 6px 18px rgba(245, 158, 11, 0.45);
}

.tv-candidate.is-right .tv-candidate-badge {
    right: 18px;
    left: auto;
}

.tv-candidate.is-leading .tv-candidate-badge {
    display: inline-flex;
    animation: tv-badge-pop 0.6s var(--tv-ease) both;
}

/* 領先者照片：靜態金色外框（不做脈動動畫，避免 box-shadow 每格重繪） */
.tv-candidate.is-leading .tv-candidate-photo {
    box-shadow: 0 0 0 3px var(--side), 0 0 0 13px rgba(245, 158, 11, 0.3), 0 26px 50px var(--side-shadow);
}

@keyframes tv-badge-pop {
    0% {
        opacity: 0;
        transform: scale(0.4);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 姓名與票數 */
.tv-candidate-info {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
}

.tv-candidate.is-right .tv-candidate-info {
    align-items: flex-end;
    text-align: right;
}

.tv-candidate-name {
    position: relative;
    max-width: 100%;
    padding-bottom: 18px;
    overflow: hidden;
    font-size: 62px;
    font-weight: 900;
    letter-spacing: 0.06em;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tv-candidate-name::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 80px;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--side), var(--side-2));
}

.tv-candidate.is-right .tv-candidate-name::after {
    right: 0;
    left: auto;
    background: linear-gradient(270deg, var(--side), var(--side-2));
}

.tv-candidate-votes {
    position: relative;
    display: flex;
    align-items: baseline;
    gap: 10px;
    color: var(--side);
    font-size: 112px;
    font-weight: 900;
    line-height: 1;
}

/* 票數位數變多時縮小字級（vote.js 另會依實際寬度再微調，避免超出版面） */
.tv-candidate-votes[data-digits="6"] {
    font-size: 96px;
}

.tv-candidate-votes[data-digits="7"] {
    font-size: 78px;
}

.tv-candidate-votes[data-digits="8"] {
    font-size: 70px;
}

.tv-candidate-unit {
    color: var(--tv-muted);
    font-size: 34px;
    font-weight: 800;
}

.tv-candidate-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tv-candidate.is-right .tv-candidate-meta {
    flex-direction: row-reverse;
}

/* 增加票數提示（顯示於票數下方） */
.tv-candidate-delta {
    padding: 4px 16px;
    border-radius: 999px;
    background: var(--tv-ok);
    color: #ffffff;
    font-size: 30px;
    font-weight: 900;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.35);
    opacity: 0;
    pointer-events: none;
}

.tv-candidate-delta.is-down {
    background: #dc2626;
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.35);
}

.tv-candidate-delta.is-show {
    animation: tv-delta 2.6s ease-out forwards;
}

@keyframes tv-delta {
    0% {
        opacity: 0;
        transform: translateY(16px) scale(0.8);
    }

    15% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    75% {
        opacity: 1;
        transform: translateY(-6px) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-22px) scale(1);
    }
}

.tv-candidate.is-empty .tv-candidate-name {
    color: var(--tv-muted);
    font-size: 40px;
}

/* ===== 中央：總票數、VS、領先差距 ===== */
.tv-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    text-align: center;
}

.tv-label {
    color: var(--tv-muted);
    font-size: 23px;
    font-weight: 800;
    letter-spacing: 0.1em;
}

.tv-total-value {
    margin-top: 4px;
    font-size: 58px;
    font-weight: 900;
    line-height: 1.1;
}

.tv-vs {
    position: relative;
    width: 136px;
    height: 136px;
}

.tv-vs-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(var(--tv-left), var(--tv-left-2), var(--tv-right-2), var(--tv-right), var(--tv-right-2), var(--tv-left-2), var(--tv-left));
}

.tv-vs-text {
    position: absolute;
    inset: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--tv-ink);
    color: #ffffff;
    font-size: 52px;
    font-style: italic;
    font-weight: 900;
    letter-spacing: 0.02em;
    box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.tv-gap-value {
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 48px;
    font-weight: 900;
    line-height: 1.1;
}

.tv-gap-unit {
    color: var(--tv-muted);
    font-size: 22px;
    font-weight: 800;
}

.tv-gap-arrow {
    display: none;
    align-self: center;
    font-size: 40px;
}

.tv-gap[data-leader="none"] .tv-gap-value,
.tv-gap[data-leader="tie"] .tv-gap-value {
    display: none;
}

.tv-gap[data-leader="left"] {
    color: var(--tv-left);
}

.tv-gap[data-leader="right"] {
    color: var(--tv-right);
}

.tv-gap[data-leader="left"] .tv-label,
.tv-gap[data-leader="right"] .tv-label {
    color: inherit;
}

.tv-gap[data-leader="left"] .tv-gap-arrow.is-left,
.tv-gap[data-leader="right"] .tv-gap-arrow.is-right {
    display: inline-block;
}

/* ===== 各開票所 ===== */
.tv-stations {
    position: absolute;
    top: 600px;
    right: 56px;
    left: 56px;
}

.tv-stations-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
    margin-bottom: 16px;
}

.tv-section-title {
    position: relative;
    margin: 0;
    padding-left: 22px;
    font-size: 30px;
    font-weight: 900;
    letter-spacing: 0.06em;
}

.tv-section-title::before {
    content: "";
    position: absolute;
    top: 6px;
    bottom: 6px;
    left: 0;
    width: 8px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--tv-left), var(--tv-right));
}

/* 全部開票所的最後更新時間 */
.tv-updated {
    color: var(--tv-muted);
    font-size: 22px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

/* 高度延伸至舞台底部，下方留白與左右邊距相同（56px） */
.tv-station-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    height: 364px;
}

.tv-station {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    padding: 20px 26px 16px;
    border: 2px solid var(--tv-box-border);
    border-radius: 24px;
    background: var(--tv-box-bg);
}

/* 開票所更新時的金色外框（覆蓋深灰邊線；光暈為靜態，動畫只改變透明度） */
.tv-station::after {
    content: "";
    position: absolute;
    inset: -2px;
    border: 3px solid var(--tv-gold);
    border-radius: inherit;
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.2), 0 0 40px rgba(245, 158, 11, 0.35);
    opacity: 0;
    pointer-events: none;
}

.tv-station.is-updated::after {
    animation: tv-station-flash 4s ease-out;
}

@keyframes tv-station-flash {
    0%,
    70% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.tv-station-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.tv-station-no {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--tv-ink);
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
}

.tv-station-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    font-size: 28px;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 「最新回報」標籤（顯示於右上角數秒） */
.tv-station-new {
    position: absolute;
    top: 21px;
    right: 26px;
    padding: 4px 16px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--tv-gold-2), var(--tv-gold));
    color: #ffffff;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.06em;
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
    opacity: 0;
    pointer-events: none;
}

.tv-station.is-updated .tv-station-new {
    animation: tv-new-badge 4s ease-out;
}

@keyframes tv-new-badge {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.8);
    }

    10%,
    80% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(0) scale(1);
    }
}

/* 左右候選人票數（上下兩列，中間以細線分隔） */
.tv-station-rows {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tv-station-row {
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
}

.tv-station-row + .tv-station-row {
    border-top: 2px solid var(--tv-box-divider);
}

.tv-station-candidate {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    overflow: hidden;
    font-size: 26px;
    font-weight: 800;
    white-space: nowrap;
}

.tv-station-candidate::before {
    content: "";
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--side);
}

.tv-station-votes {
    flex: 0 0 auto;
    color: var(--side);
    font-size: 60px;
    font-weight: 900;
    line-height: 1;
}

.tv-station-unit {
    margin-left: 6px;
    color: var(--tv-muted);
    font-size: 22px;
    font-weight: 700;
}

/* 尚未回報的開票所：票數改為灰色 */
.tv-station.is-pending .tv-station-votes {
    color: #94a3b8;
}

.tv-station-time {
    color: var(--tv-muted);
    font-size: 17px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* 尚未設定的開票所 */
.tv-station.is-empty {
    align-items: center;
    justify-content: center;
    border-style: dashed;
}

.tv-station-placeholder {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--tv-muted);
    font-size: 26px;
    font-weight: 800;
}

/* ===== 數字滾動（Odometer） ===== */
.vote-odometer {
    display: inline-block;
    font-variant-numeric: tabular-nums;
}

.odometer-inner {
    display: inline-flex;
    align-items: flex-start;
    height: var(--vote-odometer-height);
    line-height: var(--vote-odometer-height);
}

.odometer-digit {
    display: inline-block;
    height: var(--vote-odometer-height);
    overflow: hidden;
}

/* 不設定 will-change：每個位數常駐一個合成圖層會佔用大量顯示記憶體，滾動時瀏覽器會自動暫時提升 */
.odometer-strip {
    display: block;
    transition: transform 1.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.odometer-strip > span {
    display: block;
    height: var(--vote-odometer-height);
    line-height: var(--vote-odometer-height);
    text-align: center;
}

.odometer-sep {
    display: inline-block;
    height: var(--vote-odometer-height);
    line-height: var(--vote-odometer-height);
}

/* =====================================================================
 * 等待畫面
 * ---------------------------------------------------------------------
 * - 開票狀態為「等待」時覆蓋於開票畫面上方（is-active），改為「開始」時淡出
 * - 有上傳圖片時（has-image）滿版顯示 1920 × 1080 圖片，否則為黑底白字、置中的大字目前時間
 * - 有設定 YouTube 影片時由 vote.js 於 .tv-wait-video 插入播放器，開始播放後才淡入（is-playing）蓋住圖片 / 時間
 * - 覆蓋期間下方票數仍持續更新
 * ===================================================================== */
.tv-wait {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 1s ease, visibility 0s linear 1s;
}

.tv-wait.is-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 1s ease, visibility 0s linear 0s;
}

.tv-wait-image {
    position: absolute;
    inset: 0;
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tv-wait.has-image .tv-wait-image {
    display: block;
}

/* 未上傳圖片時：正中央的目前時間 */
.tv-wait-clock {
    color: #ffffff;
    font-size: 320px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    line-height: 1;
}

.tv-wait.has-image .tv-wait-clock {
    display: none;
}

/* YouTube 影片：不接收滑鼠事件（雙擊全螢幕、點擊恢復聲音由頁面處理） */
.tv-wait-video {
    position: absolute;
    inset: 0;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.tv-wait-video.is-playing {
    opacity: 1;
}

.tv-wait-video iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ===== 使用者設定減少動態效果 ===== */
@media (prefers-reduced-motion: reduce) {
    .tv-candidate.is-leading .tv-candidate-badge,
    .tv-candidate.is-updated .tv-candidate-photo::after,
    .tv-candidate-delta.is-show,
    .tv-station.is-updated::after,
    .tv-station.is-updated .tv-station-new {
        animation: none;
    }

    .odometer-strip {
        transition: none;
    }
}

/* =====================================================================
 * 恭喜當選
 * ---------------------------------------------------------------------
 * - 後台開啟「恭喜當選」且開票狀態為「開始」時循環播放（vote.js：顯示 10 秒→淡出→10 秒後再淡入），顯示期間舞台加上 is-celebrating：
 *   夜空與煙火畫布（vote-fireworks.js）淡入於開票內容下層，
 *   候選人對決區移到畫面下方並縮小（保留原本介面與即時票數），
 *   各開票所淡出，上方留給煙火，中間顯示當選文字
 * - 文字與數字改為夜間配色；領先標示改為「當選」
 * - 為降低電視負擔，星空、當選人光環與當選文字皆為靜態（不做閃爍、脈動、光澤掃過），日夜配色一次切換不做漸變
 * ===================================================================== */
.tv-celebrate {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease, visibility 0s linear 0.8s;
}

.tv-stage.is-celebrating .tv-celebrate {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.8s ease, visibility 0s linear 0s;
}

/* 夜空 */
.tv-celebrate-sky {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 70% 45% at 50% 108%, rgba(255, 140, 60, 0.22) 0%, rgba(255, 140, 60, 0) 70%),
        radial-gradient(ellipse 120% 90% at 50% 100%, rgb(58, 30, 104) 0%, rgb(14, 18, 54) 48%, rgb(3, 5, 18) 100%);
}

/* 星空 */
.tv-celebrate-sky::before,
.tv-celebrate-sky::after {
    content: "";
    position: absolute;
    inset: 0 0 35% 0;
    background-image:
        radial-gradient(1.6px 1.6px at 6% 14%, rgba(255, 255, 255, 0.9), transparent),
        radial-gradient(1.2px 1.2px at 14% 38%, rgba(255, 255, 255, 0.7), transparent),
        radial-gradient(2px 2px at 23% 8%, rgba(255, 240, 210, 0.9), transparent),
        radial-gradient(1.2px 1.2px at 31% 27%, rgba(255, 255, 255, 0.6), transparent),
        radial-gradient(1.6px 1.6px at 42% 12%, rgba(220, 230, 255, 0.85), transparent),
        radial-gradient(1.2px 1.2px at 53% 33%, rgba(255, 255, 255, 0.6), transparent),
        radial-gradient(2px 2px at 61% 6%, rgba(255, 255, 255, 0.9), transparent),
        radial-gradient(1.2px 1.2px at 70% 22%, rgba(255, 240, 210, 0.7), transparent),
        radial-gradient(1.6px 1.6px at 79% 41%, rgba(255, 255, 255, 0.75), transparent),
        radial-gradient(1.2px 1.2px at 86% 10%, rgba(220, 230, 255, 0.8), transparent),
        radial-gradient(2px 2px at 94% 30%, rgba(255, 255, 255, 0.85), transparent);
    opacity: 0.8;
}

.tv-celebrate-sky::after {
    transform: translate(48px, 36px) scaleX(-1);
    opacity: 0.5;
}

/* 煙火畫布 */
.tv-fireworks {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ===== 版面調整：候選人對決區移到下方，各開票所淡出 ===== */
.tv-match {
    transform-origin: 50% 0;
    transition: transform 1s var(--tv-ease);
}

.tv-stations {
    transition: opacity 0.8s ease, visibility 0s linear 0s;
}

.tv-stage.is-celebrating .tv-match {
    transform: translateY(560px) scale(0.8);
}

.tv-stage.is-celebrating .tv-stations {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}

/* ===== 夜間配色 ===== */
/* 深色背景上的代表色（較原本代表色明亮） */
.tv-stage.is-celebrating {
    --tv-left-night: #6aa8ff;
    --tv-right-night: #ff9d52;
}

.tv-stage.is-celebrating .tv-candidate.is-left {
    --side-night: var(--tv-left-night);
}

.tv-stage.is-celebrating .tv-candidate.is-right {
    --side-night: var(--tv-right-night);
}

.tv-title,
.tv-clock-time,
.tv-clock-date,
.tv-candidate-name,
.tv-candidate-votes,
.tv-candidate-unit,
.tv-label,
.tv-total-value,
.tv-gap,
.tv-gap-unit {
    /* 不做顏色漸變（避免移動中的候選人區每格重繪），於夜空淡入約一半時一次切換 */
    transition: color 0s linear 0.4s, background-color 0s linear 0.4s;
}

.tv-stage.is-celebrating .tv-title,
.tv-stage.is-celebrating .tv-clock-time,
.tv-stage.is-celebrating .tv-candidate-name,
.tv-stage.is-celebrating .tv-total-value {
    color: #ffffff;
}

.tv-stage.is-celebrating .tv-clock-date,
.tv-stage.is-celebrating .tv-candidate-unit,
.tv-stage.is-celebrating .tv-label,
.tv-stage.is-celebrating .tv-gap-unit {
    color: rgba(226, 232, 240, 0.72);
}

.tv-stage.is-celebrating .tv-candidate-votes {
    color: var(--side-night);
    text-shadow: 0 0 28px var(--side-shadow);
}

.tv-stage.is-celebrating .tv-gap[data-leader="left"] {
    color: var(--tv-left-night);
}

.tv-stage.is-celebrating .tv-gap[data-leader="right"] {
    color: var(--tv-right-night);
}

/* 當選人照片：金色光環（靜態） */
.tv-stage.is-celebrating .tv-candidate.is-leading .tv-candidate-photo {
    box-shadow: 0 0 0 3px var(--side), 0 0 0 12px rgba(251, 191, 36, 0.85), 0 0 60px 16px rgba(251, 191, 36, 0.45);
}

.tv-stage.is-celebrating .tv-gap[data-leader="left"] .tv-label,
.tv-stage.is-celebrating .tv-gap[data-leader="right"] .tv-label {
    color: inherit;
}

.tv-stage.is-celebrating .tv-vs-text {
    box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.16);
}

/* 領先標示改為「當選」 */
.tv-badge-win,
.tv-stage.is-celebrating .tv-badge-lead {
    display: none;
}

.tv-stage.is-celebrating .tv-badge-win {
    display: inline;
}

/* ===== 當選文字 ===== */
.tv-celebrate-message {
    position: absolute;
    top: 320px;
    left: 50%;
    width: 1760px;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%);
    transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}

.tv-celebrate-message::before {
    content: "";
    position: absolute;
    inset: -60px -40px;
    z-index: -1;
    background: radial-gradient(closest-side, rgba(3, 5, 18, 0.55), rgba(3, 5, 18, 0));
}

.tv-stage.is-celebrating .tv-celebrate-message {
    opacity: 1;
    visibility: visible;
    transition: none;
    animation: tv-celebrate-in 1s var(--tv-ease) 0.2s both;
}

.tv-celebrate-text {
    display: inline-block;
    padding: 0 0.1em;
    background-image: linear-gradient(100deg, #fff1c2 0%, #ffd36b 22%, #f5a524 40%, #fff9e6 50%, #f5a524 60%, #ffd36b 78%, #fff1c2 100%);
    background-position: 0 0;
    background-size: 260% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 116px;
    font-weight: 900;
    letter-spacing: 0.06em;
    line-height: 1.25;
    white-space: nowrap;
    filter: drop-shadow(0 5px 0 rgba(122, 58, 0, 0.6)) drop-shadow(0 0 30px rgba(255, 186, 84, 0.55));
}

.tv-celebrate-name {
    padding: 0 0.14em;
    background-image: linear-gradient(180deg, #ffffff 0%, #fff3c4 38%, #ffc53d 72%, #ff9a1a 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: 1.276em; /* 姓名放大（1.16em × 1.1） */
}

/* 進場只使用 opacity / transform（不做 blur 濾鏡動畫） */
@keyframes tv-celebrate-in {
    0% {
        opacity: 0;
        transform: translate(-50%, 40px) scale(0.72);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tv-stage.is-celebrating .tv-celebrate-message {
        animation: none;
    }

    .tv-match {
        transition: none;
    }
}
