/* Écran d'app plein cadre : barre en haut, contenu défilant, barre d'action fixe en bas quand il y en a une */
@font-face {
  font-family: "Grandstander";
  src: url("fonts/grandstander-800.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}
:root {
  --paper: #efe4cc; --card: #fbf6ea; --ink: #3b2a1e; --muted: #7a6754; --line: #e0d2b6;
  --water: #1f7f8f; --water-ink: #fff; --soft: #f5ecd9; --danger: #b0392e; --gold: #c98a12;
  --t-blue: #2a93a8; --t-grey: #9aa1a4; --t-brown: #7b4b2c; --t-green: #8db83c;
  --t-yellow: #e9b824; --t-red: #c4453a; --t-purple: #8a62c9;
  --f-display: "Grandstander", "Chalkboard SE", "Comic Sans MS", system-ui, sans-serif;
  --f-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1b1814; --card: #26211b; --ink: #f1e6d2; --muted: #b3a28c; --line: #3a3229;
    --water: #3fb0c1; --water-ink: #0f1a1c; --soft: #2f2921; --danger: #e0675b; --gold: #f0b53a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper); color: var(--ink); font: 15px/1.4 var(--f-body);
  touch-action: manipulation; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--water); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 800; margin: 0; text-wrap: balance; }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.bar {
  position: sticky; top: 0; z-index: 5; background: var(--paper);
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
}
.bar h2 { font-size: 21px; flex: 1; min-width: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; background: var(--card); border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 18px; flex: none;
}
.body { flex: 1; padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.body.with-foot { padding-bottom: calc(96px + var(--safe-b)); }
.sec { font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 8px 2px -4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.note { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 0; }
.tag { display: inline-block; font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; background: var(--soft); color: var(--muted); margin-right: 3px; }
.cta {
  background: var(--water); color: var(--water-ink); border-radius: 14px; padding: 14px;
  font-weight: 800; font-size: 16px; width: 100%; text-align: center;
}
.cta:disabled { opacity: .45; }
.cta.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.cta.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }
.cta:active, .step button:active, .pad button:active, .acard:active { transform: scale(.96); }

/* Accueil */
.hero { position: relative; height: 210px; overflow: hidden; }
.hero img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 45%; display: block; }
.hero::after { content: ""; position: absolute; inset: auto 0 0; height: 90px; background: linear-gradient(transparent, var(--paper)); }
.hero h1 { position: absolute; left: 16px; bottom: 8px; z-index: 1; font-size: 34px; letter-spacing: .06em; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; text-align: center; min-width: 0; }
.stat b { display: block; font-family: var(--f-display); font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; }
.game .thumb svg { width: 48px; height: 40px; display: block; }
.game .n { font-weight: 800; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game .m { font-size: 12px; color: var(--muted); }
.game .s { font-family: var(--f-display); font-size: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.game .s small { display: block; font-family: var(--f-body); font-weight: 600; font-size: 11px; color: var(--muted); }
.empty { text-align: center; padding: 22px 12px; color: var(--muted); }
.links { display: flex; justify-content: center; gap: 18px; font-size: 13px; color: var(--muted); padding-top: 8px; }
.links button { text-decoration: underline; text-underline-offset: 3px; }

/* Paramètres */
.players { display: flex; flex-direction: column; gap: 8px; }
.prow { display: flex; align-items: center; gap: 8px; }
.prow input {
  flex: 1; min-width: 0; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-weight: 700;
}
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 11px; border-radius: 999px; background: var(--card); border: 1px dashed var(--line); font-weight: 700; font-size: 13px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row .txt { flex: 1; min-width: 0; }
.row .txt b { display: block; font-size: 14px; }
.row .txt span { font-size: 12px; color: var(--muted); }
.sw { width: 46px; height: 28px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.sw[aria-checked="true"] { background: var(--water); }
.sw[aria-checked="true"]::after { transform: translateX(18px); }
.subopts { padding-left: 14px; border-left: 2px solid var(--line); margin-left: 6px; }
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.board {
  background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 6px 6px 8px;
  text-align: left; display: flex; flex-direction: column; gap: 3px; position: relative;
}
.board svg { width: 100%; height: auto; display: block; }
.board b { font-family: var(--f-display); font-size: 15px; padding: 0 4px; }
.board span { font-size: 11px; color: var(--muted); padding: 0 4px; line-height: 1.3; }
.board[aria-pressed="true"] { border-color: var(--water); }
.board[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--water); color: var(--water-ink); display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.board .x { position: absolute; top: 10px; left: 10px; font-size: 9px; font-weight: 800; letter-spacing: .06em; background: var(--t-purple); color: #fff; padding: 2px 6px; border-radius: 6px; }

/* Saisie */
.ptabs { display: flex; gap: 6px; padding: 0 16px 8px; overflow-x: auto; scrollbar-width: none; position: sticky; top: calc(56px + var(--safe-t)); z-index: 4; background: var(--paper); }
.ptabs::-webkit-scrollbar { display: none; }
.ptab { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 6px 12px; display: flex; flex-direction: column; align-items: flex-start; min-width: 78px; }
.ptab b { font-size: 13px; display: flex; align-items: center; gap: 5px; }
.ptab b .dot { width: 9px; height: 9px; }
.ptab span { font-family: var(--f-display); font-size: 17px; font-variant-numeric: tabular-nums; }
.ptab[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.cat { display: flex; flex-direction: column; gap: 8px; }
.cat-h { display: flex; align-items: center; gap: 8px; }
.cat-h h3 { font-size: 17px; flex: 1; }
.cat-h h3 small { font-family: var(--f-body); font-size: 11px; color: var(--muted); font-weight: 600; }
.pts { font-family: var(--f-display); font-size: 19px; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.pts small { font-family: var(--f-body); font-size: 11px; color: var(--muted); font-weight: 600; }
.ln { display: grid; grid-template-columns: 30px 1fr auto; gap: 8px; align-items: center; }
.ln .lt { font-size: 14px; min-width: 0; }
.ln .lt small { color: var(--muted); font-size: 11px; display: block; }
.step { display: flex; align-items: center; background: var(--soft); border-radius: 11px; }
.step button { width: 40px; height: 40px; font-size: 20px; font-weight: 800; color: var(--water); }
.step input {
  width: 34px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums;
  background: transparent; border: 0; padding: 0; -moz-appearance: textfield;
}
.step input::-webkit-outer-spin-button, .step input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.count { font-size: 12px; font-weight: 800; background: var(--water); color: var(--water-ink); padding: 3px 9px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.howto { background: var(--soft); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.howto b { font-size: 13px; }
.howto span { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.cards { display: flex; flex-wrap: wrap; gap: 8px; min-height: 44px; align-items: center; }
.acard {
  position: relative; width: 36px; height: 46px; border-radius: 7px; background: linear-gradient(160deg, #c98a4e, #8a5530);
  color: #fff; font-family: var(--f-display); display: grid; place-items: center; font-size: 17px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.25);
}
.acard i { position: absolute; top: -6px; right: -6px; width: 17px; height: 17px; border-radius: 50%; background: var(--ink); color: var(--paper); font-style: normal; font-size: 9px; display: grid; place-items: center; font-family: var(--f-body); }
.pad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pad button { border: 1px solid var(--line); background: var(--card); border-radius: 9px; padding: 9px 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(12px + var(--safe-b));
}
.foot-in { max-width: 528px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.foot .who { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); }
.foot .who b { display: block; color: var(--ink); font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot .big { font-family: var(--f-display); font-size: 32px; font-variant-numeric: tabular-nums; }
.foot .cta { width: auto; padding: 12px 16px; }
.seg { display: flex; background: var(--soft); border-radius: 11px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 9px; font-weight: 700; font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* Résultats */
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 8px; padding-top: 6px; }
.pod { flex: 1; max-width: 130px; text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; min-width: 0; }
.av { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-display); font-size: 20px; color: #fff; }
.pod b { font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blk { width: 100%; border-radius: 12px 12px 4px 4px; background: var(--card); border: 1px solid var(--line); font-family: var(--f-display); font-size: 22px; padding: 8px 0; font-variant-numeric: tabular-nums; }
.pod.r1 .blk { padding: 20px 0; background: color-mix(in srgb, var(--gold) 22%, var(--card)); border-color: var(--gold); }
.pod.r2 .blk { padding: 12px 0; }
.crown { font-size: 20px; line-height: 1; }
.tblwrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 7px 4px; text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th { font-size: 12px; color: var(--muted); font-weight: 800; max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
.tbl tbody tr + tr td { border-top: 1px solid var(--line); }
.tbl .cn { display: flex; align-items: center; gap: 6px; }
.tbl tfoot td { font-family: var(--f-display); font-size: 17px; border-top: 2px solid var(--ink); }
.suns { font-family: var(--f-display); font-size: 26px; text-align: center; color: var(--gold); }
.suns small { display: block; font-family: var(--f-body); font-size: 12px; color: var(--muted); font-weight: 600; }

/* Fenêtre de confirmation */
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(20,14,8,.45); display: grid; place-items: end center; padding: 16px 16px calc(16px + var(--safe-b)); }
#modal[hidden] { display: none; }
.sheet { background: var(--card); border-radius: 18px; padding: 18px; width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 12px; }
.sheet h3 { font-size: 19px; }

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