/* matches: rules no other view shares. Loads after app.css in the same layer. */
@layer app {
  /* ---------- export & setup ---------- */
  .export { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: start; }
  @media (min-width: 980px) {
    .export { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
    .card--wide { grid-column: 1 / -1; }
  }
  .card { position: relative; min-width: 0; padding: 18px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--inner), var(--shadow); display: flex; flex-direction: column; gap: 14px; }
  .card::before { content: ''; position: absolute; top: -1px; left: -1px; width: 12px; height: 12px; border: solid var(--phos-dim); border-width: 2px 0 0 2px; border-top-left-radius: var(--r); }
  .card h2 { font: 400 26px/1 var(--f-slate); letter-spacing: .04em; text-transform: uppercase; display: flex; align-items: baseline; gap: 10px; }
  .card h2 small { font: 400 24px/1 var(--f-led); color: var(--phos); }
  .offsets .inp { font: 400 28px/1 var(--f-led); color: var(--amber); }
  .mins { width: 100%; border-collapse: collapse; font-size: 13.5px; }
  .mins th { padding: 6px 8px; border-bottom: 1px solid var(--line-2); font: 600 9.5px var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--mute); text-align: left; white-space: nowrap; }
  .mins td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
  .mins td.mono { font: 400 22px/1 var(--f-led); color: var(--amber); }
  .mins td.mono:first-child { color: var(--mute); }
  .mins tr.dim td { opacity: .5; }
  .mins .w { width: 28%; }
  .mins td:nth-child(2) { white-space: nowrap; }
  .card--wide { overflow-x: auto; }
  /* ---------- export formats ---------- */
  .fmt-list { list-style: none; padding: 0; display: flex; flex-direction: column; }
  .fmt-list li { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
  .fmt-list li > div:first-child { display: flex; flex-direction: column; gap: 3px; min-width: 200px; flex: 1; }
  .fmt-list b { font: 400 30px/.9 var(--f-led); color: var(--phos); }
  .fmt-list span { font-size: 12.5px; color: var(--mute); }
  .fmt-actions { display: flex; gap: 6px; }
  .fmt-actions .btn { min-height: 46px; padding: 0 14px; }
  /* ---------- matches ---------- */
  .matches { display: flex; flex-direction: column; gap: 14px; max-width: 1680px; }
  .matches-h { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
  .matches-h h2 { font: 400 30px/1 var(--f-slate); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
  .match-list { list-style: none; padding: 0; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--inner); overflow: hidden; }
  .match { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); transition: background .15s; }
  .enter .match { animation: rise .35s both; animation-delay: calc(var(--i, 0) * 30ms); }
  .match__hit { position: absolute; inset: 0; z-index: 1; }
  .match:active { background: var(--panel-3); }
  @media (hover: hover) {
    .match:hover { background: var(--panel-2); }
    .match:hover .match__go { color: var(--phos); }
  }
  .match__go { font: 600 11px var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--mute); white-space: nowrap; }
  .match:last-child { border-bottom: 0; }
  .match__date { display: flex; flex-direction: column; align-items: center; padding: 4px 0; background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; }
  .match__date b { font: 400 34px/.85 var(--f-led); color: var(--amber); }
  .match__date span { font: 500 9.5px var(--f-mono); letter-spacing: .12em; color: var(--mute); }
  .match__teams { font: 400 22px/1.1 var(--f-slate); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .match__score { font: 400 30px/1 var(--f-led); color: var(--amber); margin: 0 8px; font-weight: 400; }
  .match__score i { font-style: normal; color: var(--mute); margin: 0 3px; }
  .match__score .is-away, .season-kpi b .is-away { color: var(--cyan); }
  .match__meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: 11.5px; color: var(--mute); letter-spacing: .04em; }
  .match__actions { display: flex; gap: 6px; align-items: center; }
  .match__actions .btn { min-height: 44px; padding: 0 12px; }
  .match__actions .icon-btn { width: 44px; height: 44px; }
  .storage-line { font-size: 12px; color: var(--mute); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
  @media (max-width: 700px) {
    .match { grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; padding: 12px; }
    .match__go { display: none; }
    .match__teams { font-size: 19px; }
  }
  /* ---------- match detail ---------- */
  .detail { display: flex; flex-direction: column; gap: 16px; }
  .detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .detail-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
  .mins-wrap { overflow-x: auto; }
  .detail .fmt-list li { flex-direction: column; align-items: stretch; }
  .detail .fmt-actions .btn { flex: 1; justify-content: center; }
  @media (max-width: 600px) {
    .detail .fmt-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .detail .fmt-actions .btn { min-width: 0; padding: 0 8px; letter-spacing: .08em; }
  }
  @media (max-width: 980px) {
    .detail-grid { grid-template-columns: minmax(0, 1fr); }
  }
  .match__crests { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
  .match__crests .crest { width: 26px; height: 26px; }
  .match__teams .crest { width: 30px; height: 30px; vertical-align: middle; margin: 0 8px; }
  /* ---------- matches: filter, results strip, list + minutes ---------- */
  .matches { min-height: 100%; }
  .team-filter { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: none; }
  .chip-f { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 6px; background: var(--sunk); font: 600 11px var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--mute); transition-property: background-color, color, border-color; transition-duration: .15s; }
  .chip-f[aria-pressed="true"] { background: var(--phos); border-color: var(--phos); color: var(--on-phos); }
  .chip-f:not(:disabled):active { scale: .96; }
  .chip-crest { width: 20px; height: 20px; object-fit: contain; }
  .season-kpis:empty { display: none; }
  .season-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--inner); }
  .season-kpi { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; border-left: 1px solid var(--line); }
  .season-kpi:first-child { border-left: 0; }
  .season-kpi b { font: 400 34px/.8 var(--f-led); color: var(--amber); font-weight: 400; }
  .season-kpi b i { font-style: normal; color: var(--mute); margin: 0 2px; }
  .season-kpi.is-w b { color: var(--phos); }
  .season-kpi.is-l b { color: var(--tally); }
  @media (max-width: 700px) {
    .season-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .season-kpi:nth-child(4) { border-left: 0; }
    .season-kpi:nth-child(n + 4) { border-top: 1px solid var(--line); }
  }
  .matches-body { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-items: start; }
  @media (min-width: 1100px) {
    .matches-body.has-season { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); }
    .season { position: sticky; top: 0; }
  }
  .match__side { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; pointer-events: none; }
  .match__side .match__del { pointer-events: auto; width: 44px; height: 44px; display: grid; place-items: center; color: var(--mute); }
  .match__del:focus-visible { color: var(--tally); border-color: var(--tally); }
  @media (hover: hover) { .match__del:hover { color: var(--tally); border-color: var(--tally); } }
  .ico-trash { width: 18px; height: 18px; }
  .season { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--inner); }
  .season[hidden] { display: none; }
  .season__h { display: flex; align-items: baseline; justify-content: space-between; font: 600 10px var(--f-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--mute); }
  .season__h small { font: 500 10px var(--f-mono); letter-spacing: .08em; text-transform: none; }
  .season-min { overscroll-behavior: contain; list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 62vh; overflow-y: auto; }
  .season-min li { display: grid; grid-template-columns: 34px minmax(0, 7.5em) minmax(40px, 1fr) auto; align-items: center; gap: 10px; min-height: 30px; padding-left: 8px; box-shadow: inset 3px 0 0 var(--gc, transparent); }
  .season-min__num { font: 400 22px/1 var(--f-led); color: var(--phos); font-weight: 400; text-align: right; }
  .season-min__name { font: 600 11px var(--f-mono); letter-spacing: .04em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .season-min__bar { height: 6px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
  .season-min__bar i { display: block; height: 100%; width: var(--w); background: var(--gc, var(--phos)); }
  .season-min__v { font: 400 20px/1 var(--f-led); color: var(--amber); white-space: nowrap; }
  .season-min__v small { margin-left: 6px; font: 500 10px var(--f-mono); color: var(--mute); }
  .storage-line { position: sticky; bottom: -1px; z-index: 3; margin-top: auto; padding: 10px 2px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 35%); font-size: 11.5px; }
  .storage-line .warn { color: var(--amber); }
  .storage-line .ok { color: var(--phos); }
  .matches > .storage-line { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  @media (max-width: 600px) {
    .storage-line { font-size: 10.5px; gap: 6px; }
    .storage-line .warn { display: none; }
  }
  .card--cliply::before { border-color: var(--pink); }
  .fmt-more summary { cursor: pointer; padding: 6px 0 2px; font: 600 10.5px var(--f-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--mute); list-style: none; }
  .fmt-more summary::-webkit-details-marker { display: none; }
  .fmt-more summary::before { content: '▸ '; }
  .fmt-more[open] summary::before { content: '▾ '; }
  /* Phone: action rows become even grids instead of a ragged stack of hugging buttons. */
  /* Partidos: what is to play, then what was played; an open match says so, the rest open in one tap. */
  .match-group { display: flex; align-items: baseline; gap: 10px; padding: 10px 16px 6px; border-bottom: 1px solid var(--line); background: var(--sunk); font: 600 10px var(--f-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--mute); }
  .match-group b { font: 400 18px/1 var(--f-led); letter-spacing: 0; color: var(--phos); font-weight: 400; }
  .match__open { position: relative; z-index: 2; min-height: 44px; padding: 0 14px; }
  .match__side { display: flex; align-items: center; gap: 8px; }
  .match-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 22px 18px; }
  .match-empty b { font: 400 24px/1 var(--f-slate); letter-spacing: .03em; text-transform: uppercase; }
  .match-empty span { font: 500 12.5px/1.4 var(--f-mono); color: var(--mute); }
  @media (max-width: 600px) {
    .match__open { padding: 0 10px; }
  }
  .match__open { pointer-events: auto; }
  @media (max-width: 600px) {
    .match { grid-template-columns: 52px minmax(0, 1fr); grid-template-areas: "date main" "date side"; row-gap: 8px; }
    .match > .match__date { grid-area: date; align-self: start; }
    .match > .match__main { grid-area: main; }
    .match > .match__side { grid-area: side; justify-content: flex-start; }
    .match__teams { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .match__meta > span:nth-child(n+3):not(.here):not([class*="cl-"]) { display: none; }
  }
  @media (max-width: 600px) {
    .storage-line { position: static; background: none; }
  }
}
@layer app {
  /* ---------- match detail: resumen ---------- */
  .sum-h { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
  .sum-h h2 { margin-right: auto; }
  .sum-periods { display: flex; flex-wrap: wrap; gap: 6px; }
  .sum-periods .chip-f { min-height: 44px; }
  .sum-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font: 600 11px var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--amber); }
  .sum-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 2px; background: currentColor; vertical-align: -1px; }
  .sum-legend .is-away { color: var(--cyan); }
  .sum-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); column-gap: 32px; }
  .sum-list li { display: grid; grid-template-columns: minmax(3ch, auto) minmax(0, 1fr) minmax(3ch, auto); align-items: center; gap: 6px 10px; padding: 10px 0 12px; border-bottom: 1px solid var(--line); }
  .sum-list li.is-zero { opacity: .4; }
  .sum-list b { font: 400 30px/.85 var(--f-led); font-weight: 400; color: var(--amber); }
  .sum-list b.is-away { color: var(--cyan); text-align: right; }
  .sum-list li > span:not(.sum-bar) { text-align: center; font: 400 17px/1.1 var(--f-slate); letter-spacing: .04em; text-transform: uppercase; overflow-wrap: break-word; }
  .sum-bar { grid-column: 1 / -1; display: flex; gap: 2px; height: 6px; border-radius: 3px; overflow: hidden; background: var(--sunk); }
  .sum-bar i { width: var(--w); background: var(--amber); transition: width .3s; }
  .sum-bar i.is-away { margin-left: auto; background: var(--cyan); }
  .sum-table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
  .sum-table { width: 100%; border-collapse: collapse; }
  .sum-table th { padding: 8px 10px; border-bottom: 1px solid var(--line-2); font: 600 9.5px var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--mute); white-space: nowrap; }
  .sum-table thead th:first-child, .sum-table tbody th { text-align: left; }
  .sum-table tbody th { position: sticky; left: 0; z-index: 1; background: var(--panel); border-bottom-color: var(--line); font: 400 16px/1.1 var(--f-slate); letter-spacing: .04em; white-space: normal; color: inherit; min-width: 110px; }
  .sum-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; font: 400 22px/1 var(--f-led); color: var(--amber); }
  .sum-table td i { font-style: normal; color: var(--mute); margin: 0 3px; }
  .sum-table td .is-away { color: var(--cyan); }
  .sum-table td.is-zero { opacity: .3; }
  .sum-table tr > :last-child { border-left: 1px solid var(--line-2); }
  .sum-note { font: 600 10px var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
  @media (max-width: 600px) {
    .card--sum { padding: 14px; }
    .sum-table-wrap { margin: 0 -14px; padding: 0 14px; }
    .sum-list b { font-size: 26px; }
  }
}
@layer app {
  /* ---------- match detail: cronología ---------- */
  .card--tl summary { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; list-style: none; }
  .card--tl summary::-webkit-details-marker { display: none; }
  .card--tl summary::after { content: '+'; margin-left: 4px; font: 400 26px/1 var(--f-mono); color: var(--mute); }
  .card--tl[open] summary::after { content: '−'; }
  .card--tl summary h2 { margin-right: auto; }
  .tl-hint { font: 600 10px var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
  .card--tl .filters { margin: 0; }
  .card--tl .log { max-height: min(70vh, 640px); overflow-y: auto; overscroll-behavior: contain; }
  .card--tl .log-head { position: sticky; top: 0; z-index: 1; }
  .card--tl[open] .tl-hint { display: none; }
  @media (max-width: 600px) { .tl-hint { display: none; } }
}
@layer app {
  /* ---------- match detail: reading first, tools after ---------- */
  .detail-sec { margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line-2); font: 600 10.5px var(--f-mono); letter-spacing: .2em; text-transform: uppercase; color: var(--mute); }
  @media (max-width: 600px) {
    .detail { gap: 12px; }
  }
}
@layer app {
  /* A phone list is for opening matches: deleting lives in the ficha. */
  @media (max-width: 600px) {
    .match__side .match__del { display: none; }
  }
}
@layer app {
  /* ---------- match detail: the result, as a final scoreboard ---------- */
  .detail-h { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 18px; background: var(--panel); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--inner); }
  .detail-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .detail-bar .btn { min-height: 44px; padding: 0 14px; }
  .detail-bar .btn-row { display: flex; flex-wrap: nowrap; gap: 8px; }
  .result { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: clamp(12px, 3vw, 36px); padding-top: 6px; }
  .result__team { display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-width: 0; font: 400 clamp(20px, 3vw, 40px)/1 var(--f-slate); letter-spacing: .03em; text-transform: uppercase; text-align: right; overflow-wrap: anywhere; }
  .result__team--away { justify-content: flex-start; text-align: left; color: var(--cyan); }
  .result__team .crest { width: clamp(28px, 3.4vw, 44px); height: clamp(28px, 3.4vw, 44px); flex: none; }
  .result__score { display: flex; align-items: center; gap: 8px; }
  .result__score b { min-width: 1.4ch; padding: 4px 10px 0; text-align: center; font: 400 clamp(44px, 6vw, 76px)/.78 var(--f-led); font-weight: 400; color: var(--amber); text-shadow: var(--glow-a); background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; }
  .result__score b.is-away { color: var(--cyan); text-shadow: var(--glow-cy); }
  .result__score i { font: 400 clamp(28px, 3vw, 40px)/1 var(--f-led); font-style: normal; color: var(--mute); }
  .result__meta { text-align: center; font: 600 10.5px/1.5 var(--f-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--mute); }
  .facts { list-style: none; padding: 10px 0 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 26px; border-top: 1px solid var(--line); font: 600 10px var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); }
  .facts li { display: flex; align-items: baseline; gap: 8px; }
  .facts b { font: 400 22px/1 var(--f-led); font-weight: 400; letter-spacing: 0; color: var(--bone); }
  @media (max-width: 600px) {
    .detail-h { padding: 10px 12px 14px; }
    .detail-bar .btn { white-space: nowrap; padding: 0 10px; letter-spacing: .1em; }
    .detail-bar .btn-row { gap: 6px; }
    .result { gap: 10px; }
    .result__team { flex-direction: column-reverse; align-items: flex-end; gap: 6px; font-size: 17px; }
    .result__team--away { flex-direction: column; align-items: flex-start; }
    .result__score b { padding: 3px 7px 0; }
    .facts { gap: 4px 16px; }
    .facts b { font-size: 18px; }
  }
}
