/* Carnet de pétanque — high contrast for full sun, team colours by lightness (inox / carbone). */
:root {
  --bg: #ebe9e4; --card: #fff; --card2: #f4f3ef; --line: #dcd9d2; --text: #1c2024; --muted: #5f656c; --faint: #9aa0a6;
  --primary: #1c2024; --on-primary: #fff;
  --buis: #c2943a; --buis-soft: #ead7aa;
  --danger: #c0392b; --danger-bg: #f8e3e0; --warn: #d9822b; --ok: #1f8a4c; --info-bg: #e7ecf2;
  --q1: #c0392b; --q2: #e07b39; --q3: #b39b2b; --q4: #5b9b3b; --q5: #1f8a4c;
  --q1s: #efcac6; --q2s: #f6d8c6; --q3s: #ece3c3; --q4s: #d6e5cc; --q5s: #c4ddcd;
  --inox-bg: #dfe3e7; --inox-fg: #1c2024; --inox-bd: #8e959c; --inox-banner: #f3f5f7;
  --carbone-bg: #343a40; --carbone-fg: #fff; --carbone-bd: #1c2024;
  --bronze-bg: #7b4a1f; --bronze-fg: #fff; --bronze-bd: #5a3412;
  --r: 16px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --bar-h: 62px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111417; --card: #1b1f24; --card2: #262b31; --line: #31373e; --text: #f0f2f4; --muted: #a3a9b1; --faint: #6f767e;
  --primary: #eceef0; --on-primary: #111417;
  --danger-bg: #3d2220; --info-bg: #22303d;
  --q1s: #4b2a27; --q2s: #4d3324; --q3s: #433d24; --q4s: #2e4128; --q5s: #1f3d2c;
  --inox-bg: #d9dde2; --inox-bd: #aab1b8; --inox-banner: #dfe3e8;
  --carbone-bg: #3a4047; --carbone-bd: #8a929a;
  --bronze-bd: #c08a58;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
html.sheet-open, html.sheet-open body { overflow: hidden; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; min-height: 100dvh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; }
h1 { font-size: 28px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 24px; font-weight: 800; }
h3 { font-size: 19px; font-weight: 750; margin: 18px 4px 8px; }
h3 small, h4 small { font-weight: 500; color: var(--muted); font-size: 14px; margin-left: 6px; }
h4 { font-size: 16px; margin: 14px 0 8px; }
.card h3, .card h2 { margin: 0 0 10px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small, small { font-size: 14px; }
.center { text-align: center; }
.pad { padding: 16px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 2px; }
.ok-t { color: var(--ok); font-weight: 600; }
.warn-t { color: var(--warn); font-weight: 600; }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

#view { max-width: 600px; margin: 0 auto; }
.screen { padding: calc(10px + var(--safe-t)) 12px calc(var(--bar-h) + 24px + var(--safe-b)); }
.splash { min-height: 90dvh; display: grid; place-content: center; text-align: center; color: var(--muted); }
.splash img { border-radius: 22px; margin: 0 auto 10px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1.5px solid var(--line); background: var(--card2); color: var(--text);
  font-weight: 700; font-size: 16px; padding: 10px 14px; min-height: 48px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center; text-decoration: none;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .42; pointer-events: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger-t, .danger-t { color: var(--danger); }
.btn.sm { min-height: 38px; padding: 6px 12px; font-size: 15px; border-radius: 12px; }
.btn.block, .block { display: flex; width: 100%; margin: 10px 0; }
.btn.big { min-height: 58px; font-size: 18px; }
.btn.sel { background: var(--primary); color: var(--on-primary); border-color: var(--primary); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary); }
.btn.sel.t-inox { background: var(--inox-bg); color: var(--inox-fg); border-color: var(--inox-bd); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.btn.sel.t-carbone { background: var(--carbone-bg); color: var(--carbone-fg); border-color: var(--carbone-bd); }
.btn.sel.t-bronze { background: var(--bronze-bg); color: var(--bronze-fg); border-color: var(--bronze-bd); }
.link { background: none; border: 0; color: var(--text); text-decoration: underline; text-underline-offset: 3px; padding: 10px 2px; font-weight: 600; }
.row2, .row3, .seg2, .seg3 { display: grid; gap: 10px; margin: 10px 0; }
.row2, .seg2 { grid-template-columns: 1fr 1fr; }
.row3, .seg3 { grid-template-columns: 1fr 1fr 1fr; }
.pts { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pts .btn { padding: 0; font-size: 22px; min-height: 52px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.actions .btn { flex: 1 1 30%; }

/* ---------- Header ---------- */
header.top { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-bottom: 8px; }
header.top h1 { font-size: 24px; flex: 1; }
.back { background: none; border: 0; font-weight: 700; font-size: 17px; padding: 10px 4px; color: var(--text); }
header.hero { padding: 14px 4px 6px; }
header.hero h1 { font-size: 32px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px; margin: 10px 0; }

/* ---------- Team pills and balls ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 5px; border-radius: 999px;
  font-weight: 800; letter-spacing: .07em; font-size: 15px; border: 1.5px solid; white-space: nowrap; line-height: 1.2;
}
.pill .ball { --bs: 18px; }
.pill.sm { font-size: 12px; padding: 2px 8px 2px 3px; gap: 4px; }
.pill.sm .ball { --bs: 14px; }
.t-inox.pill { background: var(--inox-bg); color: var(--inox-fg); border-color: var(--inox-bd); }
.t-carbone.pill { background: var(--carbone-bg); color: var(--carbone-fg); border-color: var(--carbone-bd); }
.t-bronze.pill { background: var(--bronze-bg); color: var(--bronze-fg); border-color: var(--bronze-bd); }

.ball {
  --bs: 54px; display: block; flex: none; width: var(--bs); height: var(--bs); border-radius: 50%; position: relative;
  box-shadow: 0 2px 3px rgba(0,0,0,.28), inset 0 -2px 4px rgba(0,0,0,.22);
}
.ball::after { content: ""; position: absolute; left: 3%; right: 3%; top: calc(50% - 1px); height: 2px; border-radius: 2px; background: rgba(0,0,0,.26); }
.ball.inox { background: radial-gradient(circle at 34% 28%, #fff 0 7%, #eef0f2 17%, #c9ced4 48%, #9aa1a8 78%, #7d848b 100%); }
.ball.carbone { background: radial-gradient(circle at 34% 28%, #a3a9af 0 5%, #5d636a 20%, #373c42 52%, #202428 82%, #15181b 100%); }
.ball.bronze { background: radial-gradient(circle at 34% 28%, #ffe4bd 0 6%, #e2a768 20%, #b47135 52%, #874a1c 82%, #653612 100%); }
.ball.xs { --bs: 16px; display: inline-block; vertical-align: -3px; margin-right: 5px; }
:root[data-theme="dark"] .ball.carbone { box-shadow: 0 0 0 1.5px #8a929a, 0 2px 3px rgba(0,0,0,.5), inset 0 -2px 4px rgba(0,0,0,.3); }
:root[data-theme="dark"] .ball.bronze { box-shadow: 0 0 0 1.5px #c08a58, 0 2px 3px rgba(0,0,0,.5); }

/* ---------- Score card ---------- */
.score { padding: 10px 12px 8px; margin-top: 4px; }
.sc-top { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; align-items: center; gap: 4px; }
.sc-num { font-size: 40px; font-weight: 850; line-height: 1; position: relative; font-variant-numeric: tabular-nums; min-width: 30px; text-align: center; margin: 0 3px; }
.buis-dot { position: absolute; right: -10px; bottom: 2px; width: 11px; height: 11px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f1d48f, var(--buis) 60%, #8e6620); }
.sc-mid { text-align: center; display: flex; flex-direction: column; min-width: 0; }
.sc-mid b { font-size: 19px; }
.sc-mid span { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-bot { display: flex; align-items: flex-end; gap: 12px; border-top: 1.5px solid var(--line); margin-top: 8px; padding-top: 6px; }
.tm { display: flex; flex-direction: column; }
.tm small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tm b { font-size: 23px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tm.warn b { color: var(--warn); }
.tm.over b, .tm.over small { color: var(--danger); }
/* Fixed-size clock controls: toggling pause never moves anything. */
.sc-ctl { margin-left: auto; display: flex; gap: 6px; flex: none; }
.ic {
  width: 44px; height: 40px; flex: none; display: grid; place-items: center; padding: 0; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card2); color: var(--text);
}
.ic svg { width: 22px; height: 22px; fill: currentColor; }
.ic svg.stroke { fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.ic.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.ic:active { transform: scale(.94); }
.score.paused .tm b { color: var(--faint); }
.score .pill { font-size: 13px; padding: 3px 9px 3px 4px; gap: 5px; }
.score .pill .ball { --bs: 16px; }
.score.paused .tm:first-child small { color: var(--warn); font-weight: 700; }

.alert { border-radius: 14px; padding: 10px 14px; margin: 10px 0; font-weight: 650; border: 1.5px solid; }
.alert.danger { background: var(--danger-bg); border-color: var(--danger); }
.alert.info { background: var(--info-bg); border-color: var(--line); }

/* ---------- "À qui de jouer" banner ---------- */
.banner { border-width: 2px; }
.banner.t-inox { background: var(--inox-banner); border-color: var(--inox-bd); color: #1c2024; }
.banner.t-carbone { background: var(--carbone-bg); border-color: var(--carbone-bd); color: #fff; }
.banner.t-bronze { background: var(--bronze-bg); border-color: var(--bronze-bd); color: #fff; }
.bn-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bn-head h2 { font-size: 22px; }
.banner { padding: 8px 12px 10px; margin: 8px 0; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .1em; padding: 3px 10px; border-radius: 999px; border: 1.5px solid currentColor; }
.badge.certain { background: var(--ok); border-color: var(--ok); color: #fff; }
.bn-why { font-size: 15px; opacity: .92; margin: 4px 0 2px; line-height: 1.35; }
.banner.done { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pt-row { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; gap: 6px 8px; margin-top: 6px; }
.pt-row b { grid-column: 1 / -1; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-row b .pt-src { font-weight: 500; opacity: .8; font-size: 13px; }
@media (min-width: 440px) {
  .pt-row:has(b) { grid-template-columns: auto 1fr 1fr 1fr; }
  .pt-row b { grid-column: auto; margin-right: 2px; }
}
.pt {
  border: 1.5px solid currentColor; background: transparent; color: inherit; border-radius: 999px; padding: 5px 8px;
  font-weight: 700; font-size: 15px; min-height: 36px; white-space: nowrap;
}
.pt.sel { background: var(--primary); color: var(--on-primary); border-color: var(--primary); outline: 2px solid currentColor; outline-offset: 3px; }
.pt.sel.t-inox { background: var(--inox-bg); color: #1c2024; border-color: var(--inox-bd); outline-color: #1c2024; }
.pt.sel.t-carbone { background: var(--carbone-bg); color: #fff; border-color: var(--carbone-bd); outline-color: currentColor; }
.banner.t-carbone .pt.sel.t-carbone, .banner.t-bronze .pt.sel.t-bronze { outline-color: #fff; box-shadow: 0 0 0 1.5px #fff inset; }
.pt.sel.t-bronze { background: var(--bronze-bg); color: #fff; border-color: var(--bronze-bd); }
.pt.sel.dashed { outline-style: dashed; }
.banner.t-inox .pt.sel.t-carbone, .banner.t-inox .pt.sel.t-bronze { outline-color: #1c2024; }

.pt-card { padding: 10px 14px; }

/* ---------- Players ---------- */
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 4px; }
.teams .col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tg-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 14px; color: var(--muted); }
.pcard { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 5px 6px 3px; transition: opacity .2s; }
.pcard.off { opacity: .45; }
.pc-head { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.pc-head b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-head small { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dots { margin-left: auto; display: flex; gap: 3px; flex: none; flex-wrap: wrap; justify-content: flex-end; max-width: 60px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--faint); }
.dots.t-inox i.full { background: #c5cbd1; border-color: #8e959c; }
.dots.t-carbone i.full { background: #3a4047; border-color: #1c2024; }
.dots.t-bronze i.full { background: #a5642c; border-color: #5a3412; }
:root[data-theme="dark"] .dots.t-carbone i.full { border-color: #8a929a; }
.pc-balls { display: flex; justify-content: space-around; gap: 4px; margin-top: 2px; }
.pc-balls .ball { --bs: 46px; }
.bb {
  background: none; border: 0; padding: 1px 2px; display: flex; flex-direction: column; align-items: center; gap: 0;
  touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; color: var(--muted);
}
.bw { display: block; border-radius: 50%; padding: 2px; border: 2.5px solid transparent; transition: transform .1s; }
.bb.tir .bw { border: 2.5px dashed var(--faint); }
.bb.sugg .bw { border: 4px solid var(--buis); padding: 0.5px; box-shadow: 0 0 0 3px var(--buis-soft); }
.bb.sugg .bl { color: var(--buis); }
.bb.pressed .bw { transform: scale(.9); }
.bl { font-size: 13px; font-weight: 650; line-height: 1.2; }
.bb:disabled { opacity: .7; }

/* ---------- Mène options ---------- */
.mopts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 2px; }
.mopts > span { color: var(--muted); }
.tog { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 14px; font-weight: 700; min-height: 40px; }
.tog.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tog:disabled { opacity: .4; }
.tog.sm { min-height: 34px; padding: 4px 12px; font-size: 14px; font-weight: 600; }

.howto { padding: 0 2px 4px; font-size: 15px; }

/* Collapsible sections under the playing area (journal, history, help) */
.fold { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; margin: 8px 0; overflow: hidden; }
.fold-h { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: none; border: 0; padding: 12px 14px; min-height: 48px; font-weight: 750; font-size: 16px; text-align: left; color: var(--text); }
.fold-h small { font-weight: 600; color: var(--on-primary); background: var(--muted); border-radius: 999px; padding: 1px 8px; margin-left: 6px; font-size: 13px; }
.fold.open > .fold-h .chev { transform: rotate(-135deg); margin-bottom: -2px; }
.fold-b { max-height: 55dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 0 10px 10px; border-top: 1px solid var(--line); }
.fold-b .mrow { margin: 8px 0 0; }
.fold-b > .journal { padding-top: 8px; }
.quick h2 { margin-bottom: 2px; }

/* Jack distance: a chip that opens a horizontal 6–10 m scroller */
.dist-pick { display: flex; align-items: center; gap: 8px; margin: 10px 2px; min-height: 40px; }
.dp-l { color: var(--muted); flex: none; }
.dp-scroll {
  flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch; scrollbar-width: none; padding: 2px; touch-action: pan-x;
  mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 14px), transparent 100%);
}
.dp-scroll::-webkit-scrollbar { display: none; }
.dp-v {
  flex: none; scroll-snap-align: center; min-width: 64px; min-height: 40px; border-radius: 999px; font-weight: 700; font-size: 15px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--text); font-variant-numeric: tabular-nums;
}
.dp-v.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.dp-x { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card2); font-size: 20px; line-height: 1; color: var(--text); }
.grille { width: 100%; border-collapse: collapse; margin: 8px 0; }
.grille td { padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }

/* ---------- Journal ---------- */
.journal { display: flex; flex-direction: column; gap: 8px; }
.jitem {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 1.5px solid var(--line);
  border-left: 6px solid var(--faint); border-radius: 14px; padding: 8px 10px; cursor: pointer;
}
.jitem.t-inox { border-left-color: #b5bcc3; }
.jitem.t-carbone { border-left-color: #343a40; }
.jitem.t-bronze { border-left-color: #8e5524; }
:root[data-theme="dark"] .jitem.t-carbone { border-left-color: #8a929a; }
.jitem.mark { box-shadow: 0 0 0 2px var(--warn); }
.jn { font-size: 18px; color: var(--muted); min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; }
.jmain { flex: 1; min-width: 0; }
.jl1 b { font-size: 17px; }
.jl1 small { color: var(--muted); }
.jx { margin-left: 4px; }
.jl2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.jl2 > small { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip {
  border: 1.5px solid var(--line); background: var(--card2); border-radius: 999px; padding: 4px 11px; font-size: 14px;
  font-weight: 600; min-height: 32px; display: inline-flex; align-items: center; gap: 4px; color: var(--text);
}
.chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.chip.dashed { border-style: dashed; }
.chip.sm { min-height: 28px; padding: 2px 9px; font-size: 13px; }
.chip:disabled { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: none; }
.chips.scroll .chip { flex: none; }
.chips.add { margin-top: 10px; }
.qb {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; font-weight: 800; font-size: 17px;
  color: #fff; flex: none; font-variant-numeric: tabular-nums;
}
.qb.q0 { background: transparent; color: var(--muted); border: 1.5px dashed var(--faint); }
.qb.q1 { background: var(--q1); } .qb.q2 { background: var(--q2); } .qb.q3 { background: var(--q3); }
.qb.q4 { background: var(--q4); } .qb.q5 { background: var(--q5); }
.mf { font-size: 26px; width: 30px; text-align: center; flex: none; }

/* ---------- Mène rows ---------- */
.prev { margin-top: 6px; }
.mrow { background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; margin: 8px 0; overflow: hidden; }
.mrow-h { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 10px 12px; text-align: left; min-height: 50px; }
.mn { font-weight: 800; font-size: 15px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--card2); flex: none; }
.mr { font-weight: 700; flex: 1; }
.ms { font-weight: 800; font-variant-numeric: tabular-nums; }
.mrow-h small { color: var(--muted); white-space: nowrap; }
.chev { width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: 0 4px 4px; transition: transform .15s; }
.mrow.open .chev { transform: rotate(-135deg); margin-bottom: -2px; }
.mrow-b { padding: 0 10px 10px; }

/* ---------- Bottom bars ---------- */
.bar, .tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 8px 12px calc(8px + var(--safe-b)); }
.bar .btn { min-height: 46px; padding: 6px 4px; font-size: 16px; }
.tabbar { display: grid; grid-template-columns: repeat(4, 1fr); padding: 4px 4px var(--safe-b); }
.tab { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab.on { color: var(--text); }
@media (min-width: 640px) { .bar, .tabbar { left: 50%; width: 600px; transform: translateX(-50%); border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }

/* ---------- Sheets ---------- */
#sheet-root .backdrop { position: fixed; inset: 0; background: rgba(10, 12, 14, .45); z-index: 40; animation: fade .18s ease-out; }
#sheet-root .sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 600px; margin: 0 auto;
  background: var(--card); border-radius: 22px 22px 0 0; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 16px calc(18px + var(--safe-b)); animation: up .24s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -8px 30px rgba(0,0,0,.2);
}
#sheet-root .sheet.tall { max-height: 94dvh; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet-body h2 { margin-bottom: 8px; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Forms ---------- */
.field { margin: 12px 0; }
.field > label { display: block; font-weight: 700; margin-bottom: 6px; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%; font-size: 17px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card2); min-height: 46px;
}
textarea { resize: vertical; }
.opt { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; }
.opt input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--ok); }
.opt input[switch] { width: auto; height: auto; }
.opt span { display: flex; flex-direction: column; }
.opt small { color: var(--muted); }
.frow { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; }
.frow input, .frow select { width: 110px; flex: none; }
.range { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.range input { width: 100%; accent-color: var(--primary); }
h4.sec { text-transform: uppercase; letter-spacing: .08em; font-size: 14px; color: var(--muted); margin-top: 20px; }
.inrow { display: flex; gap: 8px; }
.inrow .btn { flex: none; min-height: 46px; }
.file-btn { cursor: pointer; }

.qrow, .hrow { display: flex; gap: 6px; flex-wrap: wrap; }
.qsel { display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--card2); border: 1.5px solid var(--line); border-radius: 12px; padding: 6px 4px; min-width: 50px; flex: 1; }
.qsel small { font-size: 11px; color: var(--muted); }
.qsel.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--text); }
.hsel { font-size: 26px; width: 46px; height: 46px; border-radius: 12px; background: var(--card2); border: 1.5px solid var(--line); display: grid; place-items: center; padding: 0; }
.hsel.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--text); background: var(--card); }
.hsel.sugg { border: 2px dashed var(--text); }
.padrow { display: flex; align-items: center; gap: 12px; }
.moodrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.moodrow > span { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.moodrow .hrow { flex-wrap: nowrap; gap: 4px; }
.moodrow .hsel { width: 40px; height: 40px; font-size: 22px; }
.seg3 .btn.rw { min-height: 54px; }

.teams.mini .pmini { background: var(--card2); border-radius: 12px; padding: 6px; }
.teams.mini .ball { --bs: 46px; }

/* ---------- End of game, review ---------- */
.end-title { font-size: 26px; }
.end-score { margin: 6px 0 4px; }
.sl { display: inline-flex; align-items: center; gap: 8px; font-size: 22px; }
.sl i { color: var(--muted); font-style: normal; }
.kv { margin: 6px 0; display: grid; gap: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.kv > div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.save-box { background: var(--card2); border-radius: 14px; padding: 4px 12px 8px; margin: 14px 0; }

.sum .big-score { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 44px; font-weight: 850; font-variant-numeric: tabular-nums; }
.sum .big-score i { color: var(--muted); font-style: normal; font-weight: 400; }
.st { text-align: center; font-weight: 700; font-size: 18px; }
.sum > .muted { text-align: center; }
.tbs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.tb ul { list-style: none; margin: 6px 0 0; padding: 0; }
.tb li { padding: 3px 0; }
.tb li small { color: var(--muted); }
.moods { white-space: nowrap; }
.notes { white-space: pre-wrap; background: var(--card2); border-radius: 10px; padding: 8px 10px; }
.lock, .todo { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.todo > div { display: flex; flex-direction: column; flex: 1; min-width: 160px; }
.todo small { color: var(--muted); }

.curve { margin: 10px 0; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r); padding: 10px 8px 6px; }
.curve svg { width: 100%; height: auto; display: block; }
.curve .grid { stroke: var(--line); stroke-width: 1; }
.curve .ax { fill: var(--muted); font-size: 10px; }
.curve .ln { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.curve .ln.dash { stroke-dasharray: 6 4; }
.curve .c-inox { stroke: #8e959c; fill: #8e959c; }
.curve .c-carbone { stroke: #343a40; fill: #343a40; }
.curve .c-bronze { stroke: #9a5a26; fill: #9a5a26; }
:root[data-theme="dark"] .curve .c-inox { stroke: #dfe3e7; fill: #dfe3e7; }
:root[data-theme="dark"] .curve .c-carbone { stroke: #8a929a; fill: #8a929a; }
.curve .ln.c-inox, .curve .ln.c-carbone, .curve .ln.c-bronze { fill: none; }
.curve figcaption { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; }

/* ---------- Home and lists ---------- */
.install { background: var(--info-bg); }
.backup { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.backup > div { display: flex; flex-direction: column; }
.backup small { color: var(--muted); }
.backup.warn { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--card)); }
.backup-ok { color: var(--ok); margin: 6px 4px; }
.resume { width: 100%; display: flex; align-items: center; justify-content: space-between; text-align: left; gap: 10px; color: var(--text); }
.rs-score { display: flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 850; margin: 2px 0; }
.rs-score i { font-style: normal; color: var(--muted); font-weight: 400; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list.dim { opacity: .6; }
.gitem, .litem {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; background: var(--card); color: var(--text);
  border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; min-height: 60px;
}
.gi-d { display: flex; flex-direction: column; min-width: 54px; }
.gi-d small, .gi-m small { color: var(--muted); }
.gi-m { flex: 1; min-width: 0; }
.gi-m > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.gi-r { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.res { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 13px; font-weight: 800; background: var(--card2); }
.res.win { background: var(--ok); color: #fff; }
.res.lose { background: var(--danger); color: #fff; }
.todo-badge { background: var(--warn); color: #fff; border-radius: 999px; font-size: 12px; font-weight: 800; min-width: 20px; height: 20px; display: grid; place-items: center; padding: 0 6px; }
.litem { justify-content: space-between; }
.litem > div { display: flex; flex-direction: column; }
.litem small { color: var(--muted); }

/* ---------- Setup ---------- */
.sel-p { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sel-p b { flex: 1; }
.x { width: 34px; height: 34px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card2); font-size: 20px; line-height: 1; }
.form-t { margin: 4px 6px 10px; font-weight: 600; }

/* ---------- Stats ---------- */
.gb { border-top: 1px solid var(--line); padding-top: 4px; }
.gb:first-of-type { border-top: 0; }
.dist { display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.dr { display: flex; align-items: center; gap: 8px; }
.dr .qb { width: 24px; height: 24px; font-size: 13px; border-radius: 7px; }
.dr .meter { flex: 1; height: 10px; border-radius: 5px; background: var(--card2); display: block; overflow: hidden; }
.dr .meter i { display: block; height: 100%; border-radius: 5px; }
.dr .meter i.q1 { background: var(--q1); } .dr .meter i.q2 { background: var(--q2); } .dr .meter i.q3 { background: var(--q3); }
.dr .meter i.q4 { background: var(--q4); } .dr .meter i.q5 { background: var(--q5); }
.dr small { width: 28px; text-align: right; color: var(--muted); }
.tl > div { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tl span { flex: 1; font-weight: 600; }
.tl small { color: var(--muted); }

/* ---------- Replay ---------- */
.rp-stage { min-height: 360px; touch-action: pan-y; }
.rp-score { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 34px; font-weight: 850; font-variant-numeric: tabular-nums; }
.rp-score i { font-style: normal; color: var(--muted); font-weight: 400; }
.rp-main { text-align: center; padding: 16px 0; min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; animation: fade .25s; }
.rp-ball .bw.xl .ball { --bs: 84px; }
.rp-q { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 18px; }
.rp-h { font-weight: 500; }
.rp-range { width: 100%; margin: 6px 0; accent-color: var(--primary); }
.rp-ctrl { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rp-ctrl .btn { font-size: 20px; padding: 0; }
.rp-speed { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Help ---------- */
.steps { padding-left: 22px; margin: 6px 0; }
.steps li { margin: 6px 0; }
.ios-share { display: inline-block; width: 16px; height: 20px; vertical-align: -3px; border: 2px solid currentColor; border-top: 0; border-radius: 0 0 3px 3px; position: relative; margin: 0 2px; }
.ios-share::before { content: "↑"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 14px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--bar-h) + 16px + var(--safe-b)); z-index: 60; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast {
  pointer-events: auto; background: #1c2024; color: #fff; border-radius: 14px; padding: 12px 16px; font-weight: 600;
  display: flex; align-items: center; gap: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: fade .2s; max-width: 560px;
}
:root[data-theme="dark"] .toast { background: #eceef0; color: #111417; }
.toast-act { background: none; border: 0; color: inherit; font-weight: 800; text-decoration: underline; padding: 4px; }

/* ---------- Gesture overlay (4.1) ---------- */
#gesture-root { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
#gesture-root:empty { display: none; }
.g-banner {
  position: fixed; top: calc(8px + var(--safe-t)); left: 12px; right: 12px; max-width: 576px; margin: 0 auto;
  background: #1c2024; color: #fff; border-radius: 18px; padding: 12px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.g-title { display: flex; align-items: center; gap: 10px; font-size: 24px; }
.g-title .ball { --bs: 26px; }
.g-val { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 20px; flex-wrap: wrap; min-height: 36px; }
.g-val small { color: #b8bec5; }
.g-val .qb.q0 { color: #fff; border-color: #8a929a; }
.g-mood { white-space: nowrap; }
.g-wrap { position: fixed; transform: translate(-50%, -50%); }
.g-grid {
  display: grid; grid-template-columns: repeat(var(--cols), var(--cran)); grid-template-rows: repeat(5, var(--cran)); gap: 2px;
  background: rgba(255,255,255,.9); padding: 2px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.g-cell { border-radius: 3px; display: grid; place-items: center; position: relative; }
.g-cell.gq1 { background: var(--q1s); } .g-cell.gq2 { background: var(--q2s); } .g-cell.gq3 { background: var(--q3s); }
.g-cell.gq4 { background: var(--q4s); } .g-cell.gq5 { background: var(--q5s); }
.g-center { background: #fff !important; }
.g-center i { font-style: normal; width: 80%; height: 80%; border-radius: 50%; border: 2px dashed #555; display: grid; place-items: center; font-size: calc(var(--cran) * .4); color: #555; }
.g-cell.on { outline: 3px solid #111; z-index: 1; }
.g-cell.on.gq1 { background: var(--q1); } .g-cell.on.gq2 { background: var(--q2); } .g-cell.on.gq3 { background: var(--q3); }
.g-cell.on.gq4 { background: var(--q4); } .g-cell.on.gq5 { background: var(--q5); }
.g-cell.on.g-center { background: #fff !important; }
.g-cell.on::after { content: attr(data-face); font-size: calc(var(--cran) * .7); line-height: 1; }
.g-lbl {
  position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; background: #fff; color: #1c2024;
  font-weight: 800; font-size: 14px; padding: 2px 10px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.g-lbl.top { bottom: calc(100% + 4px); }
.g-lbl.bottom { top: calc(100% + 4px); }
.g-face { position: absolute; top: 50%; transform: translateY(-50%); font-size: 26px; background: #fff; border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.g-face.left { right: calc(100% + 6px); }
.g-face.right { left: calc(100% + 6px); }

/* Small phones (iPhone SE / mini) */
@media (max-width: 380px) {
  .sc-num { font-size: 38px; }
  .pill { font-size: 13px; padding-right: 9px; }
  .tm b { font-size: 22px; }
  .ball { --bs: 46px; }
  .bn-head h2 { font-size: 22px; }
  .pc-head b { font-size: 16px; }
  .pt { padding: 5px 10px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
