/* TV-läge – storbild. Storlekar i vw/vh så att det skalar till skärmen. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: #fff; font-family: Kanit, system-ui, sans-serif; overflow: hidden; }
#tv { display: flex; flex-direction: column; height: 100vh; }

.tv-head { display: flex; align-items: center; gap: 2vw; padding: 1.2vh 2vw; background: linear-gradient(180deg, #161616, #0a0a0a); border-bottom: 1px solid #2a2a2a; }
.tv-logo img { height: 5vh; display: block; }
.tv-title { flex: 1; min-width: 0; }
.tv-name { font-size: 3vh; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-sub { color: #999; font-size: 1.8vh; }
.tv-tabs { display: flex; gap: .5vw; }
.tv-tabs button { background: #1a1a1a; border: 1px solid #333; color: #bbb; font: inherit; font-size: 1.9vh; padding: .8vh 1.4vw; border-radius: 999px; cursor: pointer; }
.tv-tabs button.active { background: #d8ff00; color: #000; border-color: #d8ff00; font-weight: 600; }
.tv-tabs .k { display: inline-block; font-size: .75em; opacity: .55; margin-right: .3em; }
.tv-clock { text-align: right; }
#tv-time { font-size: 4vh; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.tv-upd { color: #777; font-size: 1.5vh; }

.tv-main { flex: 1; min-height: 0; padding: 1.5vh 2vw; overflow: hidden; }
.tv-main.fade { animation: tvfade .5s ease; }
@keyframes tvfade { from { opacity: 0; transform: translateY(1vh); } to { opacity: 1; transform: none; } }

.tv-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1vh; color: #888; font-size: 3vh; }
.tv-empty .big { font-size: 5vh; color: #ccc; font-weight: 600; }
.tv-empty.small { height: auto; font-size: 2.2vh; padding: 3vh 0; }

/* Nu på mattorna */
.tv-mats { display: grid; gap: 1.5vw; height: 100%; }
.tv-mats.cols-1 { grid-template-columns: 1fr; }
.tv-mats.cols-2 { grid-template-columns: 1fr 1fr; }
.tv-mats.cols-3 { grid-template-columns: repeat(3, 1fr); }
.tv-mats.cols-4 { grid-template-columns: repeat(4, 1fr); }
.tv-mat { display: flex; flex-direction: column; min-height: 0; background: #0c0c0c; border: 1px solid #262626; border-radius: 1.2vh; overflow: hidden; }
.tv-mat h2 { margin: 0; padding: 1vh 1.5vw; font-size: 2.6vh; font-weight: 700; background: #161616; border-bottom: 1px solid #262626; display: flex; justify-content: space-between; }
.tv-mat h2 small { color: #888; font-weight: 400; font-size: .7em; }
.tv-live { padding: 1.5vh 1.5vw; border-bottom: 1px solid #262626; background: radial-gradient(ellipse at top, rgba(220, 53, 69, .18), transparent 70%); }
.tv-live.tv-last { background: none; }
.tv-live.tv-idle { color: #777; font-size: 2.4vh; text-align: center; padding: 4vh 0; }
.tv-live-head { display: flex; align-items: center; gap: 1vw; font-size: 1.8vh; color: #aaa; margin-bottom: 1vh; }
.tv-badge { background: #dc3545; color: #fff; font-weight: 700; padding: .2vh .8vw; border-radius: .6vh; font-size: 1.7vh; animation: pulse 1.6s infinite; }
.tv-badge.done { background: #333; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.tv-matchnr { font-weight: 600; color: #fff; }
.tv-info { margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-vs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1vw; }
.tv-side { min-width: 0; padding-left: 1vw; border-left: .6vw solid; }
.tv-side.red { border-color: #e53935; }
.tv-side.blue { border-color: #1e88e5; text-align: right; border-left: 0; border-right: .6vw solid #1e88e5; padding-left: 0; padding-right: 1vw; }
.tv-side.lose { opacity: .55; }
.tv-side.win .tv-nm::after { content: ' ✓'; color: #59b71a; }
.tv-nm { font-size: 3.2vh; font-weight: 700; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-club { font-size: 1.9vh; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-score { display: flex; align-items: baseline; gap: .4vw; font-size: 6vh; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.tv-score .r { color: #ff6b6b; } .tv-score .b { color: #5dade2; } .tv-score .d { color: #555; font-size: .6em; }
.tv-wt { margin-top: .8vh; color: #999; font-size: 1.8vh; text-align: center; }
.tv-mats.cols-3 .tv-nm, .tv-mats.cols-4 .tv-nm { font-size: 2.4vh; }
.tv-mats.cols-3 .tv-score, .tv-mats.cols-4 .tv-score { font-size: 4.5vh; }

.tv-next { flex: 1; min-height: 0; overflow: hidden; padding: 1vh 1.5vw; }
.tv-next-head { color: #d8ff00; font-size: 1.8vh; text-transform: uppercase; letter-spacing: .1em; margin-bottom: .6vh; }
.tv-next-empty { color: #666; font-size: 2vh; }
.tv-next-row { display: grid; grid-template-columns: 3.5vw 1fr auto 1fr auto; gap: .8vw; align-items: center; padding: .7vh 0; border-bottom: 1px solid #1e1e1e; font-size: 2.1vh; }
.tv-next-row .nr { color: #888; font-weight: 600; }
.tv-next-row .who { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-next-row .who small { color: #888; font-size: .75em; margin-left: .4em; }
.tv-next-row .who b.r { color: #ff8a80; } .tv-next-row .who b.b { color: #82b1ff; }
.tv-next-row .who:nth-child(4) { text-align: right; }
.tv-next-row .vs { color: #555; }
.tv-next-row .cls { color: #999; font-size: .85em; white-space: nowrap; }
.tv-mats.cols-3 .tv-next-row, .tv-mats.cols-4 .tv-next-row { grid-template-columns: 2.5vw 1fr 1fr; font-size: 1.8vh; }
.tv-mats.cols-3 .tv-next-row .vs, .tv-mats.cols-4 .tv-next-row .vs, .tv-mats.cols-3 .tv-next-row .cls, .tv-mats.cols-4 .tv-next-row .cls { display: none; }

/* Senaste resultat */
.tv-results { display: grid; grid-template-rows: repeat(14, 1fr); height: 100%; gap: .3vh; }
.tv-res { display: grid; grid-template-columns: 5vw 1fr 8vw 1fr 8vw 11vw; gap: 1vw; align-items: center; padding: 0 1vw; background: #0c0c0c; border-radius: .8vh; font-size: 2.3vh; min-height: 0; }
.tv-res .nr { color: #888; font-weight: 600; } .tv-res .nr small { color: #555; margin-left: .3em; font-size: .7em; }
.tv-res .who { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-res .who b { font-weight: 600; } .tv-res .who small { color: #888; font-size: .75em; margin-left: .5em; }
.tv-res .who.win b { color: #d8ff00; }
.tv-res .who.win.red b::before, .tv-res .who.win.blue b::before { content: ''; display: inline-block; width: .5vw; height: 2vh; margin-right: .5vw; vertical-align: -.3vh; border-radius: .2vh; }
.tv-res .who.win.red b::before { background: #e53935; } .tv-res .who.win.blue b::before { background: #1e88e5; }
.tv-res .sc { text-align: center; font-weight: 800; font-size: 1.15em; font-variant-numeric: tabular-nums; }
.tv-res .wt { text-align: center; } .tv-res .wt small { display: block; color: #777; font-size: .7em; }
.tv-res .cls { color: #999; text-align: right; font-size: .85em; } .tv-res .cls small { display: block; color: #666; font-size: .85em; }

/* Medaljer */
.tv-medal-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 3vw; height: 100%; }
.tv-medal-wrap h3 { margin: 0 0 1vh; font-size: 2.6vh; font-weight: 700; color: #d8ff00; }
.tv-medals { width: 100%; border-collapse: collapse; font-size: 2.4vh; }
.tv-medals th { color: #888; font-weight: 500; text-align: center; padding: .6vh .6vw; border-bottom: 1px solid #333; }
.tv-medals td { padding: .8vh .6vw; text-align: center; border-bottom: 1px solid #1e1e1e; font-variant-numeric: tabular-nums; }
.tv-medals .l { text-align: left; }
.tv-medals tbody tr:first-child td { color: #d8ff00; font-weight: 700; }
.tv-podiums { overflow: hidden; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5vh 2vw; align-content: start; }
.tv-podiums h3 { grid-column: 1 / -1; }
.tv-podium { background: #0c0c0c; border: 1px solid #262626; border-radius: 1vh; padding: 1vh 1vw; font-size: 2vh; }
.tv-podium .h { font-weight: 700; color: #ccc; margin-bottom: .4vh; }
.tv-podium div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tv-podium small { color: #888; font-size: .8em; }

/* Ticker + fot */
.tv-foot { display: flex; align-items: center; background: #0a0a0a; border-top: 1px solid #2a2a2a; height: 5.5vh; }
.tv-ticker { flex: 1; overflow: hidden; white-space: nowrap; }
.tv-ticker-track { display: inline-block; padding-left: 100%; animation: ticker linear infinite; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tv-ticker .ti { display: inline-block; margin-right: 4vw; font-size: 2.2vh; }
.tv-ticker .ti b { color: #d8ff00; } .tv-ticker .ti i { font-style: normal; color: #aaa; margin: 0 .4em; } .tv-ticker .ti u { text-decoration: none; color: #777; margin-left: .6em; font-size: .85em; }
.tv-brand { padding: 0 2vw; color: #666; font-size: 2vh; letter-spacing: .1em; }

/* Inställningar – visas när musen rör sig */
.tv-settings { position: fixed; left: 50%; bottom: 7vh; transform: translate(-50%, 2vh); display: flex; gap: 1vw; align-items: center; background: rgba(20, 20, 20, .95); border: 1px solid #444; border-radius: 999px; padding: .8vh 1.5vw; font-size: 1.8vh; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.show-ui .tv-settings { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.tv-settings label { color: #bbb; display: flex; gap: .4vw; align-items: center; }
.tv-settings select, .tv-settings button { font: inherit; background: #222; color: #fff; border: 1px solid #555; border-radius: .6vh; padding: .3vh .6vw; cursor: pointer; }
.tv-settings a { color: #9bd; text-decoration: none; }

@media (orientation: portrait) {
    .tv-tabs { display: none; }
    .tv-mats { grid-template-columns: 1fr !important; }
    .tv-medal-wrap { grid-template-columns: 1fr; }
    .tv-res { grid-template-columns: 8vw 1fr 12vw 1fr; }
    .tv-res .wt, .tv-res .cls { display: none; }
}
