*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
html {
    height: 100%;
}
body {
    height: 100%;
    background-color: #000;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    -webkit-box-align: start;
        -ms-flex-align: start;
            align-items: flex-start;
    font-family: 'Noto Sans TC', sans-serif;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
       -moz-text-size-adjust: 100%;
            text-size-adjust: 100%;
}
.TV-screen {
    width: 1080px;
    height: 1920px;
    background-color: #151515;
    position: relative;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    overflow: hidden;
    -ms-flex-negative: 0;
        flex-shrink: 0;
}
/* ── COUNTDOWN BAR ── */
.countdown-bar {
    width: 710px;
    height: 112px;
    -ms-flex-negative: 0;
        flex-shrink: 0;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    margin-top: 35px;
}
.countdown-bar p {
    font-family: 'Noto Sans TC', sans-serif;
    font-size: 30px;
    font-weight: 500;
    color: #e7e7e7;
    letter-spacing: 0.05em;
    line-height: 1.2;
}
.countdown-bar .cd-num {
    font-size: 80px;
    font-weight: 900;
    color: #FDD001;
    margin: 0 10px;
    vertical-align: bottom;
    line-height: 1;
    display: inline-block;
}
/* ── MAIN RESULT CARD ── */
.result-card {
    width: 790px;
    height: 1400px;
    -ms-flex-negative: 0;
        flex-shrink: 0;
    position: relative;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    overflow: hidden;
    background-image: url('../img_TV/Result_01.svg');
    background-size: 100% auto;
    background-repeat: no-repeat;
    background-position: top center;
    border-radius: 20px;
}
/* ── Cheetah illustration ── */
.cheetah {
    width: 500px;
    height: 500px;
    position: relative;
    display: block;
    top: 16.5%;
    -ms-flex-item-align: center;
        align-self: center;
    -ms-flex-negative: 0;
        flex-shrink: 0;
}
/* ── Stat value overlays ── */
.score {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    position: relative;
    top: 26.5%;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    color: #2a2a2a;
}
.stat-val {
    position: relative;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: baseline;
        -ms-flex-align: baseline;
            align-items: baseline;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    gap: 8px;
    z-index: 1;
    width: 33%;
}
.stat-val .num {
    font-weight: 900;
    font-size: 60px;
    line-height: 1;
    letter-spacing: -0.02em;
}
.stat-val .unit {
    font-weight: 700;
    font-size: 20px;
    line-height: 1;
}
#val-height {
    left: 20px;
}
#val-score {
    right: 20px;
}
/* ── QR SECTION ── */
.qr-section {
    width: 780px;
    height: 200px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-negative: 0;
        flex-shrink: 0;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    position: relative;
    margin: 36px 0 10px 0;
    gap: 5%;
}
.QRcode {
    width: 25%;
    height: 100%;
    position: relative;
    -ms-flex-negative: 0;
        flex-shrink: 0;
}
/* Scan frame fills the QRcode container */
.qr-scan {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    -o-object-fit: contain;
       object-fit: contain;
    -o-object-position: center;
       object-position: center;
}
/* QR code image centered on top of the scan frame */
.qr-code {
    width: 76%;
    height: 76%;
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
        -ms-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
    display: block;
    -o-object-fit: contain;
       object-fit: contain;
    z-index: 1;
}
.QRcode-instruction {
    width: 70%;
    position: relative;
}
.player-name {
    font-weight: 500;
    font-size: 32px;
    color: #ffffff;
    letter-spacing: 0.05em;
    line-height: 2.25;
}
.qr-instructions {
    font-family: 'Noto Sans TC', sans-serif;
    font-weight: 400;
    font-size: 28px;
    color: #ffffff;
    letter-spacing: 0.04em;
    line-height: 1.5;
}
/* ── FOOTER ── */
.footer-area {
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 100%;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
}
.footer-area img {
    width: 345px;
    display: block;
}
/* ── MOBILE LAYOUT (hidden by default on TV) ── */
.mobile-screen {
    display: none;
}
/* ─ INVALID / ERROR STATE ─ */
.TV-screen.state--invalid {
    -webkit-box-pack: start;
        -ms-flex-pack: start;
            justify-content: flex-start;
}
.error-content {
    -webkit-box-flex: 1;
        -ms-flex: 1 1 auto;
            flex: 1 1 auto;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
}
.error-line {
    font-weight: 900;
    font-size: 70px;
    color: #ffffff;
    text-align: center;
    letter-spacing: 0.05em;
    line-height: 1.3;
}
/* MOBILE LAYOUT */
@media (max-width: 768px) {
    html {
        height: auto;
    }
    body {
        display: block;
        background-color: #151515;
        overflow-x: hidden;
    }
    .TV-screen {
        display: none !important;
    }
    .mobile-screen {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-orient: vertical;
        -webkit-box-direction: normal;
            -ms-flex-direction: column;
                flex-direction: column;
        -webkit-box-align: center;
            -ms-flex-align: center;
                align-items: center;
        width: 100%;
        min-height: 100vh;
        min-height: 100svh;
        background-color: #151515;
        padding: 24px 20px 40px;
        -webkit-box-sizing: border-box;
                box-sizing: border-box;
        gap: 20px;
        position: relative;
    }
    /* ── Download failure overlay ── */
    .m-fail-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.65);
        z-index: 200;
        -webkit-box-pack: center;
            -ms-flex-pack: center;
                justify-content: center;
        -webkit-box-align: center;
            -ms-flex-align: center;
                align-items: center;
    }
    .m-fail-overlay.is-visible {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-animation: m-fail-fade-in 0.2s ease-out;
                animation: m-fail-fade-in 0.2s ease-out;
    }
    .m-fail-dialog {
        width: min(280px, 82%);
        height: auto;
        display: block;
    }
    .m-result-card {
        width: 100%;
        aspect-ratio: 790 / 1400;
        position: relative;
        overflow: hidden;
        border-radius: 16px;
        -ms-flex-negative: 0;
            flex-shrink: 0;
        background-image: url('../img_TV/Result_01.svg');
        background-size: 100% auto;
        background-repeat: no-repeat;
        background-position: top center;
    }
    .m-cheetah {
        width: 63.29%;
        height: auto;
        position: absolute;
        top: 16.5%;
        left: 50%;
        -webkit-transform: translateX(-50%);
            -ms-transform: translateX(-50%);
                transform: translateX(-50%);
        display: block;
    }
    .m-score {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        position: absolute;
        top: 62.21%;
        left: 0;
        width: 100%;
        -webkit-box-pack: center;
            -ms-flex-pack: center;
                justify-content: center;
        color: #2a2a2a;
    }
    .m-stat-val {
        position: relative;
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-align: baseline;
            -ms-flex-align: baseline;
                align-items: baseline;
        -webkit-box-pack: center;
            -ms-flex-pack: center;
                justify-content: center;
        gap: 3px;
        width: 33.33%;
    }
    #m-val-height {
        left: 10px;
    }
    #m-val-score {
        right: 10px;
    }
    .m-num {
        font-weight: 900;
        font-size: 7vw;
        line-height: 1;
        letter-spacing: -0.02em;
    }
    .m-unit {
        font-weight: 700;
        font-size: 2.6vw;
        line-height: 1;
    }
    .m-save-btn {
        width: 90%;
        height: 64px;
        background-color: #FDD001;
        border: none;
        border-radius: 14px;
        font-family: 'Noto Sans TC', sans-serif;
        font-weight: 700;
        font-size: 22px;
        color: #1a1a1a;
        letter-spacing: 0.05em;
        cursor: pointer;
        -webkit-appearance: none;
           -moz-appearance: none;
                appearance: none;
        outline: none;
        -ms-flex-negative: 0;
            flex-shrink: 0;
        -webkit-animation: m-btn-breathe 2s ease-in-out infinite;
                animation: m-btn-breathe 2s ease-in-out infinite;
    }
    .m-save-btn:active {
        background-color: #D4A800;
        -webkit-animation: none;
                animation: none;
    }
    .m-save-note {
        font-family: 'Noto Sans TC', sans-serif;
        font-weight: 200;
        font-size: 16px;
        color: #888888;
        text-align: center;
        line-height: 1.8;
        letter-spacing: 0.03em;
    }
}

/* ── Failure overlay fade-in ── */
@-webkit-keyframes m-fail-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes m-fail-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Breathing glow for .m-save-btn ── */
@-webkit-keyframes m-btn-breathe {
    0%, 100% {
        box-shadow:
            0 0  3px 0px rgba(235, 215, 140, 0.40),
            0 0  7px 1px rgba(240, 225, 165, 0.18);
    }
    50% {
        box-shadow:
            0 0  6px 1px rgba(235, 215, 140, 0.62),
            0 0 14px 3px rgba(240, 225, 165, 0.28);
    }
}
@keyframes m-btn-breathe {
    0%, 100% {
        box-shadow:
            0 0  3px 0px rgba(235, 215, 140, 0.40),
            0 0  7px 1px rgba(240, 225, 165, 0.18);
    }
    50% {
        box-shadow:
            0 0  6px 1px rgba(235, 215, 140, 0.62),
            0 0 14px 3px rgba(240, 225, 165, 0.28);
    }
}


.beast-glow {
  position: relative;
  display: inline-block;
}

.beast-glow::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 24px;
  background: linear-gradient(
    120deg,
    #fdd001,
    #ff6a00,
    #00eaff,
    #fdd001
  );
  background-size: 300% 300%;
  filter: blur(12px);
  opacity: 0.8;
  z-index: 0;
  animation: glowFlow 3s linear infinite;
}

.beast-glow img {
  position: relative;
  z-index: 1;
  border-radius: 16px;
}

@keyframes glowFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}

.tv-beast-glow {
    width: 500px;
    height: 500px;
    position: relative;
    top: 16.5%;
    align-self: center;
    flex-shrink: 0;
}

.tv-beast-glow .cheetah {
    width: 100%;
    height: 100%;
    top: 0;
}


.beast-glow::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 20px;
  border: 2px solid rgba(255,255,255,0.4);
  animation: pulseBorder 1.5s ease-in-out infinite;
}

@keyframes pulseBorder {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}


.m-beast-glow {
    width: 63.29%;
    position: absolute;
    top: 16.5%;
    left: 50%;
    transform: translateX(-50%);
}

.m-beast-glow .m-cheetah {
    width: 100%;
    height: auto;
    position: relative;
    top: 0;
    left: 0;
    transform: none;
}