:root {
  --bg: #0d0b14;
  --surface: #17141f;
  --surface-2: #1f1b2b;
  --text: #f5f3ff;
  --hint: #9b96ad;
  --accent: #00ff87;
  --accent-2: #3fd0ff;
  --brand: #38003c;
  --brand-glow: rgba(0, 255, 135, 0.18);
  --danger: #ff4d6d;
  --success: #00e07a;
  --warning: #ffb84d;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(0, 255, 135, 0.10), transparent 60%),
    radial-gradient(800px 460px at 96% 4%, rgba(63, 208, 255, 0.09), transparent 62%),
    radial-gradient(700px 500px at 50% 108%, rgba(140, 82, 255, 0.10), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(13, 11, 20, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-size: 15px;
  box-shadow: 0 4px 14px var(--brand-glow);
}

.brand-text { min-width: 0; }

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
  line-height: 1.1;
  white-space: nowrap;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--hint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

.round-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(0,255,135,0.16), rgba(63,208,255,0.14));
  border: 1px solid rgba(0, 255, 135, 0.3);
  color: var(--accent);
  white-space: nowrap;
}

.round-badge.locked {
  background: rgba(255, 77, 109, 0.12);
  border-color: rgba(255, 77, 109, 0.32);
  color: var(--danger);
}

/* ---------- Layout ---------- */

.content {
  flex: 1;
  padding: 14px 14px 100px;
  max-width: 620px;
  width: 100%;
  margin: 0 auto;
}

.hidden { display: none !important; }

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 70px 0;
  color: var(--hint);
  gap: 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 15px;
  margin-bottom: 12px;
  animation: rise 0.28s ease both;
}

.section-title {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 20px 6px 10px;
}

.section-title:first-child { margin-top: 2px; }

/* ---------- Fixture kartasi ---------- */

.fixture-head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.team-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.team-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.45));
}

.team-logo-fallback {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04));
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.team-name {
  font-size: 12.5px;
  font-weight: 700;
  text-align: center;
  line-height: 1.25;
  color: var(--text);
  word-break: break-word;
}

.middle-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
}

.vs-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--hint);
  letter-spacing: 0.14em;
}

.kickoff-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.kickoff-date {
  font-size: 10px;
  color: var(--hint);
  white-space: nowrap;
}

.final-score {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.status-pill.open { background: rgba(0,255,135,0.12); color: var(--accent); }
.status-pill.locked { background: rgba(255,77,109,0.13); color: var(--danger); }
.status-pill.finished { background: rgba(0,224,122,0.13); color: var(--success); }
.status-pill.cancelled { background: rgba(155,150,173,0.14); color: var(--hint); }

.card-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.my-pred-text {
  font-size: 12.5px;
  color: var(--hint);
}

.my-pred-text b { color: var(--text); font-weight: 800; }

.points-badge {
  font-size: 11.5px;
  font-weight: 900;
  padding: 4px 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04231a;
}

.points-badge.zero {
  background: rgba(155, 150, 173, 0.2);
  color: var(--hint);
}

/* ---------- Hisob kiritish (raqamli input) ---------- */

.score-entry {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

.score-input {
  width: 66px;
  height: 60px;
  border-radius: 16px;
  border: 1.5px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-size: 27px;
  font-weight: 900;
  text-align: center;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  -moz-appearance: textfield;
}

.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.score-input:focus {
  border-color: var(--accent);
  background: rgba(0, 255, 135, 0.07);
  box-shadow: 0 0 0 4px rgba(0, 255, 135, 0.12);
}

.score-input::placeholder { color: rgba(155, 150, 173, 0.45); font-weight: 700; }

.score-sep {
  font-size: 24px;
  font-weight: 900;
  color: var(--hint);
}

/* ---------- Tugmalar ---------- */

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04231a;
  font-size: 14.5px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.15s ease;
  margin-top: 12px;
}

.btn:active { transform: scale(0.985); opacity: 0.9; }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn.danger { background: linear-gradient(135deg, #ff4d6d, #ff7a5c); color: #fff; }
.btn.saved { background: linear-gradient(135deg, #00e07a, #00c2ff); }

.btn-row { display: flex; gap: 9px; margin-top: 12px; }
.btn-row .btn { flex: 1; margin-top: 0; }

/* ---------- Jadval ---------- */

.table-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}

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

.rank {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-weight: 900;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--hint);
}

.rank.top1 { background: linear-gradient(135deg, #ffd94d, #ffab00); color: #3a2600; }
.rank.top2 { background: linear-gradient(135deg, #e2e8f0, #a8b3c4); color: #1f2733; }
.rank.top3 { background: linear-gradient(135deg, #e8a56a, #c76f2f); color: #2e1400; }

.player-name { flex: 1; font-weight: 700; font-size: 14px; min-width: 0; }
.player-meta { font-size: 11px; color: var(--hint); font-weight: 500; }

.player-points {
  font-weight: 900;
  font-size: 17px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.history-round {
  font-weight: 800;
  font-size: 14.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.history-top { font-size: 12.5px; color: var(--hint); line-height: 1.7; }
.history-top b { color: var(--text); }

.empty-state {
  text-align: center;
  color: var(--hint);
  padding: 46px 18px;
  font-size: 13.5px;
  line-height: 1.6;
}

.empty-icon { font-size: 38px; display: block; margin-bottom: 12px; opacity: 0.55; }

/* ---------- Tabbar ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgba(13, 11, 20, 0.9);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 20;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 0;
  background: none;
  border: none;
  color: var(--hint);
  font-size: 10.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.16s ease;
}

.tab-btn.active { color: var(--accent); }
.tab-icon { font-size: 19px; line-height: 1; }

/* ---------- Admin ---------- */

.admin-note {
  font-size: 12.5px;
  color: var(--hint);
  line-height: 1.6;
  margin: 0 0 4px;
}

.admin-fixture {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.admin-mini-logo { width: 22px; height: 22px; object-fit: contain; flex-shrink: 0; }

.result-inputs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 12px 0;
}

.result-inputs .score-input { width: 58px; height: 52px; font-size: 22px; }

/* ---------- Kirish kodi ---------- */

.gate-card {
  max-width: 320px;
  margin: 60px auto 0;
  text-align: center;
}

.gate-icon { font-size: 40px; margin-bottom: 10px; }

.gate-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 6px;
}

.gate-note {
  font-size: 13px;
  color: var(--hint);
  line-height: 1.6;
  margin-bottom: 18px;
}

.gate-input {
  width: 100%;
  height: 48px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.18s ease;
}

.gate-input:focus { border-color: var(--accent); }

.gate-error {
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 10px;
}

/* ---------- Liga (haqiqiy chempionat) ---------- */

.subtab-row {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.subtab-btn {
  flex: 1;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--hint);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 8px 10px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.subtab-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0d0b14;
  border-color: transparent;
}

.league-table-card { padding: 4px 10px; }

.league-table-row {
  display: grid;
  grid-template-columns: 20px 1fr 22px 22px 22px 22px 32px 38px;
  align-items: center;
  gap: 4px;
  padding: 9px 2px;
  font-size: 11.5px;
  border-bottom: 1px solid var(--border);
}

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

.league-table-row.header {
  color: var(--hint);
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.league-table-row.top4 .lt-rank { color: var(--accent); }

.lt-rank {
  font-weight: 800;
  color: var(--hint);
  text-align: center;
}

.lt-team {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
}

.lt-logo { width: 18px; height: 18px; object-fit: contain; flex-shrink: 0; }

.lt-team-name {
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lt-stat {
  text-align: center;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}

.lt-pts {
  text-align: center;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------- Shaxsiy statistika ---------- */

.stats-card {
  background: linear-gradient(160deg, rgba(0, 255, 135, 0.08), var(--surface-2));
  border-color: var(--border-strong);
}

.stats-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.stats-points-value {
  font-size: 34px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.stats-points-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--hint);
  margin-left: 6px;
}

.stats-rank {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.stat-chip {
  background: rgba(255, 255, 255, 0.045);
  border-radius: var(--radius-sm);
  padding: 9px 4px;
  text-align: center;
}

.stat-chip.exact .stat-value { color: var(--accent); }
.stat-chip.miss .stat-value { color: var(--hint); }

.stat-value {
  font-size: 19px;
  font-weight: 900;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--hint);
  margin-top: 2px;
  letter-spacing: 0.2px;
}

.stats-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--hint);
  line-height: 1.6;
}

.prediction-rank {
  min-width: 22px;
  font-weight: 800;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}

.prediction-exact { font-size: 11.5px; }

/* ---------- Barcha bashoratlar ---------- */

.all-predictions {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.link-btn {
  width: 100%;
  background: none;
  border: none;
  color: var(--accent-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 0;
  cursor: pointer;
  text-align: left;
}

.link-btn:active { opacity: 0.7; }

.prediction-list {
  margin-top: 8px;
  font-size: 13px;
  color: var(--hint);
}

.prediction-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
}

.prediction-row + .prediction-row { margin-top: 4px; }

.prediction-row.me {
  background: rgba(0, 255, 135, 0.09);
  color: var(--text);
}

.prediction-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prediction-score {
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.prediction-empty {
  padding: 8px 2px;
  font-size: 12.5px;
}

.time-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  margin-top: 4px;
}

.time-input:focus { border-color: var(--accent); }

/* ---------- Taklifnomalar ---------- */

.invite-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.invite-info { flex: 1; min-width: 120px; }

.invite-name {
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
}

.invite-code {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: "SF Mono", "IBM Plex Mono", ui-monospace, monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-2);
  letter-spacing: 1px;
  margin-top: 4px;
  padding: 6px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(63, 208, 255, 0.08);
  cursor: pointer;
}

.invite-code:active { transform: scale(0.97); background: rgba(63, 208, 255, 0.16); }

.invite-copy-icon { font-size: 13px; opacity: 0.8; }

.invite-row .btn-row {
  margin-top: 0;
  width: 100%;
}

.admin-fixture-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--hint);
  margin-top: 2px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(31, 27, 43, 0.97);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 60;
  opacity: 0;
  transition: opacity 0.24s ease, transform 0.24s ease;
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

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