/* Thème « terrain de padel » : bleu nuit, bleu du terrain, jaune de la balle. */
:root {
  --bg: #eaf2fc; --card: #fff; --ink: #0b2a5b; --muted: #5a6f8f; --line: #d3e0f2;
  --brand: #0b2a5b; --court: #1d5fd1; --btn: #0b2a5b; --accent: #d4f04a; --accent-ink: #0b2a5b; --tint: #eef9b8; --focus: #1d5fd1;
  --ok: #1b8a4b; --danger: #d9442b; --radius: 22px; --shadow: 0 2px 10px rgba(11, 42, 91, .07);
  --a: #1d5fd1; --b: #d4a900;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a1630; --card: #12254a; --ink: #eaf2fc; --muted: #9db2d4; --line: #23396b; --brand: #0a1630; --btn: #2a54a8; --tint: rgba(212, 240, 74, .14);
    --focus: #d4f04a; --ok: #4cd08a; --danger: #ff7b6b; --shadow: none; --a: #6ea2ff; --b: #d4f04a; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, .brand { font-family: "Bricolage Grotesque", "DM Sans", system-ui, sans-serif; }
h1 { font-size: 1.7rem; letter-spacing: -.5px; margin: 8px 0 4px; }
h2 { font-size: 1.15rem; margin: 22px 0 8px; }
a { color: inherit; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top)); background: #0b2a5b; color: #fff; }
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.25rem; letter-spacing: -.4px; display: flex; align-items: center; gap: 10px; }
.top button.ghost { color: #fff; background: rgba(255, 255, 255, .16); border: 0; min-height: 40px; padding: 0 16px; }
.top[hidden], #account[hidden], .tabs[hidden] { display: none; }

main { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin: 10px 0; box-shadow: var(--shadow); }
a.card { display: block; text-decoration: none; }
a.card:active { transform: scale(.99); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--line); color: var(--ink); }
.badge.live { background: var(--accent); color: var(--accent-ink); letter-spacing: .04em; }
.badge.win { background: var(--ok); color: #fff; }
.badge.loss { background: var(--danger); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.err { color: var(--danger); font-size: .9rem; min-height: 1.3em; }

/* Boutons et champs */
button, .btn { font: inherit; border: 0; border-radius: 99px; padding: 11px 18px; min-height: 44px; cursor: pointer; background: var(--btn); color: #fff; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); }
button.ghost { background: transparent; color: inherit; border: 2px solid var(--line); padding: 6px 14px; min-height: 40px; font-size: .9rem; }
button.danger { background: transparent; color: var(--danger); border: 2px solid var(--danger); }
button.small { padding: 6px 14px; min-height: 40px; font-size: .9rem; }
button.big { min-height: 64px; font-size: 1.2rem; width: 100%; }
button:disabled { opacity: .5; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
input, select, textarea { font: inherit; width: 100%; min-height: 46px; padding: 8px 14px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
textarea { resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 16px; border: 2px solid var(--line); background: var(--card); color: var(--ink); font-weight: 700; text-align: center; padding: 4px 8px; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Navigation du bas */
.tabs { position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom)); width: min(calc(100% - 24px), 520px);
  display: flex; gap: 2px; padding: 6px; border-radius: 30px; background: var(--card); box-shadow: 0 8px 30px rgba(11, 42, 91, .22); }
.tabs a { flex: 1; min-width: 0; min-height: 54px; border-radius: 24px; color: var(--muted); font-size: .72rem; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; }
.tabs a svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }

/* Accueil */
.hero { border-radius: 28px; padding: 20px; background: #0b2a5b; color: #fff; margin: 4px 0 12px; }
.hero h1 { margin-top: 0; }
.hero .muted { color: rgba(255, 255, 255, .75); }
.hero button.primary { margin-top: 14px; }
.gcard { display: block; text-decoration: none; }
.gcard .teams { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.gcard .t { font-weight: 800; overflow-wrap: anywhere; }
.gcard .t.w { color: var(--ok); }
.gcard .sc { font-variant-numeric: tabular-nums; font-size: 1.1rem; letter-spacing: .06em; white-space: nowrap; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips button { flex: none; background: var(--card); color: var(--ink); border: 2px solid var(--line); min-height: 40px; padding: 6px 14px; font-size: .9rem; }
.chips button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Statistiques */
.stats4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.stats4 > div { background: var(--card); border-radius: 20px; padding: 14px 4px; text-align: center; box-shadow: var(--shadow); }
.stats4 b { display: block; font: 800 1.45rem/1 "Bricolage Grotesque", sans-serif; }
.stats4 span { display: block; font-size: .72rem; color: var(--muted); margin-top: 6px; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dot { display: inline-flex; width: 30px; height: 30px; border-radius: 50%; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; color: #fff; }
.dot.v { background: var(--ok); } .dot.d { background: var(--danger); } .dot.n { background: var(--line); color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list td, table.list th { padding: 8px 4px; border-top: 1px solid var(--line); text-align: right; }
table.list th { color: var(--muted); font-weight: 500; font-size: .78rem; border-top: 0; }
table.list td:first-child, table.list th:first-child { text-align: left; font-weight: 700; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ref { stroke: var(--muted); stroke-dasharray: 4 4; stroke-width: 1; }
.chart .line { fill: none; stroke: var(--a); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--a); opacity: .12; }
.chart text { fill: var(--muted); font-size: 11px; font-family: "DM Sans", sans-serif; }
.chart .dotw { fill: var(--ok); } .chart .dotl { fill: var(--danger); }
.chart .bw { fill: var(--ok); } .chart .bl { fill: var(--danger); } .chart .ba { fill: var(--a); } .chart .bb { fill: var(--b); }
.cmp { display: grid; grid-template-columns: 3.5rem 1fr 3.5rem; align-items: center; gap: 8px; margin: 10px 0; font-variant-numeric: tabular-nums; }
.cmp .l { text-align: left; font-weight: 800; } .cmp .r { text-align: right; font-weight: 800; }
.cmp .mid { min-width: 0; }
.cmp .mid small { display: block; text-align: center; color: var(--muted); font-size: .78rem; margin-bottom: 3px; }
.cmp .bars { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line); gap: 2px; }
.cmp .bars i { display: block; height: 100%; }
.cmp .bars i:first-child { background: var(--a); } .cmp .bars i:last-child { background: var(--b); }

/* Dialogues et message */
dialog { border: 0; border-radius: 26px; padding: 20px; width: min(94vw, 460px); background: var(--card); color: var(--ink); max-height: 92vh; overflow-y: auto; }
dialog::backdrop { background: rgba(5, 15, 40, .6); }
#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--btn); color: #fff;
  padding: 10px 18px; border-radius: 99px; opacity: 0; pointer-events: none; transition: .25s; z-index: 20; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.sets { display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px; align-items: center; }
.sets input, .sets select { text-align: center; font-size: 1.1rem; padding-inline: 6px; }
.sets .lab { font-size: .8rem; color: var(--muted); }
.sets .tbonly { display: none; }
.sets.tb .tbonly { display: block; } .sets.tb .notb { display: none; }

/* Page de comptage : plein écran, gros boutons, pensée pour le paysage (téléphone sur un support) */
body.playing .top, body.playing .tabs { display: none; }
body.playing { overscroll-behavior: none; }
body.playing main { max-width: none; padding: 0; }
.keeper { position: relative; height: 100dvh; display: flex; flex-direction: column; gap: 8px; color: #fff; background: #0b2a5b; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.kbar { display: flex; align-items: center; gap: 8px; }
.kmeta { flex: 1; min-width: 0; font-size: .85rem; line-height: 1.2; }
.ksync { font-size: .72rem; opacity: .85; } .ksync.off { color: var(--accent); font-weight: 700; opacity: 1; }
.kicon { width: 50px; height: 50px; min-height: 0; padding: 0; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; font-size: 1.5rem; line-height: 1; text-decoration: none; }
.kboard { background: rgba(0, 0, 0, .28); border-radius: 18px; padding: 4px 14px; }
.krow { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.krow + .krow { border-top: 1px solid rgba(255, 255, 255, .2); }
.kn { flex: 1; min-width: 0; font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: clamp(1rem, 4.4vw, 1.5rem); line-height: 1.1; overflow-wrap: anywhere; }
.kserve { display: inline-block; width: .6em; height: .6em; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: .1em; }
.kball { display: block; font: 700 .7rem "DM Sans", sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.ks { min-width: 1.4em; text-align: center; font-size: clamp(1.1rem, 5vw, 1.6rem); opacity: .75; }
.ks.w { opacity: 1; font-weight: 800; }
.ks.cur { opacity: 1; font-weight: 800; background: rgba(255, 255, 255, .16); border-radius: 10px; padding: 0 6px; }
.kp { min-width: 2.2ch; text-align: center; font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: clamp(2.1rem, 10vw, 3.4rem); line-height: 1; color: var(--accent); }
.krow.win .kn { color: var(--accent); }
.kstate { min-height: 1.3em; text-align: center; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .9rem; color: var(--accent); }
.kpads { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.kpad { flex: 1; min-height: 0; flex-direction: column; border-radius: 26px; padding: 10px; border: 4px solid #fff; background: #fff; color: #0b2a5b; transition: transform .08s; -webkit-tap-highlight-color: transparent; }
.kpad.p2 { background: var(--accent); border-color: var(--accent); }
.kpad:active { transform: scale(.97); filter: brightness(.92); }
.kname { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: clamp(1.1rem, 5.5vw, 1.9rem); text-align: center; line-height: 1.1; overflow-wrap: anywhere; }
.kplus { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: clamp(3rem, 16vw, 6rem); line-height: 1; }
.kdone { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 8px; }
.kdone h2 { margin: 0; font-size: clamp(1.4rem, 6vw, 2rem); }
.kdone .muted { color: rgba(255, 255, 255, .8); }
.kdone button.ghost, .krotate button.ghost { color: #fff; border-color: rgba(255, 255, 255, .5); }
.kdone .btn { background: rgba(255, 255, 255, .16); color: #fff; }
.kdone .btn.primary { background: var(--accent); color: #0b2a5b; }
.ktrophy { font-size: 3rem; line-height: 1; }
.kfinal { font: 800 clamp(1.8rem, 9vw, 3rem) "Bricolage Grotesque", sans-serif; color: var(--accent); letter-spacing: .06em; }
.krotate { display: none; }
@media (orientation: portrait) {
  .keeper:not(.stay) .krotate { display: flex; position: absolute; inset: 0; z-index: 3; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: #0b2a5b; }
}
.krotate h2 { margin: 0; font-size: 1.4rem; } .krotate p { margin: 0; opacity: .85; }
.kphone { font-size: 4rem; line-height: 1; animation: kturn 2.4s ease-in-out infinite; }
@keyframes kturn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (prefers-reduced-motion: reduce) { .kphone { animation: none; } }
@media (orientation: landscape) {
  .kpads { flex-direction: row; }
  .keeper { gap: 6px; padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: calc(8px + env(safe-area-inset-bottom));
    padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); }
  .kicon { width: 44px; height: 44px; font-size: 1.35rem; }
  .kmeta { font-size: .8rem; }
  .kboard { padding: 2px 14px; border-radius: 14px; }
  .krow { padding: 3px 0; }
  .kn { font-size: clamp(.95rem, 5vh, 1.4rem); } .ks { font-size: clamp(1rem, 5.5vh, 1.5rem); } .kp { font-size: clamp(1.7rem, 10vh, 2.8rem); }
  .kstate { min-height: 1.1em; font-size: .75rem; line-height: 1.1; }
  .kpad { border-radius: 22px; padding: 6px; }
  .kname { font-size: clamp(1rem, 6vh, 1.7rem); } .kplus { font-size: clamp(2.2rem, 17vh, 5.5rem); }
  .kdone { flex-direction: row; flex-wrap: wrap; gap: 8px 20px; }
  .ktrophy { font-size: 2.2rem; } .kfinal { font-size: clamp(1.4rem, 8vh, 2.2rem); }
}
@media (min-width: 640px) { main { padding: 24px; } }
