:root {
  --bg: #0b0e14;
  --bg-soft: #10141d;
  --card: #141a26;
  --card-hover: #1a2130;
  --border: #232c3d;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --gray: #64748b;
  --grad: linear-gradient(135deg, #10b981, #22c55e);
  --radius: 16px;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(34, 197, 94, 0.08), transparent 60%),
    radial-gradient(800px 500px at -10% 10%, rgba(16, 185, 129, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 14, 20, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 0.2px;
  color: var(--text);
}

.brand-accent { color: var(--green); }

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-clock {
  text-align: right;
  line-height: 1.2;
}

.clock-date { display: block; font-size: 0.75rem; color: var(--muted); }
.clock-time { display: block; font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.btn-refresh {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.3s ease, border-color 0.2s ease;
}

.btn-refresh:hover { border-color: var(--green); }
.btn-refresh.spinning svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.updated-bar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  display: none;
}

/* ---------- Layout ---------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}

.section { margin-bottom: 34px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 16px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

/* ---------- Match card ---------- */
.card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: #31405a;
  box-shadow: var(--shadow);
}

.card.is-live {
  border-color: rgba(34, 197, 94, 0.5);
  background:
    radial-gradient(320px 120px at 50% 0%, rgba(34, 197, 94, 0.09), transparent 70%),
    linear-gradient(180deg, var(--card), var(--bg-soft));
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.competition {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}

.chip-live { background: var(--green-soft); color: var(--green); animation: pulse-soft 1.8s infinite; }
@keyframes pulse-soft { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.chip-upcoming { background: var(--amber-soft); color: var(--amber); }
.chip-finished { background: rgba(100, 116, 139, 0.16); color: var(--gray); }
.chip-cancelled { background: var(--red-soft); color: var(--red); }

.teams {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.team .crest {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.team .name {
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.center {
  flex-shrink: 0;
  width: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.center .vs {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--muted);
}

.center .score {
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.center .minute {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.5px;
}

.center .time {
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.countdown {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.countdown strong { color: var(--amber); font-weight: 700; }

.btn-watch {
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  color: #04140b;
  background: var(--grad);
  padding: 9px 16px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.25);
}

.btn-watch:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(34, 197, 94, 0.35); }

.btn-watch:disabled {
  cursor: not-allowed;
  background: var(--border);
  color: var(--muted);
  box-shadow: none;
}

.btn-watch .count-src {
  background: rgba(0, 0, 0, 0.22);
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
}

/* ---------- Empty ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

.empty-hint { margin-top: 8px; font-size: 0.85rem; }
.empty-hint code, .site-footer code { background: var(--card); padding: 2px 6px; border-radius: 6px; font-size: 0.85em; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 40px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

/* ---------- Modal / player ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 13, 0.82);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  width: min(940px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 20px;
  animation: rise 0.22s ease;
}

@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.modal-league {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.modal-heading h3 { font-size: 1.15rem; margin: 2px 0 4px; }

.modal-status {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-close:hover { border-color: var(--red); color: var(--red); }

.source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.source-tab {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.source-tab:hover { border-color: var(--green); }
.source-tab.active { background: var(--green-soft); border-color: var(--green); color: var(--green); }

.tag {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.4px;
}

.tag-hd { background: var(--green-soft); color: var(--green); }
.tag-sd { background: rgba(100, 116, 139, 0.18); color: var(--muted); }
.tag-lowlat { background: var(--amber-soft); color: var(--amber); }
.tag-tv { background: rgba(96, 165, 250, 0.18); color: #60a5fa; }

.player-stage {
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.player-empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 20px;
  text-align: center;
}

.player-stage video,
.player-stage iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

.player-error {
  color: var(--red);
  font-size: 0.9rem;
  text-align: center;
  padding: 30px;
}

.player-stage.controls-on { aspect-ratio: auto; }
.player-stage.controls-on video,
.player-stage.controls-on iframe { aspect-ratio: 16 / 9; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .match-grid { grid-template-columns: 1fr; }
  .clock-date { display: none; }
  .team .crest { width: 44px; height: 44px; }
  .modal { padding: 10px; }
  .modal-panel { padding: 14px; }
}


/* ================= Ver partido (watch page) ================= */
.watch-body { overflow-x: hidden; }

.btn-back {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}
.btn-back:hover { border-color: var(--green); color: var(--green); }

.watch-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 60px;
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
  align-items: start;
  transition: grid-template-columns 0.2s ease;
}
.watch-main.maximized { grid-template-columns: 1fr; }
.watch-main.no-chat .chat-box { display: none; }

@media (max-width: 900px) {
  .watch-main { grid-template-columns: 1fr; }
}

.player-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.player-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.match-heading h2 { font-size: 1.05rem; line-height: 1.3; }
.match-status { display: inline-block; margin-top: 4px; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; }
.match-status.live { color: var(--green); animation: pulse-soft 1.8s infinite; }
.match-status.upcoming { color: var(--amber); }
.match-status.off { color: var(--muted); }

.player-controls { display: flex; gap: 8px; }

.ctl {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ctl:hover:not(.disabled) { border-color: var(--green); }
.ctl.active { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.ctl.disabled { opacity: 0.35; cursor: not-allowed; }

.source-bar {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
}

.source-group-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 2px 6px;
}
.source-group-label:first-child { margin-top: 2px; }

/* ---------- Match status oculto en el reproductor ---------- */
.watch-body .match-status { display: none; }

/* ---------- Sonido ---------- */
.ctl.muted { background: var(--amber-soft); border-color: var(--amber); color: var(--amber); }

/* ---------- Toast ---------- */
.player-toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  max-width: 90%;
  background: rgba(11, 14, 20, 0.92);
  border: 1px solid var(--amber);
  color: var(--amber);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  z-index: 20;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-box { position: relative; }
.player-toast.hidden { display: none; }

/* ---------- Chat ---------- */
.chat-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 130px);
  min-height: 420px;
  position: sticky;
  top: 84px;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.9rem;
}
.chat-conn { font-size: 0.72rem; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.conn-dot.on { background: var(--green); }
.conn-dot.off { background: var(--amber); }
.conn-dot.err { background: var(--red); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 8px 11px; }
.msg-name { font-weight: 800; font-size: 0.8rem; color: var(--green); }
.msg-time { font-size: 0.66rem; color: var(--muted); margin-left: 8px; }
.msg-text { margin-top: 2px; font-size: 0.86rem; word-break: break-word; line-height: 1.4; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.chat-form input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.86rem;
  outline: none;
}
.chat-form input:focus { border-color: var(--green); }
.chat-form input:disabled { opacity: 0.5; }
.chat-form button {
  border: none;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  color: #04140b;
  background: var(--grad);
  padding: 0 16px;
  border-radius: 10px;
  cursor: pointer;
}
.chat-form button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Mini player ---------- */
.mini-player {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 320px;
  max-width: 45vw;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  z-index: 200;
  box-shadow: var(--shadow);
}
.mini-player .mini-stage { aspect-ratio: 16 / 9; display: grid; place-items: center; }
.mini-player .mini-stage video,
.mini-player .mini-stage iframe { width: 100%; height: 100%; border: 0; display: block; }
.mini-restore {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
}

/* ---------- Modal nombre ---------- */
.modal-name { max-width: 400px; }
.modal-sub { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
#nameForm { display: flex; flex-direction: column; gap: 10px; }
#nameForm input {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 13px;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
}
#nameForm input:focus { border-color: var(--green); }
.name-error { color: var(--red); font-size: 0.78rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-ghost {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 9px 16px;
  border-radius: 12px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--red); color: var(--red); }

/* ================= Partidos de ayer ================= */
.section-sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin: -8px 0 14px;
}

/* ================= Empieza en (próximos) ================= */
.starts-in {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 0 4px;
}
.starts-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.starts-time {
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
  line-height: 1;
  text-shadow: 0 0 24px rgba(245, 158, 11, 0.25);
}
.card-foot .countdown {
  font-size: 0.86rem;
  font-weight: 600;
}

/* ================= Tablas de posiciones ================= */
.standings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 18px;
}
.standings-col {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}
.standings-col-title {
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text);
  margin: 0 0 10px;
}
.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.standings-table th {
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
.standings-table th:nth-child(2) { text-align: left; }
.standings-table td {
  text-align: center;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}
.standings-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.standings-table td.c-team {
  text-align: left;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.standings-table td.c-pts { font-weight: 800; color: var(--green); }
.zone-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.58rem;
  font-weight: 800;
  vertical-align: middle;
  background: rgba(245, 158, 11, 0.16);
  color: var(--amber);
}
@media (max-width: 640px) {
  .standings-grid { grid-template-columns: 1fr; }
}

/* ================= Ver TV ================= */
.tv-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.tv-select {
  flex: 1;
  min-width: 240px;
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  padding: 11px 14px;
  cursor: pointer;
  outline: none;
}
.tv-select:focus { border-color: var(--green); }
.tv-select option { background: var(--bg-soft); color: var(--text); }
