/* ═══════════════════════════════════════════════════════════════════
   web/css/quiniela.css  —  Mobile-First + Responsive completo  v3
   Breakpoints: 360 · 480 · 600 · 768 · 1024 · 1280 · 1440
   Orientaciones: portrait · landscape
   Media: screen · print
   Autor: SIRSG78
═══════════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
    --color-bg:        #faf6f0;
    --color-frame:     #f0e8dc;
    --color-accent:    #c05a42;
    --color-text:      #2c2318;
    --color-highlight: #e8d8c8;
    --color-success:   #5a7f6a;
    --color-warning:   #b07030;
    --color-error:     #b83228;
    --card-bg:         #fff8f2;
    --shadow:          0 2px 8px rgba(44,35,24,.08);
    --shadow-md:       0 4px 16px rgba(44,35,24,.12);
    --radius:          8px;
    --radius-sm:       5px;
    --transition:      all 0.2s ease;

    /* Layout tokens — se sobreescriben por breakpoint */
    --header-h:        56px;
    --content-pad:     12px;
    --table-fs:        0.82rem;
    --nav-gap:         4px;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; scroll-behavior:smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Utilidades ─────────────────────────────────────────────────── */
.hidden  { display:none !important; }
.screen  { display:none; min-height:100vh; }
.screen.active { display:flex; flex-direction:column; }

/* ═══════════════════════════════════════════════════════════════════
   AUTH SCREEN
═══════════════════════════════════════════════════════════════════ */
#auth-screen {
    justify-content: center;
    align-items: center;
    padding: var(--content-pad);
    background: linear-gradient(135deg, var(--color-frame) 0%, var(--color-bg) 100%);
}

.auth-container {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.auth-container h1 {
    color: var(--color-accent);
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    line-height: 1.3;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--color-frame);
}

.tab-btn {
    flex: 1;
    padding: 0.65rem;
    background: none;
    border: none;
    color: var(--color-accent);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    touch-action: manipulation;
}

.tab-btn.active {
    color: var(--color-text);
    border-bottom: 2px solid var(--color-success);
    margin-bottom: -2px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.auth-form input {
    padding: 0.875rem;
    border: 2px solid var(--color-frame);
    border-radius: var(--radius);
    font-size: 1rem;          /* ≥16px → evita zoom en iOS */
    transition: var(--transition);
    width: 100%;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.auth-form button {
    padding: 1rem;
    background: var(--color-success);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;          /* tap target mínimo */
    transition: var(--transition);
    touch-action: manipulation;
}

.auth-form button:hover  { background: #4a6b5a; transform:translateY(-1px); }
.auth-form button:active { transform:translateY(0); }

.recover-link {
    color: var(--color-accent);
    font-size: 0.875rem;
    text-decoration: none;
    padding: 8px 0;
    display: inline-block;
}

/* ═══════════════════════════════════════════════════════════════════
   APP HEADER  — mobile base
═══════════════════════════════════════════════════════════════════ */
.app-header {
    background: white;
    padding: 0 var(--content-pad);
    height: auto;
    min-height: var(--header-h);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 200;

    display: grid;
    grid-template-rows: auto auto;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "logo  usermenu"
        "nav   nav";
    align-items: center;
    gap: 0;
}

.app-header h1 {
    grid-area: logo;
    font-size: 1rem;
    color: var(--color-accent);
    padding: 10px 0 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu {
    grid-area: usermenu;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    padding: 10px 0 4px;
    white-space: nowrap;
}

#user-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

#logout-btn {
    padding: 5px 10px;
    background: var(--color-frame);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-text);
    font-size: 0.8rem;
    min-height: 34px;
    touch-action: manipulation;
}

/* Nav — scroll horizontal en móvil */
.main-nav {
    grid-area: nav;
    display: flex;
    gap: var(--nav-gap);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 0 8px;
    border-top: 1px solid var(--color-frame);
}

.main-nav::-webkit-scrollbar { display:none; }

.nav-btn {
    padding: 6px 12px;
    background: none;
    border: none;
    color: var(--color-accent);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 34px;
    transition: var(--transition);
    touch-action: manipulation;
}

.nav-btn:hover, .nav-btn.active {
    background: var(--color-frame);
    color: var(--color-text);
}

/* ═══════════════════════════════════════════════════════════════════
   MAIN CONTENT
═══════════════════════════════════════════════════════════════════ */
.app-content {
    flex: 1;
    padding: var(--content-pad);
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.view       { display:none; }
.view.active { display:block; }

/* View header — stack en móvil */
.view-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-frame);
}

.view-header h2 {
    color: var(--color-text);
    font-size: 1.15rem;
    flex: 1 1 100%;
}

.view-header select,
.view-header button {
    font-size: 0.85rem;
    min-height: 36px;
}

/* ═══════════════════════════════════════════════════════════════════
   QUINIELA TABLE — mobile: scroll horizontal + fuente mínima
═══════════════════════════════════════════════════════════════════ */
.matches-table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.matches-table {
    width: 100%;
    min-width: 420px;               /* fuerza scroll antes de romper */
    border-collapse: collapse;
    font-size: var(--table-fs);
}

.matches-table th {
    background: var(--color-accent);
    color: white;
    padding: 0.6rem 0.5rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.matches-table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--color-frame);
    vertical-align: middle;
}

.matches-table tr:hover { background: var(--color-bg); }

.matches-table .prob-bar {
    display: inline-block;
    width: 30px; height: 4px;
    background: var(--color-frame);
    border-radius: 2px;
    margin-left: 4px;
    overflow: hidden;
}

.matches-table .prob-bar span {
    display: block; height:100%;
    background: var(--color-success);
    border-radius: 2px;
}

.matches-table .prediction    { font-weight:700; color:var(--color-success); }
.matches-table .confidence-high   { color:var(--color-success); }
.matches-table .confidence-medium { color:var(--color-warning); }
.matches-table .confidence-low    { color:var(--color-error); }

/* ═══════════════════════════════════════════════════════════════════
   PLENO 15
═══════════════════════════════════════════════════════════════════ */
.pleno-section {
    margin-top: 1.25rem;
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.pleno-section h3 {
    color: var(--color-accent);
    margin-bottom: 0.875rem;
    font-size: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════
   BOTONES GLOBALES
═══════════════════════════════════════════════════════════════════ */
.btn-primary, .btn-secondary {
    min-height: 40px;
    padding: 8px 14px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
    font-size: 0.875rem;
    border: none;
}

.btn-primary {
    background: var(--color-success);
    color: white;
}
.btn-primary:hover  { background:#4a6b5a; transform:translateY(-1px); }
.btn-primary:active { transform:translateY(0); }

.btn-secondary {
    background: var(--color-frame);
    color: var(--color-text);
}
.btn-secondary:hover  { background:var(--color-highlight); }

/* ═══════════════════════════════════════════════════════════════════
   PREDICTOR H2H
═══════════════════════════════════════════════════════════════════ */
.predictor-form {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.team-selector label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-accent);
}

.team-selector select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--color-frame);
    border-radius: var(--radius);
    font-size: 1rem;             /* evita zoom iOS */
    min-height: 44px;
}

.vs-divider {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-accent);
    text-align: center;
}

.prediction-result {
    background: white;
    padding: 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ═══════════════════════════════════════════════════════════════════
   FACTORES
═══════════════════════════════════════════════════════════════════ */
.factors-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.factors-sidebar {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.factors-sidebar h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: var(--color-accent);
}

.factors-sidebar ul {
    list-style: none;
    margin-bottom: 0.75rem;
    max-height: 200px;
    overflow-y: auto;
}

.factors-sidebar ul li {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
}

.factors-sidebar ul li:hover { background: var(--color-frame); }

.factors-editor {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.factors-editor h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: var(--color-accent);
}

/* ═══════════════════════════════════════════════════════════════════
   SIMULACIÓN
═══════════════════════════════════════════════════════════════════ */
.sim-config {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 1rem;
}

.sim-config label {
    font-size: 0.875rem;
    color: var(--color-accent);
    font-weight: 600;
}

.sim-config select,
.sim-config input[type="number"] {
    padding: 6px 10px;
    border: 2px solid var(--color-frame);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    min-height: 38px;
    width: 64px;
}

.sim-config select { width: auto; }

.sim-results {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

/* ═══════════════════════════════════════════════════════════════════
   ESTADÍSTICAS
═══════════════════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
}

.stat-card h4 {
    font-size: 0.8rem;
    color: var(--color-accent);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-success);
}

#stats-chart {
    width: 100% !important;
    height: auto !important;
    max-height: 300px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
}

/* ═══════════════════════════════════════════════════════════════════
   PREMIOS
═══════════════════════════════════════════════════════════════════ */
.prizes-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
}

.prizes-header h2 {
    flex: 1;
    font-size: 1.15rem;
}

.prizes-results {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

/* ═══════════════════════════════════════════════════════════════════
   COMBINACIONES
═══════════════════════════════════════════════════════════════════ */
#view-combinations > div:first-child {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

#view-combinations h2 {
    margin: 0;
    font-size: 1.1rem;
    flex: 1 1 100%;
}

#comb-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
}

#comb-controls label {
    font-size: 0.85rem;
    color: #9ca3af;
    white-space: nowrap;
}

#comb-max-boletos {
    background: #fff8f0;
    border: 1px solid var(--color-frame);
    color: var(--color-accent);
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 0.875rem;
    min-height: 36px;
}

#comb-matches {
    background: #fff8f0;
    border: 1px solid var(--color-frame);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 14px;
    overflow-x: auto;
    font-size: 0.85rem;
}

#comb-results {
    overflow-x: auto;
}

/* ═══════════════════════════════════════════════════════════════════
   INTERNACIONAL
═══════════════════════════════════════════════════════════════════ */
.matches-grid { padding: 8px 0; }

.int-matches-list { display:flex; flex-direction:column; gap:6px; padding:8px 0; }

.int-match-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 8px;
    background: #fff8f2;
    border: 1px solid var(--color-frame);
    border-radius: 8px;
    padding: 8px 10px;
    min-width: 0;
}

.int-teams { display:flex; align-items:center; gap:6px; font-size:.88em; min-width:0; }
.int-home  { text-align:right; flex:1; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--color-text); }
.int-away  { text-align:left;  flex:1; font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--color-text); }
.int-vs    { color:var(--color-accent); font-size:.75em; flex-shrink:0; opacity:.6; }
.elo-tag   { color:var(--color-warning); font-size:.72em; }

.int-probs { display:flex; gap:6px; }
.int-prob-bar {
    display:flex; flex-direction:column; align-items:center;
    width:38px; gap:3px;
}
.int-fill { height:4px; border-radius:2px; min-width:2px; }
.int-fill-1 { background:#4a7ec8; }
.int-fill-x { background:var(--color-warning); }
.int-fill-2 { background:var(--color-accent); }
.int-prob-label { font-size:.68em; color:var(--color-warning); white-space:nowrap; }

.int-pred {
    display:flex; flex-direction:column;
    align-items:center; gap:4px; min-width:50px;
}
.int-conf { font-size:.78em; color:var(--color-text); }
.score-result { font-size:.78em; font-weight:700; color:var(--color-success); }

/* ── Internacional: select de competición ── */
#comp-select, #jornada-select {
    width: 100%;
    padding: 6px 8px;
    border: 2px solid var(--color-frame);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    min-height: 38px;
    background: white;
}

/* ═══════════════════════════════════════════════════════════════════
   PREDICTOR — barras de probabilidad
═══════════════════════════════════════════════════════════════════ */
.prob-row { display:flex; align-items:center; gap:10px; margin:6px 0; }
.prob-label { width:80px; font-size:.875em; color:var(--color-warning); flex-shrink:0; }
.prob-bar-large { flex:1; height:8px; background:var(--color-frame); border-radius:4px; overflow:hidden; }
.prob-fill { height:100%; background:linear-gradient(90deg,var(--color-accent),var(--color-warning)); border-radius:4px; }
.prob-val { width:40px; text-align:right; font-size:.875em; font-weight:600; color:var(--color-text); }
.pred-section { margin-top:12px; padding-top:12px; border-top:1px solid var(--color-frame); }
.pred-section h4 { margin:0 0 8px; color:var(--color-warning); font-size:.875em; text-transform:uppercase; letter-spacing:.05em; }

/* ═══════════════════════════════════════════════════════════════════
   BADGES / CHIPS
═══════════════════════════════════════════════════════════════════ */
.conf-high  { color:var(--color-success); font-weight:bold; }
.conf-med   { color:var(--color-warning); }
.conf-low   { color:var(--color-error); }

.pred-badge {
    display:inline-flex; align-items:center; justify-content:center;
    width:26px; height:26px; border-radius:50%;
    font-weight:700; font-size:.85em; color:#fff;
}
.pred-1 { background:#3b82f6; }
.pred-x { background:#f59e0b; }
.pred-2 { background:#ef4444; }

.status-played  { background:#22c55e; color:#16a34a; padding:2px 6px; border-radius:4px; font-size:.82em; font-weight:600; }
.status-pending { color:#9ca3af; }

/* ═══════════════════════════════════════════════════════════════════
   PLENO15
═══════════════════════════════════════════════════════════════════ */
.pleno15-card {
    background: var(--card-bg);
    border: 1px solid var(--color-frame);
    border-radius: 10px;
    padding: 14px;
    margin-top: 14px;
    text-align: center;
}
.pleno15-card h3 { margin:0 0 8px; font-size:.95em; color:var(--color-text); }
.pleno15-teams {
    display:flex; gap:10px; justify-content:center;
    align-items:center; font-size:1em; font-weight:600; margin-bottom:8px;
    flex-wrap: wrap; color:var(--color-text);
}
.pleno15-pred {
    display:flex; gap:10px; justify-content:center;
    align-items:center; margin-bottom:8px; flex-wrap:wrap;
}
.pleno15-probs {
    display:flex; gap:16px; justify-content:center;
    color:var(--color-warning); font-size:.875em; flex-wrap:wrap;
}

/* ═══════════════════════════════════════════════════════════════════
   PORRA GOLES (pleno15)
═══════════════════════════════════════════════════════════════════ */
.porra-table {
    display:grid; grid-template-columns:auto 1fr 1fr;
    gap:5px 14px; align-items:center;
    margin:10px 0; font-size:.875em;
}
.porra-header { font-weight:700; color:var(--color-warning); text-transform:uppercase; font-size:.78em; }
.porra-label  { color:var(--color-text); opacity:.7; }
.porra-bar-cell { display:flex; align-items:center; gap:7px; }
.porra-bar  { flex:1; height:6px; background:var(--color-frame); border-radius:3px; overflow:hidden; }
.porra-fill { height:100%; border-radius:3px; }
.porra-fill.home { background:var(--color-accent); }
.porra-fill.away { background:var(--color-warning); }
.porra-pct  { font-size:.78em; color:var(--color-text); opacity:.8; min-width:34px; text-align:right; }
.porra-gol-0 { color:var(--color-success); }
.porra-gol-1 { color:#7ba87b; }
.porra-gol-2 { color:var(--color-warning); }
.porra-gol-M { color:var(--color-accent); }

/* ═══════════════════════════════════════════════════════════════════
   TABLA QUINIELA: acierto / fallo
═══════════════════════════════════════════════════════════════════ */
.row-hit  { background:#dff0e6; color:#2d5a3d; }
.row-miss { background:#fdecea; color:#8b2020; }
.row-hit td, .row-hit .prob-cell   { color:#3a7a50; }
.row-miss td, .row-miss .prob-cell { color:#c04040; }
.team-cell { font-size:.875em; }
.prob-cell { font-size:.82em; color:var(--color-warning); }
.match-no  { font-weight:700; color:var(--color-accent); width:24px; }

/* ── Refresh + selects deshabilitados ── */
select:disabled { opacity:.5; cursor:not-allowed; }
#refresh-quiniela { background:transparent; border:1px solid var(--color-frame); color:var(--color-accent); }
#refresh-quiniela:hover { border-color:var(--color-success); color:var(--color-success); }

/* ═══════════════════════════════════════════════════════════════════
   INTERNACIONAL: played / pending highlight
═══════════════════════════════════════════════════════════════════ */
.int-match-row.played  { border-color:#c8e8d0; background:#f0faf3 !important; }
.int-match-row.pending { border-color:#e8ddd0; background:#fffaf5 !important; }

/* ═══════════════════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════════════════ */
footer {
    text-align: center;
    padding: 12px var(--content-pad) 8px;
    font-size: 0.72rem;
    color: #6b7280;
    letter-spacing: .03em;
}

footer a { color:#a78bfa; text-decoration:none; }
footer a:hover { text-decoration:underline; }

/* ══════════════════════════════════════════════════════════════════
   ▐████████████████████████████████████████████████████████████████
   █  RESPONSIVE — MOBILE-FIRST BREAKPOINTS
   ▐████████████████████████████████████████████████████████████████
══════════════════════════════════════════════════════════════════ */

/* ──────────────────────────────────────────────────────────────────
   ≥ 480px  (móviles grandes / phablets)
────────────────────────────────────────────────────────────────── */
@media screen and (min-width: 480px) {
    :root {
        --content-pad: 16px;
        --table-fs: 0.875rem;
    }

    .auth-container { padding: 2rem; }
    .auth-container h1 { font-size:1.6rem; }

    .app-header h1  { font-size:1.1rem; }
    .nav-btn        { font-size:0.875rem; padding:6px 14px; }

    .view-header h2 { font-size:1.25rem; flex:0; }

    .matches-table th,
    .matches-table td { padding:0.75rem 0.6rem; }

    #comb-controls { flex-wrap:nowrap; }
    #view-combinations h2 { flex:0; }
}

/* ──────────────────────────────────────────────────────────────────
   ≥ 600px  (tablets pequeñas / móvil landscape amplio)
────────────────────────────────────────────────────────────────── */
@media screen and (min-width: 600px) {
    :root {
        --content-pad: 20px;
        --table-fs: 0.9375rem;
        --header-h: 60px;
    }

    /* Header: una sola fila */
    .app-header {
        grid-template-rows: 1fr;
        grid-template-columns: auto 1fr auto;
        grid-template-areas: "logo nav usermenu";
        padding: 0 var(--content-pad);
        align-items: center;
    }

    .app-header h1 {
        padding: 0;
        font-size: 1.1rem;
        margin-right: 12px;
    }

    .user-menu { padding: 0; }

    .main-nav {
        border-top: none;
        padding: 0;
        justify-content: flex-start;
    }

    /* Predictor: fila */
    .predictor-form {
        flex-direction: row;
        align-items: flex-end;
    }

    .team-selector { flex:1; }
    .vs-divider { padding-bottom: 8px; }

    /* Factors: sidebar + editor */
    .factors-layout {
        flex-direction: row;
    }

    .factors-sidebar {
        width: 200px;
        flex-shrink: 0;
    }
    .factors-editor { flex:1; }

    /* Estadísticas: 4 columnas */
    .stats-grid { grid-template-columns: repeat(4, 1fr); }

    /* Internacional */
    #comp-select { width: auto; }
    .view-header #comp-select,
    .view-header #jornada-select { width: auto; }
}

/* ──────────────────────────────────────────────────────────────────
   ≥ 768px  (tablets estándar)
────────────────────────────────────────────────────────────────── */
@media screen and (min-width: 768px) {
    :root {
        --content-pad: 24px;
        --nav-gap: 6px;
    }

    .app-header h1 { font-size: 1.25rem; }
    .nav-btn { font-size: 0.9rem; padding: 7px 16px; }

    .matches-table th,
    .matches-table td { padding: 0.875rem 0.75rem; }

    .matches-table { min-width: 540px; }

    .int-match-row { padding: 10px 14px; gap: 12px; }
    .int-teams { font-size: .95em; }
    .int-prob-bar { width: 44px; }

    .sim-config { gap: 12px; }
    .sim-config input[type="number"] { width: 72px; }

    .pleno15-card { padding: 16px; }

    /* View header en fila */
    .view-header h2  { flex:0 1 auto; margin-right:auto; }
}

/* ──────────────────────────────────────────────────────────────────
   ≥ 1024px  (tablets grandes / laptops pequeños)
────────────────────────────────────────────────────────────────── */
@media screen and (min-width: 1024px) {
    :root {
        --content-pad: 28px;
        --nav-gap: 8px;
    }

    .app-content { padding: var(--content-pad); }

    .nav-btn { font-size: 0.9375rem; padding: 8px 18px; }

    .matches-table { min-width: unset; }

    .factors-sidebar { width: 240px; }
    .factors-sidebar ul { max-height: 400px; }

    #stats-chart { max-height: 380px; }

    .int-match-row { grid-template-columns: 1fr 160px 70px; }

    .predictor-form { padding: 1.75rem; gap: 2rem; }
}

/* ──────────────────────────────────────────────────────────────────
   ≥ 1280px  (escritorio estándar)
────────────────────────────────────────────────────────────────── */
@media screen and (min-width: 1280px) {
    :root { --content-pad: 2rem; }

    .auth-container { padding: 3rem; }
    .auth-container h1 { font-size: 1.8rem; }

    .app-header h1 { font-size: 1.25rem; }

    .matches-table th,
    .matches-table td { padding: 1rem; }

    .pleno-section { padding: 1.5rem; }

    .stat-value { font-size: 2rem; }
}

/* ──────────────────────────────────────────────────────────────────
   ≥ 1440px  (escritorios anchos)
────────────────────────────────────────────────────────────────── */
@media screen and (min-width: 1440px) {
    .app-content { padding: 2rem 3rem; }

    .nav-btn { padding: 8px 22px; }

    .int-match-row { padding: 12px 18px; }
}

/* ══════════════════════════════════════════════════════════════════
   ORIENTACIÓN
══════════════════════════════════════════════════════════════════ */

/* Landscape móvil (altura reducida) */
@media screen and (orientation: landscape) and (max-height: 500px) {

    :root { --header-h: auto; }

    /* Header compacto: todo en una fila */
    .app-header {
        grid-template-rows: 1fr;
        grid-template-columns: auto 1fr auto;
        grid-template-areas: "logo nav usermenu";
        padding: 4px var(--content-pad);
        min-height: 44px;
    }
    .app-header h1 { font-size:.9rem; padding:0; margin-right:8px; }
    .user-menu     { padding:0; }
    .main-nav      { border-top:none; padding:0; }
    .nav-btn       { font-size:.78rem; padding:4px 10px; min-height:30px; }

    /* Auth: formulario horizontal condensado */
    #auth-screen   { padding: 8px; }
    .auth-container { padding: 1rem 1.25rem; max-width: 520px; }
    .auth-container h1 { font-size:1.1rem; margin-bottom:.75rem; }

    /* Quiniela: tabla más compacta */
    .matches-table th,
    .matches-table td { padding: 5px 6px; }

    /* Limitar altura de listas internacionales */
    .matches-grid  { max-height: calc(100vh - 90px); overflow-y: auto; }
}

/* Landscape tablet: aprovecha el ancho */
@media screen and (orientation: landscape) and (min-width: 768px) and (max-height: 768px) {

    .app-content { padding: 12px var(--content-pad); }

    .factors-layout { flex-direction: row; }
    .factors-sidebar { width: 200px; }

    .predictor-form { flex-direction: row; align-items: flex-end; }
    .team-selector  { flex: 1; }
}

/* Portrait tablet: contenido full-width */
@media screen and (orientation: portrait) and (min-width: 600px) and (max-width: 1023px) {

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .int-match-row {
        grid-template-columns: 1fr auto auto;
    }
}

/* ══════════════════════════════════════════════════════════════════
   HOVER — sólo dispositivos con puntero fino (no touch)
══════════════════════════════════════════════════════════════════ */
@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover  { background:#4a6b5a; transform:translateY(-1px); }
    .btn-secondary:hover { background:var(--color-highlight); }
    .auth-form button:hover { background:#4a6b5a; transform:translateY(-1px); }
    .nav-btn:hover { background:var(--color-frame); color:var(--color-text); }
    .matches-table tr:hover { background:var(--color-bg); }
    .factors-sidebar ul li:hover { background:var(--color-frame); }
}

/* ══════════════════════════════════════════════════════════════════
   PREFERENCIAS DE ACCESIBILIDAD
══════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* ══════════════════════════════════════════════════════════════════
   PRINT — impresión limpia de la quiniela
══════════════════════════════════════════════════════════════════ */
@media print {

    /* Reset colores para impresión */
    :root {
        --color-bg:      #fff;
        --color-frame:   #ccc;
        --color-text:    #000;
        --color-accent:  #000;
        --color-success: #000;
        --color-warning: #666;
        --color-error:   #000;
    }

    /* Ocultar elementos no relevantes */
    #auth-screen,
    .app-header,
    .main-nav,
    .user-menu,
    #logout-btn,
    .view-header button,
    .view-header select,
    #view-international,
    #view-predictor,
    #view-factors,
    #view-simulation,
    #view-stats,
    #view-prizes,
    #view-combinations,
    footer { display: none !important; }

    /* Mostrar sólo la quiniela activa */
    body, .screen, #main-screen, .app-content { display: block !important; }
    #view-quiniela { display: block !important; }

    .view-header {
        border-bottom: 2px solid #000;
        margin-bottom: 8pt;
    }

    .view-header h2 {
        font-size: 14pt;
        color: #000;
    }

    /* Tabla limpia */
    .matches-table-container {
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }

    .matches-table {
        width: 100%;
        font-size: 9pt;
        border-collapse: collapse;
    }

    .matches-table th {
        background: #333 !important;
        color: #fff !important;
        padding: 5pt 6pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .matches-table td {
        padding: 4pt 6pt;
        border-bottom: 1px solid #ccc;
    }

    /* Colores de acierto/fallo */
    .row-hit  { background: #d4edda !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
    .row-miss { background: #f8d7da !important; -webkit-print-color-adjust:exact; print-color-adjust:exact; }

    /* Pleno 15 */
    .pleno-section {
        box-shadow: none;
        border: 1pt solid #000;
        margin-top: 12pt;
    }

    /* Evitar corte de tabla entre páginas */
    .matches-table tr { page-break-inside: avoid; }
    .pleno-section    { page-break-inside: avoid; }

    /* Pie de página de impresión */
    body::after {
        content: "Quiniela Inter Neural — " attr(data-jornada) " — Generado: " attr(data-date);
        display: block;
        text-align: center;
        font-size: 7pt;
        color: #666;
        margin-top: 16pt;
        border-top: 1pt solid #ccc;
        padding-top: 4pt;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   TEAM SEARCH INPUT — buscador con sugerencias (predictor)
═══════════════════════════════════════════════════════════════════ */
.team-search-wrap {
    position: relative;
    width: 100%;
}

.team-search-input {
    width: 100%;
    padding: 0.75rem 2.2rem 0.75rem 0.875rem;
    border: 2px solid var(--color-frame);
    border-radius: var(--radius);
    font-size: 1rem;          /* ≥16px — evita zoom iOS */
    color: var(--color-text);
    background: #fff;
    transition: var(--transition);
    min-height: 44px;
    -webkit-appearance: none;
}

.team-search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(192,90,66,.12);
}

.team-search-input.selected {
    border-color: var(--color-success);
    background: #f4faf6;
    padding-right: 2.4rem;
}

/* Icono lupa / check */
.team-search-wrap::after {
    content: '🔍';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .85rem;
    pointer-events: none;
}
.team-search-wrap.has-value::after { content: '✅'; }

/* Dropdown de sugerencias */
.team-search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--color-frame);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(44,35,24,.14);
    max-height: 260px;
    overflow-y: auto;
    z-index: 300;
    -webkit-overflow-scrolling: touch;
}

.team-search-dropdown.open { display: block; }

.tsd-group {
    padding: 5px 10px 2px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--color-warning);
    background: var(--color-bg);
    position: sticky;
    top: 0;
    border-bottom: 1px solid var(--color-frame);
}

.tsd-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: .9rem;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-frame);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 44px;   /* tap target móvil */
    transition: background .1s;
}

.tsd-item:last-child { border-bottom: none; }
.tsd-item:active,
.tsd-item:hover { background: var(--color-bg); }

.tsd-item-name { flex: 1; font-weight: 500; }
.tsd-item-elo  { font-size: .72rem; color: var(--color-warning); flex-shrink: 0; }

.tsd-empty {
    padding: 16px;
    text-align: center;
    color: var(--color-warning);
    font-size: .88rem;
}
