:root {
  /* دورة الشهيد حاتم بالطاهر — poster palette: deep green + gold */
  --bg: #06231a;
  --bg-2: #0a3324;
  --card: #0d3626;
  --card-2: #0f4630;
  --ink: #f3ecd8;
  --ink-soft: #a8bfae;
  --gold: #e2b64b;
  --gold-bright: #f2d478;
  --gold-dark: #8a6a1e;
  --gold-ink: #2e2205;
  --line: rgba(226, 182, 75, 0.22);
  --green-accent: #2ea169;
  --red: #e06a6a;
  --radius: 14px;
  --shadow: 0 3px 14px rgba(0, 0, 0, 0.35);
  --good: #2ea169;
  --mid: #dfa036;
  --low: #7d8b99;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: radial-gradient(1200px 700px at 50% -10%, var(--bg-2), var(--bg) 70%) fixed, var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: 76px; /* room for bottom nav */
}

.hidden { display: none !important; }

/* ---------- header ---------- */
.topbar {
  background: linear-gradient(150deg, #0b3a28, #062015);
  color: var(--ink);
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 2px solid var(--gold);
  box-shadow: 0 3px 16px rgba(0, 0, 0, 0.5);
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 46px; height: 52px; object-fit: contain; flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}
.brand h1 {
  font-size: 17px; font-weight: 900; letter-spacing: 0.3px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.25;
}
.brand-year { font-size: 11px; font-weight: 800; color: var(--gold); letter-spacing: 2px; }
.brand-tag { font-size: 10px; color: var(--ink-soft); }
.lang-btn {
  background: rgba(226, 182, 75, 0.12);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  flex-shrink: 0;
}
.lang-btn:active { background: rgba(226, 182, 75, 0.3); }

/* ---------- layout ---------- */
#main { max-width: 960px; margin: 0 auto; padding: 16px; }
.view { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card h2 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--gold-bright);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- bottom nav ---------- */
.bottomnav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  background: #071f16;
  border-top: 1.5px solid var(--gold);
  display: flex;
  z-index: 40;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 8px 2px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.nav-item svg { width: 22px; height: 22px; fill: currentColor; }
.nav-item.active { color: var(--gold-bright); }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.06s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(180deg, #2a9265, #1c6e4a); color: #fff; }
.btn-gold { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: var(--gold-ink); }
.btn-ghost { background: rgba(226, 182, 75, 0.08); color: var(--gold-bright); border: 1px solid var(--line); }
.btn-danger { background: rgba(224, 106, 106, 0.12); color: var(--red); border: 1px solid rgba(224, 106, 106, 0.4); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }

/* ---------- dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 8px;
  text-align: center;
}
.stat b { display: block; font-size: 26px; font-weight: 900; color: var(--gold-bright); line-height: 1.1; }
.stat span { font-size: 11px; color: var(--ink-soft); font-weight: 600; }

.level-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin-top: 8px; background: rgba(0,0,0,.3); }
.level-bar i.g { background: var(--good); }
.level-bar i.m { background: var(--mid); }
.level-bar i.l { background: var(--low); }
.level-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 11.5px; color: var(--ink-soft); flex-wrap: wrap; }
.level-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 4px; }

.step { display: flex; gap: 12px; align-items: flex-start; }
.step-num {
  min-width: 34px; height: 34px; border-radius: 50%;
  background: var(--card-2); border: 1.5px solid var(--gold); color: var(--gold-bright);
  font-weight: 900; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.step-num.done { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); color: var(--gold-ink); }
.step h3 { font-size: 14.5px; color: var(--ink); }
.step p { font-size: 12.5px; color: var(--ink-soft); margin: 2px 0 10px; }

.status-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); color: var(--ink-soft);
  border: 1px solid transparent;
}
.chip.ok { background: rgba(46, 161, 105, 0.15); color: #5fd39c; border-color: rgba(46, 161, 105, 0.4); }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar .btn { flex: 1; min-width: 130px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select { flex: 1; min-width: 110px; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #082419;
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
}
select option { background: #0d3626; }
label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); display: block; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.check-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(226, 182, 75, 0.07); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; user-select: none;
}
.check-row input { width: 20px; height: 20px; accent-color: var(--gold); flex: none; }
.check-row span { font-weight: 700; font-size: 13.5px; color: var(--gold-bright); }

/* ---------- player list ---------- */
.plist { display: flex; flex-direction: column; }
.prow {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.prow:last-child { border-bottom: none; }
.prow .pname { font-weight: 700; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .pteam { font-size: 11px; color: var(--ink-soft); display: block; font-weight: 600; }
.badge {
  font-size: 10.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; color: #fff; flex-shrink: 0;
}
.badge.good { background: var(--good); }
.badge.mid { background: var(--mid); color: #3a2a05; }
.badge.low { background: var(--low); color: #14202b; }
.badge.gk { background: #3d6fb0; }
.badge.cap {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--gold-ink); min-width: 22px; text-align: center; padding: 3px 7px;
}
.page-badge { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.icon-btn {
  background: rgba(255, 255, 255, 0.07); border: none; border-radius: 8px; width: 32px; height: 32px;
  cursor: pointer; font-size: 14px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.icon-btn.danger { background: rgba(224, 106, 106, 0.14); }

.empty { text-align: center; color: var(--ink-soft); font-size: 13.5px; padding: 26px 10px; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- teams ---------- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.team-card { overflow: hidden; padding: 0; }
.team-head {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  background: linear-gradient(120deg, #0c4530, #093122);
  border-bottom: 1px solid var(--line);
  color: var(--ink); cursor: pointer;
}
.team-logo {
  width: 44px; height: 44px; border-radius: 50%; background: #0a281c;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 18px; color: var(--gold-bright);
  overflow: hidden; flex-shrink: 0; border: 2px solid var(--gold);
}
.team-logo img { width: 100%; height: 100%; object-fit: cover; }
.team-logo.sm { width: 26px; height: 26px; font-size: 12px; border-width: 1px; }
.team-head .tname { font-weight: 800; font-size: 15px; flex: 1; min-width: 0; }
.team-head .tmeta { font-size: 11px; color: var(--ink-soft); font-weight: 600; display: block; }
.team-body { padding: 6px 16px 12px; }
.team-actions { display: flex; gap: 8px; padding: 0 16px 12px; }
.caret { transition: transform 0.18s; color: var(--gold); }
.team-card.open .caret { transform: rotate(180deg); }

/* ---------- matches ---------- */
.match-card {
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px;
}
.match-teams { display: flex; align-items: center; gap: 8px; }
.match-side { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.match-side.away { flex-direction: row-reverse; text-align: end; }
.match-side .mname { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-score {
  min-width: 74px; text-align: center; font-weight: 900; font-size: 17px;
  background: rgba(226, 182, 75, 0.1); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 4px; cursor: pointer;
  color: var(--gold-bright); flex-shrink: 0;
}
.match-score.unplayed { color: var(--ink-soft); font-size: 12px; }
.match-pens { text-align: center; font-size: 11px; color: var(--ink-soft); margin-top: 5px; font-weight: 700; }
.match-tag {
  font-size: 10.5px; color: var(--gold); font-weight: 800; margin-bottom: 6px;
  display: flex; justify-content: space-between; gap: 8px;
}
.match-tag .mdate { color: var(--ink-soft); }
.winner { color: var(--gold-bright); }

.section-title {
  font-size: 15px; font-weight: 900; color: var(--gold-bright);
  display: flex; align-items: center; gap: 8px; margin: 4px 2px 0;
}
.section-title::before, .section-title::after {
  content: ''; flex: 1; height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.section-title::before { max-width: 40px; }

/* ---------- standings ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.standings { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 420px; }
.standings th {
  font-size: 11px; color: var(--gold); font-weight: 800;
  padding: 7px 6px; border-bottom: 2px solid var(--line); text-align: center;
}
.standings td { padding: 8px 6px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); text-align: center; font-weight: 600; }
.standings .tcell { display: flex; align-items: center; gap: 8px; text-align: start; }
.standings .tcell span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; font-weight: 700; }
.standings tr.q td { background: rgba(46, 161, 105, 0.1); }
.standings tr.qline td { border-bottom: 2.5px dashed var(--gold); }
.standings .rank-n { font-weight: 900; color: var(--ink-soft); }
.standings .pts { font-weight: 900; color: var(--gold-bright); }

/* ---------- knockout bracket ---------- */
.bracket-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.bracket { display: flex; gap: 18px; min-width: 640px; }
.bracket-col { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 12px; min-width: 200px; }
.bracket-col h3 { font-size: 12.5px; font-weight: 900; color: var(--gold); text-align: center; }
.bk-match {
  background: linear-gradient(160deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
}
.bk-date { font-size: 10px; font-weight: 800; color: var(--ink-soft); text-align: center; padding: 4px 6px 0; }
.bk-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.bk-row + .bk-row { border-top: 1px solid rgba(255, 255, 255, 0.06); }
.bk-row .mname { flex: 1; font-weight: 700; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-row .sc { font-weight: 900; min-width: 22px; text-align: center; }
.bk-row.win { background: rgba(226, 182, 75, 0.09); }
.bk-row.win .mname, .bk-row.win .sc { color: var(--gold-bright); }
.bk-final { border: 2px solid var(--gold); }
.champion-card {
  text-align: center;
  background: linear-gradient(150deg, #3c2f0d, #191002);
  border: 2px solid var(--gold);
}
.champion-card .cup { font-size: 44px; }
.champion-card .cname { font-size: 20px; font-weight: 900; color: var(--gold-bright); margin-top: 4px; }

/* ---------- modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 10, 6, 0.7); }
.modal {
  position: relative; background: linear-gradient(170deg, #10402c, #0b2e20);
  border: 1px solid var(--gold); border-bottom: none;
  width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 86vh; overflow-y: auto; animation: slideUp 0.22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 16px; font-weight: 900; margin-bottom: 14px; color: var(--gold-bright); }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

.logo-pick { display: flex; align-items: center; gap: 12px; }
.logo-pick .team-logo { width: 54px; height: 54px; }

.score-entry { display: flex; align-items: center; justify-content: center; gap: 10px; }
.score-entry input { width: 64px; text-align: center; font-size: 22px; font-weight: 900; padding: 8px 4px; }
.score-entry .vs { font-weight: 900; color: var(--gold); }
.score-team { flex: 1; text-align: center; font-size: 12px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 86px; inset-inline: 0; margin: 0 auto; width: fit-content;
  max-width: 88vw; background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--gold-ink); font-size: 13.5px; font-weight: 800;
  padding: 10px 20px; border-radius: 999px; z-index: 80; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.2s ease; text-align: center;
}
.toast.error { background: #b34545; color: #fff; }

.muted { color: var(--ink-soft); font-size: 12.5px; }

/* ---------- live match ---------- */
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.live-badge {
  color: #ff6b6b; font-weight: 900; font-size: 11px; letter-spacing: 0.5px;
  animation: pulse 1.4s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.match-card.is-live { border-color: rgba(255, 107, 107, 0.55); }
.match-card { cursor: pointer; }
.match-big .match-score { font-size: 22px; min-width: 86px; }
.match-big .mname { font-size: 15px; }

.live-score {
  text-align: center; font-size: 15px; font-weight: 800; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.live-score b { font-size: 26px; color: var(--gold-bright); }
.live-cols { display: flex; gap: 10px; }
.live-side {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px;
  background: rgba(0, 0, 0, 0.18); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px;
}
.live-side-name {
  display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 12.5px;
  overflow: hidden; white-space: nowrap;
}
.live-btns { display: flex; gap: 6px; }
.live-btns .btn { flex: 1; padding-inline: 4px; }

.ev-list { display: flex; flex-direction: column; }
.ev-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06); font-size: 13.5px;
}
.ev-row:last-child { border-bottom: none; }
.ev-row .ev-name { flex: 1; font-weight: 700; min-width: 0; }
.ev-row .ev-name small { display: block; color: var(--ink-soft); font-size: 11px; }

/* ---------- login ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card { width: 100%; max-width: 380px; padding: 26px 22px; }
.login-logo { display: block; margin: 0 auto 10px; width: 72px; height: 82px; object-fit: contain; }
.login-brand {
  text-align: center; font-size: 18px; font-weight: 900;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-err { color: var(--red); font-weight: 700; font-size: 13px; margin-top: 10px; text-align: center; }
.warn-note {
  background: rgba(226, 182, 75, 0.1); border: 1px solid var(--line); color: var(--gold-bright);
  border-radius: 10px; padding: 9px 13px; font-size: 12.5px; font-weight: 700;
}

/* ---------- desktop ---------- */
@media (min-width: 768px) {
  body { padding-bottom: 20px; }
  .bottomnav {
    position: sticky; top: 74px; bottom: auto;
    max-width: 960px; margin: 0 auto; border-top: none;
    border-bottom: 1.5px solid var(--gold);
    border-radius: 0 0 14px 14px; box-shadow: var(--shadow);
  }
  .nav-item { flex-direction: row; gap: 8px; font-size: 13px; padding: 12px; }
  .modal-root { align-items: center; }
  .modal { border-radius: 18px; border-bottom: 1px solid var(--gold); }
  .brand h1 { font-size: 21px; }
  .brand-logo { width: 54px; height: 62px; }
  .stat b { font-size: 32px; }
  .toast { bottom: 30px; }
}
