/* ────────────────────────────────────────────────────────────────────────────
   Pantalla gigante — dirección de arte: GRÁFICA DE RETRANSMISIÓN DEPORTIVA.

   La sala mira esto desde 5–30 metros, con luz ambiente y a veces por un HDMI
   largo. El lenguaje de una transmisión de carreras (torre de tiempos, chyron
   con lomo de color, numerales condensados en cursiva) es el que el público ya
   sabe leer sin aprender nada, y deja hueco limpio para el color de cualquier
   marca. La tesis: mobiliario de cabina arriba —rígido, mecánico, preciso— y
   caricatura debajo, en el mundo del canvas.
   ──────────────────────────────────────────────────────────────────────────── */

@font-face {
  font-family: 'Barlow Condensed';
  src: url('/shared/fonts/barlow-condensed-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Barlow Condensed';
  src: url('/shared/fonts/barlow-condensed-800.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Barlow Condensed';
  src: url('/shared/fonts/barlow-condensed-800-italic.woff2') format('woff2');
  font-weight: 800;
  font-style: italic;
  font-display: swap;
}

.screen {
  --font-display: 'Barlow Condensed', 'Arial Narrow', Impact, system-ui, sans-serif;
  --chyron: rgb(9 12 18 / 0.9);
  --chyron-solid: #0a0d14;
  --spine: 6px;
  --cut: 14px; /* corte diagonal: el detalle material de todo el paquete gráfico */
  height: 100vh;
  overflow: hidden;
}

.bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.3;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(70vw 70vw at 8% -10%, color-mix(in srgb, var(--brand-primary) 26%, transparent), transparent 65%),
    linear-gradient(180deg, transparent 55%, rgb(0 0 0 / 0.6));
}

/* ───────────────────────────────── gate ───────────────────────────────── */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  z-index: 20;
}

.gate-card {
  display: grid;
  gap: 0.9rem;
  padding: 2rem;
  width: min(420px, 92vw);
  text-align: center;
  border-radius: 0;
  border-left: var(--spine) solid var(--brand-primary);
}

.gate-card input {
  text-align: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  border-radius: 0;
}

.gate-error {
  color: #ff8b8b;
}

/* ───────────────────────────────── shell ──────────────────────────────── */
.app {
  position: relative;
  z-index: 2;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(0.6rem, 1.3vh, 1.3rem) clamp(0.8rem, 1.8vw, 2rem);
  gap: clamp(0.5rem, 1.1vh, 1rem);
}

.topbar {
  display: flex;
  align-items: center;
  gap: clamp(0.7rem, 1.5vw, 1.6rem);
}

.logo {
  height: clamp(2rem, 4.6vh, 4rem);
  width: auto;
  object-fit: contain;
}

.sponsor {
  height: clamp(1.6rem, 3.6vh, 3rem);
  width: auto;
  object-fit: contain;
}

.titles {
  min-width: 0;
}

.titles h1 {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.6vw, 2.5rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.titles p {
  font-size: clamp(0.62rem, 1vw, 0.92rem);
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: clamp(0.4rem, 0.9vw, 0.9rem);
}

/* Etiqueta de cabina: cuerpo oscuro, lomo de color, esquina cortada. */
.tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.34em 0.85em 0.34em 0.7em;
  background: var(--chyron);
  border-left: var(--spine) solid var(--brand-primary);
  clip-path: polygon(0 0, 100% 0, calc(100% - var(--cut)) 100%, 0 100%);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(0.72rem, 1.15vw, 1.1rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-right: calc(0.85em + var(--cut));
}

.tag-code {
  border-left-color: var(--brand-accent);
  letter-spacing: 0.24em;
  color: var(--brand-accent);
}

.stage {
  position: relative;
  min-height: 0;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 0;
}

.view.active {
  display: block;
  animation: cut-in 0.28s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

@keyframes cut-in {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
}

.footbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: clamp(0.6rem, 0.9vw, 0.9rem);
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.footbar .status {
  margin-left: auto;
}

.footbar .status.online {
  color: #6ee7a8;
}

.footbar .status.offline {
  color: #ff8b8b;
}

.eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.34em;
  font-size: clamp(0.62rem, 0.95vw, 0.95rem);
  font-weight: 800;
  color: var(--brand-accent);
}

/* ───────────────────────────────── sala ───────────────────────────────── */
.lobby {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(220px, 28%) 1fr;
  gap: clamp(1rem, 2.4vw, 3rem);
  align-items: center;
}

.qr-card {
  background: #fff;
  color: #0a0d14;
  padding: clamp(0.7rem, 1.4vh, 1.3rem);
  display: grid;
  gap: 0.4rem;
  justify-items: center;
  border-left: var(--spine) solid var(--brand-primary);
}

.qr-box {
  width: 100%;
  aspect-ratio: 1;
}

.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.qr-code {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 3.2vw, 2.8rem);
  letter-spacing: 0.26em;
  line-height: 1;
}

.qr-url {
  font-size: clamp(0.58rem, 0.85vw, 0.85rem);
  color: #5b6373;
  word-break: break-all;
  text-align: center;
}

.lobby-main {
  min-width: 0;
  height: 100%;
  display: grid;
  align-content: center;
  gap: clamp(0.35rem, 0.9vh, 0.9rem);
  grid-template-rows: auto auto auto minmax(0, auto) auto;
}

.lobby-count {
  display: flex;
  align-items: baseline;
  /* El numeral es enorme y va en cursiva: el hueco se mide en el ancho de la
     pantalla, no en em del contenedor, o la etiqueta se pega al glifo. */
  gap: clamp(0.7rem, 1.8vw, 1.8rem);
}

.lobby-count strong {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(3.5rem, 13vh, 11rem);
  line-height: 0.82;
  letter-spacing: -0.01em;
}

.lobby-count span {
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 1.8vw, 1.7rem);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--muted);
}

.lobby-hint {
  font-size: clamp(0.75rem, 1.2vw, 1.15rem);
  color: var(--muted);
}

.wall {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-content: flex-start;
  overflow: hidden;
  min-height: 0;
  max-height: 46vh;
  mask-image: linear-gradient(to bottom, #000 80%, transparent);
}

.wall-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.28em 0.7em;
  background: var(--chyron);
  border-left: 3px solid var(--brand-primary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.72rem, 1.1vw, 1.05rem);
  letter-spacing: 0.04em;
  max-width: 14em;
  animation: slide-in 0.32s cubic-bezier(0.2, 1.1, 0.3, 1) both;
}

.wall-item .glyph {
  font-size: 1.25em;
}

.wall-item .alias {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wall-item.off {
  opacity: 0.38;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(-14px);
  }
}

.lobby-footer {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ──────────────────────────────── carrera ─────────────────────────────── */
.race {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(0.4rem, 0.9vh, 0.9rem);
  min-height: 0;
}

/* El chyron: bloques duros pegados, cada uno con su lomo. */
.chyron {
  display: flex;
  align-items: stretch;
  gap: 3px;
  min-height: 0;
}

.chyron-id {
  flex: 1;
  min-width: 0;
  background: var(--chyron);
  border-left: var(--spine) solid var(--brand-primary);
  padding: 0.35rem 1rem 0.4rem 0.75rem;
  display: grid;
  align-content: center;
  gap: 0.1rem;
}

.chyron-id h2 {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(1.1rem, 2.4vw, 2.2rem);
  line-height: 1;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chyron-stat {
  background: var(--chyron);
  padding: 0.35rem 1rem;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.05rem;
  min-width: clamp(80px, 8vw, 130px);
}

.chyron-stat span {
  font-family: var(--font-display);
  font-size: clamp(0.55rem, 0.85vw, 0.82rem);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.chyron-stat strong {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(1.2rem, 2.6vw, 2.4rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.chyron-clock {
  background: var(--brand-primary);
  color: #fff;
  clip-path: polygon(0 0, 100% 0, 100% 100%, var(--cut) 100%);
  padding-left: calc(1rem + var(--cut));
}

.chyron-clock span {
  color: rgb(255 255 255 / 0.75);
}

.chyron-clock.urgent {
  animation: clock-alarm 0.55s steps(2, end) infinite;
}

@keyframes clock-alarm {
  50% {
    background: var(--brand-accent);
    color: #0a0d14;
  }
}

.race-body {
  display: grid;
  grid-template-columns: 1fr clamp(210px, 21%, 340px);
  gap: 3px;
  min-height: 0;
}

.viewport {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #05070c;
}

.viewport canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ───────────────────── torre de tiempos (el elemento firma) ────────────── */
.tower {
  background: var(--chyron);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
  overflow: hidden;
}

.tower-head {
  display: grid;
  grid-template-columns: 2.4em 1fr auto;
  gap: 0.5em;
  padding: 0.45em 0.7em;
  background: var(--brand-primary);
  color: #fff;
  font-family: var(--font-display);
  font-size: clamp(0.55rem, 0.85vw, 0.8rem);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.tower-head span:last-child {
  text-align: right;
}

.tower-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  align-content: start;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
}

.tower-row {
  display: grid;
  grid-template-columns: 2.4em 1fr auto;
  align-items: center;
  gap: 0.5em;
  padding: 0.22em 0.7em 0.22em 0;
  background: rgb(255 255 255 / 0.04);
  font-family: var(--font-display);
  font-size: clamp(0.8rem, 1.35vw, 1.35rem);
  line-height: 1.25;
}

.tower-row .pos {
  background: rgb(255 255 255 / 0.12);
  color: var(--text);
  font-style: italic;
  font-weight: 800;
  text-align: center;
  padding: 0.1em 0;
  font-variant-numeric: tabular-nums;
}

.tower-row .who {
  display: flex;
  align-items: center;
  gap: 0.4em;
  min-width: 0;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tower-row .who .alias {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tower-row .val {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.tower-row.p1 {
  background: var(--brand-accent);
  color: #0a0d14;
}

.tower-row.p1 .pos {
  background: #0a0d14;
  color: var(--brand-accent);
}

.tower-row.p1 .val {
  color: #0a0d14;
}

.tower-row.p2 .pos,
.tower-row.p3 .pos {
  background: var(--brand-primary);
  color: #fff;
}

/* Un adelantamiento no se anuncia con un cartel: se ve moverse la fila. */
.tower-row.gained {
  animation: gained 0.5s ease-out;
}

@keyframes gained {
  0% {
    box-shadow: inset 0 0 0 2px var(--brand-accent);
    transform: translateX(6px);
  }
  100% {
    box-shadow: inset 0 0 0 0 transparent;
    transform: translateX(0);
  }
}

.tower-row.done .val {
  color: var(--brand-accent);
}

/* ──────────────────────── resultado y cierre ──────────────────────────── */
.result,
.event-result {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: clamp(0.4rem, 1vh, 1rem);
  min-height: 0;
}

.result-head {
  background: var(--chyron);
  border-left: var(--spine) solid var(--brand-primary);
  padding: 0.4rem 1rem 0.5rem 0.8rem;
}

.result-head h2 {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(1.4rem, 3.2vw, 3rem);
  line-height: 1;
}

.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  align-items: end;
}

.pod {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  padding: clamp(0.5rem, 1.4vh, 1.2rem) 0.6rem;
  background: var(--chyron);
  border-top: 4px solid rgb(255 255 255 / 0.2);
  text-align: center;
  animation: rise 0.45s cubic-bezier(0.2, 1.1, 0.3, 1) both;
}

.pod .glyph {
  font-size: clamp(1.5rem, 4.6vh, 3.6rem);
  line-height: 1;
}

.pod .p-medal {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 800;
  font-size: clamp(1rem, 2.2vw, 1.9rem);
  color: var(--muted);
}

.pod .p-alias {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(0.9rem, 1.9vw, 1.8rem);
  letter-spacing: 0.03em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pod .p-stat {
  font-family: var(--font-display);
  font-size: clamp(0.62rem, 1vw, 0.95rem);
  letter-spacing: 0.1em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.pod.rank1 {
  order: 2;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-accent) 26%, var(--chyron-solid)), var(--chyron-solid));
  border-top-color: var(--brand-accent);
  transform: scale(1.04);
  animation-delay: 0.08s;
}

.pod.rank1 .p-medal {
  color: var(--brand-accent);
}

.pod.rank2 {
  order: 1;
  border-top-color: var(--brand-primary);
}

.pod.rank3 {
  order: 3;
  animation-delay: 0.16s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.95);
  }
}

.result-lower {
  display: grid;
  grid-template-columns: 1fr minmax(210px, 27%);
  gap: 3px;
  min-height: 0;
}

.panel {
  background: var(--chyron);
  padding: clamp(0.45rem, 1.1vh, 0.9rem);
  overflow: auto;
  min-height: 0;
}

.table-panel {
  border-left: var(--spine) solid var(--brand-primary);
}

.side-panel h3 {
  font-family: var(--font-display);
  font-size: clamp(0.62rem, 0.95vw, 0.9rem);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.side-panel h3.mt {
  margin-top: 0.9rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-display);
  font-size: clamp(0.68rem, 1.15vw, 1.1rem);
}

.rank-table th {
  text-align: left;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 600;
  padding: 0.25em 0.5em;
  position: sticky;
  top: 0;
  background: var(--chyron-solid);
}

.rank-table td {
  padding: 0.22em 0.5em;
  border-top: 1px solid rgb(255 255 255 / 0.07);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.rank-table td:first-child {
  font-style: italic;
  font-weight: 800;
  color: var(--muted);
}

.rank-table tr.win td {
  color: var(--brand-accent);
  font-weight: 800;
}

.rank-table tr.adv td:first-child::after {
  content: ' ▲';
  color: #6ee7a8;
}

.rank-table .flagged {
  color: #ffb86b;
}

.mini-rank {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  font-family: var(--font-display);
  font-size: clamp(0.68rem, 1.05vw, 1rem);
}

.mini-rank li {
  display: grid;
  grid-template-columns: 1.8em 1fr auto;
  gap: 0.4em;
  padding: 0.14em 0.35em;
  background: rgb(255 255 255 / 0.04);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mini-rank li span:first-child {
  font-style: italic;
  font-weight: 800;
  color: var(--muted);
}

.mini-rank li:first-child {
  background: var(--brand-accent);
  color: #0a0d14;
}

.mini-rank li:first-child span:first-child {
  color: #0a0d14;
}

.champ {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  text-align: center;
}

.champ .glyph {
  font-size: clamp(2.6rem, 12vh, 8rem);
  line-height: 1;
  animation: bob 1.9s ease-in-out infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-7%);
  }
}

.champ .c-alias {
  font-family: var(--font-display);
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
  font-size: clamp(1.6rem, 4.4vw, 3.6rem);
  line-height: 1;
}

.champ .c-stat {
  font-family: var(--font-display);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.prize {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(0.95rem, 1.9vw, 1.7rem);
  letter-spacing: 0.04em;
  color: var(--brand-accent);
}

/* ─────────────────────────────── responsive ───────────────────────────── */
@media (max-aspect-ratio: 1/1) {
  .lobby,
  .race-body,
  .result-lower {
    grid-template-columns: 1fr;
  }

  .tower,
  .side-panel {
    display: none;
  }

  .qr-card {
    max-width: 60vw;
    margin: 0 auto;
  }
}
