*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0a1628;
  --surface:   #0f2137;
  --surface2:  #162a4a;
  --border:    #1e3a5f;
  --accent:    #3b82f6;
  --accent2:   #06b6d4;
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #eab308;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Inter', system-ui, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,22,40,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.logo svg { color: var(--accent2); }

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.updated {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent);
  color: white;
}

.btn-refresh {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.btn-refresh:hover { background: var(--border); }

/* ── Main ──────────────────────────────────────── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Sections ──────────────────────────────────── */
.section, .qualifying-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.section-header, .qualifying-section .section-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface2);
}

.section-title {
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.tour-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
}
.tour-badge.atp { background: #1d4ed8; color: white; }
.tour-badge.wta { background: #be185d; color: white; }

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.tag-qualify { background: rgba(234,179,8,0.15); color: var(--yellow); border: 1px solid rgba(234,179,8,0.3); }
.tag-odds { color: var(--muted); background: transparent; }

/* ── Qualifying Grid ────────────────────────────── */
.qualifying-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  padding: 12px;
}

/* ── Match Cards ───────────────────────────────── */
.match-list {
  display: flex;
  flex-direction: column;
}

.match-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.match-card:last-child { border-bottom: none; }
.match-card:hover { background: var(--surface2); }

.match-card.status-live {
  background: rgba(34,197,94,0.05);
  border-left: 3px solid var(--green);
}

.player {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.player.right { text-align: right; }

.player-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-rank {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.score-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.match-score {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.2;
}

.score-live {
  color: var(--green);
  text-shadow: 0 0 12px rgba(34,197,94,0.4);
}

.score-done {
  color: var(--muted);
}

.match-time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}
.match-time.live { color: var(--green); }

.odds-badge {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-align: center;
}
.odds-back { background: rgba(34,197,94,0.15); color: var(--green); }
.odds-lay  { background: rgba(239,68,68,0.15); color: var(--red); }

.qualify-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(234,179,8,0.2);
  color: var(--yellow);
  white-space: nowrap;
}

/* ── Qualifying Card ───────────────────────────── */
.qual-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.qual-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.qual-card.live::before {
  background: var(--green);
  animation: pulse 2s ease-in-out infinite;
}

.qual-players {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.qual-fav {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent2);
}
.qual-dog {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
.qual-vs { font-size: 11px; color: var(--muted); font-family: var(--mono); }

.qual-odds {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.qual-odds-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
}
.qual-action {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent);
  color: white;
}
.qual-action.monitor {
  background: rgba(234,179,8,0.2);
  color: var(--yellow);
}

.qual-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.qual-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.qual-tour {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
}
.qual-tour.atp { background: #1d4ed8; color: white; }
.qual-tour.wta { background: #be185d; color: white; }

/* ── Empty State ───────────────────────────────── */
.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── Footer ────────────────────────────────────── */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10,22,40,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 8px 20px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  z-index: 100;
}

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

/* ── Mobile ────────────────────────────────────── */
@media (max-width: 600px) {
  .qualifying-grid { grid-template-columns: 1fr; }
  .match-card { padding: 10px 12px; gap: 8px; }
  .match-score { font-size: 15px; }
}
