/* TV mode: 16:9 landscape layout, all in rem; 1rem ≈ 20px at 1920×1080. */
html { font-size: min(1.04vw, 1.85vh); }
html, body { height: 100%; overflow: hidden; }
body { font-size: 1rem; background: radial-gradient(ellipse 80% 60% at 50% 0%, #135c41 0%, var(--felt-dark) 55%, #06261b 100%); }
body.idle { cursor: none; }
.conn { font-size: .8rem; padding: .3rem .8rem; }

/* Pairing */
.pairing { height: 100%; display: grid; place-items: center; }
.pair-card { text-align: center; display: grid; gap: 1.2rem; justify-items: center; padding: 3rem 4rem; border-radius: 2rem; background: rgba(11,19,17,.55); border: .5rem solid var(--rail); box-shadow: inset 0 0 0 .15rem var(--rail-hi), 0 2rem 4rem rgba(0,0,0,.5); }
.pairing h1 { font-family: var(--f-display); font-weight: 400; font-size: 4.5rem; margin: 0; line-height: 1; }
.pairing p { margin: 0; font-size: 1.4rem; color: #cfe3d8; }
.pair-balls { display: flex; gap: .6rem; }
.pair-balls .ball { --size: 3rem; }
#pairForm { display: flex; gap: 1rem; }
#codeIn { width: 16rem; font-family: var(--f-display); font-size: 3rem; letter-spacing: .2em; text-align: center; text-transform: uppercase; background: var(--ink); border: .15rem solid var(--line); border-radius: 1rem; padding: .4rem .6rem; color: var(--brass); }
#codeIn:focus { border-color: var(--brass); outline: none; }
#pairForm button { font-size: 1.6rem; font-weight: 700; padding: 0 2rem; border-radius: 1rem; border: 0; background: var(--brass); color: #1b1305; }
.perr { color: #ffc2b8 !important; min-height: 1.6rem; }

/* Screen */
.screen { height: 100%; display: grid; grid-template-rows: auto 1fr auto; padding: 1.2rem 1.6rem .8rem; gap: 1rem; }
.tvbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.tvbar .tl { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.tvbar .tl .ball { --size: 3.6rem; }
.tvbar h1 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 2.6rem; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tvbar p { margin: .3rem 0 0; font-family: var(--f-label); font-weight: 600; text-transform: uppercase; letter-spacing: .12em; color: #cfe3d8; font-size: 1.1rem; }
.tvbar .tr { display: flex; align-items: center; gap: 1rem; flex: none; }
.clock { font-family: var(--f-display); font-size: 1.8rem; color: #cfe3d8; }
.tvgrid { display: grid; grid-template-columns: 1fr 26rem; gap: 1.2rem; min-height: 0; }
.tvgrid.with-plist { grid-template-columns: 1fr 15rem 23rem; }
.stage { min-height: 0; border-radius: 1.4rem; padding: 1.2rem 1.4rem; background: rgba(6,20,15,.55); border: .4rem solid var(--rail); box-shadow: inset 0 0 0 .12rem var(--rail-hi), inset 0 0 3rem rgba(0,0,0,.4); overflow: hidden; display: flex; flex-direction: column; }
.stage .bracket { flex: 1; min-height: 0; --gap: 2.2rem; --h-size: 1rem; }
.stage .m { background: rgba(11,19,17,.92); border-radius: .7rem; }
.stage .bracket .pair.join::after, .stage .bracket .pair.join .slot::after, .stage .bracket .col.fed .slot::before { border-color: rgba(207,227,216,.35); }
.stage-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .6rem; }
.stage-title h2 { margin: 0; font-family: var(--f-label); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: 1.3rem; color: var(--brass); }
.stage-title span { color: #cfe3d8; font-size: 1.1rem; }

.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .6rem; align-content: start; overflow: hidden; }
.roster div { background: rgba(11,19,17,.85); border: 1px solid var(--line); border-radius: .7rem; padding: .5rem .8rem; font-size: 1.3rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.waiting { margin: auto; text-align: center; }
.waiting b { display: block; font-family: var(--f-display); font-weight: 400; font-size: 3rem; }
.waiting span { font-size: 1.4rem; color: #cfe3d8; }

.side { display: flex; flex-direction: column; gap: 1rem; min-height: 0; overflow: hidden; }
.box { background: rgba(11,19,17,.88); border: 1px solid var(--line); border-radius: 1.1rem; padding: .9rem 1rem; }
.box h2 { margin: 0 0 .6rem; font-family: var(--f-label); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: 1.05rem; color: var(--brass); }
.box ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.tbl { display: grid; grid-template-columns: 3.2rem 1fr; gap: .8rem; align-items: center; }
.tbl .n { width: 3.2rem; height: 3.2rem; border-radius: .7rem; background: var(--felt); border: .2rem solid var(--rail-hi); display: grid; place-items: center; font-family: var(--f-display); font-size: 1.6rem; }
.tbl .who { min-width: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.tbl .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl .who small { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; font-family: var(--f-label); letter-spacing: .08em; text-transform: uppercase; }
.vs { color: var(--muted); font-weight: 500; font-size: .9em; }
.res { display: flex; justify-content: space-between; gap: .6rem; font-size: 1.15rem; }
.res .w { font-weight: 700; color: #ffe5a3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res .s { font-family: var(--f-display); flex: none; }
.res .l { color: var(--muted); font-size: .95rem; display: block; }
.box .none { color: var(--muted); font-size: 1.1rem; }
.box.champ { text-align: center; border-color: var(--brass); background: radial-gradient(ellipse at 50% 0, rgba(216,178,90,.35), transparent 70%), rgba(11,19,17,.9); }
.box.champ b { display: block; font-family: var(--f-display); font-weight: 400; font-size: 2.2rem; color: #ffe5a3; line-height: 1.1; overflow-wrap: anywhere; }

.tvfoot { display: flex; justify-content: center; gap: .6rem; min-height: .8rem; align-items: center; color: #cfe3d8; font-size: 1rem; }
.dot { width: .8rem; height: .8rem; border-radius: 50%; background: rgba(255,255,255,.25); }
.dot.on { background: var(--brass); }

/* Draw and champion animations */
.fx { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-rows: auto 1fr; padding: 2.4rem 3rem; gap: 1.6rem;
  background: radial-gradient(ellipse at 50% 40%, var(--felt-hi), var(--felt) 45%, var(--felt-dark)); border: 1.2rem solid var(--rail); box-shadow: inset 0 0 0 .3rem var(--rail-hi), inset 0 0 6rem rgba(0,0,0,.5); }
.fx h2 { margin: 0; text-align: center; font-family: var(--f-display); font-weight: 400; font-size: 4rem; line-height: 1; text-shadow: 0 .3rem 1rem rgba(0,0,0,.4); }
.fx h2 small { display: block; font-family: var(--f-label); font-size: 1.4rem; letter-spacing: .2em; text-transform: uppercase; color: #cfe3d8; margin-top: .6rem; }
.fx.out { opacity: 0; transition: opacity .6s; }
.shuffle { display: flex; justify-content: center; align-items: center; gap: 1rem; }
.shuffle .ball { --size: 5rem; animation: hop .5s ease-in-out infinite alternate; }
.shuffle .ball:nth-child(2n) { animation-delay: .25s; }
@keyframes hop { to { transform: translateY(-1.6rem) rotate(40deg); } }
.pairs { display: grid; gap: .8rem 1.4rem; align-content: center; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
.dp { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .8rem; background: rgba(11,19,17,.85); border: 1px solid rgba(207,227,216,.25); border-radius: 1rem; padding: .6rem 1rem; font-size: var(--dp, 1.6rem); font-weight: 700; }
.dp .a, .dp .b { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.dp .b { justify-content: flex-end; text-align: right; }
.dp .a span, .dp .b span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp .ball { --size: 1.6em; }
.dp .x { font-family: var(--f-label); color: var(--brass); letter-spacing: .1em; font-size: .8em; }
.dp .bye { color: var(--muted); font-style: italic; font-weight: 500; }
@media (prefers-reduced-motion: no-preference) {
  .dp { animation: dpin .45s cubic-bezier(.2,1.2,.4,1) both; }
  .dp .a .ball { animation: rollL .6s ease-out both; }
  .dp .b .ball { animation: rollR .6s ease-out both; }
  .champfx b { animation: pop .8s cubic-bezier(.2,1.4,.4,1) both; }
}
@keyframes dpin { from { opacity: 0; transform: scale(.85); } }
@keyframes rollL { from { transform: translateX(-6rem) rotate(-360deg); } }
@keyframes rollR { from { transform: translateX(6rem) rotate(360deg); } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }
.champfx { place-items: center; grid-template-rows: 1fr; text-align: center; }
.champfx .inner { display: grid; gap: 1.4rem; justify-items: center; }
.champfx .ball { --size: 9rem; }
.champfx span { font-family: var(--f-label); font-size: 2rem; letter-spacing: .3em; text-transform: uppercase; color: #cfe3d8; }
.champfx b { font-family: var(--f-display); font-weight: 400; font-size: 7rem; line-height: 1; color: #ffe5a3; text-shadow: 0 .4rem 2rem rgba(0,0,0,.5); }
#codeIn::placeholder { font-size: 2rem; letter-spacing: .12em; color: #5f7670; }

/* Player list next to the bracket */
.plist { min-height: 0; display: flex; flex-direction: column; background: rgba(11,19,17,.88); border: 1px solid var(--line); border-radius: 1.1rem; padding: .9rem 1rem; overflow: hidden; }
.plist .ph { display: flex; justify-content: space-between; align-items: baseline; }
.plist h2 { margin: 0; font-family: var(--f-label); font-weight: 700; text-transform: uppercase; letter-spacing: .14em; font-size: 1.05rem; color: var(--brass); }
.plist .ph b { font-family: var(--f-display); font-weight: 400; font-size: 2.2rem; line-height: 1; color: var(--ivory); }
.plist .pin { margin: .2rem 0 .7rem; color: var(--muted); font-size: .95rem; font-family: var(--f-label); letter-spacing: .08em; text-transform: uppercase; }
.plist ol { flex: 1; min-height: 0; margin: 0; padding: 0; list-style: none; column-gap: .8rem; overflow: hidden; }
.plist li { break-inside: avoid; padding: .14em 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid rgba(42,59,54,.6); }
.plist li.out { color: var(--muted); font-weight: 500; text-decoration: line-through; text-decoration-color: rgba(148,170,161,.6); }
.plist li.champ { color: #ffe5a3; }
.plist li.champ::before { content: "★ "; }
.stage .bracket.free .col-body { justify-content: flex-start; gap: .3rem; }
.stage .bracket.free .pair { flex: 0 1 auto; }

/* Spinning wheel draw */
.wheelfx { display: grid; grid-template-columns: auto 1fr; gap: 3rem; align-items: center; min-height: 0; }
.wheelbox { position: relative; width: min(62vh, 38vw); aspect-ratio: 1; }
.wheel { width: 100%; height: 100%; display: block; border-radius: 50%; box-shadow: 0 1.5rem 3rem rgba(0,0,0,.5), 0 0 0 .6rem var(--rail), 0 0 0 .8rem var(--rail-hi); }
.wheel text { text-anchor: middle; dominant-baseline: central; font-family: var(--f-body); font-weight: 700; }
.wheel text.hub { fill: #121212; font-family: var(--f-display); }
.wheel g.hit path, .wheel g.hit circle { filter: brightness(1.35); stroke: #fff; stroke-width: 1.5; }
.pointer { position: absolute; z-index: 2; left: 50%; top: -1.6rem; transform: translateX(-50%); width: 0; height: 0; border-left: 1.4rem solid transparent; border-right: 1.4rem solid transparent; border-top: 3rem solid var(--ivory); filter: drop-shadow(0 .3rem .4rem rgba(0,0,0,.5)); }
.wheelbox.done .wheel { opacity: .35; transition: opacity .6s; }
.drawside { display: grid; gap: 1.2rem; align-content: center; min-height: 0; }
.picked { text-align: center; min-height: 4.6rem; }
.picked b { font-family: var(--f-display); font-weight: 400; font-size: 3.6rem; line-height: 1.2; color: #ffe5a3; text-shadow: 0 .3rem 1rem rgba(0,0,0,.5); }
.dp.wait { opacity: .6; }
.dp .q { color: var(--muted); font-family: var(--f-display); font-weight: 400; }
@media (prefers-reduced-motion: no-preference) {
  .picked.pop b { display: inline-block; animation: pop .45s cubic-bezier(.2,1.4,.4,1) both; }
  .dp .in > span { animation: dpin .4s ease-out both; }
}
