/* Lagbalans – pitch green, chalk lines, bib colours. Mobile first, one-handed use at the pitch. */
*{box-sizing:border-box}
html{color-scheme:light;-webkit-text-size-adjust:100%}
body{margin:0}
[hidden]{display:none!important}
button,input,textarea,select{font:inherit;color:inherit}

:root{
  --bg:#F1F4EF;
  --surface:#FFFFFF;
  --surface-2:#E7EDE6;
  --ink:#11201A;
  --muted:#56675E;
  --faint:#86958C;
  --line:#D4DDD5;
  --pitch:#11774A;
  --pitch-deep:#0B5A37;
  --pitch-ink:#FFFFFF;
  --pitch-soft:#DDEFE5;
  --pitch-card:#11774A;   /* stays dark enough for white text in both themes */
  --gold:#E3A400;
  --danger:#C5372D;
  --warn:#B86E00;
  --ok:#11774A;
  --shadow:0 1px 2px rgba(17,32,26,.06),0 6px 18px -8px rgba(17,32,26,.2);
  --shadow-lg:0 -6px 30px -10px rgba(17,32,26,.25);
  --radius:14px;
  --display:"Bebas Neue","IBM Plex Sans Arabic",Impact,"Arial Narrow",sans-serif;
  --body:"Source Sans 3","IBM Plex Sans Arabic",system-ui,-apple-system,"Segoe UI",sans-serif;
  /* bib colours (team 1..8) */
  --t1:#D7263D;--t2:#1F6FEB;--t3:#1E9E57;--t4:#F2B705;--t5:#F26B1D;--t6:#7B4FD6;--t7:#26292C;--t8:#F3F3EF;
  --tab-h:68px;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    color-scheme:dark;
    --bg:#0B130F;--surface:#131D18;--surface-2:#1B2721;--ink:#E6EFE9;--muted:#9DB0A5;--faint:#6D7F75;--line:#26332C;
    --pitch:#35B677;--pitch-deep:#1F7E50;--pitch-ink:#04130B;--pitch-soft:#173526;--pitch-card:#1A6E45;--gold:#F2C140;--danger:#F06B5F;--warn:#E9A13B;--ok:#35B677;
    --shadow:0 1px 2px rgba(0,0,0,.35),0 8px 22px -8px rgba(0,0,0,.6);--shadow-lg:0 -6px 30px -10px rgba(0,0,0,.7);
    --t7:#0A0C0D;
  }
}
:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#0B130F;--surface:#131D18;--surface-2:#1B2721;--ink:#E6EFE9;--muted:#9DB0A5;--faint:#6D7F75;--line:#26332C;
  --pitch:#35B677;--pitch-deep:#1F7E50;--pitch-ink:#04130B;--pitch-soft:#173526;--pitch-card:#1A6E45;--gold:#F2C140;--danger:#F06B5F;--warn:#E9A13B;--ok:#35B677;
  --shadow:0 1px 2px rgba(0,0,0,.35),0 8px 22px -8px rgba(0,0,0,.6);--shadow-lg:0 -6px 30px -10px rgba(0,0,0,.7);
  --t7:#0A0C0D;
}

body{background:var(--bg);color:var(--ink);font-family:var(--body);font-size:17px;line-height:1.45;-webkit-font-smoothing:antialiased;
  padding-bottom:calc(var(--tab-h) + env(safe-area-inset-bottom,0px) + 24px);min-height:100dvh}
html[lang="ar"] body{font-size:17px;line-height:1.7}
:focus-visible{outline:3px solid var(--pitch);outline-offset:2px;border-radius:6px}
svg:has(> use){width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex:none}
.wrap{max-width:640px;margin-inline:auto;padding-inline:16px}
h1,h2,h3{margin:0;font-family:var(--display);font-weight:400;letter-spacing:.02em;line-height:1}
html[lang="ar"] :is(h1,h2,h3){font-weight:700;letter-spacing:0;line-height:1.3}
p{margin:0}
.muted{color:var(--muted)}
.num{font-variant-numeric:tabular-nums}

/* header */
.top{position:sticky;top:0;z-index:20;background:color-mix(in srgb,var(--bg) 88%,transparent);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);padding-top:env(safe-area-inset-top,0px);border-bottom:1px solid var(--line)}
.top-inner{max-width:640px;margin-inline:auto;padding:10px 16px;display:flex;align-items:center;justify-content:space-between;gap:12px}
.brand{display:flex;align-items:center;gap:10px;min-width:0}
.brand-mark{width:38px;height:38px;border-radius:10px;background:var(--pitch);color:var(--pitch-ink);display:grid;place-items:center;flex:none}
.brand-text{display:grid;line-height:1.1;min-width:0}
.brand-text strong{font-family:var(--display);font-weight:400;font-size:1.5rem;letter-spacing:.04em}
html[lang="ar"] .brand-text strong{font-family:var(--body);font-weight:700;font-size:1.15rem;letter-spacing:0}
.brand-text small{font-size:.8rem;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.lang{display:flex;gap:2px;padding:3px;border-radius:999px;background:var(--surface);border:1px solid var(--line)}
.lang button{min-width:40px;height:36px;border:0;border-radius:999px;background:transparent;color:var(--muted);font-weight:600;font-size:.85rem;cursor:pointer}
.lang button[aria-pressed="true"]{background:var(--ink);color:var(--bg)}

/* bottom tabs */
.tabs{position:fixed;inset-inline:0;bottom:0;z-index:30;display:grid;grid-template-columns:repeat(3,1fr);background:var(--surface);border-top:1px solid var(--line);
  padding-bottom:env(safe-area-inset-bottom,0px);box-shadow:var(--shadow-lg)}
.tab{position:relative;height:var(--tab-h);border:0;background:none;display:grid;place-items:center;align-content:center;gap:3px;color:var(--faint);font-weight:600;font-size:.78rem;cursor:pointer;letter-spacing:.02em}
.tab svg{width:24px;height:24px}
.tab[aria-current="page"]{color:var(--pitch)}
.tab[aria-current="page"]::before{content:"";position:absolute;top:0;inset-inline:28%;height:3px;border-radius:0 0 3px 3px;background:var(--pitch)}
.tab-badge{position:absolute;top:8px;inset-inline-start:calc(50% + 6px);min-width:20px;height:20px;padding:0 6px;border-radius:999px;background:var(--pitch);color:var(--pitch-ink);font-size:.72rem;display:grid;place-items:center;font-weight:700}
@media (min-width:700px){.tabs{inset-inline:auto;left:50%;translate:-50% 0;bottom:14px;width:min(420px,90vw);border:1px solid var(--line);border-radius:20px;overflow:hidden}}

/* view header */
.view{padding-top:18px;animation:in .25s ease}
@keyframes in{from{opacity:0;transform:translateY(6px)}}
.vhead{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin-bottom:14px}
.vhead h1{font-size:2.3rem}
html[lang="ar"] .vhead h1{font-size:1.75rem}
.vhead .row{flex-wrap:nowrap}
.vhead .sub{color:var(--muted);font-size:.95rem;margin-top:4px}
.row{display:flex;gap:8px;flex-wrap:wrap;align-items:center}

/* buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:48px;padding:0 18px;border-radius:12px;border:1px solid transparent;font-weight:700;font-size:1rem;cursor:pointer;text-decoration:none;transition:transform .12s ease,background-color .15s,border-color .15s,opacity .15s;-webkit-tap-highlight-color:transparent}
.btn:active{transform:scale(.97)}
.btn.primary{background:var(--pitch);color:var(--pitch-ink)}
.btn.primary:hover{background:var(--pitch-deep);color:#fff}
.btn.ghost{background:var(--surface);border-color:var(--line);color:var(--ink)}
.btn.ghost:hover{border-color:var(--faint)}
.btn.danger{background:transparent;border-color:color-mix(in srgb,var(--danger) 45%,var(--line));color:var(--danger)}
.btn.block{width:100%}
.btn.big{min-height:58px;font-size:1.1rem;border-radius:14px}
.btn[disabled]{opacity:.45;cursor:not-allowed;transform:none}
.icon-btn{width:48px;height:48px;border-radius:12px;border:1px solid var(--line);background:var(--surface);display:grid;place-items:center;cursor:pointer;color:var(--ink)}

/* cards */
.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}
.card + .card{margin-top:14px}
.card-pad{padding:16px}
.card-title{font-family:var(--display);font-size:1.35rem;letter-spacing:.03em;margin-bottom:10px}
html[lang="ar"] .card-title{font-family:var(--body);font-weight:700;font-size:1.05rem;letter-spacing:0}

/* search */
.search{position:relative;margin-bottom:12px}
.search svg{position:absolute;top:50%;translate:0 -50%;inset-inline-start:14px;color:var(--faint);width:20px;height:20px}
.search input{width:100%;height:50px;border-radius:12px;border:1px solid var(--line);background:var(--surface);padding-inline:44px 14px;font-size:1rem}

/* player list */
.plist{list-style:none;margin:0;padding:0}
.prow{display:flex;align-items:center;gap:12px;width:100%;min-height:62px;padding:8px 14px;border:0;background:none;text-align:start;cursor:pointer;border-bottom:1px solid var(--line)}
.prow:last-child{border-bottom:0}
.prow:hover{background:color-mix(in srgb,var(--pitch) 5%,transparent)}
.avatar{width:40px;height:40px;border-radius:50%;flex:none;display:grid;place-items:center;font-weight:700;font-size:.95rem;background:var(--surface-2);color:var(--muted)}
.lv5 .avatar,.avatar.lv5{background:color-mix(in srgb,var(--gold) 26%,transparent);color:color-mix(in srgb,var(--gold) 60%,var(--ink))}
.pinfo{display:grid;gap:2px;flex:1;min-width:0}
.pname{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.pmeta{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font-size:.82rem;color:var(--muted)}
.chip{display:inline-flex;align-items:center;gap:4px;padding:1px 8px;border-radius:999px;background:var(--surface-2);font-size:.76rem;font-weight:600;color:var(--muted)}
.chip.gk{background:color-mix(in srgb,var(--gold) 22%,transparent);color:color-mix(in srgb,var(--gold) 55%,var(--ink))}
.chip svg{width:14px;height:14px}
.stars{display:inline-flex;gap:1px;direction:ltr}
.stars svg{width:15px;height:15px;stroke-width:1.5;stroke:var(--gold);fill:transparent}
.stars svg.on{fill:var(--gold)}

/* attendance */
.here{display:flex;align-items:center;gap:12px}
.check{width:30px;height:30px;border-radius:9px;border:2px solid var(--line);display:grid;place-items:center;flex:none;transition:background-color .15s,border-color .15s;color:transparent}
.check svg{width:18px;height:18px;stroke-width:3}
.prow[aria-pressed="true"] .check{background:var(--pitch);border-color:var(--pitch);color:var(--pitch-ink)}
.prow[aria-pressed="false"] .pname{color:var(--muted)}

/* today hero: pitch with chalk lines */
.pitch{position:relative;overflow:hidden;border-radius:18px;background:
  repeating-linear-gradient(90deg,var(--pitch-card) 0 46px,color-mix(in srgb,var(--pitch-card) 86%,#000) 46px 92px);color:#fff;padding:18px 18px 16px;margin-bottom:14px;box-shadow:var(--shadow)}
.pitch::before{content:"";position:absolute;inset:10px;border:2px solid rgba(255,255,255,.35);border-radius:10px;pointer-events:none}
.pitch::after{content:"";position:absolute;top:50%;inset-inline-end:-38px;width:120px;height:120px;translate:0 -50%;border:2px solid rgba(255,255,255,.35);border-radius:50%;pointer-events:none}
.pitch-num{font-family:var(--display);font-size:4.2rem;line-height:.9;letter-spacing:.01em;position:relative}
.pitch-label{position:relative;font-weight:600;opacity:.92}
.pitch .row{position:relative;margin-top:12px}
.pitch .btn.ghost{background:rgba(255,255,255,.16);border-color:rgba(255,255,255,.35);color:#fff;min-height:40px;padding:0 14px}

/* settings */
.setting{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 0;border-top:1px solid var(--line)}
.setting:first-of-type{border-top:0;padding-top:4px}
.setting label,.setting .lbl{font-weight:600}
.stepper{display:flex;align-items:center;gap:4px;background:var(--surface-2);border-radius:12px;padding:4px}
.stepper button{width:44px;height:44px;border-radius:10px;border:0;background:var(--surface);cursor:pointer;display:grid;place-items:center;box-shadow:var(--shadow)}
.stepper output{min-width:42px;text-align:center;font-family:var(--display);font-size:1.7rem;line-height:1}
.seg{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end}
.seg button{min-width:44px;height:44px;padding:0 12px;border-radius:10px;border:1px solid var(--line);background:var(--surface);font-weight:700;cursor:pointer}
.seg button[aria-pressed="true"]{background:var(--ink);border-color:var(--ink);color:var(--bg)}
.switch{position:relative;width:52px;height:32px;flex:none}
.switch input{position:absolute;inset:0;opacity:0;margin:0;cursor:pointer}
.switch span{position:absolute;inset:0;border-radius:999px;background:var(--line);transition:background-color .2s}
.switch span::after{content:"";position:absolute;top:3px;inset-inline-start:3px;width:26px;height:26px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.3);transition:transform .2s}
.switch input:checked + span{background:var(--pitch)}
.switch input:checked + span::after{transform:translateX(20px)}
html[dir="rtl"] .switch input:checked + span::after{transform:translateX(-20px)}
.switch input:focus-visible + span{outline:3px solid var(--pitch);outline-offset:2px}
.preview{margin-top:10px;padding:10px 12px;border-radius:10px;background:var(--pitch-soft);color:var(--ink);font-weight:600;display:flex;gap:8px;align-items:center}
.preview.bad{background:color-mix(in srgb,var(--danger) 12%,transparent);color:var(--danger)}
.preview svg{width:18px;height:18px}

/* sticky action above the tab bar */
.sticky-cta{position:sticky;bottom:calc(var(--tab-h) + env(safe-area-inset-bottom,0px) + 10px);z-index:10;margin-top:16px;display:flex;gap:10px}
@media (min-width:700px){.sticky-cta{bottom:calc(var(--tab-h) + 30px)}}
.sticky-cta .btn{box-shadow:var(--shadow)}

/* teams */
.balance{display:flex;align-items:center;gap:14px;padding:14px 16px;margin-bottom:14px}
.bal-status{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border-radius:999px;font-weight:700;font-size:.85rem;background:color-mix(in srgb,var(--ok) 14%,transparent);color:var(--ok)}
.bal-status.ok{background:color-mix(in srgb,var(--warn) 16%,transparent);color:var(--warn)}
.bal-status.bad{background:color-mix(in srgb,var(--danger) 14%,transparent);color:var(--danger)}
.bal-text{display:grid;gap:4px;flex:1}
.bal-text small{color:var(--muted);font-size:.82rem}
/* dot plot of team averages on the 1–5 scale */
.dotplot{position:relative;height:34px;margin:2px 4px 0}
.dotplot .axis{position:absolute;inset-inline:0;top:15px;height:2px;background:var(--line);border-radius:2px}
.dotplot .tick{position:absolute;top:22px;translate:-50% 0;font-size:.68rem;color:var(--faint)}
html[dir="rtl"] .dotplot .tick{translate:50% 0}
.dotplot .dot{position:absolute;top:8px;width:16px;height:16px;border-radius:50%;translate:-50% 0;border:2px solid var(--surface);box-shadow:0 0 0 1px var(--line)}
html[dir="rtl"] .dotplot .dot{translate:50% 0}
.tgrid{display:grid;gap:14px}
@media (min-width:600px){.tgrid{grid-template-columns:1fr 1fr}}
.team{overflow:hidden}
.team-head{display:flex;align-items:center;gap:12px;padding:12px 14px;border-top:6px solid var(--tc);background:color-mix(in srgb,var(--tc) 9%,var(--surface))}
.bib{width:34px;height:38px;flex:none;background:var(--tc);border-radius:9px 9px 6px 6px;clip-path:polygon(22% 0,78% 0,100% 18%,88% 34%,88% 100%,12% 100%,12% 34%,0 18%);box-shadow:inset 0 0 0 1px rgba(0,0,0,.12)}
.team-name{font-family:var(--display);font-size:1.6rem;letter-spacing:.03em;line-height:1}
html[lang="ar"] .team-name{font-family:var(--body);font-weight:700;font-size:1.1rem;letter-spacing:0}
.team-meta{color:var(--muted);font-size:.85rem}
.team-avg{margin-inline-start:auto;text-align:end;line-height:1}
.team-avg b{display:block;font-family:var(--display);font-weight:400;font-size:2.2rem}
.team-avg small{font-size:.72rem;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}
html[lang="ar"] .team-avg small{letter-spacing:0}
.team .prow{min-height:52px;padding-block:6px}
.team .avatar{width:34px;height:34px;font-size:.85rem}
.note{display:flex;gap:8px;align-items:center;margin:10px 2px 0;font-size:.85rem;color:var(--muted)}
.note svg{width:18px;height:18px}

/* empty states */
.empty{text-align:center;padding:36px 20px;display:grid;justify-items:center;gap:12px}
.empty .empty-ic{width:72px;height:72px;border-radius:20px;background:var(--pitch-soft);color:var(--pitch);display:grid;place-items:center}
.empty .empty-ic svg{width:36px;height:36px}
.empty h2{font-size:1.8rem}
.empty p{color:var(--muted);max-width:34ch}

/* level badge (1–10): number + small bar */
.lvl{display:inline-flex;align-items:center;gap:6px}
.lvl b{min-width:24px;height:22px;padding:0 6px;border-radius:6px;display:inline-grid;place-items:center;font-size:.8rem;background:color-mix(in srgb,var(--gold) 22%,transparent);color:color-mix(in srgb,var(--gold) 55%,var(--ink))}
.lvl-bar{width:46px;height:5px;border-radius:5px;background:var(--surface-2);overflow:hidden;direction:ltr}
.lvl-bar i{display:block;height:100%;background:var(--gold);border-radius:5px}
.lv9 .avatar,.lv10 .avatar{background:color-mix(in srgb,var(--gold) 26%,transparent);color:color-mix(in srgb,var(--gold) 60%,var(--ink))}
.team-pos{font-size:.78rem;color:var(--muted);margin-top:2px}
.vhead .eye{min-height:42px;padding:0 12px;font-size:.88rem;flex:none}
.scale-q{background:var(--pitch-soft);border-radius:12px;padding:10px 12px!important;border:0!important}
.share-preview{border-radius:14px;overflow:hidden;background:var(--surface-2);min-height:160px;display:grid;place-items:center;max-height:52dvh;overflow-y:auto}
.share-preview img{width:100%;height:auto;display:block}
.share-actions{display:grid;gap:10px}
/* import / export */
.io{margin-top:14px}
.io-help{font-size:.9rem;margin-bottom:12px}
.io-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px}
.import-list{max-height:42dvh;overflow:auto;box-shadow:none}
.import-list .more{padding:10px 14px;font-size:.9rem}
/* backup row */
.backup{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:14px;padding:12px 14px}
.backup .lbl{font-weight:600;color:var(--muted);font-size:.9rem}

/* bottom sheet */
.sheet{border:0;padding:0;margin:auto auto 0;width:100%;max-width:560px;max-height:92dvh;border-radius:22px 22px 0 0;background:var(--surface);color:var(--ink);box-shadow:var(--shadow-lg)}
.sheet::backdrop{background:rgba(5,12,8,.5)}
.sheet[open]{animation:up .25s cubic-bezier(.2,.9,.3,1)}
@keyframes up{from{transform:translateY(40px);opacity:.4}}
@media (min-width:700px){.sheet{margin:auto;border-radius:22px}}
.sheet-body{padding:8px 18px calc(18px + env(safe-area-inset-bottom,0px));display:grid;gap:16px}
.sheet-grip{width:44px;height:5px;border-radius:5px;background:var(--line);margin:4px auto 0}
.sheet-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.sheet-head h2{font-size:1.9rem}
.field{display:grid;gap:8px}
.field > label,.field > .lbl{font-weight:700;font-size:.92rem}
.field input[type="text"],.field textarea{width:100%;min-height:52px;border-radius:12px;border:1px solid var(--line);background:var(--bg);padding:12px 14px;font-size:1.05rem}
.field textarea{min-height:170px;resize:vertical;font-family:ui-monospace,monospace;font-size:.95rem;line-height:1.5}
.field .help{font-size:.85rem;color:var(--muted)}
.levels{display:grid;grid-template-columns:repeat(5,1fr);gap:6px}
.levels button{height:52px;border-radius:12px;border:1px solid var(--line);background:var(--bg);font-family:var(--display);font-size:1.5rem;cursor:pointer;display:grid;place-items:center}
.levels button[aria-pressed="true"]{background:var(--gold);border-color:var(--gold);color:#241a00}
.level-name{text-align:center;color:var(--muted);font-weight:600;min-height:1.4em}
.positions{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}
.positions button{height:48px;border-radius:12px;border:1px solid var(--line);background:var(--bg);font-weight:700;cursor:pointer;font-size:.92rem}
.positions button[aria-pressed="true"]{background:var(--ink);border-color:var(--ink);color:var(--bg)}
.sheet-actions{display:flex;gap:10px}
.sheet-actions .btn{flex:1}
.move-list{display:grid;gap:8px}
.move-list button{display:flex;align-items:center;gap:12px;min-height:56px;padding:0 14px;border-radius:12px;border:1px solid var(--line);background:var(--bg);cursor:pointer;font-weight:700;text-align:start}
.move-list button .bib{width:26px;height:30px}
.move-list small{margin-inline-start:auto;color:var(--muted);font-weight:500}

/* toast */
.toast{position:fixed;inset-inline:16px;bottom:calc(var(--tab-h) + env(safe-area-inset-bottom,0px) + 86px);z-index:40;max-width:420px;margin-inline:auto;padding:12px 16px;border-radius:12px;background:var(--ink);color:var(--bg);font-weight:600;text-align:center;box-shadow:var(--shadow);animation:in .2s ease}

.hint{display:flex;gap:10px;align-items:flex-start;margin-top:16px;padding:12px 14px;border-radius:12px;border:1px dashed var(--line);color:var(--muted);font-size:.88rem}
.hint svg{width:18px;height:18px;margin-top:2px}

@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{animation:none!important;transition:none!important}
}
