/* =====================================================================
   Hipódromo: la tribuna en 3D ocupa toda la pantalla (usa el armado de la
   Ruleta Rusa: rusa-stage, rusa-hud, rusa-panel…) y esto suma lo propio.
   ===================================================================== */

body:has(#screen-hipo:not([hidden])) { overflow: hidden; }
.race-spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.12); border-top-color: var(--neo-gold); animation: race-spin 0.9s linear infinite; }
@keyframes race-spin { to { transform: rotate(360deg); } }
.rusa-loading i { font-style: normal; font-weight: 800; color: var(--neo-gold); }
.hipo-stage { background: #9fb8cf; }
.hipo-stage::before { background: radial-gradient(ellipse at 50% 45%, transparent 62%, rgba(0, 0, 0, 0.35) 100%); }
.rusa-tool[hidden] { display: none; }

/* Número con los colores de la chaquetilla. */
.silk {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; font-weight: 900; font-size: 0.72rem;
  background: var(--s1); color: var(--s2); box-shadow: inset 0 0 0 2px var(--s2), 0 1px 3px rgba(0, 0, 0, 0.4); flex: none;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.35);
}
.silk.big { width: 34px; height: 34px; font-size: 1rem; border-radius: 9px; }

/* En la carrera: el orden y los metros que faltan. */
.hipo-ticker {
  position: absolute; left: 50%; top: 142px; translate: -50% 0; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 24px); overflow: hidden;
  padding: 6px 10px; border-radius: 14px; background: rgba(10, 6, 22, 0.78); border: 1px solid rgba(255, 255, 255, 0.14); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.hipo-ticker[hidden] { display: none; }
.ht-togo { font: 900 0.95rem system-ui, sans-serif; color: var(--neo-gold); min-width: 54px; font-variant-numeric: tabular-nums; }
.ht-h { display: flex; align-items: center; gap: 3px; padding: 2px 6px 2px 4px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); white-space: nowrap; }
.ht-h small { font-size: 0.68rem; color: var(--neo-muted); }
.ht-h em { font-style: normal; font-size: 0.66rem; color: var(--neo-muted); font-variant-numeric: tabular-nums; }
.ht-h.mine { box-shadow: 0 0 0 2px var(--neo-cyan); }
.hipo-label {
  position: absolute; left: 14px; top: 64px; padding: 4px 10px; border-radius: 6px; font: 900 0.8rem system-ui, sans-serif; letter-spacing: 0.12em;
  background: #c01f2f; color: #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.hipo-label[hidden] { display: none; }

/* Programa: las tarjetas de los caballos. */
.hipo-panel { width: min(760px, calc(100% - 24px)); max-height: 56%; overflow: hidden; display: flex; flex-direction: column; }
.hp-head { display: grid; gap: 2px; }
.hp-toggle { appearance: none; border: 0; background: none; color: var(--neo-text); cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 0; font: inherit; }
.hp-toggle b { font-size: 0.98rem; }
.hp-head small { color: var(--neo-muted); font-size: 0.8rem; }
.hp-cards { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(214px, 236px); gap: 8px; overflow-x: auto; overflow-y: hidden; min-height: 0; padding: 2px 2px 6px; scroll-snap-type: x proximity; }
.hcard { scroll-snap-align: start; }
/* Reacciones a la izquierda (a la derecha van las herramientas). */
#hipo-emotes { right: auto; left: 12px; }
#hipo-mic { left: auto; right: 14px; }
.hcard { display: grid; gap: 6px; padding: 9px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); }
.hcard.mine { border-color: rgba(46, 230, 255, 0.6); background: rgba(46, 230, 255, 0.08); }
.hc-top { display: flex; align-items: center; gap: 8px; }
.hc-name { flex: 1; min-width: 0; display: grid; }
.hc-name b { font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-name small { font-size: 0.72rem; color: var(--neo-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-form { font-size: 0.85rem; font-weight: 900; }
.hc-form.up { color: var(--neo-green, #39f0a5); }
.hc-form.down { color: #ff8f8f; }
.hc-form.flat { color: var(--neo-muted); }
.hc-bars { display: grid; gap: 3px; }
.hb-row { display: grid; grid-template-columns: 30px 1fr 22px; align-items: center; gap: 6px; font-size: 0.66rem; color: var(--neo-muted); }
.hb-row i { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.hb-row i b { display: block; height: 100%; border-radius: 4px; }
.hb-row.vel i b { background: linear-gradient(90deg, #ff9b4a, #ff5e3a); }
.hb-row.acel i b { background: linear-gradient(90deg, #ffe066, #f5b700); }
.hb-row.res i b { background: linear-gradient(90deg, #6ee7b7, #10b981); }
.hb-row em { font-style: normal; text-align: right; color: var(--neo-text); font-weight: 700; font-variant-numeric: tabular-nums; }
.hc-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 0.72rem; color: var(--neo-muted); }
.hc-owners { font-size: 0.74rem; color: var(--neo-cyan); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-owners.none { color: var(--neo-muted); font-style: italic; }
.hc-buy { display: flex; align-items: center; gap: 6px; }
.hc-buy .rr-cta { flex: 1; }
.hc-buy .rr-ghost { min-height: 38px; width: 42px; padding: 0; font-size: 1.2rem; }
.hc-mine { font-size: 0.78rem; color: var(--neo-cyan); white-space: nowrap; }
.rr-cta.small { min-height: 38px; padding: 6px 10px; font-size: 0.9rem; border-radius: 12px; }

.hp-mine { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.88rem; color: var(--neo-muted); justify-content: center; }
.hp-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 4px; border-radius: 10px; background: rgba(46, 230, 255, 0.12); color: var(--neo-text); }

/* Llegada y premios. */
.hipo-result { max-height: calc(100% - 40px); overflow-y: auto; }
.hipo-result h4 { margin: 12px 0 6px; font-size: 0.95rem; color: var(--neo-gold); }
.hr-order { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.hr-order li { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.06); text-align: left; }
.hr-order li.me { box-shadow: 0 0 0 2px var(--neo-cyan); }
.hr-order b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr-order small { color: var(--neo-muted); font-variant-numeric: tabular-nums; }
.hr-order .medal { width: 26px; text-align: center; }
.hr-who { flex: 1; min-width: 0; display: grid; }
.hr-who small { font-size: 0.74rem; color: var(--neo-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr-mine { margin: 10px 0 4px; font-weight: 900; font-size: 1.1rem; color: var(--neo-green, #39f0a5); }

/* Lobby. */
.hipo-card .tc-status.wait { color: var(--neo-gold); }

@media (max-width: 700px) {
  .hipo-ticker { top: 104px; gap: 4px; padding: 4px 6px; }
  .ht-togo { min-width: 44px; font-size: 0.82rem; }
  .ht-h em, .ht-h small { display: none; }
  .hipo-label { top: 46px; left: 8px; font-size: 0.68rem; }
  .hipo-panel { max-height: 50%; }
  .hp-cards { grid-auto-columns: minmax(208px, 72%); scroll-snap-type: x mandatory; }
  #hipo-emotes { left: 8px; right: 8px; }
  #hipo-mic { right: 8px; }
}
@media (max-height: 520px) {
  .hipo-panel { max-height: 62%; }
  .hipo-ticker { top: 78px; }
  .hp-cards { grid-auto-columns: 210px; }
}

/* Chance de ganar (estimada) y récord de la distancia. */
.hc-chance { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; font-size: 0.72rem; color: var(--neo-text); }
.hc-chance i { height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.hc-chance i b { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #7dd3fc, #38bdf8); }
.hc-chance.fav span { color: var(--neo-gold); font-weight: 800; }
.hc-chance.long span { color: #c4b5fd; }
.hc-chance.wait { display: block; color: var(--neo-muted); font-style: italic; }
.hp-record { color: var(--neo-gold) !important; }

/* Cartel de repetición y foto (siempre visible). */
.hipo-label.replay { left: 50%; translate: -50% 0; top: auto; bottom: calc(var(--rr-panel-h, 120px) + 26px); font-size: 0.9rem; padding: 6px 14px; animation: hl-blink 1.4s ease-in-out infinite; }
@keyframes hl-blink { 50% { opacity: 0.65; } }

/* Foto de llegada. */
.hipo-photo {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: min(640px, calc(100% - 24px)); z-index: 4; pointer-events: auto; cursor: pointer;
  display: grid; gap: 8px; padding: 12px; border-radius: 18px; text-align: center;
  background: linear-gradient(170deg, rgba(40, 30, 16, 0.96), rgba(16, 12, 6, 0.97)); border: 1px solid rgba(232, 194, 90, 0.6);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); animation: modal-in 0.35s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.hipo-photo[hidden] { display: none; }
.hipo-photo b { font-size: 1.1rem; color: #f5e7c0; letter-spacing: 0.06em; }
.hipo-photo img { width: 100%; border-radius: 10px; display: block; }
.hipo-photo span { font-size: 0.9rem; color: #e9dcc0; }

.hr-note { margin: 8px 0 0; font-weight: 700; font-size: 0.92rem; color: #c4b5fd; }
.hr-note.gold { color: var(--neo-gold); }
.hr-photo { margin: 10px 0 0; }
.hr-photo img { width: 100%; border-radius: 10px; display: block; }
.hr-photo figcaption { font-size: 0.78rem; color: var(--neo-muted); margin-top: 4px; }

/* Historial y récords. */
.hipo-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hs-modal { width: min(820px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; gap: 12px; }
#hs-body { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; }
.hs-tabs button { font-size: 0.85rem; padding: 8px 4px; }
.hs-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hs-list li { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08); display: grid; gap: 4px; }
.hs-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.hs-row small { color: var(--neo-muted); }
.hs-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.hs-tags span { font-size: 0.74rem; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); }
.hs-tags .gold, .hs-table .gold { color: var(--neo-gold); font-weight: 800; }
.hs-table-wrap { overflow-x: auto; }
.hs-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; white-space: nowrap; }
.hs-table th { text-align: left; font-size: 0.72rem; color: var(--neo-muted); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.15); position: sticky; top: 0; background: #160c2a; }
.hs-table td { padding: 6px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); font-variant-numeric: tabular-nums; }
.hs-table td small { color: var(--neo-muted); }
.hs-records { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.hs-records section { padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); }
.hs-records h4 { margin: 0 0 6px; }
.hs-rec b { font-size: 1.3rem; color: var(--neo-gold); }
.hs-rec small { color: var(--neo-muted); }
.hs-top { margin: 8px 0 0; padding-left: 20px; font-size: 0.85rem; color: var(--neo-muted); }
@media (max-width: 700px) { .hipo-label.replay { font-size: 0.75rem; } }
