/* ============================================================
   FIFA World Cup 2026 — Llave eliminatoria 3D
   ============================================================ */
:root {
  --bg: #04060d;
  --ink: #e8eeff;
  --ink-dim: #8fa8e0;
  --accent: #f5c842;
  --line: rgba(120, 160, 255, 0.25);
  --glass: rgba(10, 16, 38, 0.82);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Kanit", "Segoe UI", Arial, sans-serif;
}

#app, #app canvas { position: fixed; inset: 0; }
#app canvas { cursor: grab; }
#app canvas:active { cursor: grabbing; }

.hidden { display: none !important; }

/* ---------- Velo de carga ---------- */
#loader {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: var(--bg);
  transition: opacity 0.6s ease;
}
#loader.done { opacity: 0; pointer-events: none; }
#loader p { color: var(--ink-dim); letter-spacing: 0.08em; }
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Cabecera ---------- */
.hud-top {
  position: fixed; top: 22px; left: 28px; z-index: 10;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.8);
}
.hud-top h1 {
  font-size: clamp(1.5rem, 3.2vw, 2.5rem);
  font-weight: 800; letter-spacing: 0.04em; line-height: 1;
}
.hud-top h1 span {
  color: var(--accent);
  text-shadow: 0 0 22px rgba(245, 200, 66, 0.55);
}
.hud-top .sub {
  margin-top: 6px; color: var(--ink-dim);
  font-size: clamp(0.72rem, 1.4vw, 0.95rem); letter-spacing: 0.06em;
}
.hud-top .updated {
  margin-top: 4px; color: #5c719f; font-size: 0.75rem; letter-spacing: 0.05em;
}

/* ---------- Botones ---------- */
.hud-buttons {
  position: fixed; top: 24px; right: 26px; z-index: 10;
  display: flex; gap: 10px;
}
.hud-buttons button {
  font: 600 0.85rem "Kanit", "Segoe UI", sans-serif;
  color: var(--ink); letter-spacing: 0.04em;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.hud-buttons button:hover { border-color: var(--accent); transform: translateY(-1px); }
.hud-buttons button.active { background: rgba(245, 200, 66, 0.16); border-color: var(--accent); color: var(--accent); }

/* ---------- Leyenda y ayuda ---------- */
#legend {
  position: fixed; left: 28px; bottom: 22px; z-index: 10;
  display: flex; gap: 18px;
  color: var(--ink-dim); font-size: 0.78rem; letter-spacing: 0.04em;
  pointer-events: none;
}
#legend span { display: flex; align-items: center; gap: 7px; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot.played { background: #3a5aa8; box-shadow: 0 0 8px #3a5aa8; }
.dot.today { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.dot.upcoming { background: transparent; border: 2px dashed #4a5f8f; }

#hint {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  z-index: 10; pointer-events: none;
  color: #5c719f; font-size: 0.75rem; letter-spacing: 0.05em;
  white-space: nowrap;
}
@media (max-width: 980px) {
  #hint { display: none; }
}

#credit {
  position: fixed; right: 26px; bottom: 22px; z-index: 10;
  color: #5c719f; font-size: 0.7rem; letter-spacing: 0.04em;
}
#credit a { color: #7f97d8; text-decoration: none; }
#credit a:hover { color: var(--ink); text-decoration: underline; }

/* ---------- Tooltip ---------- */
#tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 13px;
  font-size: 0.8rem; letter-spacing: 0.03em;
  backdrop-filter: blur(6px);
  max-width: 320px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}

/* ---------- Panel de detalle ---------- */
#panel {
  position: fixed; top: 50%; right: 30px; transform: translateY(-50%);
  z-index: 30; width: min(340px, calc(100vw - 40px));
  max-height: 84vh; overflow-y: auto;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 22px 18px;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  animation: panelIn 0.35s ease;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(-50%) translateX(24px); }
  to { opacity: 1; transform: translateY(-50%) translateX(0); }
}
#panel-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: var(--ink-dim);
  font-size: 1rem; cursor: pointer; padding: 6px;
}
#panel-close:hover { color: var(--ink); }

.p-round { font-weight: 800; font-size: 1.15rem; letter-spacing: 0.06em; text-transform: uppercase; }
.p-date { color: var(--ink-dim); font-size: 0.8rem; margin: 2px 0 16px; letter-spacing: 0.04em; }

.p-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 10px; margin-bottom: 6px;
}
.p-row.winner { background: rgba(245, 200, 66, 0.1); }
.p-row.loser { opacity: 0.5; }
.p-name { flex: 1; font-weight: 600; font-size: 0.98rem; }
.p-score { font-weight: 800; font-size: 1.3rem; color: var(--accent); min-width: 30px; text-align: right; }
.p-row.loser .p-score { color: var(--ink-dim); }
.p-score small { font-size: 0.75rem; color: var(--ink-dim); }

.badge {
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.68rem; color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}
.badge.tbd { border: 2px dashed #4a5f8f; background: none; }

.p-scorers {
  margin: -4px 0 8px; padding: 0 10px 0 60px;
  font-size: 0.72rem; color: var(--ink-dim); letter-spacing: 0.02em;
}
.p-scorers.loser { opacity: 0.5; }

/* Links a Instagram (equipos y goleadores) */
.p-name a, .p-scorers a {
  color: inherit; text-decoration: none;
  border-bottom: 1px dotted rgba(143, 168, 224, 0.65);
}
.p-name a:hover, .p-scorers a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.p-note {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.8rem; color: var(--ink-dim); letter-spacing: 0.03em;
}
.p-note.today { color: var(--accent); }

/* Líneas extra por equipo: asistencias y fase de grupos */
.p-assists, .p-group {
  padding: 0 10px 0 60px;
  font-size: 0.7rem; color: #5c719f; letter-spacing: 0.02em;
}
.p-assists { margin: -2px 0 4px; }
.p-group { margin: 0 0 10px; }

/* Metadatos del partido: figura, rojas, árbitro, espectadores */
.p-meta { margin-top: 10px; font-size: 0.76rem; color: var(--ink-dim); }
.p-meta div { margin-bottom: 3px; }

/* Detalle de la tanda de penales */
.p-pens {
  margin-top: 10px; padding: 8px 10px;
  background: rgba(20, 32, 70, 0.55); border-radius: 10px;
  font-size: 0.72rem; color: var(--ink-dim); line-height: 1.7;
}
.p-pens b { color: var(--ink); margin-right: 4px; }
.pen-ok { color: #9fd3a8; margin-right: 6px; white-space: nowrap; }
.pen-x { color: #e07777; margin-right: 6px; white-space: nowrap; text-decoration: line-through; }

/* Cuenta regresiva de los partidos de hoy */
.p-countdown {
  margin-top: 10px; font-weight: 800; font-size: 1rem;
  color: var(--accent); letter-spacing: 0.04em;
}

/* Insignia clicable = resaltar camino del equipo */
.badge[data-code] { cursor: pointer; transition: transform 0.15s; }
.badge[data-code]:hover { transform: scale(1.12); }

/* Tabla de goleadores (Botín de Oro) */
.gb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 8px; border-radius: 8px; margin-bottom: 2px;
}
.gb-row:first-of-type { background: rgba(245, 200, 66, 0.1); }
.gb-pos { width: 18px; text-align: right; color: var(--ink-dim); font-size: 0.78rem; }
.gb-row .p-name { font-size: 0.92rem; }
.gb-goals { font-weight: 800; font-size: 1.05rem; color: var(--accent); }

/* Contenido solo para lectores de pantalla y buscadores */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Errores ---------- */
#webgl-error, .nojs {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); color: var(--ink); text-align: center; padding: 30px;
}

/* Con tres botones, en ventanas medianas la botonera pisaría el
   título: bajarla a la esquina inferior derecha antes. */
@media (max-width: 900px) {
  .hud-buttons {
    top: auto; bottom: 60px; right: 16px;
    flex-direction: column; align-items: flex-end;
  }
}

/* ---------- Móvil ---------- */
@media (max-width: 640px) {
  .hud-top { left: 16px; top: 14px; }
  .hud-buttons { top: auto; bottom: 60px; right: 16px; flex-direction: column; }
  #hint { display: none; }
  #legend { left: 16px; bottom: 14px; gap: 12px; font-size: 0.68rem; }
  #panel { right: 50%; transform: translate(50%, -50%); }
  @keyframes panelIn {
    from { opacity: 0; transform: translate(50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(50%, -50%) scale(1); }
  }
}
