/* خبير المونديال — WC26-inspired palette: deep navy base, electric blue actions,
   red for live/danger, trophy gold reserved for points & medals. */
:root {
  --bg: #03122B;
  --bg2: #051C3F;
  --card: #0A2348;
  --card2: #11305E;
  --line: rgba(255, 255, 255, .09);
  --text: #F2F6FF;
  --muted: #93A5C4;
  --accent: #0A84FF;
  --accent-press: #045694;
  --gold: #F0C44C;
  --red: #F43056;
  --green: #30D158;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  font-family: "Cairo", Tahoma, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  color: var(--text);
  min-height: 100%;
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

/* icons */
.ic { width: 20px; height: 20px; fill: currentColor; vertical-align: -4px; }
.ic-gold { fill: var(--gold); }
.ic-sm { width: 15px; height: 15px; vertical-align: -2px; }

#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 10px;
  background: rgba(3, 18, 43, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; display: flex; align-items: center; gap: 7px; }
.brand b { color: var(--gold); }
.brand .ic { width: 22px; height: 22px; }
#top-me { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
main { padding: 14px 14px 24px; max-width: 560px; margin: 0 auto; }

/* tab bar */
#tabbar {
  position: fixed; bottom: 0; right: 0; left: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: rgba(3, 18, 43, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}
#tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
  min-width: 76px;
}
#tabbar a .ic { width: 22px; height: 22px; }
#tabbar a.active { color: var(--accent); }
#tabbar a.active .ic { fill: var(--accent); }

/* cards & generic */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
h2 { font-size: 17px; margin: 18px 4px 10px; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
button, .btn {
  font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 11px 18px; transition: opacity .15s, transform .1s; text-decoration: none; display: inline-block;
}
button:disabled { opacity: .45; cursor: default; }
button:active, .btn:active { transform: scale(.97); }
.btn-gold { background: var(--gold); color: #03122B; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
input[type=email], input[type=text], input[type=password] {
  width: 100%; font-family: inherit; font-size: 16px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
input:focus, select:focus { outline: 2px solid var(--accent); }
label { font-size: 14px; font-weight: 600; display: block; margin: 14px 0 6px; }
select {
  width: 100%; font-family: inherit; font-size: 15px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  appearance: none; -webkit-appearance: none;
}
.check-row { display: flex; gap: 10px; align-items: center; font-size: 14px; font-weight: 600; margin: 14px 0 0; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* day groups + match cards */
.day-head {
  font-size: 14px; font-weight: 700; color: var(--accent);
  margin: 18px 4px 8px; display: flex; justify-content: space-between; align-items: center;
}
.match { padding: 12px; }
.match-top { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.live { color: var(--red); font-weight: 800; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.team { display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; text-align: center; }
.team img {
  width: 44px; height: 44px; object-fit: cover; border-radius: 50%;
  background: var(--card2); box-shadow: 0 3px 10px rgba(0, 0, 0, .5);
}
.team .ph {
  width: 44px; height: 44px; border-radius: 50%; background: var(--card2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: var(--muted); border: 2px dashed var(--line);
  font-family: Poppins, sans-serif;
}
.score-mid { text-align: center; min-width: 86px; }
.score-final { font-size: 24px; font-weight: 800; direction: ltr; font-family: Poppins, sans-serif; }
.score-sub { font-size: 11px; color: var(--muted); }
.kick-time { font-size: 18px; font-weight: 800; color: var(--text); direction: ltr; font-family: Poppins, sans-serif; }

/* prediction row */
.pred { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.pred-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 8px; direction: ltr; }
.stepper button {
  width: 34px; height: 34px; padding: 0; border-radius: 50%;
  background: var(--card2); font-size: 18px; line-height: 1;
}
.stepper .val { font-size: 20px; font-weight: 800; min-width: 26px; text-align: center; font-family: Poppins, sans-serif; }
.pred-actions { margin-top: 10px; display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.qualifier { margin-top: 10px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.qualifier button { background: var(--card2); font-size: 13px; padding: 8px 14px; }
.qualifier button.sel { background: var(--accent); color: #fff; }
.chip { display: inline-block; font-size: 12px; font-weight: 800; border-radius: 999px; padding: 3px 10px; background: var(--card2); color: var(--muted); }
.chip.win { background: rgba(48, 209, 88, .16); color: var(--green); }
.chip.gold { background: rgba(240, 196, 76, .16); color: var(--gold); }
.chip.lose { background: rgba(244, 48, 86, .14); color: var(--red); }

/* filter pills */
.pills { display: flex; gap: 8px; margin-bottom: 4px; overflow-x: auto; padding: 2px; }
.pills button { background: var(--card); color: var(--muted); font-size: 13px; padding: 8px 16px; border-radius: 999px; white-space: nowrap; }
.pills button.active { background: var(--accent); color: #fff; }

/* leaderboard */
.lb-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.lb-row:last-child { border-bottom: 0; }
.lb-row.me-row { background: rgba(10, 132, 255, .08); border-radius: 10px; }
.lb-rank { font-weight: 800; font-size: 15px; min-width: 30px; text-align: center; color: var(--muted); font-family: Poppins, sans-serif; }
.lb-rank.top { color: var(--gold); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .5);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar .ic { width: 55%; height: 55%; fill: #fff; }
.lb-name { flex: 1; font-weight: 700; font-size: 14px; }
.cflag { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; vertical-align: -3px; margin-inline-start: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.lb-sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.lb-pts { font-weight: 800; color: var(--gold); font-size: 16px; font-family: Poppins, sans-serif; }

/* avatar picker */
.avatar-grid { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 12px; margin-top: 10px; }
.avatar-grid .avatar { width: 64px; height: 64px; cursor: pointer; border: 2px solid transparent; }
@media (max-width: 389px) { .avatar-grid .avatar { width: 56px; height: 56px; } }
@media (max-width: 339px) { .avatar-grid .avatar { width: 48px; height: 48px; } }
.avatar-fill { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.avatar-fill .ic { width: 50%; height: 50%; fill: #fff; }
.avatar-grid .avatar.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10, 132, 255, .3); }
.picker-tabs { display: flex; gap: 8px; margin-top: 8px; }
.picker-tabs button { background: var(--card2); color: var(--muted); font-size: 12px; padding: 6px 14px; border-radius: 999px; }
.picker-tabs button.active { background: var(--accent); color: #fff; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.stat-grid .num { font-size: 22px; font-weight: 800; color: var(--gold); font-family: Poppins, sans-serif; }
.stat-grid .lbl { font-size: 11px; color: var(--muted); }

#toast {
  position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); right: 50%; transform: translateX(50%);
  background: #0A1B36; color: #fff; font-size: 14px; font-weight: 600; border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 22px; z-index: 50; max-width: 90vw; text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
a { color: var(--accent); }

/* hero */
.hero {
  text-align: center; padding: 26px 18px 22px; margin-bottom: 14px;
  background: radial-gradient(120% 140% at 50% 0%, rgba(10, 132, 255, .16) 0%, transparent 55%), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.hero h1 { font-size: 26px; font-weight: 900; color: var(--gold); margin-bottom: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.hero h1 .ic { width: 28px; height: 28px; }
.hero p { font-size: 14px; color: var(--text); line-height: 1.9; max-width: 40ch; margin: 0 auto 14px; }

/* notices */
.notice {
  font-size: 12px; color: var(--gold); background: rgba(240, 196, 76, .08);
  border: 1px solid rgba(240, 196, 76, .25); border-radius: 10px; padding: 9px 12px; margin-top: 14px;
}
.banner {
  font-size: 13px; font-weight: 600; color: #FFD98A; background: rgba(240, 196, 76, .1);
  border: 1px solid rgba(240, 196, 76, .3); border-radius: var(--radius); padding: 11px 14px; margin-bottom: 12px;
}
.banner a { color: var(--gold); font-weight: 800; }

/* skeleton shimmer */
.skel { position: relative; overflow: hidden; background: var(--card); }
.skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .05), transparent);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

/* staggered reveal */
.rise { animation: rise .35s cubic-bezier(.2, .7, .3, 1) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .rise { animation: none; }
  .skel::after { animation: none; }
  .live { animation: none; }
}

/* admin member actions */
.member-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.member-actions[hidden] { display: none; }

/* auth links row */
.auth-links { display: flex; justify-content: space-between; margin-top: 12px; font-size: 13px; }

/* hidden attribute always wins over display rules */
[hidden] { display: none !important; }

/* hero trophy image */
.hero-trophy { height: 120px; margin-bottom: 10px; filter: drop-shadow(0 6px 18px rgba(240, 196, 76, .25)); }

/* community prediction stats */
.cstats { margin-top: 10px; }
.cbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--card2); }
.cbar .ch { background: var(--accent); }
.cbar .cd { background: #5A6B8C; }
.cbar .ca { background: var(--red); }
.cnums { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 5px; font-weight: 600; }

/* knockout qualifier rows (team + method) */
.qualifier { flex-direction: column; align-items: stretch; }
.qrow { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.qrow .muted { min-width: 64px; text-align: start; font-size: 12px; }
.qrow + .qrow { margin-top: 8px; }


/* ---- hard guarantee: never exceed screen width ---- */
html, body { max-width: 100%; overflow-x: hidden; overflow-x: clip; }
img, svg, canvas, video { max-width: 100%; }
main, .card { min-width: 0; }
/* flex/grid children must be allowed to shrink + long tokens (emails, names) must wrap */
.lb-name { min-width: 0; }
.lb-name, .lb-sub, .team div, .hero p, .notice, .banner { overflow-wrap: anywhere; }
.lb-sub[dir="ltr"], .muted[dir="ltr"] { word-break: break-all; }
.cnums { flex-wrap: wrap; gap: 2px 10px; }
.pills { max-width: 100%; }
.stat-grid .num { overflow-wrap: anywhere; font-size: clamp(15px, 5.5vw, 22px); }

/* picker pager + optional sections + crop canvas */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px; }
.pager button { padding: 8px 12px; line-height: 1; }
.pager .ind { font-family: Poppins, sans-serif; font-size: 13px; color: var(--muted); min-width: 52px; text-align: center; direction: ltr; }
.optx summary { font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; margin: 14px 0 8px; list-style-position: inside; }
.optx[open] summary { color: var(--text); }
#crop-cv { border-radius: 50%; background: var(--bg); max-width: 240px; touch-action: none; cursor: grab; border: 2px dashed var(--line); }
#photo-zoom { width: 75%; margin-top: 12px; accent-color: var(--accent); }

/* match card states: live pulses, predicted = calm green, awaiting prediction = amber nudge */
.match { position: relative; }
.m-live { border-color: rgba(244, 48, 86, .45); }
.m-live::before {
  content: ""; position: absolute; inset: -1px; border-radius: var(--radius);
  border: 2px solid var(--red); opacity: 0; pointer-events: none;
  animation: livepulse 1.6s ease-in-out infinite;
}
@keyframes livepulse { 50% { opacity: .55; } }
.m-predicted {
  border-color: rgba(48, 209, 88, .35);
  background: linear-gradient(180deg, rgba(48, 209, 88, .05), transparent 45%), var(--card);
}
.m-needpred {
  border-color: rgba(240, 196, 76, .45);
  background: linear-gradient(180deg, rgba(240, 196, 76, .07), transparent 45%), var(--card);
}
@media (prefers-reduced-motion: reduce) { .m-live::before { animation: none; opacity: .4; } }
