/* =============================================================
   1. Tokens
   ============================================================= */
:root {
  --primario: #12813f;
  --secundario: #0b3d22;
  --acento: #f2c744;
  --claro: #f3faf5;
  --texto: #0d1b12;

  --bg: #ffffff;
  --bg-alt: #f6f8f7;
  --borde: #e2e8e4;
  --texto-suave: #5b6b61;
  --blanco: #ffffff;
  --peligro: #c1121f;
  --exito: #12813f;

  --radio: 14px;
  --radio-sm: 8px;
  --sombra: 0 10px 30px -12px rgba(10, 30, 20, .18);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Manrope", var(--sans);
}

body[data-plantilla="moderno-profesional"] {
  --primario: #0b2545; --secundario: #134074; --acento: #4cc9f0; --claro: #eef5fc; --texto: #0a1524;
}
body[data-plantilla="escolar-comunitario"] {
  --primario: #e8590c; --secundario: #6a4c93; --acento: #ffd23f; --claro: #fff8ec; --texto: #241528;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1512; --bg-alt: #131b17; --borde: #23302a; --texto: #eef4f0; --texto-suave: #9fb3a8; --blanco: #17201b;
  }
}

/* =============================================================
   2. Reset & base
   ============================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; tab-size: 2; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--sans);
  font-size: 16px; line-height: 1.55;
  color: var(--texto); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font: inherit; color: inherit; min-width: 0; }
h1, h2, h3, h4 { font-family: var(--display); text-wrap: balance; line-height: 1.15; letter-spacing: -0.01em; color: var(--texto); }
p { text-wrap: pretty; }
::selection { background: var(--acento); color: var(--texto); }
:focus-visible { outline: 2px solid var(--primario); outline-offset: 3px; border-radius: 4px; }

.container { max-width: 1080px; margin-inline: auto; padding-inline: 1.1rem; }

.skip-link {
  position: fixed; top: -100px; left: 1rem; padding: .6rem 1rem;
  background: var(--primario); color: #fff; z-index: 9999; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

/* =============================================================
   3. Header / Footer
   ============================================================= */
.site-header { position: sticky; top: 0; z-index: 40; background: var(--bg); border-bottom: 1px solid var(--borde); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding-block: .8rem; }
.brand { display: flex; align-items: center; gap: .5rem; font-family: var(--display); font-weight: 800; font-size: 1.15rem; color: var(--primario); }
.header-nav { display: flex; align-items: center; gap: 1.1rem; font-size: .92rem; font-weight: 600; }
.header-nav a { color: var(--texto-suave); }
.header-nav a:hover { color: var(--primario); }

.site-footer { border-top: 1px solid var(--borde); background: var(--bg-alt); margin-top: 3rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: .8rem 1.4rem; align-items: center; justify-content: space-between; padding-block: 1.6rem; font-size: .88rem; color: var(--texto-suave); }
.footer-inner nav { display: flex; gap: 1.2rem; }
.footer-inner a:hover { color: var(--primario); }

/* =============================================================
   4. Hero + pasos
   ============================================================= */
.hero { padding-block: 1.6rem 2.4rem; }
.hero h1 { font-size: clamp(1.7rem, 4.4vw, 2.6rem); max-width: 22ch; }
.hero-sub { margin-top: .6rem; color: var(--texto-suave); max-width: 60ch; font-size: 1.02rem; }

.steps-nav { display: flex; flex-wrap: wrap; gap: .5rem; margin-block: 1.3rem; }
.step-pill {
  padding: .5rem .9rem; border-radius: 999px; background: var(--bg-alt); border: 1px solid var(--borde);
  font-size: .85rem; font-weight: 700; color: var(--texto-suave); transition: all .2s var(--ease-out);
}
.step-pill.is-active { background: var(--primario); color: #fff; border-color: var(--primario); }
.step-pill.is-disabled { opacity: .45; cursor: not-allowed; }

/* =============================================================
   5. Tool card + steps
   ============================================================= */
.tool-card {
  background: var(--bg); border: 1px solid var(--borde); border-radius: var(--radio);
  box-shadow: var(--sombra); padding: clamp(1.1rem, 3vw, 2rem);
}
.step-panel { display: none; }
.step-panel.is-active { display: block; animation: fadeIn .25s var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.step-title { display: flex; align-items: center; gap: .6rem; font-size: 1.35rem; margin-bottom: 1.2rem; }
.step-title .ic { width: 24px; height: 24px; color: var(--primario); flex-shrink: 0; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.field { display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; font-weight: 600; color: var(--texto-suave); }
.field input[type="text"], .field input[type="date"], .field input[type="number"], .field input[type="file"],
.field input[type="time"], .field select, .field textarea {
  font-weight: 500; color: var(--texto); background: var(--bg-alt); border: 1.5px solid var(--borde);
  border-radius: var(--radio-sm); padding: .6rem .75rem; font-size: .95rem; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primario); background: var(--bg); }
.field.checkbox { flex-direction: row; align-items: center; gap: .55rem; }
.field.checkbox input { width: 18px; height: 18px; accent-color: var(--primario); }

.color-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.color-swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--bg); box-shadow: 0 0 0 2px var(--borde); transition: transform .15s var(--ease-out); }
.color-swatch:hover { transform: scale(1.1); }

.step-actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px dashed var(--borde); }
.hint { font-size: .82rem; color: var(--texto-suave); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .68rem 1.15rem; border-radius: 999px; font-weight: 700; font-size: .92rem; transition: all .18s var(--ease-out); white-space: nowrap; }
.btn-primary { background: var(--primario); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1.5px solid var(--primario); color: var(--primario); }
.btn-outline:hover { background: var(--claro); }
.btn-ghost { background: transparent; color: var(--texto-suave); }
.btn-ghost:hover { color: var(--texto); }
.btn-sm { padding: .5rem .85rem; font-size: .85rem; }
.btn-xs { padding: .3rem .6rem; font-size: .78rem; border-radius: 999px; background: var(--bg-alt); border: 1px solid var(--borde); }
.btn-lg { padding: .9rem 1.5rem; font-size: 1rem; }
.link-btn { text-decoration: underline; color: inherit; font: inherit; }

/* =============================================================
   6. Equipos
   ============================================================= */
.equipos-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; }
.pegar-lista { background: var(--bg-alt); border: 1px dashed var(--borde); border-radius: var(--radio-sm); padding: 1rem; margin-bottom: 1rem; display: grid; gap: .7rem; }
.pegar-lista textarea { font-family: monospace; }

.equipo-form { display: grid; grid-template-columns: 2fr 2fr auto auto; gap: .6rem; margin-bottom: 1rem; align-items: center; }
.equipo-form input[type="text"] { background: var(--bg-alt); border: 1.5px solid var(--borde); border-radius: var(--radio-sm); padding: .6rem .75rem; }
.equipo-form input[type="color"] { width: 44px; height: 40px; border: 1.5px solid var(--borde); border-radius: var(--radio-sm); padding: 2px; }

.equipos-count { font-size: .88rem; color: var(--texto-suave); margin-bottom: .6rem; }
.error-msg { color: var(--peligro); font-weight: 600; }

.equipos-list { list-style: none; display: grid; gap: .5rem; max-height: 360px; overflow-y: auto; padding-right: .2rem; }
.equipo-item { display: flex; align-items: center; gap: .6rem; background: var(--bg-alt); border: 1px solid var(--borde); border-radius: var(--radio-sm); padding: .55rem .7rem; }
.equipo-color { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.equipo-nombre { font-weight: 700; flex: 1; }
.equipo-edit-input { flex: 1; background: var(--bg); border: 1px solid var(--primario); border-radius: 6px; padding: .3rem .5rem; }
.equipo-delegado { font-size: .82rem; color: var(--texto-suave); }
.equipo-edit, .equipo-del { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.equipo-del { color: var(--peligro); font-size: 1.1rem; }
.equipo-edit:hover, .equipo-del:hover { background: var(--borde); }

/* =============================================================
   7. Formato
   ============================================================= */
.formato-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.formato-card { text-align: left; background: var(--bg-alt); border: 2px solid var(--borde); border-radius: var(--radio-sm); padding: 1rem; display: grid; gap: .35rem; transition: all .18s var(--ease-out); }
.formato-card strong { font-size: 1rem; }
.formato-card span { font-size: .85rem; color: var(--texto-suave); }
.formato-card:hover { border-color: var(--primario); }
.formato-card.is-selected { border-color: var(--primario); background: var(--claro); }
.formato-opciones { background: var(--bg-alt); border-radius: var(--radio-sm); padding: 1rem; margin-bottom: 1rem; }

/* =============================================================
   8. Fixture: tabs, filtros, partidos
   ============================================================= */
.fixture-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid var(--borde); padding-bottom: .8rem; }
.tab { padding: .5rem 1rem; border-radius: 999px; font-weight: 700; font-size: .88rem; color: var(--texto-suave); }
.tab.is-active { background: var(--primario); color: #fff; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.fixture-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; align-items: center; }
.fixture-toolbar select { background: var(--bg-alt); border: 1.5px solid var(--borde); border-radius: var(--radio-sm); padding: .5rem .7rem; }

.fecha-grupo { margin-bottom: 1.3rem; }
.fecha-grupo h4 { font-size: .95rem; color: var(--primario); margin-bottom: .6rem; text-transform: capitalize; }

.partido-card { background: var(--bg-alt); border: 1px solid var(--borde); border-radius: var(--radio-sm); padding: .8rem; margin-bottom: .6rem; display: grid; gap: .55rem; }
.partido-card[data-estado="jugado"] { border-left: 4px solid var(--exito); }
.partido-card[data-estado="suspendido"] { border-left: 4px solid var(--peligro); }
.partido-card[data-estado="reprogramado"] { border-left: 4px solid var(--acento); }

.partido-top { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.partido-top select { flex: 1; min-width: 120px; background: var(--bg); border: 1.5px solid var(--borde); border-radius: var(--radio-sm); padding: .45rem .6rem; font-weight: 700; }
.vs { font-size: .78rem; color: var(--texto-suave); font-weight: 700; }
.icon-btn { width: 28px; height: 28px; border-radius: 50%; background: var(--bg); border: 1px solid var(--borde); display: grid; place-items: center; flex-shrink: 0; }
.icon-btn:hover { background: var(--borde); }

.partido-meta { display: flex; flex-wrap: wrap; gap: .5rem; }
.partido-meta input, .partido-meta select { background: var(--bg); border: 1.5px solid var(--borde); border-radius: var(--radio-sm); padding: .4rem .55rem; font-size: .85rem; flex: 1; min-width: 110px; }

.partido-resultado { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.marcador { width: 64px; text-align: center; background: var(--bg); border: 1.5px solid var(--borde); border-radius: var(--radio-sm); padding: .4rem; font-weight: 800; }
.guion { font-weight: 700; color: var(--texto-suave); }
.penales-select { background: var(--bg); border: 1.5px solid var(--acento); border-radius: var(--radio-sm); padding: .35rem .5rem; font-size: .82rem; }
.sets-editor { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.set-row { display: inline-flex; gap: .2rem; }
.set-row input { width: 46px; text-align: center; background: var(--bg); border: 1.5px solid var(--borde); border-radius: 6px; padding: .3rem; }
.obs { background: var(--bg); border: 1px solid var(--borde); border-radius: var(--radio-sm); padding: .4rem .6rem; font-size: .82rem; width: 100%; }
.vacio { color: var(--texto-suave); font-style: italic; padding: 1rem 0; }

/* =============================================================
   9. Grupos / tabla de posiciones
   ============================================================= */
.grupos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.1rem; }
.grupo-card { background: var(--bg-alt); border: 1px solid var(--borde); border-radius: var(--radio-sm); padding: 1rem; overflow-x: auto; }
.grupo-card h4 { color: var(--primario); margin-bottom: .7rem; }
.tabla-posiciones { width: 100%; border-collapse: collapse; font-size: .82rem; }
.tabla-posiciones th { background: var(--secundario); color: #fff; padding: .5rem .4rem; text-align: center; }
.tabla-posiciones th:nth-child(2) { text-align: left; }
.tabla-posiciones td { padding: .45rem .4rem; text-align: center; border-bottom: 1px solid var(--borde); }
.tabla-posiciones td.eq-nombre { text-align: left; font-weight: 700; }
.tabla-posiciones tr.fila-clasifica { background: color-mix(in srgb, var(--primario) 12%, transparent); }
.clasifica-nota { margin-top: .6rem; font-size: .78rem; color: var(--texto-suave); }

/* =============================================================
   10. Llave de eliminación
   ============================================================= */
.llave-rondas { display: flex; gap: 1.4rem; overflow-x: auto; padding-bottom: .6rem; }
.llave-ronda { min-width: 220px; display: flex; flex-direction: column; gap: 1.6rem; justify-content: space-around; }
.llave-ronda h4 { font-size: .85rem; text-align: center; color: var(--primario); margin-bottom: .4rem; }
.llave-partido { background: var(--bg-alt); border: 1px solid var(--borde); border-radius: var(--radio-sm); padding: .6rem; display: grid; gap: .3rem; }
.llave-equipo { display: flex; align-items: center; justify-content: space-between; gap: .4rem; font-size: .85rem; font-weight: 600; padding: .25rem .35rem; border-radius: 6px; }
.llave-equipo.es-ganador { background: color-mix(in srgb, var(--primario) 15%, transparent); font-weight: 800; }
.llave-marcador { width: 40px; text-align: center; background: var(--bg); border: 1.5px solid var(--borde); border-radius: 6px; padding: .2rem; }
.llave-penales { margin-top: .3rem; font-size: .75rem; background: var(--bg); border: 1px solid var(--acento); border-radius: 6px; padding: .25rem; }
.bye-nota { font-size: .72rem; color: var(--texto-suave); font-style: italic; }
.llave-tercer { margin-top: 1.6rem; max-width: 260px; }
.llave-tercer h4 { font-size: .85rem; color: var(--acento); margin-bottom: .5rem; }

/* =============================================================
   11. Plantillas / vista previa / descargas
   ============================================================= */
.plantillas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.4rem; }
.plantilla-card { border: 2px solid var(--borde); border-radius: var(--radio-sm); padding: .8rem; display: grid; gap: .5rem; text-align: center; background: var(--bg-alt); }
.plantilla-card.is-active { border-color: var(--primario); }
.plantilla-swatch { display: block; height: 46px; border-radius: 8px; }
.plantilla-nombre { font-size: .82rem; font-weight: 700; }
.plantilla-check { font-size: .74rem; color: var(--exito); font-weight: 700; }
.plantilla-lock { font-size: .74rem; color: var(--texto-suave); }
.plantilla-card.is-premium { opacity: .8; }

.preview-frame { border: 1px dashed var(--borde); border-radius: var(--radio-sm); padding: 1.2rem; margin-bottom: 1.4rem; background: var(--bg-alt); }
.preview-header { display: flex; align-items: center; gap: 1rem; }
.preview-header img { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: #fff; }
.preview-header h3 { font-size: 1.2rem; color: var(--primario); }
.preview-header p { color: var(--texto-suave); font-size: .88rem; }
.preview-nota { margin-top: .8rem; font-size: .8rem; color: var(--texto-suave); }

.descargas-botones { display: flex; flex-wrap: wrap; gap: .8rem; margin-bottom: .8rem; }
.descargas-secundarias { justify-content: space-between; }

/* =============================================================
   12. Ads (placeholders)
   ============================================================= */
.ad-slot { display: grid; place-items: center; min-height: 90px; border: 1.5px dashed var(--borde); border-radius: var(--radio-sm); color: var(--texto-suave); font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-block: 1.2rem; background: var(--bg-alt); }
.ad-banner { min-height: 90px; }
.ad-inline { min-height: 120px; }
.ad-corner { position: fixed; bottom: 14px; right: 14px; width: 160px; min-height: 60px; z-index: 30; background: var(--bg); box-shadow: var(--sombra); margin: 0; }
.ad-corner-close { position: absolute; top: 2px; right: 6px; font-size: 1rem; color: var(--texto-suave); }
.dialog-ad-label { text-align: center; font-size: .74rem; color: var(--texto-suave); margin-bottom: .4rem; text-transform: uppercase; letter-spacing: .08em; }
.ad-popup { min-height: 200px; width: min(320px, 80vw); }

/* =============================================================
   13. Dialog (popup al descargar)
   ============================================================= */
dialog[data-dialog-descarga] { border: none; border-radius: var(--radio); padding: 0; box-shadow: var(--sombra); }
dialog[data-dialog-descarga]::backdrop { background: rgba(10, 20, 15, .5); }
.dialog-inner { position: relative; padding: 1.6rem; display: grid; gap: 1rem; place-items: center; }
.dialog-close { position: absolute; top: .6rem; right: .8rem; font-size: 1.3rem; color: var(--texto-suave); }

/* =============================================================
   14. Toast
   ============================================================= */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--texto); color: #fff; padding: .8rem 1.2rem; border-radius: 999px;
  font-size: .88rem; font-weight: 600; opacity: 0; pointer-events: none; transition: all .28s var(--ease-out);
  z-index: 200; max-width: min(90vw, 420px); text-align: center; box-shadow: var(--sombra);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* =============================================================
   15. Secciones inferiores (cómo funciona, SEO, más herramientas, FAQ)
   ============================================================= */
.privacy-badge { margin-top: 1.2rem; text-align: center; font-size: .85rem; color: var(--texto-suave); }

.section-como, .section-seo, .section-mas, .section-faq { padding-block: 2.4rem; }
.section-como h2, .section-seo h2, .section-mas h2, .section-faq h2 { font-size: 1.5rem; margin-bottom: 1.3rem; }
.pasos-list { list-style: none; display: grid; gap: 1rem; counter-reset: paso; }
.pasos-list li { display: flex; gap: 1rem; align-items: flex-start; }
.paso-num { flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--primario); color: #fff; display: grid; place-items: center; font-weight: 800; }
.pasos-list strong { display: block; margin-bottom: .2rem; }
.pasos-list p { color: var(--texto-suave); font-size: .92rem; }

.section-seo p { color: var(--texto-suave); margin-bottom: 1rem; max-width: 76ch; }
.section-seo h3 { font-size: 1.15rem; margin-top: 1.4rem; margin-bottom: .6rem; }

.mas-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.mas-card { background: var(--bg-alt); border: 1px solid var(--borde); border-radius: var(--radio-sm); padding: 1rem; }
.mas-card strong { display: block; margin-bottom: .3rem; color: var(--primario); }
.mas-card p { font-size: .86rem; color: var(--texto-suave); }

[data-faq-list] details { background: var(--bg-alt); border: 1px solid var(--borde); border-radius: var(--radio-sm); padding: .9rem 1rem; margin-bottom: .6rem; }
[data-faq-list] summary { font-weight: 700; cursor: pointer; }
[data-faq-list] p { margin-top: .5rem; color: var(--texto-suave); font-size: .92rem; }

/* =============================================================
   16. Responsive (mobile-first)
   ============================================================= */
@media (max-width: 539px) {
  .equipo-form { grid-template-columns: 1fr 1fr; }
  .equipo-form button { grid-column: 1 / -1; }
  .descargas-botones { flex-direction: column; }
  .descargas-botones .btn { width: 100%; justify-content: center; }
  .ad-corner { width: 120px; }
  .header-nav a { display: none; }
  .header-nav { gap: .5rem; }
  .brand span { font-size: 1rem; }
  .header-nav .btn-sm { padding: .45rem .7rem; font-size: .78rem; }
}
@media (min-width: 720px) {
  .hero { padding-block: 2.2rem 3rem; }
}
@media (min-width: 960px) {
  .form-grid { grid-template-columns: repeat(3, 1fr); }
}

/* =============================================================
   17. Impresión — muestra el fixture completo, oculta controles
   ============================================================= */
@media print {
  .site-header, .site-footer, .steps-nav, .step-actions, .equipos-toolbar, .equipo-form,
  .formato-cards, .formato-opciones, .fixture-tabs, .fixture-toolbar, .ad-slot, .ad-corner,
  .descargas-botones, .plantillas-grid, .privacy-badge, .icon-btn, [data-mover], [data-eliminar-partido],
  .section-como, .section-seo, .section-mas, .section-faq, .skip-link, dialog { display: none !important; }
  .step-panel { display: none !important; }
  .step-panel[data-step="fixture"] { display: block !important; }
  .tab-panel { display: block !important; margin-bottom: 1.5rem; }
  .tool-card { box-shadow: none; border: none; padding: 0; }
  body { background: #fff; }
  .partido-card { break-inside: avoid; border: 1px solid #ccc; }
  .grupo-card, .llave-ronda { break-inside: avoid; }
}

/* Estado listo (evita FOUC de animaciones) */
html:not(.is-ready) .step-panel.is-active { opacity: 1; }
