/* ────────────────────────────────────────────────────────────
   QUINIELA MUNDIAL 2026 · look & feel oficial FIFA
   Inspirado en fifa.com/canadamexicousa2026
   ──────────────────────────────────────────────────────────── */

/* ─── Banderas: webfont para que se vean en Windows también ─── */
@font-face {
  font-family: 'Twemoji Country Flags';
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067, U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url('https://cdn.jsdelivr.net/npm/country-flag-emoji-polyfill@0.1.8/dist/TwemojiCountryFlags.woff2') format('woff2');
}

:root {
  /* Superficies — FIFA real palette */
  --bg:           #ffffff;
  --bg-2:         #f4f4f4;
  --bg-3:         #ededed;
  --row-hover:    #fafafa;

  /* Brand FIFA */
  --fifa-navy:    #1F4380;
  --fifa-navy-2:  #2A5599;
  --fifa-black:   #0A0A0A;

  /* Texto */
  --text:        #0A0A0A;
  --text-2:      #3A3A3A;
  --muted:       #6F6F6F;
  --dim:         #9A9A9A;

  /* Bordes */
  --border:      #E5E5E5;
  --border-2:    #D4D4D4;

  /* Acentos */
  --signature:   #DC2626;
  --green:       #16A34A;
  --green-soft:  #DCFCE7;
  --gold:        #C89414;
  --gold-soft:   #FEF3C7;
  --blue:        #1F4380;
  --blue-soft:   #DBEAFE;

  /* Misc */
  --radius:      4px;
  --radius-sm:   3px;
  --shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.08);

  --font-ui:     'Inter', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display:'Inter', sans-serif;
}

/* ─────────── Reset ─────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Twemoji Country Flags', var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

img { max-width: 100%; display: block; }
a { color: var(--fifa-navy); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--fifa-navy-2); }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ─────────── Topbar (doble) ─────────── */
.topbar {
  background: var(--fifa-black);
  position: sticky;
  top: 0;
  z-index: 100;
}
/* Barra superior navy FIFA */
.topbar::before {
  content: '';
  display: block;
  height: 56px;
  background: var(--fifa-navy);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  min-height: 64px;
  position: relative;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  background: #fff;
  border-radius: 6px;
  flex-shrink: 0;
  position: relative;
}
.brand-mark::before {
  content: '🏆';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
}
.brand-text {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
}

.topbar nav {
  display: flex;
  gap: 0;
  align-items: center;
  flex-wrap: wrap;
}
.topbar nav a {
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 22px 18px;
  position: relative;
  transition: color 0.15s;
}
.topbar nav a:hover { color: #BFD3EE; }
.topbar nav a.active::after,
.topbar nav a:hover::after {
  content: '';
  position: absolute;
  left: 18px; right: 18px; bottom: 14px;
  height: 2px;
  background: #fff;
}

.user {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-left: 8px;
}

button.link {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #fff;
  cursor: pointer;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 3px;
  font-family: var(--font-ui);
  transition: all 0.15s;
  margin-left: 8px;
}
button.link:hover {
  background: #fff;
  color: var(--fifa-black);
  border-color: #fff;
}

/* ─────────── Main ─────────── */
main { padding: 32px 0 80px; background: var(--bg); min-height: calc(100vh - 120px); }

h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 8px;
}

h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  margin-bottom: 16px;
  text-transform: lowercase;
  padding: 24px 0 12px;
  border-bottom: 1px solid var(--border);
}
h2::first-letter { text-transform: uppercase; }

/* ─────────── Cards base ─────────── */
.card {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 32px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.card.narrow {
  max-width: 420px;
  margin: 64px auto;
  padding: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.card.narrow::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--fifa-navy);
}

/* ─────────── Forms ─────────── */
form label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
  margin-top: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
form label:first-of-type { margin-top: 0; }

form input[type="text"],
form input[type="password"],
form input[type="number"],
form select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
form input:focus,
form select:focus {
  outline: none;
  border-color: var(--fifa-navy);
  box-shadow: 0 0 0 3px rgba(31, 67, 128, 0.12);
}

button.primary {
  background: var(--fifa-navy);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 20px;
  transition: background 0.15s;
}
button.primary:hover { background: var(--fifa-navy-2); }

button.secondary {
  background: var(--bg);
  color: var(--fifa-navy);
  border: 1.5px solid var(--fifa-navy);
  padding: 11px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 0.15s;
}
button.secondary:hover { background: var(--fifa-navy); color: #fff; }

button.danger {
  background: var(--bg);
  color: var(--signature);
  border: 1.5px solid var(--signature);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
button.danger:hover { background: var(--signature); color: #fff; }

/* ─────────── Flash messages ─────────── */
.flash {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-weight: 500;
  font-size: 14px;
  border-left: 4px solid;
}
.flash.error {
  background: #FEF2F2;
  color: #7F1D1D;
  border-left-color: var(--signature);
}
.flash.success {
  background: var(--green-soft);
  color: #14532D;
  border-left-color: var(--green);
}

/* ─────────── Legend (reglas) ─────────── */
.legend {
  background: #F8F9FA;
  border: 1px solid var(--border);
  border-left: 4px solid var(--fifa-navy);
  color: var(--text-2);
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 28px;
  line-height: 1.6;
}
.legend b {
  color: var(--fifa-navy);
  font-weight: 700;
  font-size: 14px;
}

/* ─────────── Rondas ─────────── */
.round {
  background: transparent;
  margin-bottom: 36px;
}
.round h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
  letter-spacing: 0;
  padding: 16px 0 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.matches {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-top: none;
}

/* ─────────── Partido (row) ─────────── */
.match {
  background: var(--bg);
  padding: 22px 24px;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.match:hover { background: var(--row-hover); }
.match.locked { background: var(--bg-2); }
.match.locked:hover { background: var(--bg-3); }

.lock-badge {
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}

.match-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
  align-items: center;
  order: 2;
  justify-content: center;
}
.match-meta .date,
.match-meta .ground,
.match-meta .group {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.match-meta .date::after,
.match-meta .group::after {
  content: '·';
  margin-left: 8px;
  color: var(--dim);
}
.match-meta .group {
  color: var(--fifa-navy);
  font-weight: 600;
}
.match-meta .ground {
  color: var(--muted);
}

.match-form {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  order: 1;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.match-form .team {
  display: flex;
  align-items: center;
  gap: 14px;
}
.match-form .team-left {
  justify-content: flex-end;
}
.match-form .team-right {
  justify-content: flex-start;
}

.match-form .flag {
  font-family: 'Twemoji Country Flags', var(--font-ui);
  font-size: 28px;
  line-height: 1;
  flex-shrink: 0;
}
.match-form .team-name {
  font-weight: 600;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.005em;
}

/* Orden: name flag select | select flag name */
.match-form .team-left .team-name   { order: 1; text-align: right; }
.match-form .team-left .flag        { order: 2; }
.match-form .team-left .goals-select{ order: 3; }

.match-form .team-right .goals-select { order: 1; }
.match-form .team-right .flag         { order: 2; }
.match-form .team-right .team-name    { order: 3; }

.goals-select {
  width: 56px !important;
  height: 56px !important;
  padding: 0 !important;
  border: 2px solid var(--border-2) !important;
  border-radius: var(--radius) !important;
  font-family: var(--font-ui) !important;
  font-weight: 700 !important;
  font-size: 22px !important;
  text-align: center;
  background: var(--bg) !important;
  color: var(--text) !important;
  text-align-last: center;
  -moz-text-align-last: center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all 0.15s;
}
.goals-select:hover:not(:disabled) {
  border-color: var(--fifa-navy) !important;
}
.goals-select:focus {
  outline: none;
  border-color: var(--fifa-navy) !important;
  box-shadow: 0 0 0 3px rgba(31, 67, 128, 0.15);
}
.goals-select:disabled {
  background: var(--bg-2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  cursor: default;
  opacity: 1;
}

.vs {
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}

/* Botón guardar — pequeño, abajo a la derecha */
.match-form > button.primary {
  margin: 0;
  grid-column: 1 / -1;
  justify-self: end;
  padding: 8px 18px;
  font-size: 12px;
  margin-top: 4px;
}

.match.locked .match-form {
  grid-template-columns: 1fr auto 1fr;
}

/* Resultado debajo */
.result {
  grid-column: 1 / -1;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.result b {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}

.result .points {
  display: inline-flex;
  align-items: center;
  background: var(--green);
  color: #fff;
  padding: 3px 9px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: auto;
}

/* ─────────── Ver grupos link ─────────── */
.round h2 .view-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--fifa-navy);
  text-transform: none;
  letter-spacing: 0;
}

/* ─────────── Ranking ─────────── */
table.ranking {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 28px;
}
table.ranking th,
table.ranking td {
  padding: 14px 18px;
  text-align: left;
  font-size: 14px;
}
table.ranking th {
  background: var(--bg-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
table.ranking td {
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
table.ranking tr:last-child td { border-bottom: none; }
table.ranking tr:hover td { background: var(--row-hover); }

table.ranking .pos {
  font-weight: 700;
  font-size: 16px;
  width: 56px;
  color: var(--text);
}
table.ranking .points b {
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  background: transparent;
  padding: 0;
}
table.ranking td:nth-child(2) {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
}

table.ranking tr.rank-1 td { background: #FEFCE8; }
table.ranking tr.rank-1 .points b { color: var(--gold); font-size: 20px; }

table.ranking tr.rank-2 td { background: #F8FAFC; }
table.ranking tr.rank-3 td { background: #FFF7ED; }

table.ranking tr.winner td {
  background: #FEFCE8;
  font-weight: 600;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px !important;
  font-size: 14px;
}

.small {
  font-size: 13px;
  color: var(--muted);
  margin-top: 20px;
  text-align: center;
}
.small a {
  font-weight: 600;
  color: var(--fifa-navy);
}

/* ─────────── Footer ─────────── */
.footer {
  text-align: center;
  padding: 32px 0;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  margin-top: 64px;
  background: var(--bg);
}
.footer a {
  color: var(--fifa-navy);
  font-weight: 600;
}

/* ─────────── Apuestas ─────────── */
.jornada-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1.5rem;
}
.jornada-tab {
  padding: .4rem .9rem;
  border-radius: 999px;
  border: 2px solid var(--fifa-navy, #1F4380);
  color: var(--fifa-navy, #1F4380);
  font-size: .85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all .2s;
}
.jornada-tab.active, .jornada-tab:hover {
  background: var(--fifa-navy, #1F4380);
  color: #fff;
}

.bet-stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  background: var(--bg-2, #f4f4f4);
  border-radius: 14px;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  border: 2px solid rgba(31,67,128,.12);
}
.bet-stat { display: flex; flex-direction: column; min-width: 130px; }
.bet-stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.bet-stat-value { font-size: 1.3rem; font-weight: 800; color: var(--text); }

.deposit-form { display: flex; gap: .5rem; align-items: center; margin-left: auto; flex-wrap: wrap; }
.deposit-input {
  width: 140px;
  padding: .55rem .8rem;
  border: 2px solid var(--border, #e5e7eb);
  border-radius: 8px;
  font-size: 1rem;
}

.bet-match { margin-bottom: 1.2rem; }

.pool-bar {
  display: flex;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  margin: .6rem 0 .3rem;
  font-size: .75rem;
  font-weight: 700;
}
.pool-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  white-space: nowrap;
  overflow: hidden;
  padding: 0 6px;
  transition: width .3s;
}
.pool-local     { background: #1F4380; color: #fff; }
.pool-empate    { background: #f59e0b; color: #000; }
.pool-visitante { background: #ef4444; color: #fff; }

.pool-total {
  font-size: .82rem;
  color: var(--muted);
  margin: 0 0 .6rem;
  font-weight: 500;
}

.bet-row-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.bet-row {
  display: flex;
  gap: .6rem;
  align-items: center;
  justify-content: center;
  margin-top: .8rem;
  width: 100%;
}
.bet-amount-input {
  width: 120px;
  padding: .55rem .8rem;
  border: 2px solid var(--fifa-navy, #1F4380);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}
.goals-static {
  width: 50px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-2, #f4f4f4);
  border: 2px solid var(--border, #e5e7eb);
  border-radius: 8px;
  font-weight: 800;
  font-size: 1.1rem;
}

/* ─────────── Instrucciones ─────────── */
.instr-list {
  padding-left: 1.2rem;
  margin: .6rem 0;
  line-height: 2;
}
.instr-list li { margin-bottom: .2rem; }

.instr-steps { display: flex; flex-direction: column; gap: 1.2rem; margin-top: .8rem; }

.instr-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.step-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--fifa-navy, #1F4380);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.instr-example {
  background: var(--bg-2, #f4f4f4);
  border-left: 4px solid var(--fifa-navy, #1F4380);
  border-radius: 0 10px 10px 0;
  padding: 1rem 1.2rem;
  margin-top: .6rem;
}
.instr-example p { margin: 0 0 .5rem; }

/* ─────────── Responsive ─────────── */
@media (max-width: 768px) {
  h1 { font-size: 24px; }
  main { padding: 24px 0 56px; }

  .topbar::before { height: 48px; }
  .topbar nav { gap: 0; }
  .topbar nav a { padding: 16px 10px; font-size: 11px; }
  .brand-text { font-size: 12px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark::before { font-size: 18px; }

  .card { padding: 24px; }
  .card.narrow { padding: 28px; margin: 28px auto; }
  .match { padding: 18px 14px; }

  .match-form {
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
  }
  .match-form > button.primary {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: 100%;
    margin-top: 8px;
  }
  .match-form .team { gap: 10px; }
  .match-form .team-name { font-size: 13px; min-width: 0; }
  .match-form .flag { font-size: 22px; }
  .goals-select {
    width: 48px !important;
    height: 48px !important;
    font-size: 18px !important;
  }
  .vs { font-size: 18px; }

  table.ranking th,
  table.ranking td { padding: 10px 8px; font-size: 13px; }
  table.ranking .pos { width: 36px; font-size: 14px; }
}

@media (max-width: 480px) {
  .brand-text { font-size: 10px; letter-spacing: 0.08em; }
  h1 { font-size: 20px; }
  .match-form .team-name { font-size: 12px; }
  .match-meta { font-size: 11px; gap: 4px; }
}
