/* =========================================================
   كلاسيكو — نظام التصميم
   لوحة الألوان: ليل الملعب + كشّافات بيضاء + لمسة بطولة ذهبية
   ========================================================= */

:root{
  --bg: #0B0F0E;
  --surface: #111715;
  --surface-2: #161D1B;
  --surface-3: #1C2421;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.16);

  --text: #F2F5F3;
  --text-muted: #8B978F;
  --text-faint: #5C6864;

  --green: #21C46B;
  --green-dim: #163A29;
  --gold: #E8B339;
  --gold-dim: #3A2E12;
  --red: #E1564B;
  --red-dim: #3A1B17;

  --font-display: "Tajawal", "IBM Plex Sans Arabic", sans-serif;
  --font-body: "IBM Plex Sans Arabic", "Tajawal", sans-serif;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 22px;
  --shadow-card: 0 8px 24px rgba(0,0,0,0.35);
}

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

body{
  background: var(--bg);
  background-image:
    radial-gradient(circle at 50% -10%, rgba(33,196,107,0.10), transparent 55%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0px, rgba(255,255,255,0.012) 1px, transparent 1px, transparent 64px);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  overscroll-behavior-y: none;
}

h1,h2,h3,h4,.display{ font-family: var(--font-display); letter-spacing: 0; }

button{ font-family: inherit; }
input, select, textarea{ font-family: inherit; }

::selection{ background: var(--green-dim); }

a{ color: inherit; }

/* ---------- App shell ---------- */
#app{
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 86px;
}

.topbar{
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, rgba(11,15,14,0.97), rgba(11,15,14,0.88));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 16px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand{ display:flex; align-items:center; gap:10px; }
.brand-mark{
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--green);
  display:flex; align-items:center; justify-content:center;
  position: relative;
  flex-shrink: 0;
}
.brand-mark .dot{ width:7px; height:7px; border-radius:50%; background: var(--gold); }

.brand-name{ font-weight: 800; font-size: 20px; }
.brand-tag{ font-size: 11px; color: var(--text-muted); margin-top: -2px; }

.installbtn{
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  display: none;
}
.installbtn.show{ display:inline-flex; align-items:center; gap:6px; }

main{ flex: 1; padding: 18px 16px 24px; }

.screen{ display: none; animation: fadein .25s ease; }
.screen.active{ display: block; }

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

.section-title{
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 22px 2px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before{
  content:"";
  width: 4px; height: 14px;
  background: var(--green);
  border-radius: 2px;
  display:inline-block;
}
.section-title:first-child{ margin-top: 2px; }

/* ---------- Cards ---------- */
.card{
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 16px;
}

.field{ margin-bottom: 14px; }
.field label{
  display:block; font-size: 12.5px; color: var(--text-muted);
  margin-bottom: 7px; font-weight: 600;
}
.field input[type=text], .field input[type=number], .field input[type=date], .field select, .field textarea{
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus{ border-color: var(--green); }
.field textarea{ resize: vertical; min-height: 64px; }
.field-row{ display:flex; gap: 10px; }
.field-row .field{ flex: 1; }

.btn{
  display: inline-flex; align-items:center; justify-content:center; gap:8px;
  border-radius: var(--radius-s);
  padding: 12px 18px;
  font-weight: 700;
  font-size: 14.5px;
  border: 1px solid transparent;
  cursor: pointer;
  width: 100%;
  transition: transform .08s, filter .15s;
}
.btn:active{ transform: scale(0.98); }
.btn-primary{ background: var(--green); color: #06140C; }
.btn-primary:hover{ filter: brightness(1.07); }
.btn-gold{ background: var(--gold); color: #241B05; }
.btn-ghost{ background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.btn-danger{ background: var(--red-dim); color: var(--red); border-color: rgba(225,86,75,0.35); }
.btn-sm{ padding: 8px 12px; font-size: 12.5px; width: auto; }

.empty{
  text-align:center;
  padding: 36px 16px;
  color: var(--text-muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-m);
}
.empty .empty-icon{ font-size: 30px; margin-bottom: 8px; opacity:.7; }
.empty .empty-title{ color: var(--text); font-weight: 700; margin-bottom: 4px; }
.empty .empty-sub{ font-size: 13px; }

/* ---------- Scoreboard (signature element) ---------- */
.scoreboard{
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 18px 14px 0;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-card);
}
.scoreboard::before{
  content:"";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(33,196,107,0.12), transparent 60%);
  pointer-events: none;
}
.scoreboard-row{
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  position: relative;
}
.sb-side{ text-align: center; min-width: 0; }
.sb-side select{
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-s);
  padding: 9px 6px;
  font-size: 12.5px;
  text-align: center;
  margin-bottom: 10px;
}
.sb-player{
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-score-display{
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 52px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sb-side.left .sb-score-display{ color: var(--green); }
.sb-side.right .sb-score-display{ color: var(--gold); }
.sb-stepper{
  display:flex; align-items:center; justify-content:center; gap: 10px;
  margin-top: 10px;
}
.sb-stepper button{
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
.sb-vs{
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 13px;
  color: var(--text-faint);
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  width: 34px; height: 34px;
  display:flex; align-items:center; justify-content:center;
}
.scoreboard-strip{
  margin: 18px -14px 0;
  padding: 8px 14px;
  background: var(--surface-3);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--text-muted);
  display:flex; justify-content: space-between;
  letter-spacing: .3px;
}
.scoreboard-strip b{ color: var(--gold); font-weight: 700; }

/* mini scoreboard used in history/draw results */
.mini-sb{
  display:flex; align-items:center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 12px 14px;
  margin-bottom: 10px;
}
.mini-sb .msb-team{ flex:1; min-width:0; }
.mini-sb .msb-name{ font-weight: 700; font-size: 14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mini-sb .msb-club{ font-size: 11.5px; color: var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mini-sb .msb-team.right{ text-align: left; }
.mini-sb .msb-score{
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 20px;
  background: var(--surface-3);
  border-radius: var(--radius-s);
  padding: 6px 10px;
  white-space: nowrap;
}
.mini-sb .win{ color: var(--green); }
.mini-sb .lose{ color: var(--text-faint); }
.mini-sb .draw{ color: var(--gold); }
.mini-sb-meta{
  display:flex; justify-content: space-between; align-items:center;
  font-size: 11px; color: var(--text-faint); margin: -2px 2px 8px;
}
.mini-sb-notes{
  font-size: 12.5px; color: var(--text-muted);
  background: var(--surface-2); border-radius: var(--radius-s);
  padding: 8px 10px; margin: 6px 0 12px;
  border-right: 2px solid var(--gold);
}
.history-item{ margin-bottom: 18px; }
.history-actions{ display:flex; gap:8px; justify-content:flex-end; }

/* ---------- Standings table ---------- */
.standings-list{ display:flex; flex-direction:column; gap:8px; }
.standing-row{
  display:grid;
  grid-template-columns: 28px 1fr auto;
  align-items:center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  padding: 12px 14px;
}
.standing-row.rank-1{ border-color: rgba(232,179,57,0.5); background: linear-gradient(90deg, var(--gold-dim), var(--surface) 60%); }
.standing-row.rank-2{ border-color: rgba(255,255,255,0.18); }
.standing-row.rank-3{ border-color: rgba(225,86,75,0.25); }
.standing-rank{
  font-family: var(--font-display); font-weight: 900; font-size: 15px;
  color: var(--text-muted); text-align:center;
}
.standing-row.rank-1 .standing-rank{ color: var(--gold); }
.standing-name{ font-weight: 700; font-size: 14.5px; }
.standing-sub{ font-size: 11.5px; color: var(--text-muted); display:flex; gap:10px; margin-top:3px; flex-wrap: wrap; }
.standing-ratio{ text-align:left; }
.standing-ratio .num{ font-family: var(--font-display); font-weight: 900; font-size: 19px; color: var(--green); }
.standing-ratio .lbl{ font-size: 10px; color: var(--text-faint); }

.sort-bar{ display:flex; gap:8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 2px; }
.chip{
  flex-shrink:0;
  font-size: 12.5px; font-weight: 600;
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.chip.active{ background: var(--green-dim); border-color: var(--green); color: var(--green); }

/* ---------- Players list ---------- */
.player-row{
  display:flex; align-items:center; justify-content:space-between;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 13px 14px; margin-bottom: 8px;
}
.player-avatar{
  width: 36px; height:36px; border-radius:50%;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-family: var(--font-display); font-size: 14px; color: var(--green);
  flex-shrink:0;
}
.player-info{ display:flex; align-items:center; gap:10px; min-width:0; }
.player-name{ font-weight:700; font-size:14.5px; }
.player-meta{ font-size: 11.5px; color: var(--text-muted); }

/* ---------- Draw ---------- */
.draw-pool{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom: 6px; }
.draw-pill{
  padding: 9px 14px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13px; cursor:pointer; user-select:none; color: var(--text-muted);
}
.draw-pill.selected{ background: var(--green-dim); border-color: var(--green); color: var(--green); font-weight:700; }
.draw-result{ display:flex; flex-direction:column; gap:10px; margin-top: 16px; }
.draw-pair{
  display:grid; grid-template-columns: 1fr auto 1fr; align-items:center; gap:8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 14px; animation: pop .35s ease;
}
@keyframes pop{ from{ opacity:0; transform: scale(.92); } to{ opacity:1; transform:none; } }
.draw-side{ text-align:center; }
.draw-side .dn{ font-weight:800; font-size:14px; }
.draw-side .dc{ font-size:11.5px; color: var(--text-muted); margin-top:3px; }
.draw-vs{
  font-family: var(--font-display); font-weight:900; color: var(--gold); font-size: 12px;
  background: var(--surface-3); border-radius:50%; width:30px; height:30px; display:flex; align-items:center; justify-content:center;
}

/* ---------- Stats ---------- */
.stats-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; margin-bottom: 18px; }
.stat-card{
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-m); padding: 14px;
}
.stat-card .si-label{ font-size: 11.5px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .si-name{ font-weight: 800; font-size: 15px; margin-bottom: 2px; }
.stat-card .si-value{ font-family: var(--font-display); font-weight: 900; font-size: 24px; }
.stat-card.gold .si-value{ color: var(--gold); }
.stat-card.green .si-value{ color: var(--green); }
.stat-card.red .si-value{ color: var(--red); }

/* ---------- Bottom nav ---------- */
.tabbar{
  position: fixed; bottom: 0; right: 50%; transform: translateX(50%);
  width: 100%; max-width: 560px;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: linear-gradient(180deg, rgba(17,23,21,0.85), rgba(11,15,14,0.98));
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}
.tab-btn{
  display:flex; flex-direction:column; align-items:center; gap: 4px;
  background: none; border: none; color: var(--text-faint);
  font-size: 10.5px; padding: 6px 2px; cursor: pointer;
  font-family: var(--font-body); font-weight: 600;
}
.tab-btn .ti{ font-size: 18px; line-height:1; }
.tab-btn.active{ color: var(--green); }
.tab-btn.active .ti{ transform: translateY(-1px); }

/* ---------- Toast ---------- */
.toast{
  position: fixed; bottom: 96px; right: 50%; transform: translateX(50%) translateY(20px);
  background: var(--surface-3); border: 1px solid var(--line-strong);
  color: var(--text); padding: 11px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-card);
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 50;
  white-space: nowrap;
}
.toast.show{ opacity:1; transform: translateX(50%) translateY(0); }

/* ---------- Modal ---------- */
.modal-overlay{
  position: fixed; inset:0; background: rgba(0,0,0,0.6);
  display:none; align-items: flex-end; justify-content:center; z-index: 60;
  backdrop-filter: blur(2px);
}
.modal-overlay.show{ display:flex; }
.modal{
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: slideup .22s ease;
}
@keyframes slideup{ from{ transform: translateY(30px); opacity:0;} to{ transform:none; opacity:1;} }
.modal h3{ margin: 0 0 14px; font-size: 16px; }
.modal-actions{ display:flex; gap:10px; margin-top: 6px; }

/* helper */
.row-gap{ display:flex; gap:10px; }
.flex1{ flex:1; }
.text-muted{ color: var(--text-muted); }
.mt8{ margin-top:8px; } .mt16{ margin-top:16px; }

@media (max-width: 380px){
  .sb-score-display{ font-size: 42px; }
}
