/* ============================================================
   Quiniela Mundial 2026 — Tema corporativo San Martín
   Azul oficial #111942 + blanco
   ============================================================ */

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

:root {
  /* Marca */
  --primary: #111942;
  --primary-dark: #0a1130;
  --primary-light: #2a3470;

  /* Fondos */
  --bg: #f5f7fb;
  --bg-2: #eef1f8;
  --card: #ffffff;
  --card-2: #f0f3fa;

  /* Texto */
  --text: #111942;
  --text-dim: #6b7280;

  /* Estado / acentos */
  --accent: #111942;
  --gold: #c9a227;
  --red: #ef476f;
  --green: #10b981;

  /* UI */
  --border: rgba(17, 25, 66, 0.10);
  --shadow: 0 4px 16px rgba(17, 25, 66, 0.06);
  --shadow-lg: 0 8px 24px rgba(17, 25, 66, 0.10);
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
select {
  font: inherit;
}

/* ============ LOGIN ============ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  max-width: 420px;
  margin: 0 auto;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--primary);
}

.auth-logo .trophy {
  font-size: 64px;
  display: block;
  margin-bottom: 12px;
}

.auth-logo p {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 8px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: flex;
  background: var(--bg-2);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.auth-tabs button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 14px;
  transition: all .2s;
}

.auth-tabs button.active {
  background: var(--primary);
  color: #ffffff;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.field input {
  width: 100%;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border .2s, box-shadow .2s;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 25, 66, 0.08);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #ffffff;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  margin-top: 8px;
  transition: transform .1s, background .2s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:active {
  transform: scale(.98);
}

.btn-primary:disabled {
  opacity: .5;
}

.auth-error {
  background: rgba(239, 71, 111, .10);
  border: 1px solid var(--red);
  color: #b13350;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-info {
  background: rgba(17, 25, 66, .05);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ============ APP HEADER ============ */
.app-header {
  position: sticky;
  top: 0;
  background: var(--primary);
  color: #ffffff;
  z-index: 50;
  padding: env(safe-area-inset-top) 16px 12px;
  box-shadow: var(--shadow);
}

.app-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
}

.app-title {
  font-size: 18px;
  font-weight: 800;
  color: #ffffff;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  color: #ffffff;
}

.user-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.user-chip button {
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  text-decoration: underline;
}

/* ============ MAIN ============ */
main {
  padding: 16px 16px 100px;
  max-width: 720px;
  margin: 0 auto;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  margin-top: 4px;
  color: var(--primary);
}

.stat-value.gold {
  color: var(--gold);
}

.stat-value.accent {
  color: var(--primary);
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  transition: all .2s;
  white-space: nowrap;
}

.chip.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* ============ DROPDOWN ============ */
.dropdown {
  position: relative;
  margin-bottom: 16px;
}

.dropdown-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dropdown-row .dropdown {
  flex: 1;
  min-width: 140px;
  margin-bottom: 0;
}

.dropdown-trigger {
  width: 100%;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}

.dropdown-trigger:hover {
  border-color: var(--primary);
}

.dropdown-arrow {
  color: var(--text-dim);
  font-size: 12px;
  transition: transform .2s;
}

.dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  overflow: hidden;
}

.dropdown.open .dropdown-panel {
  display: block;
}

.dropdown-search {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  outline: none;
  background: var(--bg);
  font-size: 14px;
  color: var(--text);
}

.dropdown-search:focus {
  background: var(--bg-2);
}

.dropdown-options {
  max-height: 280px;
  overflow-y: auto;
}

.dropdown-option {
  display: block;
  width: 100%;
  padding: 11px 14px;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.dropdown-option:last-child {
  border-bottom: none;
}

.dropdown-option:hover {
  background: var(--bg);
}

.dropdown-option.active {
  background: rgba(17, 25, 66, 0.08);
  color: var(--primary);
  font-weight: 700;
}

/* ============ MATCH CARD ============ */
.match {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
  transition: transform .15s;
  box-shadow: var(--shadow);
}

.match.locked {
  opacity: .65;
}

/* Resaltado por puntos obtenidos */
.match.match-exact {
  opacity: 1;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold), var(--shadow);
}

.match.match-exact .points,
.match.match-exact .match-winner {
  color: var(--gold);
}

.match.match-won {
  opacity: 1;
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green), var(--shadow);
}

.match.match-won .points,
.match.match-won .match-winner {
  color: var(--green);
}

.match.match-lost {
  border-color: rgba(239, 71, 111, 0.3);
  background: rgba(239, 71, 111, 0.025);
}

.match-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
}

.match-group {
  background: var(--bg-2);
  padding: 3px 8px;
  border-radius: 8px;
  color: var(--primary);
}

.match-info {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.match-when {
  color: var(--primary);
  font-weight: 600;
}

.match-where {
  color: var(--text-dim);
}

/* ============ ADMIN — HORARIOS ============ */
.schedule-row {
  display: grid;
  grid-template-columns: 70px 60px 1fr auto 32px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.edit-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--primary);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.edit-btn:hover {
  background: var(--card-2);
}

.edit-btn:active {
  transform: scale(.95);
}

.schedule-time {
  color: var(--primary);
  font-weight: 700;
}

.schedule-group {
  background: var(--bg-2);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

.schedule-teams {
  color: var(--text);
  font-weight: 600;
}

.schedule-venue {
  color: var(--text-dim);
  font-size: 11px;
}

@media (max-width: 480px) {
  .schedule-row {
    grid-template-columns: 1fr auto 32px;
    grid-auto-flow: row;
  }
  .schedule-time { grid-column: 1; grid-row: 1; }
  .schedule-group { grid-column: 2; grid-row: 1; }
  .edit-btn { grid-column: 3; grid-row: 1 / span 3; align-self: center; }
  .schedule-teams { grid-column: 1 / 3; grid-row: 2; }
  .schedule-venue { grid-column: 1 / 3; grid-row: 3; }
}

.match-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-pill {
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
}

.status-pill.live {
  background: var(--red);
  color: #ffffff;
  animation: pulse 2s infinite;
}

.status-pill.done {
  background: var(--primary);
  color: #ffffff;
}

.status-pill.open {
  background: var(--green);
  color: #ffffff;
}

.status-pill.locked {
  background: #9ca3af;
  color: #ffffff;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .6;
  }
}

.teams-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.team {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.team-flag {
  font-size: 36px;
  line-height: 1;
  margin-bottom: 6px;
}

.team-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}

.score-input {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.score-input input {
  width: 42px;
  height: 42px;
  text-align: center;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  outline: none;
  transition: border .2s, box-shadow .2s;
}

.score-input input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 25, 66, 0.08);
}

.score-input input:disabled {
  background: var(--card-2);
  color: var(--text-dim);
}

.score-input span {
  font-size: 20px;
  color: var(--text-dim);
  font-weight: 700;
}

.match-result {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
}

.match-result .official {
  color: var(--text-dim);
}

.match-result .points {
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.match-winner {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  padding: 8px 0 0;
}

/* ============ RANKING ============ */
.ranking-list {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.rank-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  padding: 14px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.rank-row:last-child {
  border-bottom: none;
}

.rank-row.me {
  background: rgba(17, 25, 66, .05);
}

.rank-pos {
  font-size: 18px;
  font-weight: 800;
  text-align: center;
  color: var(--text-dim);
}

.rank-pos.gold {
  color: var(--gold);
}

.rank-pos.silver {
  color: #9ca3af;
}

.rank-pos.bronze {
  color: #cd7f32;
}

.rank-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.rank-name small {
  display: block;
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 2px;
  font-weight: 400;
}

.rank-pts {
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
}

.rank-pts small {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 600;
  display: block;
  text-align: right;
}

/* ============ KNOCKOUT ============ */
.ko-round {
  margin-bottom: 20px;
}

.ko-round h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 10px;
  font-weight: 700;
}

.ko-match {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}

.ko-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.ko-team-input {
  width: 100%;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  text-align: center;
  outline: none;
  transition: border .2s;
}

.ko-team-input:focus {
  border-color: var(--primary);
}

.ko-team-input:disabled {
  background: var(--card-2);
}

.ko-vs {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 700;
}

/* ============ NAV BOTTOM ============ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
  box-shadow: 0 -4px 16px rgba(17, 25, 66, 0.06);
}

.bottom-nav-inner {
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.nav-btn {
  padding: 8px 2px;
  border-radius: 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  transition: all .2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.nav-btn .icon {
  display: block;
  font-size: 22px;
  margin-bottom: 2px;
}

.nav-btn.active {
  color: var(--primary);
  background: rgba(17, 25, 66, .08);
}

/* ============ ADMIN ============ */
.admin-banner {
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
}

.admin-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.admin-toggle .switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--bg-2);
  border-radius: 12px;
  transition: background .2s;
}

.admin-toggle .switch.on {
  background: var(--primary);
}

.admin-toggle .switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.admin-toggle .switch.on::after {
  transform: translateX(20px);
}

/* ============ MODAL ============ */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(17, 25, 66, .5);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-bg.show {
  display: flex;
}

.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.modal h3 {
  margin-bottom: 12px;
  font-size: 18px;
  color: var(--primary);
}

.modal p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ============ EMPTY STATE ============ */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.empty .icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
  opacity: .5;
}

/* ============ LOADING ============ */
.spinner {
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  animation: spin 1s linear infinite;
  margin: 40px auto;
}

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

/* ============ TABS WITHIN VIEW ============ */
.sub-tabs {
  display: flex;
  background: var(--card);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}

.sub-tabs button {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  transition: all .2s;
}

.sub-tabs button.active {
  background: var(--primary);
  color: #ffffff;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all .3s;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
