:root {
  --ink: #101820;
  --accent: #e10600;
  --bg: #f4f4f5;
  --card: #ffffff;
  --border: #e2e2e4;
  --muted: #6b7280;
  --up: #1a8f3c;
  --down: #c8281f;
  --font-display: "Barlow Condensed", sans-serif;
  --font-body: "Inter", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.accent {
  color: var(--accent);
}

.topbar {
  background: var(--ink);
  color: #fff;
  padding: 14px 16px;
}

.topbar h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 0.02em;
  margin: 0;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 12px 4px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 16px;
}

.footer p {
  margin: 4px 0;
}

.version {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.7;
}

/* Cards / sections */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 18px;
  margin: 4px 0 10px;
}

/* Avatars (circular placeholder until photos are uploaded) */
.avatar-wrap {
  position: relative;
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
  vertical-align: middle;
  margin-right: 6px;
  flex-shrink: 0;
}

.avatar-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
}

/* Siguiente partido / countdown */
.countdown {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 28px;
  color: var(--accent);
  margin-top: 6px;
}

.my-quiniela-header {
  display: flex;
  align-items: center;
}

.my-quiniela-header .avatar-wrap {
  width: 32px;
  height: 32px;
}

/* Podium */
.podium {
  margin-bottom: 16px;
  text-align: center;
}

.podium-risers,
.podium-labels {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.podium-risers {
  align-items: flex-end;
}

.podium-labels {
  margin-top: 8px;
}

.podium-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
  padding: 10px 6px;
}

/* Fixed riser heights so 1st > 2nd > 3rd always, regardless of how many
   names/ties are shown below (those live in .podium-labels instead). */
.podium-step.rank-1 { order: 2; height: 130px; border-top: 3px solid #ffd700; }
.podium-step.rank-2 { order: 1; height: 100px; border-top: 3px solid #c0c0c0; }
.podium-step.rank-3 { order: 3; height: 75px; border-top: 3px solid #cd7f32; }

.podium-label {
  flex: 1;
}

.podium-label.rank-1 { order: 2; }
.podium-label.rank-2 { order: 1; }
.podium-label.rank-3 { order: 3; }

.podium-rank {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 26px;
  color: var(--accent);
}

.podium-name {
  font-weight: 600;
  font-size: 13px;
  word-break: break-word;
}

.podium-name.empty {
  color: var(--muted);
}

.podium-avatar {
  margin: 4px auto 2px;
}

.podium-avatar .avatar-wrap {
  margin-right: 0;
  width: 32px;
  height: 32px;
}

.podium-points {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
}

.podium-tied {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* Standings table */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

td.num, th.num {
  text-align: right;
  font-family: var(--font-display);
  font-weight: 700;
}

.delta {
  display: inline-block;
  min-width: 28px;
  font-weight: 700;
  font-size: 12px;
  text-align: center;
}

.rank-cell {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.rank-num {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  min-width: 1.2ch;
  text-align: right;
}

.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.same { color: var(--muted); }

.gained {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  color: var(--up);
}

/* Mi quiniela */
.code-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.code-form input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.suggestion {
  display: flex;
  align-items: center;
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}

.suggestion:active {
  background: var(--bg);
}

.error-msg {
  color: var(--down);
  font-size: 13px;
  margin: 4px 0 12px;
}

.empty-msg {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px 8px;
}

/* Matches list */
.match-card {
  margin-bottom: 8px;
}

.match-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.match-teams {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}

.match-id {
  color: var(--muted);
  font-weight: 700;
  margin-right: 2px;
}

.match-score {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 18px;
  white-space: nowrap;
}

.match-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.match-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.match-status.live {
  background: var(--accent);
  color: #fff;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.match-status.scheduled {
  background: var(--bg);
  color: var(--muted);
}

.match-picks {
  display: none;
  margin-top: 10px;
}

.match-picks.open {
  display: block;
}

.match-picks.scrollable.open {
  max-height: 165px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(16, 24, 32, 0.25) transparent;
}

.match-picks.scrollable.open::-webkit-scrollbar {
  width: 6px;
}

.match-picks.scrollable.open::-webkit-scrollbar-thumb {
  background: rgba(16, 24, 32, 0.25);
  border-radius: 3px;
}

.picks-toggle {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  margin-left: 4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.picks-toggle.open {
  transform: rotate(225deg);
}

.pick-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.pick-row:last-child {
  border-bottom: none;
}

.pick-row .pick-name {
  flex: 1;
}

.pick-row .pick-value {
  font-family: var(--font-display);
  font-weight: 700;
  width: 50px;
  text-align: right;
}

.pick-row .pick-points {
  width: 50px;
  text-align: right;
  font-weight: 700;
}

.pick-row.exact .pick-points { color: var(--up); }
.pick-row.outcome .pick-points { color: #c08a00; }
.pick-row.miss .pick-points,
.pick-row.pending .pick-points { color: var(--muted); }

.group-heading {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
  margin: 16px 0 6px;
  letter-spacing: 0.04em;
}

@media (min-width: 480px) {
  main {
    padding: 16px;
  }
}

/* Evolución (bump chart) */
.evolucion-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.evolucion-tab {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}

.evolucion-tab.active {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  overflow-x: auto;
}

.chart-card svg {
  display: block;
}

.chart-card .grid-line {
  stroke: #ececed;
  stroke-width: 1;
}

.chart-card .axis-label {
  font-family: var(--font-display);
  font-weight: 700;
  fill: var(--muted);
  font-size: 12px;
}

.chart-card .match-label {
  font-family: "Inter", sans-serif;
  fill: var(--muted);
  font-size: 9px;
}

.chart-card .name-label {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 11px;
}

.chart-card .player-line {
  fill: none;
  stroke-width: 2.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  opacity: 0.92;
}

.chart-card .node {
  stroke: #fff;
  stroke-width: 0.8;
}
