:root {
    --ink: #f5f1df;
    --muted: #a6b2a6;
    --line: #ffffff20;
    --field: #102d25;
    --gold: #f0cb51;
    --display: "Fraunces", Georgia, serif;
    --body: "DM Sans", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body { overflow: hidden; color: var(--ink); background-color: var(--field); background-image: linear-gradient(45deg, #ffffff05 25%, transparent 25%, transparent 75%, #ffffff05 75%), linear-gradient(45deg, #ffffff05 25%, transparent 25%, transparent 75%, #ffffff05 75%); background-position: 0 0, 24px 24px; background-size: 48px 48px; font-family: var(--body); }
.tv-header { height: 12vh; min-height: 92px; max-height: 132px; display: flex; align-items: center; justify-content: space-between; padding: 0 4.2vw; border-bottom: 1px solid var(--line); background: #0b251f; }
.tv-brand { display: flex; align-items: center; gap: 17px; }
.tv-brand img { width: 65px; height: 65px; object-fit: contain; background: #f5f2e7; border-radius: 2px; }
.tv-brand span { display: grid; gap: 4px; }
.tv-brand small, .tv-class > span { color: #b3c3b3; font-size: 10px; font-weight: 700; letter-spacing: 1.3px; }
.tv-brand strong { font-family: var(--display); font-size: 23px; font-weight: 600; }
.tv-class { display: grid; gap: 4px; text-align: center; }
.tv-class strong { color: var(--gold); font-family: var(--display); font-size: 26px; font-weight: 600; }
.tv-lesson-hours { color: #94a89a; font-size: 10px; font-variant-numeric: tabular-nums; }
.tv-time { min-width: 220px; display: flex; justify-content: end; align-items: center; gap: 11px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.sound-toggle { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 10px; border: 1px solid #ffffff30; border-radius: 3px; color: #d9e4d8; background: #ffffff0a; }
.sound-toggle span { color: var(--gold); font-size: 18px; }
.sound-toggle small { font-family: var(--body); font-size: 10px; font-weight: 600; white-space: nowrap; }
.sound-toggle[aria-pressed="true"] { border-color: #90c9a1; color: #e8f4e8; background: #72b48522; }
.sound-toggle[aria-pressed="true"] span { color: #9ee0ad; }
.tv-time i { width: 8px; height: 8px; border-radius: 50%; background: #caa43e; box-shadow: 0 0 0 4px #caa43e26; }
.tv-time i.is-live { background: #66c98b; box-shadow: 0 0 0 4px #66c98b26; }
.tv-layout { height: 88vh; max-height: calc(100vh - 92px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 27.5vw); }
.tv-countdown { position: fixed; z-index: 6; inset: 0; display: grid; place-items: center; padding: 4vw; background: #071b15ef; animation: countdown-enter .35s ease-out both; }
.tv-countdown[hidden] { display: none; }
.tv-countdown-panel { width: min(1000px, 90vw); display: grid; justify-items: center; gap: 12px; padding: 5vh 5vw; border: 2px solid #f0cb51; border-radius: 8px; background: #123c30; box-shadow: 0 0 0 9px #f0cb5118, 0 25px 90px #0009; text-align: center; }
.tv-countdown-kicker { color: #f0cb51; font-size: clamp(15px, 1.6vw, 24px); font-weight: 700; letter-spacing: 2px; }
.tv-countdown-panel > strong { color: #fff8df; font-family: var(--display); font-size: clamp(110px, 24vw, 330px); line-height: .95; font-weight: 600; font-variant-numeric: tabular-nums; }
.tv-countdown-class { color: #d6e4d5; font-size: clamp(17px, 2vw, 26px); }
.tv-countdown.is-urgent .tv-countdown-panel { border-color: #ff9a80; animation: countdown-pulse 1s ease-in-out infinite alternate; }
.tv-countdown.is-urgent .tv-countdown-kicker { color: #ffad8f; }
.tv-round { min-width: 0; display: flex; flex-direction: column; padding: 2.5vh 2.4vw 2.5vh 4.2vw; }
.tv-section-head { min-height: 77px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.tv-kicker { display: block; color: var(--gold); font-size: 10px; font-weight: 700; letter-spacing: 1.6px; margin-bottom: 5px; }
.tv-section-head h1, .tv-section-head h2 { margin: 0; font-family: var(--display); font-size: 30px; line-height: 1; font-weight: 600; letter-spacing: 0; }
.round-status { flex: none; color: #bdcbbf; font-size: 11px; }
.tv-pairings { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 12px; padding-top: 13px; }
.tv-match { min-width: 0; display: flex; align-items: center; border: 1px solid #ffffff24; border-radius: 4px; overflow: hidden; background: linear-gradient(115deg, #ffffff0c, #ffffff04); animation: match-enter .45s both; }
.tv-match:nth-child(2) { animation-delay: .04s; }
.tv-match:nth-child(3) { animation-delay: .08s; }
.tv-match:nth-child(4) { animation-delay: .12s; }
.tv-match:nth-child(5) { animation-delay: .16s; }
.tv-match:nth-child(6) { animation-delay: .2s; }
.match-table { width: 34px; height: 100%; flex: none; display: grid; place-items: center; border-right: 1px solid #ffffff1c; color: var(--gold); font-family: var(--display); font-size: 14px; }
.tv-player-pair { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) 25px minmax(0, 1fr); align-items: center; justify-items: center; gap: 2px; padding: 9px 12px; }
.tv-player { width: 100%; min-width: 0; height: 100%; display: grid; justify-items: center; align-content: center; gap: 5px; text-align: center; }
.tv-player img { width: clamp(62px, 7.2vw, 112px); height: clamp(72px, 9.7vh, 115px); object-fit: cover; border: 2px solid #f3eedc; border-radius: 3px; background: #dfe7df; }
.tv-player strong { width: 100%; display: -webkit-box; overflow: hidden; color: #f8f5e9; font-size: clamp(11px, 1vw, 16px); line-height: 1.17; font-weight: 600; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.tv-vs { color: var(--gold); font-family: var(--display); font-size: 15px; }
.tv-bye { margin: 0 14px; color: var(--muted); font-size: 12px; }
.tv-board { min-height: 0; display: flex; flex-direction: column; padding: 2.5vh 2.1vw 1.8vh; background: #0b251f; border-left: 1px solid var(--line); }
.ranking-head { min-height: 77px; }
.ranking-head h2 { font-size: 25px; }
.trophy-mark { color: var(--gold); font-size: 26px; }
.tv-standings { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.standing-row { min-height: 0; flex: 1 1 0; display: grid; grid-template-columns: 23px 39px minmax(0, 1fr) auto; gap: 8px; align-items: center; border-top: 1px solid #ffffff17; }
.standing-rank { color: #92a69a; font-size: 11px; text-align: center; font-variant-numeric: tabular-nums; }
.standing-row:nth-child(-n+3) .standing-rank { color: var(--gold); font-weight: 700; }
.standing-row img { width: 34px; height: 41px; object-fit: cover; border-radius: 2px; background: #dfe7df; }
.standing-name { min-width: 0; display: grid; gap: 4px; }
.standing-name strong { overflow: hidden; color: #f1f3e8; font-size: clamp(10px, .8vw, 13px); line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.standing-name span { color: #98aa9c; font-size: 9px; }
.standing-score { padding-left: 3px; color: var(--gold); font-family: var(--display); font-size: clamp(15px, 1.2vw, 20px); font-variant-numeric: tabular-nums; }
.tv-board-footer { display: grid; gap: 4px; padding-top: 11px; color: #799083; font-size: 8px; letter-spacing: .8px; }
.tv-announcement { position: fixed; z-index: 4; left: 50%; bottom: 5vh; width: min(940px, 86vw); min-height: 168px; display: flex; align-items: center; gap: 23px; padding: 18px 28px; border: 2px solid #f4d66b; border-radius: 6px; background: #0b251ff7; box-shadow: 0 18px 80px #0009, 0 0 0 100vmax #071a1280; opacity: 0; transform: translate(-50%, 18px) scale(.96); pointer-events: none; transition: opacity .3s ease, transform .3s cubic-bezier(.2,.8,.2,1); }
.tv-announcement.is-visible { opacity: 1; transform: translate(-50%, 0) scale(1); animation: announcement-pop .42s cubic-bezier(.2,.8,.2,1) both; }
.tv-announcement.is-positive { border-color: #9bdc8a; }
.tv-announcement.is-negative { border-color: #f08b70; }
.tv-announcement img { width: 98px; height: 126px; flex: none; object-fit: cover; border: 3px solid var(--gold); border-radius: 4px; background: #dfe7df; }
.tv-announcement.is-positive img { border-color: #9bdc8a; }
.tv-announcement.is-negative img { border-color: #f08b70; }
.tv-announcement > div { min-width: 0; flex: 1; }
.tv-announcement > div span { display: block; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: 1.5px; }
.tv-announcement.is-positive > div span, .tv-announcement.is-positive > b { color: #afe89e; }
.tv-announcement.is-negative > div span, .tv-announcement.is-negative > b { color: #ff9a80; }
.tv-announcement > div strong { display: block; margin-top: 7px; font-family: var(--display); font-size: clamp(25px, 2.2vw, 36px); line-height: 1.1; font-weight: 600; }
.tv-announcement > div p { margin: 7px 0 0; color: #d1dbd0; font-size: clamp(14px, 1.15vw, 18px); line-height: 1.35; }
.tv-announcement > b { flex: none; color: var(--gold); font-family: var(--display); font-size: 38px; }
.tv-demo { position: fixed; left: 14px; bottom: 10px; color: #ffffff40; font-size: 9px; letter-spacing: .5px; }
.empty-round { grid-column: 1 / -1; display: grid; place-content: center; text-align: center; color: #9fb1a4; font-size: 15px; border: 1px dashed #ffffff36; }
.empty-round strong { color: #e4e9da; font-family: var(--display); font-size: 25px; font-weight: 600; margin-bottom: 7px; }
@keyframes match-enter { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }
@keyframes announcement-pop { 0% { filter: brightness(.8); } 45% { filter: brightness(1.24); } 100% { filter: brightness(1); } }
@keyframes countdown-enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes countdown-pulse { from { box-shadow: 0 0 0 7px #ff9a8018, 0 25px 90px #0009; } to { box-shadow: 0 0 0 15px #ff9a8030, 0 25px 100px #000b; } }
.tv-quiz[hidden] { display: none; }
.tv-quiz { position: fixed; z-index: 8; inset: 0; display: grid; place-items: center; overflow: hidden; padding: 4vw; background: radial-gradient(ellipse at 50% 42%, #1d503d 0, #12372d 45%, #071d17 100%); animation: quiz-stage-enter .7s ease-out both; }
.tv-body.quiz-mode { background: #071d17; }
.tv-body.quiz-mode .tv-header, .tv-body.quiz-mode .tv-layout, .tv-body.quiz-mode .tv-countdown, .tv-body.quiz-mode .tv-announcement, .tv-body.quiz-mode .tv-demo { display: none !important; }
.tv-quiz-shell { width: min(1100px, 92vw); min-height: min(820px, 90vh); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.tv-quiz-logo { width: clamp(52px, 6vw, 82px); height: clamp(52px, 6vw, 82px); margin-bottom: 20px; border-radius: 4px; object-fit: contain; background: #f5f2e7; }
.tv-quiz-kicker { color: var(--gold); font-size: clamp(12px, 1.25vw, 19px); font-weight: 700; letter-spacing: 3px; }
.tv-quiz-shell > h1 { margin: 8px 0 28px; color: #eef1e3; font-family: var(--display); font-size: clamp(28px, 4vw, 54px); font-weight: 600; }
.tv-quiz-stage { width: min(850px, 90vw); min-height: clamp(250px, 46vh, 470px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; border: 1px solid #ffffff2c; border-radius: 10px; background: linear-gradient(135deg, #ffffff12, #ffffff05); box-shadow: 0 25px 100px #0005, inset 0 1px #ffffff14; }
.tv-quiz-status { color: var(--gold); font-size: clamp(12px, 1.2vw, 18px); font-weight: 700; letter-spacing: 2px; }
.tv-quiz-stage > strong { max-width: 90%; color: #fff8df; font-family: var(--display); font-size: clamp(34px, 6.3vw, 82px); line-height: 1.05; font-weight: 600; overflow-wrap: anywhere; }
.tv-quiz-stage > strong.tv-quiz-student-name { font-size: clamp(28px, 4.8vw, 58px); }
.tv-quiz-stage > img { width: clamp(120px, 17vh, 180px); height: clamp(155px, 23vh, 235px); border: 4px solid #f1d56e; border-radius: 7px; object-fit: cover; box-shadow: 0 10px 45px #0007; animation: quiz-photo-reveal .65s cubic-bezier(.2,.8,.2,1) both; }
.tv-quiz-question { width: min(760px, 88%); margin: 1px 0 4px; color: #fff8df; font-family: var(--display); font-size: clamp(22px, 3.4vw, 46px); line-height: 1.18; }
.tv-quiz-wait { color: #b5c7b8; font-size: clamp(13px, 1.3vw, 19px); }
.tv-quiz-spinner { color: var(--gold); font-size: clamp(54px, 10vw, 116px); line-height: 1; animation: quiz-spin 1.6s linear infinite; text-shadow: 0 0 30px #f0cb5177; }
.tv-quiz-stage.is-drawing > strong { min-height: 1.2em; animation: quiz-name-flash .35s ease-in-out infinite alternate; }
.tv-quiz-countdown { color: #f5e9bc; font-size: clamp(18px, 2.3vw, 30px); font-variant-numeric: tabular-nums; }
.tv-quiz-progress { width: min(850px, 90vw); height: 7px; margin-top: 19px; overflow: hidden; border-radius: 10px; background: #ffffff20; }
.tv-quiz-progress span { width: 0; height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, #d4ad31, #ffe985); box-shadow: 0 0 15px #f0cb51; transition: width .1s linear; }
.tv-quiz-stage.is-result.is-correct .tv-quiz-status, .tv-quiz-stage.is-result.is-correct .tv-quiz-result-points { color: #a9e99c; }
.tv-quiz-stage.is-result.is-incorrect .tv-quiz-status { color: #e8c670; }
.tv-quiz-stage.is-result.is-refused .tv-quiz-status, .tv-quiz-stage.is-result.is-refused .tv-quiz-result-points { color: #ff9b82; }
.tv-quiz-result-points { color: var(--gold); font-family: var(--display); font-size: clamp(24px, 3vw, 40px); }
.tv-quiz-footer { margin: 24px 0 0; color: #739082; font-size: 9px; font-weight: 700; letter-spacing: 2px; }
.tv-mural[hidden] { display: none; }
.tv-mural { position: fixed; z-index: 9; inset: 0; display: grid; place-items: center; overflow: hidden; padding: 1vh 1vw; background: radial-gradient(ellipse at 50% 45%, #1d503d 0, #12372d 48%, #071d17 100%); }
.tv-body.chessboard-mode { background: #071d17; }
.tv-body.chessboard-mode .tv-header, .tv-body.chessboard-mode .tv-layout, .tv-body.chessboard-mode .tv-countdown, .tv-body.chessboard-mode .tv-quiz, .tv-body.chessboard-mode .tv-announcement, .tv-body.chessboard-mode .tv-demo { display: none !important; }
.tv-mural-shell { width: 100%; height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); justify-items: center; gap: clamp(4px, 1vh, 10px); }
.tv-mural-title { color: #f0cb51; font-size: clamp(9px, .8vw, 13px); font-weight: 700; letter-spacing: clamp(1px, .3vw, 4px); }
.tv-mural-frame { width: min(94vh, 96vw); max-height: 94vh; aspect-ratio: 1; border: clamp(6px, 1vw, 14px) solid #684526; border-radius: 5px; padding: clamp(4px, .6vw, 8px); background: #b8834d; box-shadow: 0 18px 70px #0008, inset 0 0 0 2px #e3bb80; }
.tv-mural-frame > div { width: 100%; }
@keyframes quiz-spin { to { transform: rotate(360deg); } }
@keyframes quiz-name-flash { from { opacity: .4; filter: blur(1.2px); transform: scale(.98); } to { opacity: 1; filter: blur(0); transform: scale(1.01); } }
@keyframes quiz-photo-reveal { from { opacity: 0; transform: translateY(20px) scale(.88); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes quiz-stage-enter { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 1800px) {
    .tv-player img { width: 118px; height: 130px; }
    .standing-row { grid-template-columns: 28px 47px minmax(0, 1fr) auto; gap: 11px; }
    .standing-row img { width: 42px; height: 48px; }
}
@media (max-width: 1100px) {
    .tv-layout { grid-template-columns: minmax(0, 1fr) minmax(255px, 30vw); }
    .tv-round { padding-left: 3vw; padding-right: 1.5vw; }
    .tv-board { padding-left: 1.5vw; padding-right: 1.5vw; }
    .tv-player-pair { padding: 8px 7px; }
    .tv-player img { width: 65px; height: 80px; }
}
@media (max-aspect-ratio: 1/1) {
    body { overflow: auto; }
    .tv-header { min-height: 76px; height: auto; padding: 12px 4vw; }
    .tv-brand img { width: 45px; height: 45px; }
    .tv-brand strong { font-size: 17px; }
    .tv-brand small { font-size: 8px; }
    .tv-class strong { font-size: 18px; }
    .tv-class > span { font-size: 8px; }
    .tv-lesson-hours { font-size: 8px; }
    .tv-time { min-width: auto; gap: 7px; font-size: 11px; }
    .sound-toggle { min-height: 32px; padding: 0 7px; }
    .sound-toggle small { font-size: 9px; }
    .tv-layout { height: auto; max-height: none; grid-template-columns: 1fr; }
    .tv-round { min-height: 64vh; padding: 18px 4vw; }
    .tv-section-head { min-height: 68px; }
    .tv-section-head h1 { font-size: 25px; }
    .tv-pairings { min-height: 54vh; grid-template-rows: none; grid-auto-rows: 170px; gap: 8px; }
    .tv-player img { width: 70px; height: 85px; }
    .tv-board { min-height: 48vh; padding: 17px 5vw 20px; border-left: 0; border-top: 1px solid var(--line); }
    .tv-standings { overflow: visible; }
    .standing-row { min-height: 52px; flex: none; }
    .tv-announcement { width: 92vw; bottom: 2vh; min-height: 118px; padding: 12px; gap: 11px; }
    .tv-announcement img { width: 63px; height: 78px; }
    .tv-announcement > div span { font-size: 8px; }
    .tv-announcement > div strong { font-size: 19px; }
    .tv-announcement > div p { margin-top: 4px; font-size: 11px; }
    .tv-announcement > b { font-size: 24px; }
    .tv-countdown-panel { width: 100%; gap: 8px; padding: 5vh 4vw; }
    .tv-countdown-panel > strong { font-size: clamp(86px, 22vw, 150px); }
    .tv-countdown-kicker { font-size: 12px; letter-spacing: 1.3px; }
    .tv-quiz { padding: 18px; }
    .tv-quiz-shell { min-height: 90vh; }
    .tv-quiz-logo { width: 48px; height: 48px; margin-bottom: 12px; }
    .tv-quiz-shell > h1 { margin: 6px 0 18px; font-size: 28px; }
    .tv-quiz-stage { min-height: 48vh; gap: 12px; padding: 15px; }
    .tv-quiz-stage > strong { font-size: clamp(32px, 9vw, 54px); }
    .tv-quiz-stage > strong.tv-quiz-student-name { font-size: clamp(26px, 7vw, 42px); }
    .tv-quiz-stage > img { width: 110px; height: 145px; }
    .tv-quiz-question { font-size: clamp(20px, 5.5vw, 30px); }
}
@media (max-width: 600px) {
    .tv-pairings { grid-template-columns: 1fr; grid-auto-rows: 148px; }
    .tv-player img { width: 67px; height: 79px; }
    .tv-player strong { font-size: 12px; }
    .round-status { font-size: 9px; text-align: right; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}