:root {
  --bg: #0E1A14;
  --bg-deep: #0B150F;
  --surface: #16261D;
  --surface-2: #1E3326;
  --line: #2A3D32;
  --line-soft: #1F3127;
  --text: #F2F5F0;
  --text-2: #C9D4CC;
  --muted: #9FB0A5;
  --accent: #C6F432;
  --accent-ink: #0E1A14;
  --live: #FF8A3D;
  --warn: #FFC83D;
  --danger: #FF7A6B;
  --radius: 14px;
  --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
a:hover { color: #E2FF8A; }
button, input, select { font: inherit; }

.wrap { max-width: 560px; margin: 0 auto; padding: 20px 16px 48px; min-height: 100vh; }
.wrap.wide { max-width: 960px; }

.brand { display: flex; flex-direction: column; gap: 2px; }
.brand b { font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: 1px; color: var(--accent); }
.brand span { font-size: 12px; color: var(--muted); }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.titlebar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.titlebar h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 28px; line-height: 1; }
.titlebar p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

h2 { font-family: var(--display); font-weight: 700; font-size: 22px; margin: 24px 0 10px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.card + .card { margin-top: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrapr { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.stat b { display: block; font-family: var(--display); font-size: 26px; font-weight: 700; }
.stat span { font-size: 12px; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .8px; padding: 4px 8px; border-radius: 6px; background: var(--accent); color: var(--accent-ink); }
.badge.live { background: var(--live); }
.badge.muted { background: var(--line); color: var(--text-2); }

.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress > i { display: block; height: 6px; background: var(--accent); }

label { font-size: 13px; font-weight: 600; color: var(--text-2); display: block; margin-bottom: 6px; }
.field { display: flex; flex-direction: column; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], select {
  min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text);
  padding: 0 14px; font-size: 15px; width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input.goal { width: 52px; text-align: center; padding: 0 4px; font-family: var(--display); font-size: 22px; font-weight: 700; min-height: 44px; }

.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-2); min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.btn { min-height: 48px; border-radius: 12px; border: none; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 15px; padding: 0 18px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { background: #D4FA5C; color: var(--accent-ink); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #5A2E29; font-weight: 600; }
.btn.small { min-height: 40px; font-size: 13px; padding: 0 12px; border-radius: 10px; }
.icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; text-decoration: none; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; }
.tab { min-height: 40px; padding: 0 13px; display: inline-flex; align-items: center; text-decoration: none; flex-shrink: 0; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab[aria-selected=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.list-item + .list-item { margin-top: 10px; }
a.list-item:hover { background: var(--surface-2); color: var(--text); }
.list-item .t { font-weight: 600; font-size: 15px; }
.list-item .s { font-size: 12px; color: var(--muted); margin-top: 3px; }

.table { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow-x: auto; }
.table table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: center; font-size: 11px; color: var(--muted); letter-spacing: .5px; font-weight: 700; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.table td { text-align: center; padding: 11px 6px; border-bottom: 1px solid var(--line-soft); color: var(--text-2); }
.table th.l, .table td.l { text-align: left; }
.table td.team { font-weight: 600; color: var(--text); white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.table td.pts { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--text); }
.pos { display: inline-flex; width: 22px; height: 22px; border-radius: 6px; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.pos.top { background: var(--accent); color: var(--accent-ink); }

.match { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.match + .match { margin-top: 8px; }
.match .teams { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.match .home { text-align: right; font-weight: 600; font-size: 14px; }
.match .away { text-align: left; font-weight: 600; font-size: 14px; }
.match .score { display: flex; align-items: center; gap: 6px; }
.match .final { font-family: var(--display); font-weight: 800; font-size: 24px; min-width: 64px; text-align: center; }
.match .meta { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.round-title { font-family: var(--display); font-weight: 700; font-size: 18px; margin: 18px 0 8px; color: var(--text-2); }

.note { font-size: 13px; color: var(--muted); line-height: 1.5; }
.msg { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 12px; }
.msg.err { background: #3A1E1B; color: #FFD6D0; border: 1px solid #5A2E29; }
.msg.ok { background: #1E3326; color: #E2FF8A; border: 1px solid #3A5444; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); font-size: 14px; border: 1px dashed #3A5444; border-radius: 16px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 50; max-width: calc(100% - 32px); }

.auth { max-width: 420px; margin: 0 auto; padding-top: 48px; }
.auth h1 { font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1; margin: 28px 0 8px; }

.linkbox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 14px; }
.linkbox code { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-2); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
footer.foot { margin-top: 40px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---- v2: fases, llaves y formato ---- */
.statusline { margin: -6px 0 14px; font-size: 13px; color: var(--text-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs.chips .tab { min-height: 36px; font-size: 13px; }
.msg.warn { background: #3A3216; color: #FFE8A3; border: 1px solid #5C4E1E; }
.warn-text { color: var(--warn) !important; }
.linkbtn { background: none; border: none; color: var(--accent); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; min-height: 0; }
.ptitle { font-family: var(--display); font-weight: 800; font-size: 36px; line-height: 1; margin: 0; }
.gtitle { font-family: var(--display); font-weight: 700; font-size: 19px; margin: 18px 0 8px; color: var(--text-2); }
.table caption { text-align: left; padding: 10px 12px; font-weight: 700; }
.pos.q { background: var(--accent); color: var(--accent-ink); }
.pos.x { background: var(--warn); color: var(--accent-ink); }
.pos.c { background: #FFD24A; color: var(--accent-ink); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.legend .pos { margin-right: 2px; }
.tiedmark { color: var(--warn); font-weight: 700; cursor: help; }
.round-sub { font-size: 13px; color: var(--muted); margin: 10px 0 6px; font-weight: 600; }
.vs { font-family: Inter, sans-serif; font-size: 13px; color: var(--muted); font-weight: 500; }
.pensnote { text-align: center; font-size: 12px; color: var(--warn); margin-top: 4px; }
.pens { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; }
.pens .note { margin-right: 4px; }
input.goal.small { width: 44px; min-height: 40px; font-size: 18px; }
.tie-res { margin: -2px 0 12px 4px; }
.advance { border-color: var(--accent); margin-bottom: 16px; }
.champion { display: flex; gap: 14px; align-items: center; background: linear-gradient(0deg, #2A2A10, #2A2A10); border: 1px solid #6B5E1A; border-radius: 18px; padding: 16px 18px; margin-bottom: 16px; }
.champion .cup { color: #FFD24A; display: inline-flex; }
.champion small { display: block; font-size: 11px; letter-spacing: 1.5px; color: #E8D58A; font-weight: 700; }
.champion b { font-family: var(--display); font-size: 28px; font-weight: 800; color: #FFF3C2; }
.bracket { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; }
.bcol { flex: 0 0 220px; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; scroll-snap-align: start; }
.bcol h3 { font-family: var(--display); font-size: 17px; margin: 0 0 4px; color: var(--text-2); }
.tie { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.bt { display: flex; justify-content: space-between; gap: 8px; padding: 9px 12px; font-size: 14px; }
.bt + .bt { border-top: 1px solid var(--line-soft); }
.bt span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt b { font-family: var(--display); font-size: 18px; }
.bt.win { color: var(--text); font-weight: 700; }
.bt.win b { color: var(--accent); }
.bt.lose { color: var(--muted); }
.bt.bye { color: var(--muted); }
.bt i { color: var(--muted); font-style: normal; }
.tnote { font-size: 11px; color: var(--muted); padding: 6px 12px 8px; border-top: 1px solid var(--line-soft); }
.flow { margin: 0; padding: 0; list-style: none; counter-reset: f; display: flex; flex-direction: column; gap: 10px; }
.flow li { counter-increment: f; display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; }
.flow li::before { content: counter(f); grid-row: span 2; width: 26px; height: 26px; border-radius: 13px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.flow li b { font-size: 15px; }
.flow li span { font-size: 13px; color: var(--text-2); line-height: 1.45; }
.flowcard { margin-bottom: 4px; }
.phase-card + .phase-card { margin-top: 12px; }
select { appearance: auto; }

.tabs.chips { flex-wrap: wrap; overflow: visible; }
@media (max-width: 480px) {
  .table th.xs, .table td.xs { display: none; }
  .tabs.main { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; overflow: visible; }
  .tabs.main .tab { padding: 0 2px; font-size: 12px; justify-content: center; }
}
@media (max-width: 640px) {
  .bracket { flex-direction: column; overflow: visible; gap: 18px; }
  .bcol { flex: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .bcol h3 { grid-column: 1 / -1; }
  .bcol .tie:only-of-type { grid-column: 1 / -1; }
}
