/* tv-page.css — Duel TV for players (spectate.html) on the v2 house style, per the approved _tv-v2 preview: the duel you're
   watching (both plates, both hands as counts, the masked board with the turn and phase), what just happened, and the list of
   live duels. Phone-first, upright and sideways. */

span.v2-bar { display: block; }
.tv { max-width: 1320px; margin: 0 auto; padding: 4px var(--pad) 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; overflow-x: clip; }
.tv [hidden], .zoom[hidden] { display: none !important; }
.head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; }
.head h1, .head h2 { margin: 0; }
.head .row { display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; }
.head .v2-seg { width: min(300px, 100%); }
.live-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: #ff4a4a; box-shadow: 0 0 10px #ff4a4a; animation: v2pulse 2.2s ease-in-out infinite; vertical-align: 1px; }
.live-dot.off { background: var(--faint); box-shadow: none; animation: none; }

/* ── the duel you're watching ── */
.watch { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.screen { position: relative; overflow: hidden; display: grid; gap: 10px; padding: 14px; border-radius: 26px; min-width: 0;
  background: radial-gradient(90% 70% at 50% 100%, rgba(90,167,255,.12), transparent 60%), rgba(10,9,8,.8); border: 1px solid var(--hair); }
.plate { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 16px; background: rgba(255,255,255,.05); min-width: 0; }
.plate .ava { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #15130f; box-shadow: 0 0 0 2px var(--pc); }
.plate .ava img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 24%; display: block; }
.plate.turn .ava { box-shadow: 0 0 0 2px var(--pc), 0 0 16px var(--pc); }
.plate .who { min-width: 0; }
.plate .nm { display: block; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plate small { display: block; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plate .lp { display: grid; justify-items: end; gap: 4px; }
.plate .lp b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.plate .lp b.hit { animation: tvHit .7s var(--ease); }
.plate .lp b.heal { animation: tvHeal .7s var(--ease); }
@keyframes tvHit { 25% { color: #ff6a5a; transform: scale(1.18); } }
@keyframes tvHeal { 25% { color: var(--ok); transform: scale(1.12); } }
.plate .lp .v2-bar { width: clamp(80px, 12vw, 140px); height: 5px; }
.plate.top .v2-bar i { background: linear-gradient(90deg, #ff5a4a, #ffb0a6); box-shadow: none; }
.hand { display: flex; justify-content: center; align-items: center; gap: 4px; height: 30px; min-width: 0; }
.hand span { width: 22px; height: 30px; flex: none; border-radius: 3px; background: url("img/ui/card_back_plain.jpg?v=2") center / cover; box-shadow: 0 4px 8px rgba(0,0,0,.4); }
.hand small { margin-left: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
/* 7 columns by 4 card rows plus the middle strip, sized by the screen's height as well as its width */
.board { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; width: min(640px, 100%, max(260px, calc((100dvh - 440px) * 1.15))); justify-self: center; }
.board .mid { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 10px; min-height: 32px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); min-width: 0; }
.board .mid span { padding: 4px 12px; border-radius: 999px; background: rgba(255,255,255,.07); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .mid span.now { color: #160f03; background: var(--hi); }
.cw { min-width: 0; }
.z { position: relative; aspect-ratio: 813 / 1185; border-radius: 6px; background: rgba(255,255,255,.035); box-shadow: inset 0 0 0 1px rgba(255,255,255,.07); }
.z img, .z .back { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.z .back { background: url("img/ui/card_back_plain.jpg?v=2") center / cover; }
.z .def { transform: rotate(90deg) scale(.68); }
.z .st { position: absolute; left: 50%; bottom: 2px; translate: -50% 0; padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 800; background: rgba(0,0,0,.8); white-space: nowrap; }
.z button { position: absolute; inset: 0; border-radius: 6px; cursor: zoom-in; }
.z.cap { display: grid; place-items: center; align-content: center; gap: 1px; background: rgba(255,255,255,.02); }
.z.cap b { font-size: clamp(12px, 1.8vw, 18px); font-variant-numeric: tabular-nums; }
.z.cap small { font-size: clamp(8px, 1.2vw, 10.5px); font-weight: 700; color: var(--muted); }
.z.pulse { animation: tvPulse 1.2s var(--ease); }
@keyframes tvPulse { 30% { box-shadow: 0 0 0 3px var(--hi), 0 0 24px var(--c); } }
.z.foil-1 { box-shadow: 0 0 0 1.5px #dfe6ef; }
.z.foil-2 { box-shadow: 0 0 0 1.5px #9fd0ff; }
.z.foil-3 { box-shadow: 0 0 0 1.5px #ffcc4d; }
.z.foil-4 { box-shadow: 0 0 0 1.5px #ba60ff, 0 0 10px rgba(186,96,255,.5); }
.z.foil-5 { box-shadow: 0 0 0 1.5px #fff3b8, 0 0 12px rgba(255,243,184,.55); }
.banner { position: absolute; left: 0; right: 0; top: 50%; translate: 0 -50%; z-index: 5; padding: 14px 0; text-align: center; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.75) 20%, rgba(0,0,0,.75) 80%, transparent); animation: tvBanner 1.6s var(--ease) forwards; }
.banner b { font: 900 clamp(20px, 4vw, 36px)/1.1 var(--display); color: var(--hi); padding: 0 16px; }
@keyframes tvBanner { 0% { opacity: 0; transform: scaleY(.4); } 15%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.ended { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; padding: 16px; background: rgba(5,5,5,.74); backdrop-filter: blur(6px); }
.ended .box { display: grid; gap: 12px; justify-items: center; text-align: center; max-width: 420px; }
.ended h2 { margin: 0; }
.ended .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.side { display: grid; gap: 12px; min-width: 0; }
.panel { display: grid; gap: 10px; padding: 14px; border-radius: 22px; background: rgba(18,16,14,.6); border: 1px solid var(--hair); min-width: 0; }
.panel h3 { margin: 0; font-size: 14px; display: flex; justify-content: space-between; gap: 10px; }
.panel h3 small { color: var(--muted); font-weight: 600; }
.log { display: grid; gap: 6px; max-height: 240px; overflow: auto; font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.log div:first-child { color: var(--ink); }
.masked { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.masked svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--hi); stroke-width: 1.8; }
.panel .row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── the list ── */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.match { display: grid; gap: 10px; padding: 14px; text-align: left; font: inherit; color: inherit; min-width: 0; }
.match.on { box-shadow: inset 0 0 0 1.5px var(--hi); }
.match .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.match .top b { color: var(--ink); font-size: 12px; }
.match .top .live-dot { width: 7px; height: 7px; }
.mp { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-width: 0; }
.mp .ini { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font-size: 12px; font-weight: 800; background: rgba(255,255,255,.1); }
.mp.act .ini { color: #160f03; background: var(--hi); }
.mp b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp > span:last-child { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tug { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: rgba(255,255,255,.08); }
.tug i:first-child { background: #ff6a5a; }
.tug i:last-child { flex: 1; background: var(--hi); }
.empty { display: grid; gap: 10px; justify-items: center; padding: 26px 18px; border-radius: 22px; text-align: center; background: rgba(255,255,255,.04); border: 1px dashed rgba(255,255,255,.14); }
.empty b { font-size: 17px; }
.empty p { margin: 0; max-width: 46ch; }

/* ── reading a face-up card ── */
.zoom { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.72); backdrop-filter: blur(8px); }
.zoom .box { display: grid; grid-template-columns: 200px minmax(0, 280px); gap: 18px; align-items: center; max-height: 100%; overflow: auto; padding: 20px; border-radius: 24px;
  background: linear-gradient(180deg, rgba(38,34,30,.97), rgba(16,14,12,.98)); border: 1px solid rgba(255,255,255,.12); animation: tvZoom .3s var(--ease); }
@keyframes tvZoom { from { opacity: 0; transform: scale(.94); } }
.zoom img { width: 200px; border-radius: 10px; box-shadow: 0 20px 40px rgba(0,0,0,.6); }
.zoom b { font-size: 18px; }
.zoom p { margin: 8px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink-2); white-space: pre-line; }

@media (max-width: 960px) {
  .watch { grid-template-columns: minmax(0, 1fr); }
  .side { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .side, .grid { grid-template-columns: minmax(0, 1fr); }
  .screen { padding: 10px; }
  .zoom .box { grid-template-columns: minmax(0, 1fr); justify-items: center; text-align: center; }
  .zoom img { width: 160px; }
  .plate .lp b { font-size: 19px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .tv > .head:first-child { display: none; }
  .watch { grid-template-columns: minmax(0, 1fr) 220px; }
  .side { grid-template-columns: minmax(0, 1fr); }
  /* the plates and hands pack at the top of the left column, clear of the chat bar docked bottom-left */
  .screen { grid-template-columns: minmax(150px, 210px) auto; grid-template-rows: auto auto auto 1fr; grid-template-areas: "pt board" "ht board" "hb board" "pb board";
    align-content: start; align-items: start; justify-content: center; column-gap: 14px; row-gap: 6px; padding: 10px; }
  #pTop { grid-area: pt; } #hTop { grid-area: ht; } #board { grid-area: board; } #hBot { grid-area: hb; } #pBot { grid-area: pb; }
  .board { width: calc((100dvh - 110px) * 1.15); }
  .board .mid { min-height: 22px; font-size: 11px; }
  .hand { height: 20px; justify-content: flex-start; } .hand span { width: 15px; height: 20px; }
  .hand span:nth-of-type(n+5) { display: none; }
  .plate { grid-template-columns: 30px minmax(0, 1fr) auto; row-gap: 5px; padding: 6px 10px; } .plate .ava { width: 30px; height: 30px; }
  .plate .lp { display: contents; }
  .plate .lp b { font-size: 16px; } .plate .lp .v2-bar { grid-column: 1 / -1; width: 100%; height: 4px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .log { max-height: 110px; }
}
@media (prefers-reduced-motion: reduce) {
  .live-dot, .z.pulse, .banner, .plate .lp b.hit, .plate .lp b.heal, .zoom .box { animation: none; }
}
