/* ── Reset & Variables ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Paleta fútbol — stadium night */
  --bg-deep:      #050e09;
  --bg-dark:      #091409;
  --bg-mid:       #0d1f12;
  --card-bg:      #112416;
  --card-hover:   #1a3520;
  --border:       #1e4228;
  --border-glow:  #2d6a40;

  --green:        #16a34a;
  --green-light:  #22c55e;
  --green-dim:    #14532d;

  --gold:         #ca8a04;
  --gold-light:   #fbbf24;
  --gold-dim:     #78350f;

  --amber:        #d97706;

  --text:         #ecfdf5;
  --text-muted:   #7fa88a;
  --white:        #ffffff;

  --radius:       12px;
  --shadow:       0 4px 24px rgba(0,0,0,0.6);
  --ad-bg:        #030a05;
  --banner-h:     90px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--banner-h) + 70px);
}

/* ── Banner Ad — TOP ─────────────────────────────────────────────────────── */
.banner-ad-top {
  background: var(--ad-bg);
  border-bottom: 1px solid var(--border);
  padding: 8px;
  text-align: center;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.banner-ad-top .ad-label {
  position: absolute;
  top: 3px; right: 8px;
  font-size: 9px;
  color: #334;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.ad-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #2a3a2a;
  font-size: 12px;
  border: 1px dashed #1a2a1a;
  border-radius: 4px;
  letter-spacing: 0.3px;
}

/* ── Banner Ad — BOTTOM (sticky) ─────────────────────────────────────────── */
.banner-ad-bottom {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--banner-h);
  background: var(--ad-bg);
  border-top: 2px solid var(--gold-dim);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.banner-ad-bottom .ad-label {
  position: absolute;
  top: 4px; right: 10px;
  font-size: 9px;
  color: #334;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Ad Card (inline en grid) ────────────────────────────────────────────── */
.ad-card {
  background: var(--ad-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  position: relative;
  overflow: hidden;
}

.ad-card .ad-label {
  position: absolute;
  top: 6px; right: 8px;
  font-size: 9px;
  color: #334;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Interstitial Rewarded ───────────────────────────────────────────────── */
.interstitial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.interstitial-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.interstitial-content {
  background: var(--bg-mid);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  width: min(380px, 94vw);
  overflow: hidden;
  text-align: center;
}

.interstitial-ad-zone {
  background: var(--ad-bg);
  min-height: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}

.interstitial-ad-zone .ad-label {
  position: absolute;
  top: 6px; right: 10px;
  font-size: 9px;
  color: #334;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.interstitial-footer {
  padding: 18px;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.interstitial-footer p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn-close-ad {
  background: linear-gradient(135deg, var(--green), var(--green-light));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  letter-spacing: 0.3px;
}

.btn-close-ad:disabled {
  background: #1a2a1a;
  color: #3a5a3a;
  cursor: not-allowed;
}

.btn-close-ad:not(:disabled):hover {
  transform: scale(1.02);
  box-shadow: 0 4px 20px rgba(22,163,74,0.5);
}

#interstitial-timer {
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
  font-weight: 600;
}

/* ── Tutorial Modal ──────────────────────────────────────────────────────── */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9998;
  /* display controlled by JS: starts display:none, becomes flex on open */
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.tutorial-overlay.visible {
  opacity: 1;
}

.tutorial-sheet {
  background: var(--bg-mid);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 0 0 24px 0;
  transform: translateY(30px);
  transition: transform 0.3s;
}

.tutorial-overlay.visible .tutorial-sheet {
  transform: translateY(0);
}

.tutorial-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-mid);
  z-index: 1;
}

.tutorial-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gold-light);
}

.btn-modal-close {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-modal-close:hover { color: var(--text); border-color: var(--border-glow); }

.tutorial-tabs {
  display: flex;
  gap: 0;
  padding: 16px 20px 0;
  border-bottom: 1px solid var(--border);
}

.tutorial-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex: 1;
}

.tutorial-tab.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold-light);
}

.tutorial-body { padding: 20px; }

.tutorial-panel { display: none; }
.tutorial-panel.active { display: block; }

.tutorial-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.step-num {
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-content h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.step-content p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.step-content .step-tip {
  display: inline-block;
  background: rgba(22,163,74,0.1);
  border: 1px solid rgba(22,163,74,0.25);
  color: var(--green-light);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  margin-top: 6px;
  font-weight: 600;
}

/* ── App Bar (compact header) ────────────────────────────────────────────── */
.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(90deg, #071a0d, #0a2010);
  border-bottom: 2px solid var(--green-dim);
  gap: 10px;
}

.app-bar-title {
  font-size: 1.05rem;
  font-weight: 900;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.btn-help {
  background: rgba(22,163,74,0.15);
  border: 1px solid rgba(22,163,74,0.3);
  color: var(--green-light);
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-help:hover { background: rgba(22,163,74,0.28); border-color: var(--green); }

/* ── Generic scrollable strip ────────────────────────────────────────────── */
.strip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  background: var(--bg-mid);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }

.strip-label { font-size: 13px; flex-shrink: 0; }

.strip-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

/* ── Pills (shared by TZ + filter buttons) ───────────────────────────────── */
.pill {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.18s;
  line-height: 1.4;
}

/* TZ pill active → gold */
.tz-btn.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold-light);
}
.tz-btn:hover:not(.active) { border-color: var(--gold); color: var(--gold-light); }

/* Filter pill active → green */
.filter-mode-btn.active {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green-light);
}
.filter-mode-btn:hover:not(.active) { border-color: var(--green); color: var(--green-light); }

/* Phase select inside strip */
.filter-strip .phase-select {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 5px 28px 5px 10px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='7' viewBox='0 0 10 7'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%237fa88a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-color: var(--card-bg);
  max-width: 155px;
}
.filter-strip .phase-select:focus { outline: none; border-color: var(--green); }

/* ── Chips strip ─────────────────────────────────────────────────────────── */
.chips-strip {
  flex-wrap: wrap;
  gap: 7px;
  padding: 8px 12px;
  border-top: none;
}

/* Estado base del chip — visible pero claramente inactivo */
.team-chip {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-glow);
  color: var(--text-muted);
}

/* Estado activo — seleccionado */
.team-chip.chip-active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold-light);
  font-weight: 700;
}

/* Hover en inactivo → sugiere que se puede activar */
.team-chip:hover:not(.chip-active) {
  background: rgba(202,138,4,0.08);
  border-color: var(--gold);
  color: var(--gold-light);
}

/* Hover en activo → sugiere que al tocar se quita (tachado) */
.team-chip.chip-active:hover {
  background: rgba(255,255,255,0.03);
  border-color: var(--border);
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--gold-dim);
}


.match-counter {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 16px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
}

/* ── FLOATING CTA Button ─────────────────────────────────────────────────── */
.floating-cta {
  position: fixed;
  bottom: calc(var(--banner-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  width: min(440px, calc(100vw - 24px));
}

.btn-download {
  width: 100%;
  background: linear-gradient(135deg, #15803d, #16a34a, #22c55e);
  border: none;
  color: #fff;
  padding: 16px 24px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow:
    0 0 0 0 rgba(22,163,74,0.5),
    0 8px 32px rgba(22,163,74,0.35),
    0 2px 8px rgba(0,0,0,0.4);
  letter-spacing: 0.2px;
  animation: cta-pulse 3s ease-in-out infinite;
}

@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,0.5), 0 8px 32px rgba(22,163,74,0.35), 0 2px 8px rgba(0,0,0,0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(22,163,74,0),  0 8px 32px rgba(22,163,74,0.5), 0 2px 8px rgba(0,0,0,0.4); }
}

.btn-download:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.01);
  background: linear-gradient(135deg, #16a34a, #22c55e, #4ade80);
  animation: none;
  box-shadow: 0 12px 40px rgba(22,163,74,0.5), 0 2px 8px rgba(0,0,0,0.4);
}

.btn-download:disabled {
  background: #1a2a1a;
  color: #2a4a2a;
  cursor: not-allowed;
  animation: none;
  box-shadow: none;
}

.btn-download .btn-icon { font-size: 20px; }
.btn-download .btn-text { flex: 1; text-align: left; line-height: 1.2; }
.btn-download .btn-text small { display: block; font-size: 12px; font-weight: 400; opacity: 0.8; }
.btn-download .btn-count {
  background: rgba(0,0,0,0.2);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* ── Match Cards ─────────────────────────────────────────────────────────── */
.matches-container {
  padding: 12px;
  max-width: 1200px;
  margin: 0 auto;
}

.phase-group { margin-bottom: 28px; }

.phase-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(202,138,4,0.12), transparent);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
}

.matches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(275px, 1fr));
  gap: 12px;
}

.match-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  cursor: default;
}

.match-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  opacity: 0;
  background: linear-gradient(135deg, rgba(22,163,74,0.04), transparent);
  transition: opacity 0.2s;
  pointer-events: none;
}

.match-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-glow); }
.match-card:hover::after { opacity: 1; }

.match-card.latam {
  border-color: rgba(202,138,4,0.3);
  background: linear-gradient(145deg, #112416, #0e1d12);
}

.match-card.latam::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold), transparent);
}

.match-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.group-badge {
  background: rgba(22,163,74,0.12);
  border: 1px solid rgba(22,163,74,0.25);
  color: var(--green-light);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.latam-badge {
  background: rgba(202,138,4,0.12);
  border: 1px solid rgba(202,138,4,0.25);
  color: var(--gold-light);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.match-date {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.match-teams {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
  text-align: center;
}

.flag { line-height: 1; display: flex; justify-content: center; }

.team-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.vs {
  font-size: 13px;
  font-weight: 900;
  color: var(--text-muted);
  flex-shrink: 0;
  background: var(--bg-dark);
  padding: 5px 8px;
  border-radius: 8px;
  letter-spacing: 1px;
}

.match-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  border: 1px solid rgba(22,163,74,0.1);
}

.match-time {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.match-time strong { font-size: 15px; color: var(--gold-light); letter-spacing: 0.5px; }

.tz-abbr {
  font-size: 10px;
  color: var(--green-light);
  font-weight: 700;
  background: rgba(22,163,74,0.1);
  padding: 2px 5px;
  border-radius: 4px;
}

.match-venue {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  min-width: 0;
}

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state span { font-size: 3rem; display: block; margin-bottom: 12px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--banner-h) + 76px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--green);
  color: #fff;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 9000;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .matches-grid { grid-template-columns: 1fr; }
  .btn-download { font-size: 14px; padding: 14px 18px; }
  .flag-img { width: 34px; }
  .floating-cta { bottom: calc(var(--banner-h) + 8px); }
  .app-bar-title { font-size: 0.95rem; }
  .btn-help { font-size: 11px; padding: 5px 10px; }
}

@media (min-width: 768px) {
  .matches-grid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
  .matches-container { padding: 16px 24px; }
}

@media (min-width: 1024px) {
  .matches-grid { grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
}

/* ── Flag images ─────────────────────────────────────────────────────────── */
.flag-img {
  display: block;
  width: 40px;
  height: auto;
  border-radius: 3px;
  object-fit: cover;
}

/* Banderas en chips — más pequeñas */
.team-chip .flag-img {
  display: inline-block;
  width: 20px;
  height: auto;
  vertical-align: middle;
  border-radius: 2px;
  margin-right: 2px;
}

.flag-fallback { font-size: 1.5rem; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-glow); }
