@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0c1117;
  --surface: #161c25;
  --surface-2: #1d2535;
  --border: #28364a;
  --border-light: #3a4f6a;
  --text: #dde5ef;
  --muted: #6b7d93;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-dim: rgba(59,130,246,0.12);
  --gold: #f59e0b;
  --gold-dim: rgba(245,158,11,0.12);
  --silver: #94a3b8;
  --silver-dim: rgba(148,163,184,0.1);
  --bronze: #c27b50;
  --bronze-dim: rgba(194,123,80,0.1);
  --green: #10b981;
  --green-dim: rgba(16,185,129,0.12);
  --blue-dim: rgba(59,130,246,0.1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Header ───────────────────────────────── */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: stretch;
  gap: 2rem;
}

.header-title {
  padding: 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}

.header-title h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.header-title .badge {
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

nav {
  display: flex;
  gap: 0;
  flex: 1;
}

.nav-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0 1rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.nav-btn:hover { color: var(--text); }
.nav-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Layout ───────────────────────────────── */

main {
  flex: 1;
  padding: 1.75rem 1.5rem;
  max-width: 1020px;
  margin: 0 auto;
  width: 100%;
}

.tab { display: none; }
.tab.active { display: block; }

.section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 1rem;
}

h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; letter-spacing: -0.01em; }
h3 { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 1.5rem 0 0.75rem; }

/* ── Prize banner ─────────────────────────── */

.prize-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.prize-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.prize-item .label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.prize-item .amount {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.prize-item .winner-name {
  font-size: 0.8rem;
  color: var(--muted);
}

.prize-item.prize-1 { border-color: rgba(245,158,11,0.3); background: var(--gold-dim); }
.prize-item.prize-1 .amount { color: var(--gold); }
.prize-item.prize-2 { border-color: rgba(148,163,184,0.25); background: var(--silver-dim); }
.prize-item.prize-2 .amount { color: var(--silver); }
.prize-item.prize-3 { border-color: rgba(194,123,80,0.25); background: var(--bronze-dim); }
.prize-item.prize-3 .amount { color: var(--bronze); }
.prize-item.prize-pot { border-color: rgba(59,130,246,0.2); background: var(--blue-dim); }
.prize-item.prize-pot .amount { color: var(--accent); }

/* ── Standings ────────────────────────────── */

.standings-list { display: flex; flex-direction: column; gap: 0.5rem; }

.standing-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto auto;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  transition: border-color 0.15s;
}

.standing-row:hover { border-color: var(--border-light); }

.standing-row.pos-1 { border-color: rgba(245,158,11,0.35); background: var(--gold-dim); }
.standing-row.pos-2 { border-color: rgba(148,163,184,0.25); background: var(--silver-dim); }
.standing-row.pos-last { border-color: rgba(194,123,80,0.2); background: var(--bronze-dim); }

.standing-pos {
  font-size: 1.1rem;
  font-weight: 800;
  text-align: center;
  line-height: 1;
}

.pos-1 .standing-pos { color: var(--gold); }
.pos-2 .standing-pos { color: var(--silver); }
.pos-last .standing-pos { color: var(--bronze); }

.standing-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.standing-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

/* ── Team pill ────────────────────────────── */

.team-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Round badge ──────────────────────────── */

.round-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.round-WINNER        { background: var(--green-dim); border-color: rgba(16,185,129,0.4); color: var(--green); }
.round-FINAL         { background: var(--gold-dim);  border-color: rgba(245,158,11,0.4); color: var(--gold); }
.round-SEMI_FINALS   { background: var(--blue-dim);  border-color: rgba(59,130,246,0.35); color: var(--accent); }
.round-QUARTER_FINALS{ background: var(--blue-dim);  border-color: rgba(59,130,246,0.25); color: #7cabf7; }
.round-LAST_16       { background: var(--surface-2); border-color: var(--border-light); color: var(--text); }
.round-LAST_32       { background: var(--surface-2); border-color: var(--border-light); color: var(--text); }
.round-GROUP_STAGE   { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

/* ── Draw table ───────────────────────────── */

.draw-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

th, td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
thead tr:last-child th { border-bottom-color: var(--border-light); }
tbody tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-2); }
tbody tr:hover td { background: var(--surface-2); }

/* ── Fixtures ─────────────────────────────── */

.fixture-group { margin-bottom: 1.75rem; }

.fixture-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.fixture {
  display: grid;
  grid-template-columns: 1fr 5rem 1fr 6rem;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  transition: border-color 0.15s;
}

.fixture:hover { border-color: var(--border-light); }
.fixture .home { text-align: right; font-weight: 500; }
.fixture .away { font-weight: 500; }

.fixture .score {
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.fixture .meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.fixture .date { color: var(--muted); font-size: 0.72rem; }

.status-pill {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-2);
}

.status-IN_PLAY .score { color: var(--green); animation: pulse 1.5s infinite; }
.status-IN_PLAY .status-pill { background: var(--green-dim); border-color: rgba(16,185,129,0.4); color: var(--green); }
.status-FINISHED .status-pill { display: none; }
.status-SCHEDULED .score { color: var(--muted); }

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

/* ── Filter ───────────────────────────────── */

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
}

.filter-row select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.65rem;
  border-radius: 7px;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
}

/* ── Admin ────────────────────────────────── */

.admin-login { display: flex; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }

input[type="text"],
input[type="password"],
input[type="number"] {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.7rem;
  border-radius: 7px;
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
}

#add-participant-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

#config-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

#config-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#config-form input { width: 90px; }

button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 0.45rem 1.1rem;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
}

button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.hidden { display: none !important; }

.admin-participant-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.admin-participant-row strong { font-weight: 600; min-width: 100px; }
.admin-participant-row span { color: var(--muted); font-size: 0.8rem; flex: 1; }

.del-btn {
  background: transparent;
  border: 1px solid rgba(239,68,68,0.4);
  color: #f87171;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  margin-left: auto;
  flex-shrink: 0;
}

.del-btn:hover { background: rgba(239,68,68,0.15); border-color: #f87171; }

.err { color: #f87171; font-size: 0.875rem; }

/* ── Ticker ───────────────────────────────── */

body { padding-bottom: 42px; }

.ticker-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 42px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 200;
  overflow: hidden;
}

.ticker-label {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 0.9rem;
  height: 100%;
  display: flex;
  align-items: center;
}

.ticker-viewport {
  flex: 1;
  overflow: hidden;
  height: 100%;
  display: flex;
  align-items: center;
}

.ticker-track {
  display: flex;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
}

.ticker-track:hover { animation-play-state: paused; }

.ticker-item {
  font-size: 0.82rem;
  padding: 0 1.75rem;
  color: var(--text);
}

.ticker-item .owner { color: var(--accent); font-weight: 600; }
.ticker-item .score { font-weight: 700; font-variant-numeric: tabular-nums; }
.ticker-item .time  { color: var(--muted); }
.ticker-item .live  { color: var(--green); font-weight: 700; }

.ticker-sep {
  color: var(--border-light);
  flex-shrink: 0;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ── Draw table cells ─────────────────────── */

.draw-name { font-weight: 600; white-space: nowrap; }
.draw-teams { display: flex; flex-wrap: wrap; gap: 0.3rem; }

/* ── Responsive ───────────────────────────── */

@media (max-width: 680px) {

  /* Header */
  header { flex-direction: column; gap: 0; padding: 0 1rem; }
  .header-title { padding: 0.75rem 0 0; }

  /* Nav — hide scrollbar but keep swipe */
  nav { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  nav::-webkit-scrollbar { display: none; }
  .nav-btn { padding: 0 0.85rem; min-height: 44px; font-size: 0.82rem; }

  /* Main */
  main { padding: 1.25rem 1rem; }

  /* Prize banner — 2×2 grid */
  .prize-banner { grid-template-columns: 1fr 1fr; }

  /* Standings — hide teams, keep pos/name/badge readable */
  .standing-row {
    grid-template-columns: 2.25rem 1fr auto;
    gap: 0.5rem;
    padding: 0.75rem 0.85rem;
  }
  .standing-teams { display: none; }

  /* Fixtures — drop meta column, truncate names */
  .fixture { grid-template-columns: 1fr 4rem 1fr; gap: 0.5rem; padding: 0.6rem 0.75rem; }
  .fixture .meta { display: none; }
  .fixture .home,
  .fixture .away { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.8rem; }
  .fixture .score { font-size: 0.9rem; min-width: 3rem; }

  /* Draw table — stack into cards on mobile */
  .draw-table-wrap table,
  .draw-table-wrap tbody { display: block; }
  .draw-table-wrap thead { display: none; }
  .draw-table-wrap tr {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
  }
  .draw-table-wrap tr:last-child { border-bottom: none; }
  .draw-table-wrap td { padding: 0; border: none; }
  .draw-name { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
  .draw-teams .team-pill { font-size: 0.75rem; }

  /* Admin form — stack inputs full-width */
  #add-participant-form { flex-direction: column; }
  #add-participant-form input { width: 100%; }
  #add-participant-form button { width: 100%; padding: 0.65rem; min-height: 44px; }

  /* Config form — 2-column grid */
  #config-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  #config-form input { width: 100%; }
  #config-form button { grid-column: 1 / -1; padding: 0.65rem; min-height: 44px; }

  /* Admin participant list — hide team names on smallest screens */
  .admin-participant-row span { display: none; }
  .admin-participant-row strong { flex: 1; }

  /* Buttons — larger touch targets globally */
  button { min-height: 40px; }

  /* Ticker */
  .ticker-label { font-size: 0.6rem; padding: 0 0.6rem; letter-spacing: 0.06em; }
  .ticker-item { font-size: 0.78rem; padding: 0 1.25rem; }
}

/* Small phones */
@media (max-width: 380px) {
  .header-title h1 { font-size: 0.95rem; }
  .prize-banner { grid-template-columns: 1fr; }
  .prize-item .amount { font-size: 1.1rem; }
  .standing-row { grid-template-columns: 1.75rem 1fr auto; }
  .standing-pos { font-size: 0.95rem; }
}
