/* Marbles3D — interface « feuille de chronométrage ».
   Graphite mat, une seule couleur de signal, chiffres à chasse fixe. Propriétés logiques pour le RTL. */
:root {
  --ink-0: #0a0b0d; --ink-1: #101215; --ink-2: #171a1e; --ink-3: #1f2328; --ink-4: #2a2f35;
  --rule: #262a30; --rule-2: #353b42;
  --fg: #ece8df; --fg-2: #a9a69e; --fg-3: #6f6d68;
  --signal: #ffc21a; --signal-ink: #1a1300;
  --gain: #2bd46f; --loss: #ff8a3d; --stop: #ff3b30; --best: #b78cff;
  --gold: #e9b949; --silver: #c5cad1; --bronze: #c48752;
  --f-disp: 'Archivo', 'Arial Narrow', sans-serif;
  --f-body: 'Archivo', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --stretch: 125%;
  --track: .14em;
  --cut: 12px;
}
[data-lang="ar"] {
  --f-disp: 'Noto Kufi Arabic', 'Archivo', sans-serif;
  --f-body: 'IBM Plex Sans Arabic', 'Archivo', sans-serif;
  --stretch: 100%;
  --track: 0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink-0); color: var(--fg); font-family: var(--f-body); font-size: 15px; user-select: none; -webkit-user-select: none; touch-action: none; -webkit-font-smoothing: antialiased; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[dir="rtl"] .flip { transform: scaleX(-1); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.label { font-family: var(--f-body); font-weight: 600; font-size: 11px; letter-spacing: var(--track); text-transform: uppercase; color: var(--fg-3); }
[data-lang="ar"] .label { text-transform: none; font-size: 12.5px; }
.disp { font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; letter-spacing: -.01em; }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }

/* ---------- logo ---------- */
.wordmark { display: flex; align-items: stretch; gap: 0; direction: ltr; font-family: 'Archivo', sans-serif; font-stretch: 125%; font-weight: 900; line-height: 1; }
.wordmark .w { font-size: 46px; letter-spacing: -.02em; padding-inline-end: 10px; }
.wordmark .b { display: grid; place-items: center; background: var(--signal); color: var(--signal-ink); font-size: 30px; padding: 0 8px; margin-block: 3px; }

/* ---------- boutons ---------- */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 12px; height: 52px; padding: 0 26px; font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 15px; letter-spacing: .04em; text-transform: uppercase;
  background: var(--signal); color: var(--signal-ink); clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%); transition: filter .12s, transform .12s; outline: none; }
[dir="rtl"] .btn { clip-path: polygon(var(--cut) 0, 100% 0, 100% 100%, 0 100%, 0 var(--cut)); }
[data-lang="ar"] .btn { letter-spacing: 0; font-size: 16px; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.focus, .btn:focus-visible { box-shadow: inset 0 0 0 2px var(--signal-ink); filter: brightness(1.12); }
.btn.ghost { background: var(--ink-2); color: var(--fg); box-shadow: inset 0 0 0 1px var(--rule-2); }
.btn.ghost:hover, .btn.ghost.focus, .btn.ghost:focus-visible { background: var(--ink-3); box-shadow: inset 0 0 0 1px var(--signal); filter: none; }
.btn.danger { background: var(--stop); color: #fff; }
.btn.block { width: 100%; }
.btn[disabled] { background: var(--ink-3); color: var(--fg-3); cursor: not-allowed; }
.btn .kc { font-family: var(--f-mono); font-size: 11px; font-weight: 600; opacity: .55; letter-spacing: 0; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; background: var(--ink-1); box-shadow: inset 0 0 0 1px var(--rule-2); color: var(--fg); transition: background .12s, color .12s; outline: none; flex: none; }
.iconbtn:hover, .iconbtn.focus, .iconbtn:focus-visible { background: var(--ink-3); color: var(--signal); box-shadow: inset 0 0 0 1px var(--signal); }

/* ---------- chargement ---------- */
#loader { position: fixed; inset: 0; z-index: 100; background: var(--ink-0); display: grid; place-content: center; gap: 28px; transition: opacity .5s; }
#loader.out { opacity: 0; pointer-events: none; }
.ld-bar { width: min(360px, 70vw); height: 2px; background: var(--rule); position: relative; }
.ld-bar i { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; background: var(--signal); transition: width .25s; }
.ld-row { display: flex; justify-content: space-between; gap: 16px; }

/* ---------- écrans ---------- */
.screen { position: fixed; inset: 0; z-index: 10; animation: scrIn .22s ease-out; }
@keyframes scrIn { from { opacity: 0; } }
.overlay { background: rgba(10,11,13,.94); }
.sheet-head { display: flex; align-items: center; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--rule); background: var(--ink-0); }
.sheet-head h2 { margin: 0; font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 24px; text-transform: uppercase; letter-spacing: -.005em; }
[data-lang="ar"] .sheet-head h2 { text-transform: none; font-size: 24px; }
.sheet-head .sp { flex: 1; }
.crumb { display: flex; gap: 10px; align-items: center; }

/* menu principal */
#title { display: grid; grid-template-columns: 440px 1fr; }
.col { background: rgba(10,11,13,.95); border-inline-end: 1px solid var(--rule); display: flex; flex-direction: column; padding: 34px 32px 24px; overflow: auto; }
.brand-sub { margin-top: 12px; display: flex; gap: 10px; }
.mainnav { margin-top: 44px; display: flex; flex-direction: column; border-top: 1px solid var(--rule); }
.nrow { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; padding: 18px 14px 18px 0; border-bottom: 1px solid var(--rule); text-align: start; position: relative; transition: background .12s, padding .15s; outline: none; }
[dir="rtl"] .nrow { padding: 18px 0 18px 14px; }
.nrow .ix { font-family: var(--f-mono); font-size: 12px; color: var(--fg-3); padding-inline-start: 4px; }
.nrow .t { font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 24px; text-transform: uppercase; line-height: 1.05; }
[data-lang="ar"] .nrow .t { text-transform: none; font-size: 22px; }
.nrow .s { display: block; font-size: 13px; color: var(--fg-2); margin-top: 3px; font-weight: 500; }
.nrow .chev { color: var(--fg-3); }
.nrow::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: -32px; width: 3px; background: var(--signal); transform: scaleY(0); transition: transform .15s; }
.nrow:hover, .nrow.focus, .nrow:focus-visible { background: var(--ink-2); padding-inline-start: 10px; }
.nrow:hover::before, .nrow.focus::before, .nrow:focus-visible::before { transform: scaleY(1); }
.nrow:hover .chev, .nrow.focus .chev { color: var(--signal); }
.nrow:hover .ix, .nrow.focus .ix { color: var(--signal); }

.career { margin-top: auto; padding-top: 28px; }
.career .label { display: block; margin-bottom: 10px; }
.cgrid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; border: 1px solid var(--rule); }
.cgrid > div { padding: 10px 12px; border-inline-end: 1px solid var(--rule); }
.cgrid > div:last-child { border-inline-end: 0; }
.cgrid b { display: block; font-family: var(--f-mono); font-size: 20px; font-weight: 500; }
.cgrid small { font-size: 11px; color: var(--fg-3); font-weight: 600; }
.ctotal { display: flex; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--rule); border-top: 0; font-size: 12px; color: var(--fg-2); }
.colfoot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.langsw { display: flex; border: 1px solid var(--rule-2); }
.langsw button { min-width: 44px; height: 34px; padding: 0 10px; font-family: var(--f-mono); font-size: 12px; font-weight: 600; color: var(--fg-2); border-inline-end: 1px solid var(--rule-2); outline: none; }
.langsw button:last-child { border-inline-end: 0; }
.langsw button[data-l="ar"] { font-family: 'Noto Kufi Arabic', sans-serif; font-size: 14px; }
.langsw button.on { background: var(--fg); color: var(--ink-0); }
.langsw button:hover, .langsw button.focus { color: var(--signal); }
.langsw button.on.focus { box-shadow: inset 0 0 0 2px var(--signal); color: var(--ink-0); }
.sitelink { font-size: 12px; color: var(--fg-3); text-decoration: none; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.sitelink:hover { color: var(--fg); }

.stage { position: relative; }
.statusbar { position: absolute; top: 22px; inset-inline-end: 24px; display: flex; border: 1px solid var(--rule); background: rgba(10,11,13,.85); }
.statusbar > div { padding: 8px 14px; border-inline-end: 1px solid var(--rule); display: flex; gap: 10px; align-items: baseline; }
.statusbar > div:last-child { border-inline-end: 0; }
.statusbar b { font-family: var(--f-mono); font-weight: 500; font-size: 12px; color: var(--fg); }
.nextcard { position: absolute; inset-inline-end: 24px; bottom: 56px; width: 380px; background: var(--ink-1); border: 1px solid var(--rule); }
.nextcard .th { aspect-ratio: 16 / 8; background: var(--ink-2) center / cover; border-bottom: 1px solid var(--rule); position: relative; }
.nextcard .th .tag { position: absolute; top: 10px; inset-inline-start: 10px; }
.nextcard .bd { padding: 14px 16px 16px; }
.nextcard .nm { font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 22px; text-transform: uppercase; margin: 6px 0 12px; line-height: 1.05; }
[data-lang="ar"] .nextcard .nm { text-transform: none; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); margin-bottom: 14px; }
.kv > div { padding: 8px 0; }
.kv > div + div { padding-inline-start: 12px; border-inline-start: 1px solid var(--rule); }
.kv b { display: block; font-family: var(--f-mono); font-weight: 500; font-size: 15px; margin-top: 2px; }

.tag { display: inline-flex; align-items: center; gap: 8px; height: 22px; padding: 0 8px; background: var(--ink-0); border: 1px solid var(--rule-2); font-size: 11px; font-weight: 700; letter-spacing: var(--track); text-transform: uppercase; color: var(--fg); }
[data-lang="ar"] .tag { text-transform: none; font-size: 12px; }
.tag i { width: 8px; height: 8px; background: var(--tc, var(--signal)); }

/* médailles : disque plat + anneau */
.medal { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-family: var(--f-mono); font-size: 11px; font-weight: 600; color: var(--ink-0); flex: none; }
.medal.gold { background: var(--gold); box-shadow: inset 0 0 0 2px #b8902c; }
.medal.silver { background: var(--silver); box-shadow: inset 0 0 0 2px #969ca5; }
.medal.bronze { background: var(--bronze); box-shadow: inset 0 0 0 2px #98623a; }
.medal.none { background: transparent; box-shadow: inset 0 0 0 1px var(--rule-2); color: var(--fg-3); }

/* ---------- parcours ---------- */
#levels { display: flex; flex-direction: column; }
.lv-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px 1fr 400px; }
.tiers { border-inline-end: 1px solid var(--rule); display: flex; flex-direction: column; overflow: auto; }
.trow { display: block; text-align: start; padding: 16px 20px; border-bottom: 1px solid var(--rule); position: relative; outline: none; transition: background .12s; }
.trow .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.trow .ix { font-family: var(--f-mono); font-size: 11px; color: var(--fg-3); }
.trow .nm { font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 18px; text-transform: uppercase; margin: 4px 0 10px; display: flex; align-items: center; gap: 8px; }
[data-lang="ar"] .trow .nm { text-transform: none; }
.trow .segs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.trow .segs i { height: 4px; background: var(--ink-4); }
.trow .segs i.gold { background: var(--gold); } .trow .segs i.silver { background: var(--silver); } .trow .segs i.bronze { background: var(--bronze); }
.trow::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--tc); opacity: 0; }
.trow.on { background: var(--ink-2); }
.trow.on::before { opacity: 1; }
.trow:hover, .trow.focus { background: var(--ink-3); }
.trow.locked .nm, .trow.locked .ix { color: var(--fg-3); }
.tierdesc { padding: 16px 20px; color: var(--fg-2); font-size: 13px; line-height: 1.5; }

.sheet { overflow: auto; }
table.timing { width: 100%; border-collapse: collapse; }
.timing th { position: sticky; top: 0; background: var(--ink-0); text-align: start; padding: 12px 14px; border-bottom: 1px solid var(--rule-2); font-weight: 600; font-size: 11px; letter-spacing: var(--track); text-transform: uppercase; color: var(--fg-3); white-space: nowrap; }
[data-lang="ar"] .timing th { text-transform: none; font-size: 12px; }
.timing th.r, .timing td.r { text-align: end; }
.timing td { padding: 0 14px; height: 60px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.timing tbody tr { cursor: pointer; position: relative; outline: none; transition: background .1s; }
.timing tbody tr:hover, .timing tbody tr.focus { background: var(--ink-2); }
.timing tbody tr.sel { background: var(--ink-3); }
.timing tbody tr.sel td:first-child, .timing tbody tr.focus td:first-child { box-shadow: inset 3px 0 0 var(--signal); }
[dir="rtl"] .timing tbody tr.sel td:first-child, [dir="rtl"] .timing tbody tr.focus td:first-child { box-shadow: inset -3px 0 0 var(--signal); }
.timing .no { font-family: var(--f-mono); color: var(--fg-3); width: 56px; }
.timing .cn { font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 16px; text-transform: uppercase; }
[data-lang="ar"] .timing .cn { text-transform: none; font-size: 16px; }
.timing .mono { font-size: 14px; }
.timing .dim { color: var(--fg-3); }
.timing tr.locked td { color: var(--fg-3); }
.timing tr.locked .cn { color: var(--fg-3); }
.sw { display: inline-flex; vertical-align: middle; margin-inline-end: 8px; }
.sw i { width: 10px; height: 10px; }

.detail { border-inline-start: 1px solid var(--rule); overflow: auto; display: flex; flex-direction: column; }
.detail .th { aspect-ratio: 16 / 9; background: var(--ink-2) center / cover; border-bottom: 1px solid var(--rule); flex: none; position: relative; }
.detail .th img, .nextcard .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail .th .lock { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,11,13,.7); color: var(--fg-2); }
.detail .bd { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.detail h3 { margin: 6px 0 4px; font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 26px; text-transform: uppercase; line-height: 1.05; }
[data-lang="ar"] .detail h3 { text-transform: none; }
.detail p { margin: 0; color: var(--fg-2); line-height: 1.5; }
.specs { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule); border-inline-start: 1px solid var(--rule); }
.specs > div { padding: 10px 12px; border-bottom: 1px solid var(--rule); border-inline-end: 1px solid var(--rule); }
.specs b { display: block; font-family: var(--f-mono); font-weight: 500; font-size: 17px; margin-top: 3px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 26px; display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--rule-2); font-size: 12px; font-weight: 600; color: var(--fg-2); }
.targets { width: 100%; border-collapse: collapse; }
.targets td { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.targets td:first-child { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.targets td.r { text-align: end; font-family: var(--f-mono); }
.splits { display: flex; flex-direction: column; }
.splits div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--rule); font-family: var(--f-mono); font-size: 13px; }
.splits span:first-child { color: var(--fg-3); }

/* ---------- garage ---------- */
#marbles { display: flex; flex-direction: column; }
.ga-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 420px 1fr 360px; }
.mlist { border-inline-end: 1px solid var(--rule); overflow: auto; background: rgba(10,11,13,.95); }
.mrow { width: 100%; display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 14px; padding: 10px 18px; border-bottom: 1px solid var(--rule); text-align: start; position: relative; outline: none; transition: background .1s; }
.mrow img, .mrow .ph { width: 56px; height: 56px; display: block; background: var(--ink-2); }
.mrow .nm { font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 16px; text-transform: uppercase; }
[data-lang="ar"] .mrow .nm { text-transform: none; }
.mrow .cl { display: block; font-size: 12px; color: var(--fg-3); font-weight: 600; margin-top: 3px; }
.mrow .nm { display: block; }
.mrow:hover, .mrow.focus { background: var(--ink-2); }
.mrow.sel { background: var(--ink-3); }
.mrow.sel::before, .mrow.focus::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--signal); }
.mrow .eq { color: var(--signal); }
.mspec { border-inline-start: 1px solid var(--rule); background: rgba(10,11,13,.95); padding: 22px 22px; overflow: auto; display: flex; flex-direction: column; gap: 18px; }
.mspec h3 { margin: 6px 0 0; font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 28px; text-transform: uppercase; line-height: 1.05; }
[data-lang="ar"] .mspec h3 { text-transform: none; }
.mspec p { margin: 0; color: var(--fg-2); line-height: 1.5; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center; }
.bar .ticks { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.bar .ticks i { height: 8px; background: var(--ink-4); }
.bar .ticks i.on { background: var(--fg); }
.bar .ticks i.on.hi { background: var(--signal); }
.bar span { font-size: 13px; font-weight: 600; }
.bar b { font-family: var(--f-mono); font-weight: 500; font-size: 13px; color: var(--fg-2); }

/* ---------- paramètres ---------- */
#options, #help, #confirm, #pause, #result { display: grid; place-items: center; padding: 20px; }
.box { width: min(980px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--ink-1); border: 1px solid var(--rule); }
.box.sm { width: min(520px, 100%); }
.box .sheet-head { background: var(--ink-1); }
.opt-wrap { display: grid; grid-template-columns: 220px 1fr; min-height: 0; flex: 1; }
.otabs { border-inline-end: 1px solid var(--rule); display: flex; flex-direction: column; }
.otab { text-align: start; padding: 16px 20px; border-bottom: 1px solid var(--rule); display: flex; gap: 14px; align-items: baseline; position: relative; outline: none; font-weight: 600; color: var(--fg-2); }
.otab .ix { font-family: var(--f-mono); font-size: 11px; color: var(--fg-3); }
.otab.on { background: var(--ink-2); color: var(--fg); }
.otab.on::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--signal); }
.otab:hover, .otab.focus { background: var(--ink-3); color: var(--fg); }
.opage { padding: 6px 26px 22px; overflow: auto; }
.orow { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--rule); }
.orow .lb { font-weight: 600; }
.orow .lb small { display: block; color: var(--fg-3); font-weight: 500; font-size: 12.5px; margin-top: 3px; }
.ohead { padding: 18px 0 10px; display: flex; justify-content: space-between; gap: 16px; align-items: end; }
.gpu { display: grid; grid-template-columns: 1fr auto auto; border: 1px solid var(--rule); margin: 14px 0 4px; }
.gpu > div { padding: 10px 14px; border-inline-end: 1px solid var(--rule); min-width: 0; }
.gpu > div:last-child { border-inline-end: 0; }
.gpu b { display: block; font-family: var(--f-mono); font-weight: 500; font-size: 13px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdesc { color: var(--fg-2); font-size: 13.5px; margin: 10px 0 6px; line-height: 1.5; min-height: 2.9em; }
.seg { display: flex; border: 1px solid var(--rule-2); }
.seg button { flex: 1; height: 38px; padding: 0 14px; font-size: 13px; font-weight: 600; color: var(--fg-2); border-inline-end: 1px solid var(--rule-2); white-space: nowrap; outline: none; }
.seg button:last-child { border-inline-end: 0; }
.seg button.on { background: var(--fg); color: var(--ink-0); }
.seg button:hover, .seg button.focus { color: var(--signal); }
.seg button.on.focus { box-shadow: inset 0 0 0 2px var(--signal); color: var(--ink-0); }
.seg.mini button { height: 32px; padding: 0 10px; font-size: 12px; }
.switch { width: 46px; height: 24px; background: var(--ink-4); position: relative; flex: none; outline: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; background: var(--fg-2); transition: inset-inline-start .15s, background .15s; }
.switch.on { background: var(--signal); }
.switch.on::after { inset-inline-start: 25px; background: var(--signal-ink); }
.switch.focus { box-shadow: 0 0 0 2px var(--ink-1), 0 0 0 4px var(--signal); }
.range { display: flex; align-items: center; gap: 14px; }
.range output { min-width: 52px; text-align: end; font-family: var(--f-mono); font-size: 13px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 200px; height: 18px; background: transparent; outline: none; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(to right, var(--signal) var(--p), var(--ink-4) var(--p)); }
[dir="rtl"] input[type=range]::-webkit-slider-runnable-track { background: linear-gradient(to left, var(--signal) var(--p), var(--ink-4) var(--p)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 18px; margin-top: -8px; background: var(--fg); cursor: pointer; }
input[type=range]::-moz-range-track { height: 2px; background: var(--ink-4); }
input[type=range]::-moz-range-progress { height: 2px; background: var(--signal); }
input[type=range]::-moz-range-thumb { width: 12px; height: 18px; border: 0; border-radius: 0; background: var(--fg); cursor: pointer; }
input[type=range].focus::-webkit-slider-thumb { background: var(--signal); }
input[type=range].focus::-moz-range-thumb { background: var(--signal); }
.langopts { display: flex; flex-direction: column; border-top: 1px solid var(--rule); margin-top: 14px; }
.lopt { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 14px; padding: 16px 4px; border-bottom: 1px solid var(--rule); text-align: start; outline: none; }
.lopt .code { font-family: var(--f-mono); font-size: 12px; color: var(--fg-3); }
.lopt .nm { font-size: 20px; font-weight: 600; }
.lopt .nm[lang="ar"] { font-family: 'Noto Kufi Arabic', sans-serif; }
.lopt .nm[lang="en"], .lopt .nm[lang="fr"] { font-family: 'Archivo', sans-serif; font-stretch: 125%; font-weight: 800; }
.lopt .dot { width: 14px; height: 14px; box-shadow: inset 0 0 0 1px var(--rule-2); }
.lopt.on .dot { background: var(--signal); box-shadow: none; }
.lopt:hover, .lopt.focus { background: var(--ink-2); }

/* commandes */
.ctl-grid { display: grid; grid-template-columns: repeat(3, 1fr); flex: 1; overflow: auto; }
.ctl-col { padding: 18px 22px 22px; border-inline-end: 1px solid var(--rule); }
.ctl-col:last-child { border-inline-end: 0; }
.ctl-col h3 { margin: 0 0 12px; font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 16px; text-transform: uppercase; }
[data-lang="ar"] .ctl-col h3 { text-transform: none; }
.bind { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.keys { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; direction: ltr; }
.key { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px; font-family: var(--f-mono); font-size: 11px; font-weight: 600; color: var(--fg); background: var(--ink-3); box-shadow: inset 0 -2px 0 var(--ink-0), inset 0 0 0 1px var(--rule-2); }
.key.w { padding: 0 10px; }
.key.a { background: #1f7a45; } .key.b { background: #8f2a33; }
.rules { padding: 0 22px 20px; border-top: 1px solid var(--rule); }
.rules ol { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: r; display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }
.rules li { counter-increment: r; display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--rule); color: var(--fg-2); font-size: 13.5px; }
.rules li::before { content: counter(r, decimal-leading-zero); font-family: var(--f-mono); color: var(--signal); font-size: 12px; }

/* pause / résultat */
#pause { place-items: center end; padding: 0; }
[dir="rtl"] #pause { place-items: center start; }
.side { width: min(420px, 100%); height: 100%; background: var(--ink-1); border-inline-start: 1px solid var(--rule); display: flex; flex-direction: column; animation: sideIn .2s ease-out; }
@keyframes sideIn { from { transform: translateX(30px); opacity: 0; } }
[dir="rtl"] .side { animation-name: sideInR; }
@keyframes sideInR { from { transform: translateX(-30px); opacity: 0; } }
.side .bd { padding: 20px 24px; display: flex; flex-direction: column; gap: 10px; flex: 1; overflow: auto; }
.statlist { border-top: 1px solid var(--rule); margin-bottom: 14px; }
.statlist div { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.statlist b { font-family: var(--f-mono); font-weight: 500; }
.res-top { padding: 22px 26px 0; }
.res-time { font-family: var(--f-mono); font-weight: 500; font-size: 64px; letter-spacing: -.02em; line-height: 1; margin: 14px 0 10px; direction: ltr; text-align: start; }
[dir="rtl"] .res-time { text-align: end; }
.res-line { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-bottom: 18px; border-bottom: 1px solid var(--rule); }
.res-line .medal { width: 30px; height: 30px; font-size: 13px; }
.delta { font-family: var(--f-mono); font-size: 13px; padding: 3px 8px; direction: ltr; }
.delta.gain { background: rgba(43,212,111,.14); color: var(--gain); }
.delta.loss { background: rgba(255,138,61,.14); color: var(--loss); }
.delta.best { background: rgba(183,140,255,.16); color: var(--best); }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; }
.res-grid > div { padding: 16px 26px; }
.res-grid > div + div { border-inline-start: 1px solid var(--rule); }
.res-split { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--rule); font-family: var(--f-mono); font-size: 13px; }
.res-split span:first-child { font-family: var(--f-body); color: var(--fg-2); font-weight: 600; }
.res-actions { display: flex; gap: 10px; padding: 18px 26px 22px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.res-actions .btn { flex: 1; min-width: 150px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.tower { position: absolute; top: max(16px, env(safe-area-inset-top)); inset-inline-start: 16px; width: 270px; background: rgba(10,11,13,.88); border: 1px solid var(--rule); }
.tower .hd { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--rule); }
.tower .hd i { width: 4px; height: 16px; background: var(--tc, var(--signal)); }
.tower .hd span { font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: 13px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-lang="ar"] .tower .hd span { text-transform: none; }
.tower .clock { padding: 8px 12px 6px; display: flex; justify-content: space-between; align-items: end; gap: 10px; }
#timer { font-family: var(--f-mono); font-weight: 500; font-size: 40px; line-height: 1; direction: ltr; }
.tower .el { text-align: end; }
#timerSub { font-family: var(--f-mono); font-size: 14px; color: var(--fg-2); direction: ltr; display: block; margin-top: 2px; }
.tower.warn #timer { color: var(--stop); }
.tower.bonus { box-shadow: inset 0 0 0 1px var(--signal); }
.tower .split { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-top: 1px solid var(--rule); font-family: var(--f-mono); font-size: 13px; }
.tower .split.empty { display: none; }
.track { position: absolute; top: max(22px, calc(env(safe-area-inset-top) + 6px)); left: 50%; transform: translateX(-50%); width: min(360px, 34vw); height: 22px; }
.track .ln { position: absolute; inset-inline: 0; top: 10px; height: 2px; background: var(--rule-2); }
.track .fill { position: absolute; inset-inline-start: 0; top: 10px; height: 2px; background: var(--signal); width: 0; }
.track .tk { position: absolute; top: 5px; width: 2px; height: 12px; background: var(--fg-3); }
.track .tk.on { background: var(--gain); }
.track .fin { position: absolute; inset-inline-end: -2px; top: 2px; width: 6px; height: 18px; background: repeating-linear-gradient(0deg, var(--fg) 0 3px, var(--ink-0) 3px 6px); }
.track .pip { position: absolute; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--fg); box-shadow: 0 0 0 2px var(--ink-0); margin-inline-start: -6px; }
#pauseBtn { pointer-events: auto; position: absolute; top: max(16px, env(safe-area-inset-top)); inset-inline-end: 16px; background: rgba(10,11,13,.88); }
.counters { position: absolute; inset-inline-start: 16px; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; border: 1px solid var(--rule); background: rgba(10,11,13,.88); }
.counters > div { padding: 8px 14px; border-inline-end: 1px solid var(--rule); display: flex; align-items: center; gap: 10px; }
.counters > div:last-child { border-inline-end: 0; }
.counters b { font-family: var(--f-mono); font-weight: 500; font-size: 18px; direction: ltr; }
#speedo { position: absolute; inset-inline-end: 16px; bottom: max(16px, env(safe-area-inset-bottom)); width: 150px; border: 1px solid var(--rule); background: rgba(10,11,13,.88); padding: 8px 12px 10px; }
#speedo .v { display: flex; justify-content: space-between; align-items: baseline; }
#speedVal { font-family: var(--f-mono); font-weight: 500; font-size: 30px; line-height: 1; }
#speedo .bar2 { margin-top: 8px; height: 3px; background: var(--ink-4); position: relative; }
#speedo .bar2 i { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; background: var(--fg); }
#toast { position: absolute; top: 30%; left: 50%; transform: translate(-50%, 6px); display: flex; flex-direction: column; align-items: center; gap: 6px; opacity: 0; transition: opacity .18s, transform .18s; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast .tt { font-family: var(--f-disp); font-stretch: var(--stretch); font-weight: 800; font-size: clamp(26px, 4vw, 40px); text-transform: uppercase; padding: 6px 18px; background: rgba(10,11,13,.88); border-block: 2px solid var(--fg); }
[data-lang="ar"] #toast .tt { text-transform: none; }
#toast.sig .tt { border-color: var(--signal); color: var(--signal); }
#toast.bad .tt { border-color: var(--stop); }
#toast .ts { font-family: var(--f-mono); font-size: 15px; padding: 3px 8px; background: rgba(10,11,13,.88); direction: ltr; }
.lights { position: absolute; top: 26%; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; padding: 12px 16px; background: var(--ink-0); border: 1px solid var(--rule-2); opacity: 0; transition: opacity .2s; direction: ltr; }
.lights.show { opacity: 1; }
.lights i { width: 40px; height: 40px; border-radius: 50%; background: #1d1f23; box-shadow: inset 0 0 0 2px #2b2e33; transition: background .08s; }
.lights i.r { background: var(--stop); box-shadow: 0 0 18px rgba(255,59,48,.65); }
.lights.go i { background: var(--gain); box-shadow: 0 0 18px rgba(43,212,111,.6); }
.lights .go-t { display: none; }
#hint { position: absolute; bottom: max(80px, calc(env(safe-area-inset-bottom) + 66px)); left: 50%; transform: translateX(-50%); padding: 7px 14px; background: rgba(10,11,13,.88); border: 1px solid var(--rule); font-size: 13px; color: var(--fg-2); white-space: nowrap; transition: opacity 1s; }
#fps { position: absolute; top: max(16px, env(safe-area-inset-top)); inset-inline-end: 72px; font-family: var(--f-mono); font-size: 12px; color: var(--fg-2); padding: 4px 8px; background: rgba(10,11,13,.8); }
#fps:empty { display: none; }

/* tactile */
#touchUI { display: none; }
body.touch.playing #touchUI { display: block; }
#joyZone { position: fixed; inset-inline-start: 0; bottom: 0; width: 50%; height: 65%; z-index: 6; touch-action: none; }
#joyBase { position: absolute; left: 96px; bottom: 96px; width: 136px; height: 136px; transform: translate(-50%, 50%); opacity: .6; transition: opacity .15s; }
#joyBase.active { opacity: 1; }
#joyBase .ring { position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(236,232,223,.5); background: rgba(10,11,13,.35); }
#joyBase .ring::before, #joyBase .ring::after { content: ''; position: absolute; background: rgba(236,232,223,.25); }
#joyBase .ring::before { left: 50%; top: 10px; bottom: 10px; width: 1px; }
#joyBase .ring::after { top: 50%; left: 10px; right: 10px; height: 1px; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; border-radius: 50%; transform: translate(-50%, -50%); background: var(--signal); box-shadow: 0 0 0 4px rgba(10,11,13,.6); }
#camBtns { position: fixed; inset-inline-end: 16px; bottom: max(120px, calc(env(safe-area-inset-bottom) + 106px)); z-index: 7; display: flex; gap: 8px; }
#camBtns .iconbtn { width: 56px; height: 56px; background: rgba(10,11,13,.88); }

/* indication des entrées */
#inputHint { position: fixed; bottom: 0; inset-inline: 0; z-index: 20; height: 38px; display: flex; align-items: center; justify-content: flex-end; gap: 18px; padding: 0 24px; pointer-events: none; font-size: 12px; font-weight: 600; color: var(--fg-2); background: var(--ink-0); border-top: 1px solid var(--rule); }
body.hinted .screen { bottom: 38px; }
body.hinted .nextcard { bottom: 24px; }
#inputHint:empty { display: none; }
#inputHint span { display: inline-flex; align-items: center; gap: 7px; }
#inputHint .key { min-width: 22px; height: 22px; font-size: 10px; }
#inputHint .key.a { background: #1f7a45; } #inputHint .key.b { background: #8f2a33; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .lv-body { grid-template-columns: 210px 1fr 340px; }
  .timing .hide-md { display: none; }
  .ga-body { grid-template-columns: 360px 1fr 320px; }
}
@media (max-width: 900px) {
  #title { grid-template-columns: 1fr; }
  .stage { display: none; }
  .col { background: rgba(10,11,13,.86); }
  .lv-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .tiers { flex-direction: row; overflow-x: auto; border-inline-end: 0; border-bottom: 1px solid var(--rule); }
  .trow { min-width: 150px; border-bottom: 0; border-inline-end: 1px solid var(--rule); padding: 10px 14px; }
  .trow .nm { font-size: 14px; margin-bottom: 6px; }
  .tierdesc { display: none; }
  .detail { display: none; }
  .timing .hide-sm { display: none; }
  .ga-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .ga-body .stage-gap { display: none; }
  .mspec { border-inline-start: 0; border-top: 1px solid var(--rule); padding: 14px 18px; }
  .mspec .bars, .mspec p { display: none; }
  .mlist { max-height: 46vh; }
  .opt-wrap { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .otabs { flex-direction: row; overflow-x: auto; border-inline-end: 0; border-bottom: 1px solid var(--rule); }
  .otab { border-bottom: 0; border-inline-end: 1px solid var(--rule); white-space: nowrap; }
  .ctl-grid { grid-template-columns: 1fr; }
  .ctl-col { border-inline-end: 0; border-bottom: 1px solid var(--rule); }
  .rules ol { grid-template-columns: 1fr; }
  #inputHint { display: none; }
}
@media (max-width: 560px) {
  .col { padding: 24px 18px 18px; }
  .wordmark .w { font-size: 38px; } .wordmark .b { font-size: 24px; }
  .mainnav { margin-top: 26px; }
  .nrow { padding-block: 13px; }
  .nrow .t { font-size: 20px; }
  .tower { width: 190px; inset-inline-start: 10px; top: max(10px, env(safe-area-inset-top)); }
  #timer { font-size: 30px; }
  .track { top: auto; bottom: max(14px, env(safe-area-inset-bottom)); width: 40vw; }
  .counters { bottom: auto; top: calc(max(10px, env(safe-area-inset-top)) + 96px); inset-inline-start: 10px; flex-direction: column; }
  #speedo { width: 110px; } #speedVal { font-size: 22px; }
  .orow { grid-template-columns: 1fr; gap: 10px; }
  input[type=range] { width: 160px; }
  .res-time { font-size: 46px; }
  .res-grid { grid-template-columns: 1fr; }
  .res-grid > div + div { border-inline-start: 0; border-top: 1px solid var(--rule); }
  #hint { display: none; }
}
/* nombres + unités : toujours de gauche à droite, alignés côté arabe */
[dir="rtl"] .mono, [dir="rtl"] .specs b, [dir="rtl"] .bar b, [dir="rtl"] .kv b, [dir="rtl"] .cgrid b, [dir="rtl"] .statlist b, [dir="rtl"] .gpu b, [dir="rtl"] .targets td.r, [dir="rtl"] .counters b { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .timing td.r, [dir="rtl"] .targets td.r { text-align: left; }
[dir="rtl"] .specs b, [dir="rtl"] .kv b, [dir="rtl"] .cgrid b, [dir="rtl"] .gpu b { text-align: right; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
