:root {
  --bg: #f3f4f6;
  --panel-bg: #ffffff;
  --border: #e0e0e0;
  --primary: #3cac3b;
  --primary-dark: #2a8b2b;
  --accent: #ffd700;
  --text: #111827;
  --muted: #6b7280;
  --danger: #b91c1c;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #e0f2f1 0, #f3f4f6 45%, #f9fafb 100%);
  color: var(--text);
}

/* Header */

.site-header {
  padding: 1rem 1.5rem;
  background: linear-gradient(90deg, #001433 0, #3cac3b 45%, #ffd700 100%);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-header h1 {
  margin: 0;
  font-size: 1.3rem;
}

.session {
  font-size: 0.9rem;
}

#sessionBadge {
  padding: 0.25rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.15);
  color: #f9fafb;
}

/* Layout */

.layout {
  max-width: 1400px;
  margin: 1.5rem auto 2rem;
  padding: 0 1rem;
  display: grid;
  gap: 1rem;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    align-items: flex-start;
  }
}

.layout.layout-authenticated {
  grid-template-columns: 1fr;
  max-width: 1500px;
}

.layout.layout-authenticated .panel-access {
  display: none;
}

.panel {
  background: var(--panel-bg);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(15,23,42,0.06);
}

.panel h2 {
  margin-top: 0;
}

.panel-inner {
  padding: 0;
}

.panel-app {
  min-height: 520px;
}

/* Auth */

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.tab {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f3f4f6;
  cursor: pointer;
  font-size: 0.9rem;
}

.tab-active {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #ffffff;
}

.auth-pane {
  display: none;
}

.auth-pane-active {
  display: block;
}

.form {
  display: grid;
  gap: 0.75rem;
}

.form label span {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

/* Buttons */

.btn {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #e5e7eb;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.actions-inline {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Messages */

.message {
  margin-top: 0.75rem;
  min-height: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* User strip */

.user-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 1rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.user-strip-main {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}

.user-strip-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.user-strip-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.user-strip-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.user-strip-stats {
  display: flex;
  gap: 1rem;
}

.user-strip-stat {
  display: flex;
  flex-direction: column;
  min-width: 80px;
}

.user-strip-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.user-strip-actions {
  display: flex;
  justify-content: flex-end;
}

/* Tabs & views */

.main-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.main-tab {
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.main-tab-active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary-dark);
}

.view {
  display: none;
}

.view-active {
  display: block;
}

.hidden {
  display: none !important;
}

/* Summary */

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.summary-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.9rem 1rem;
}

.summary-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.summary-value-sm {
  font-size: 0.95rem;
  line-height: 1.35;
}

/* Filters + matches */

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 240px;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.matches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (min-width: 1500px) {
  .matches {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.match-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: linear-gradient(135deg, #ffffff 0, #f9fafb 60%, #f1f5f9 100%);
}

.match-header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.match-header-left {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.match-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.match-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.match-badge-open {
  background: #eefbf0;
  color: #1f7a31;
}

.match-badge-locked {
  background: #fff7e8;
  color: #9a6700;
}

.match-badge-finished {
  background: #eef4ff;
  color: #1d4ed8;
}

.match-badge-saved {
  background: #f1f5f9;
  color: #334155;
}

.match-teams {
  font-weight: 700;
  font-size: 1.02rem;
  margin-bottom: 0.2rem;
}

.match-meta {
  font-size: 0.82rem;
  color: var(--muted);
}

.prediction-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  margin-top: 0.7rem;
  align-items: center;
}

.prediction-row input[type="number"] {
  text-align: center;
}

/* Lists */

.list-empty {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Leaderboard tabla */

.leaderboard-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #ffffff;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.leaderboard-table thead th {
  text-align: left;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
  padding: 0.9rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.leaderboard-table tbody td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

.leaderboard-table tbody tr:hover {
  background: #f9fbff;
}

.leaderboard-rank {
  font-weight: 700;
  white-space: nowrap;
}

.leaderboard-alias {
  font-weight: 600;
}

.leaderboard-points {
  font-weight: 700;
  color: var(--primary);
}

.leaderboard-me {
  background: #f3fff4;
}

.leaderboard-me:hover {
  background: #ecfceb !important;
}

.leaderboard-you {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
}

/* Mi porra */

.predictions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.prediction-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffff;
  padding: 1rem;
}

.prediction-card-exact {
  border-color: rgba(34, 197, 94, 0.6);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25);
  background: linear-gradient(135deg, #ecfdf3 0, #ffffff 40%, #f8fafc 100%);
}

.prediction-card-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.prediction-kicker {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.prediction-title {
  font-size: 1.05rem;
  line-height: 1.25;
  margin: 0;
}

.prediction-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.9rem;
}

.prediction-status {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-pending {
  background: #eefbf0;
  color: #1f7a31;
}

.status-locked {
  background: #fff7e8;
  color: #9a6700;
}

.status-finished {
  background: #eef4ff;
  color: #1d4ed8;
}

.prediction-score-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.prediction-score-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem;
  background: #f8fafc;
}

.prediction-score-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.prediction-score {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.prediction-points {
  color: var(--primary);
}

/* Misc */

.note,
.save-status {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Responsivo */

@media (max-width: 1100px) {
  .matches,
  .predictions-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .summary-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .user-strip {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .user-strip-stats {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .leaderboard-table thead th,
  .leaderboard-table tbody td {
    padding: 0.8rem 0.75rem;
  }
}

@media (max-width: 640px) {
  .match-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .prediction-card-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .prediction-score-row,
  .summary-cards {
    grid-template-columns: 1fr;
  }

  .prediction-row {
    grid-template-columns: 1fr 1fr;
  }

  .prediction-row .btn,
  .prediction-row .save-status {
    grid-column: 1 / -1;
  }
}

.match-status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.chip {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9fafb;
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--muted);
}

.chip-active {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #ffffff;
}

.league-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.75rem 0;
}

.player-details {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f9fafb;
  padding: 0.9rem 1rem 1rem;
  margin-bottom: 0.85rem;
}

.player-details-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.player-details-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.player-details-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.player-details-position {
  text-align: right;
}

.player-details-position-label {
  font-size: 0.8rem;
  color: var(--muted);
  display: block;
}

.player-details-position-value {
  font-size: 1.15rem;
  font-weight: 700;
}

.player-details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.player-details-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #ffffff;
  padding: 0.55rem 0.7rem;
}

.player-details-card-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.player-details-card-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.player-details-footer {
  font-size: 0.82rem;
  color: var(--muted);
}

.player-details-footer-strong {
  font-weight: 600;
  color: var(--text);
}

@media (max-width: 900px) {
  .player-details-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .player-details-grid {
    grid-template-columns: 1fr;
  }

  .player-details-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .player-details-position {
    text-align: left;
  }
}

.leaderboard-row-click {
  cursor: pointer;
}

.player-details-tabs {
  display: inline-flex;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.player-details-tab {
  padding: 0.28rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 0.8rem;
  cursor: pointer;
}

.player-details-tab-active {
  background: var(--primary);
  border-color: var(--primary-dark);
  color: #ffffff;
}

.player-details-section {
  display: none;
}

.player-details-section-active {
  display: block;
}

.player-predictions-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  margin-top: 0.4rem;
}

.player-prediction-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  background: #ffffff;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.player-prediction-header {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: flex-start;
}

.player-prediction-match {
  margin-bottom: 0.1rem;
}

.player-prediction-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.player-prediction-status {
  font-size: 0.78rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
  white-space: nowrap;
}

.player-prediction-body {
  margin-top: 0.25rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.2rem 0.6rem;
}

.player-prediction-line {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
}

.player-prediction-label {
  color: var(--muted);
}

.player-prediction-value {
  font-weight: 600;
}

.player-prediction-footer {
  margin-top: 0.25rem;
}

.player-prediction-badge {
  display: inline-block;
  padding: 0.16rem 0.6rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.player-prediction-badge-exact {
  background: #dcfce7;
  color: #15803d;
}

.player-prediction-badge-sign {
  background: #e0f2fe;
  color: #0369a1;
}

.player-prediction-badge-miss {
  background: #fee2e2;
  color: #b91c1c;
}

.player-prediction-badge-neutral {
  background: #f3f4f6;
  color: #4b5563;
}

@media (max-width: 900px) {
  .player-prediction-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .player-predictions-list {
    grid-template-columns: 1fr;
  }
}

.match-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Abierto: azul suave */
.match-badge-open {
  background-color: #e3f2fd;
  color: #0b5394;
}

/* Cerrado: gris */
.match-badge-locked {
  background-color: #eeeeee;
  color: #555555;
}

/* En juego: naranja/ámbar */
.match-badge-live {
  background-color: #fff3cd;
  color: #92400e;
}

/* Finalizado: verde */
.match-badge-finished {
  background-color: #e7f5e9;
  color: #14532d;
}

/* Pronóstico guardado: verde más intenso */
.match-badge-saved {
  background-color: #d1fae5;
  color: #047857;
}

.prediction-helper {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #b91c1c;
}
.status-live {
  background-color: #fff3cd;
  color: #92400e;
}

.match-card-next {
  border: 2px solid #0b5394;
}

/* Contenedor general de la vista de grupos */
.groups-standings {
  display: grid;
  gap: 1rem;
}

/* Tarjeta de cada grupo */
.group-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 0.75rem 1rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.group-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

/* Tabla de grupo */
.group-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.group-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.group-table thead {
  background-color: #f3f4f6;
}

.group-table th,
.group-table td {
  padding: 0.35rem 0.4rem;
  text-align: center;
  white-space: nowrap;
}

.group-table th:first-child,
.group-table td:first-child {
  text-align: left;
}

.group-table th:nth-child(2),
.group-table td:nth-child(2) {
  text-align: left;
}

/* Líneas de la tabla */
.group-table tbody tr:nth-child(even) {
  background-color: #f9fafb;
}

/* Resaltar puestos de clasificación (por ejemplo top 2) */
.group-table tbody tr:nth-child(1),
.group-table tbody tr:nth-child(2) {
  font-weight: 600;
}

/* Opcional: bordes suaves */
.group-table tbody tr {
  border-bottom: 1px solid #e5e7eb;
}

.match-card-next {
  border: 2px solid #0b5394;
}