/* Torneo de Exalumnos — estilos */
:root {
  --navy: #16205b;
  --navy-2: #222f7e;
  --gold: #f2b705;
  --gold-soft: #fff4cc;
  --pitch: #138a4b;
  --pitch-2: #0e6e3b;
  --bg: #f3f5f0;
  --card: #ffffff;
  --card-2: #f8faf7;
  --ink: #141a2e;
  --muted: #5f6b7a;
  --line: #e2e6e0;
  --red: #e5383b;
  --yellow: #ffc300;
  --win: #16a34a;
  --draw: #94a3b8;
  --loss: #dc2626;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px;
  --font: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bebas Neue', 'Outfit', sans-serif;
  --display-weight: 400;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1220; --card: #151c2e; --card-2: #1a2236; --ink: #e8ecf4; --muted: #98a2b3;
    --line: #26304a; --gold-soft: #3a3214; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1220; --card: #151c2e; --card-2: #1a2236; --ink: #e8ecf4; --muted: #98a2b3;
  --line: #26304a; --gold-soft: #3a3214; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.45; font-size: 15px; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--pitch); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .6rem; }
h1 { font-family: var(--display); font-weight: 400; font-size: clamp(2rem, 5vw, 2.8rem); letter-spacing: .02em; }
h2 { font-size: 1.2rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: 1rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: center; }

/* ---------- Header ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.topbar-in { max-width: 1200px; margin: 0 auto; padding: .55rem 16px; display: flex; align-items: center; gap: 1rem; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; color: #fff; min-width: 0; }
.brand img { width: 38px; height: 38px; object-fit: contain; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { display: block; font-weight: 400; font-size: .72rem; opacity: .75; }
.brand:hover { color: var(--gold); }
.search { margin-left: auto; position: relative; }
/* El buscador va sobre la barra azul en los dos modos, así que usa colores fijos (no los del tema). */
.search input[type=search] { width: 240px; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: .5rem .9rem .5rem 2.3rem; background: rgba(255,255,255,.14); color: #fff; font: inherit; }
.search input[type=search]::placeholder { color: rgba(255,255,255,.8); opacity: 1; }
.search input[type=search]:focus { outline: 2px solid var(--gold); border-color: transparent; background: rgba(255,255,255,.22); }
.search input[type=search]::-webkit-search-cancel-button { filter: invert(1); }
.search::before { content: ''; position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2.6' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M15.5 15.5 21 21'/%3E%3C/svg%3E") center / contain no-repeat; }
.ac { position: absolute; right: 0; top: calc(100% + 6px); width: 320px; background: var(--card); color: var(--ink); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; display: none; border: 1px solid var(--line); }
.ac.open { display: block; }
.ac a { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; border-bottom: 1px solid var(--line); }
.ac a:last-child { border-bottom: 0; }
.ac a:hover, .ac a.sel { background: var(--card-2); color: var(--ink); }
.theme-btn { background: none; border: 0; font-size: 1.1rem; cursor: pointer; padding: .3rem; color: #fff; }

.nav { background: var(--navy-2); }
.nav-in { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; gap: .1rem; overflow-x: auto; scrollbar-width: none; }
.nav-in::-webkit-scrollbar { display: none; }
.nav a { color: rgba(255,255,255,.82); padding: .65rem .62rem; white-space: nowrap; font-weight: 500; font-size: .92rem; border-bottom: 3px solid transparent; }
.nav a:hover { color: #fff; }
.nav a.on { color: #fff; border-bottom-color: var(--gold); }

/* Menú hamburguesa: en pantallas chicas la navegación se despliega desde un botón */
.menu-btn { display: none; flex: none; width: 40px; height: 40px; border: 1px solid rgba(255,255,255,.35); border-radius: 10px; background: rgba(255,255,255,.08); cursor: pointer; padding: 0; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.menu-btn span { display: block; width: 18px; height: 2px; border-radius: 2px; background: #fff; transition: transform .2s, opacity .2s; }
.menu-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.nav-open .menu-btn span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-open .menu-btn span:nth-child(2) { opacity: 0; }
.nav-open .menu-btn span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
/* Debajo de este ancho el menú completo no entra en una línea: pasa a hamburguesa */
@media (max-width: 1100px) {
  .menu-btn { display: inline-flex; }
  .topbar-in { gap: .6rem; }
  .nav { display: none; border-top: 1px solid rgba(255,255,255,.12); max-height: calc(100vh - 60px); overflow-y: auto; }
  .nav-open .nav { display: block; }
  .nav-in { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .3rem; padding: .6rem 16px .9rem; overflow: visible; }
  .nav a { padding: .7rem .8rem; border-bottom: 0; border-radius: 10px; background: rgba(255,255,255,.06); font-size: .95rem; }
  .nav a.on { background: var(--gold); color: var(--navy); font-weight: 700; }
}
@media (max-width: 560px) {
  .brand img { width: 32px; height: 32px; }
  .brand span { font-size: .9rem; }
  .theme-btn { padding: .2rem; }
}
@media (max-width: 420px) {
  .brand span { display: none; }
  .search { flex: 1; min-width: 0; }
  .search input[type=search] { width: 100%; }
}

/* ---------- Hero ---------- */
.hero { background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 60px, transparent 60px 120px),
    linear-gradient(135deg, var(--pitch) 0%, var(--pitch-2) 100%);
  color: #fff; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -80px; top: 50%; width: 260px; height: 260px; border: 3px solid rgba(255,255,255,.15); border-radius: 50%; transform: translateY(-50%); }
.hero-in { max-width: 1200px; margin: 0 auto; padding: 1.6rem 16px 1.4rem; position: relative; z-index: 1; }
.hero h1 { margin: 0; }
.hero p { margin: .2rem 0 0; opacity: .9; }
.hero .chips { margin-top: .8rem; }

/* ---------- Layout ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 1.2rem 16px 3rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
@media (max-width: 900px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g2 { grid-template-columns: 1fr; } .span2 { grid-column: auto; } }
@media (max-width: 560px) { .g3 { grid-template-columns: 1fr; } .search input { width: 150px; } .brand small { display: none; } .ac { width: 280px; } }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; border: 1px solid var(--line); min-width: 0; }
.card + .card { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head a.more { font-size: .85rem; color: var(--pitch); font-weight: 600; }
.section { margin-top: 1.4rem; }

/* Stats */
.stat { display: flex; flex-direction: column; gap: .1rem; }
.stat .ico { font-size: 1.4rem; }
.stat b { font-family: var(--display); font-size: 2.3rem; font-weight: 400; line-height: 1; letter-spacing: .02em; }
.stat span { color: var(--muted); font-size: .85rem; }

/* Chips / tabs / pills */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .35rem .8rem; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: .88rem; font-weight: 500; }
.chip:hover { border-color: var(--pitch); color: var(--pitch); }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.hero .chip { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); color: #fff; }
.hero .chip.on { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.pill { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--card-2); border: 1px solid var(--line); }
.pill.ok { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.pill.warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.pill.bad { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.pill.info { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }

/* Tables */
.tbl-wrap { overflow-x: auto; margin: 0 -1.1rem; padding: 0 1.1rem; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: .5rem .45rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: .5rem .45rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--card-2); }
.tbl th.num, .tbl td.num { text-align: center; }
.tbl .pts { font-weight: 800; font-size: 1rem; }
.tbl .pos { width: 2rem; text-align: center; font-weight: 700; color: var(--muted); }
.tbl tr.top1 .pos { color: var(--gold); }
.tbl tr.zone-up td:first-child { box-shadow: inset 4px 0 0 var(--win); }
.tbl tr.zone-down td:first-child { box-shadow: inset 4px 0 0 var(--loss); }
.tbl tr.zone-promo td:first-child { box-shadow: inset 4px 0 0 var(--gold); }
.rank-1 td:first-child::after { content: ' 🥇'; }
.rank-2 td:first-child::after { content: ' 🥈'; }
.rank-3 td:first-child::after { content: ' 🥉'; }

.team-cell { display: inline-flex; align-items: center; gap: .55rem; font-weight: 600; min-width: 0; }
.team-cell span { white-space: nowrap; }
.crest { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 50%; object-fit: contain; }
.crest-sm { width: 26px; height: 26px; font-size: .7rem; }
.crest-md { width: 44px; height: 44px; font-size: 1rem; }
.crest-lg { width: 96px; height: 96px; font-size: 2rem; }
.crest-txt { background: hsl(var(--h) 55% 42%); color: #fff; font-weight: 800; letter-spacing: -.02em; }
.crest-empty { background: var(--card-2); }
img.crest { background: transparent; border-radius: 6px; }

.form { display: inline-flex; gap: 3px; }
.form i { width: 20px; height: 20px; border-radius: 5px; font-style: normal; font-size: .68rem; font-weight: 700; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.tbl td.form-cell { white-space: nowrap; }
.form .G { background: var(--win); } .form .E { background: var(--draw); } .form .P { background: var(--loss); }

/* Matches */
.match { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .6rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.match:last-child { border-bottom: 0; }
.match .home { justify-self: end; text-align: right; }
.match .home .team-cell { flex-direction: row-reverse; }
.match .meta { grid-column: 1 / -1; font-size: .75rem; color: var(--muted); text-align: center; margin-top: -.2rem; }
.score { font-family: var(--display); font-size: 1.5rem; background: var(--navy); color: #fff; padding: .05rem .7rem; border-radius: 8px; letter-spacing: .05em; white-space: nowrap; }
.score small { font-family: var(--font); font-size: .7rem; opacity: .85; }
.score-pending { background: var(--card-2); color: var(--muted); font-size: 1rem; padding: .25rem .7rem; border: 1px solid var(--line); }
@media (max-width: 560px) { .match .team-cell span { white-space: normal; font-size: .85rem; } }
.round-title { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.round-title h2 { font-family: var(--display); font-weight: 400; font-size: 1.6rem; letter-spacing: .03em; margin: 0; }

/* Bars (ranking inline) */
.bar { display: flex; align-items: center; gap: .5rem; }
.bar .b { height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--pitch), #3fbf7f); min-width: 4px; }
.bar.y .b { background: linear-gradient(90deg, #e6a700, var(--yellow)); }
.bar.r .b { background: linear-gradient(90deg, #b91c1c, var(--red)); }
.bar.s .b { background: linear-gradient(90deg, var(--navy), #4f5fd1); }

.chart-box { position: relative; height: 320px; }
.chart-box.tall { height: 460px; }
.chart-box.short { height: 240px; }

/* Profile */
.profile { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.profile .shirt { width: 96px; height: 96px; object-fit: contain; }
.profile h1 { margin: 0; }
.kv { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: .4rem; color: var(--muted); }
.kv b { color: var(--ink); }
.avatar { width: 96px; height: 96px; border-radius: 50%; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 2.6rem; flex: none; border: 4px solid var(--gold); }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.team-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-align: center; box-shadow: var(--shadow); transition: transform .15s; display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.team-card:hover { transform: translateY(-3px); color: var(--ink); border-color: var(--pitch); }
.team-card .imgs { display: flex; align-items: center; justify-content: center; gap: .4rem; height: 72px; }
.team-card .imgs img.shirt { height: 64px; width: auto; }
.team-card b { font-size: .95rem; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.empty .big { font-size: 2.5rem; display: block; }
.note { background: var(--gold-soft); border-left: 4px solid var(--gold); padding: .6rem .8rem; border-radius: 8px; font-size: .88rem; }

/* Zonas de la tabla (qué se juega cada puesto) */
.tbl-zones { --z-champ: #eab308; --z-final: #8b5cf6; --z-up: #3b82f6; --z-promo: #22c55e; --z-down: #f97316; --z-baja: #94a3b8; }
.zones-legend { --z-champ: #eab308; --z-final: #8b5cf6; --z-up: #3b82f6; --z-promo: #22c55e; --z-down: #f97316; --z-baja: #94a3b8; }
.tbl-zones tr[class*="z-"] td { background: color-mix(in srgb, var(--zc) 13%, transparent); }
.tbl-zones tbody tr[class*="z-"]:hover td { background: color-mix(in srgb, var(--zc) 22%, transparent); }
.tbl-zones tr[class*="z-"] td:first-child { box-shadow: inset 4px 0 0 var(--zc); }
.tbl-zones tr[class*="z-"] .pos span { display: inline-flex; align-items: center; justify-content: center; min-width: 1.6rem; height: 1.6rem; border-radius: 6px; background: var(--zc); color: #fff; }
.tbl-zones tr.z-champ .pos span { color: #3b2f00; }
.tbl-zones tr.z-baja td { opacity: .75; }
.tbl-zones tr.z-baja td:first-child, .tbl-zones tr.z-baja .pos span { opacity: 1; }
.z-champ { --zc: var(--z-champ); } .z-final { --zc: var(--z-final); } .z-up { --zc: var(--z-up); }
.z-promo { --zc: var(--z-promo); } .z-down { --zc: var(--z-down); } .z-baja { --zc: var(--z-baja); }
.zones-legend { display: flex; gap: .45rem .9rem; flex-wrap: wrap; font-size: .82rem; color: var(--ink); margin-top: .8rem; padding-top: .7rem; border-top: 1px dashed var(--line); }
.zones-legend .zl { display: inline-flex; align-items: center; gap: .4rem; }
.zones-legend .zl i { width: 14px; height: 14px; border-radius: 4px; background: var(--zc); flex: none; }
.zones-legend .zl b { font-weight: 700; }
.zl-champ { --zc: var(--z-champ); } .zl-final { --zc: var(--z-final); } .zl-up { --zc: var(--z-up); }
.zl-promo { --zc: var(--z-promo); } .zl-down { --zc: var(--z-down); } .zl-baja { --zc: var(--z-baja); }

/* Peso de la tipografía de títulos (depende de la fuente elegida) */
h1, .stat b, .score, .round-title h2 { font-weight: var(--display-weight); }

/* Canchas */
.venues { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.venue { display: flex; flex-direction: column; gap: .7rem; }
.venue .card-head { margin-bottom: 0; }
.venue-addr { margin: 0; font-weight: 600; }
.map-box { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--card-2); }
.map-box iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.venue-go { align-self: flex-start; }
.match .meta a.venue-link { color: inherit; text-decoration: underline dotted; text-underline-offset: 2px; }
.match .meta a.venue-link:hover { color: var(--pitch); }

.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: .6rem; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.legend .l-up::before { background: var(--win); } .legend .l-down::before { background: var(--loss); } .legend .l-promo::before { background: var(--gold); }

.footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 2rem 16px; border-top: 1px solid var(--line); }
.footer a { color: var(--pitch); }

/* ---------- Forms (admin) ---------- */
.btn { display: inline-flex; align-items: center; gap: .35rem; border: 0; border-radius: 10px; padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer; background: var(--pitch); color: #fff; font-size: .9rem; }
.btn:hover { background: var(--pitch-2); color: #fff; }
.btn.sec { background: var(--card-2); color: var(--ink); border: 1px solid var(--line); }
.btn.sec:hover { border-color: var(--pitch); color: var(--pitch); }
.btn.navy { background: var(--navy); }
.btn.danger { background: var(--red); }
.btn.sm { padding: .3rem .6rem; font-size: .8rem; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label.f { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=time], select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; width: 100%; font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pitch); border-color: transparent; }
input[type=number].n { width: 4.5rem; text-align: center; }
.row-form { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.flash.ok { background: #dcfce7; color: #166534; }
.flash.error { background: #fee2e2; color: #991b1b; }
.flash.warn { background: #fef3c7; color: #92400e; }
.inline { display: inline; }
details > summary { cursor: pointer; font-weight: 600; }
.admin-bar { background: var(--gold); color: var(--navy); font-size: .85rem; font-weight: 600; }
.admin-bar .wrap { padding: .35rem 16px; display: flex; gap: 1rem; align-items: center; justify-content: space-between; }
.thumb { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; background: var(--card-2); }
.login-box { max-width: 380px; margin: 3rem auto; }
.ev-list { list-style: none; padding: 0; margin: 0; }
.ev-list li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem 0; border-bottom: 1px dashed var(--line); }
