/* Mise en page : une colonne de 560 px max, mobile d'abord.
   Thème « par avion » : papier bleuté, liseré rouge et bleu d'enveloppe,
   tampons pour les points, cartes d'embarquement pour les étapes. */
:root {
  --paper: #EEF2F7;
  --card: #FFFFFF;
  --card-2: #F5F7FB;
  --ink: #13203A;
  --ink-2: #4A5874;
  --ink-3: #7B879D;
  --line: #D6DDE8;
  --red: #CE2F3C;
  --blue: #1E4FA6;
  --blue-soft: #E2EAF8;
  --amber: #B5650E;
  --gold: #D9A21B;
  --silver: #8C98AB;
  --bronze: #B8703A;
  --ok: #17805A;
  --ok-bg: #DFF2E8;
  --bad: #C0303D;
  --bad-bg: #FBE5E7;
  --warn-bg: #FFF2D6;
  --on-accent: #FFFFFF;
  --shadow: 0 1px 2px rgba(19, 32, 58, .06), 0 6px 18px rgba(19, 32, 58, .07);
  --radius: 16px;
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0C1322;
    --card: #152036;
    --card-2: #1B2842;
    --ink: #E8EDF6;
    --ink-2: #A6B2C8;
    --ink-3: #7D8AA3;
    --line: #2A3854;
    --red: #F06571;
    --blue: #7EA6F4;
    --blue-soft: #1D2E50;
    --amber: #F0A64B;
    --gold: #F2C14E;
    --silver: #A9B4C6;
    --bronze: #D99260;
    --ok: #4CC891;
    --ok-bg: #12342A;
    --bad: #F27985;
    --bad-bg: #3A1B25;
    --warn-bg: #3A2E12;
    --on-accent: #0C1322;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

/* ───────────── Base ───────────── */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 500 16px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.no-scroll { overflow: hidden; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
a { color: var(--blue); }
h1, h2, h3 { text-wrap: balance; }
p { margin: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

.wrap {
  width: 100%;
  max-width: 560px;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.page {
  display: grid;
  gap: 24px;
  padding-block: calc(env(safe-area-inset-top, 0px) + 20px) calc(env(safe-area-inset-bottom, 0px) + 40px);
}
.center { min-height: 60vh; place-content: center; justify-items: center; text-align: center; }
.center-text { text-align: center; }
.stack { display: grid; gap: 14px; }
.stack-sm { display: grid; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-nowrap { display: flex; gap: 10px; align-items: stretch; }
.row-nowrap > .field { flex: 1; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.mono {
  font-family: var(--f-mono);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.eyebrow {
  font: 600 .74rem/1.3 var(--f-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--red);
}
.h1 { margin: 0; font: 800 clamp(1.9rem, 7vw, 2.4rem)/1.05 var(--f-display); letter-spacing: -.02em; }
.h2 { margin: 0; font: 700 1.3rem/1.2 var(--f-display); }
.sec-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 0; font: 700 1.3rem/1.2 var(--f-display); letter-spacing: -.01em;
}
.sec-title .mono, .sec-title .link { font-size: .72rem; }
.empty {
  padding: 18px; border: 2px dashed var(--line); border-radius: var(--radius);
  color: var(--ink-2); text-align: center; text-wrap: pretty;
}
.note { color: var(--ink-2); text-wrap: pretty; }
.panel { background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.foot { text-align: center; padding-top: 8px; }
.back { justify-self: start; font-weight: 700; text-decoration: none; }

.loader {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px dashed var(--blue);
  animation: spin 2.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────── Boutons et champs ───────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border: 2px solid transparent; border-radius: 14px;
  font-weight: 700; text-decoration: none; text-align: center; line-height: 1.2;
  transition: transform .12s ease, background-color .15s ease, opacity .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-3); }
.btn-danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-sm { min-height: 38px; padding: 6px 14px; font-size: .9rem; border-radius: 11px; }
.btn-lg { min-height: 56px; font-size: 1.06rem; }
.btn-block { width: 100%; }
.link {
  background: none; border: 0; padding: 4px 0; color: var(--blue);
  font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
}
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 1.15rem; line-height: 1;
}
.icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 1rem; }
.icon-btn:disabled { opacity: .35; cursor: default; }

.field {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--ink);
  font-size: 16px; /* évite le zoom automatique sur iPhone */
}
.field:focus { outline: none; border-color: var(--blue); }
textarea.field { resize: vertical; line-height: 1.45; }
.field-big { min-height: 58px; font: 700 1.5rem/1 var(--f-display); text-align: center; letter-spacing: .01em; }
.field-text { font-size: 1.2rem; text-align: left; }
.field-code { width: 5.5em; text-transform: uppercase; font-family: var(--f-mono); font-weight: 600; letter-spacing: .08em; }
.field.is-right { border-color: var(--ok); background: var(--ok-bg); }
.field.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.field:disabled { opacity: 1; color: var(--ink); -webkit-text-fill-color: var(--ink); }

/* ───────────── Accueil ───────────── */

.local-banner {
  padding: 12px 14px; border-radius: 12px; background: var(--warn-bg);
  font-size: .9rem; color: var(--ink);
}

.envelope {
  padding: 8px;
  border-radius: 20px;
  background: repeating-linear-gradient(135deg,
    var(--red) 0 14px, var(--card) 14px 22px, var(--blue) 22px 36px, var(--card) 36px 44px);
  box-shadow: var(--shadow);
}
.envelope-in {
  display: grid; gap: 12px;
  padding: 18px 18px 20px;
  border-radius: 13px;
  background: var(--card);
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.hero-top .eyebrow { padding-top: 4px; }
.postmark { width: 74px; height: 74px; flex: none; color: var(--red); transform: rotate(12deg); opacity: .85; margin: -4px -4px -18px 0; }
.postmark text { font-family: var(--f-mono); letter-spacing: .5px; }
.title {
  margin: 0;
  font: 800 clamp(2.2rem, 10vw, 3.1rem)/.98 var(--f-display);
  letter-spacing: -.03em;
}
.lead { color: var(--ink-2); max-width: 46ch; text-wrap: pretty; }
.scale { display: flex; flex-wrap: wrap; gap: 10px 12px; padding-top: 4px; }

.stamp {
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 4px 8px;
  border: 2px solid currentColor; border-radius: 6px;
  font: 600 .68rem/1.1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase;
  transform: rotate(-2deg);
}
.stamp.d1, .seg-btn.d1 { color: var(--blue); }
.stamp.d2, .seg-btn.d2 { color: var(--amber); }
.stamp.d3, .seg-btn.d3 { color: var(--red); }

.player {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
}
.player-name { font: 700 1.2rem/1.2 var(--f-display); flex: 1; min-width: 0; overflow-wrap: anywhere; }
.player-ask { display: grid; gap: 12px; }
.player-form { display: grid; gap: 8px; }
.player-msg { display: grid; gap: 10px; padding: 12px; border-radius: 12px; background: var(--blue-soft); }

/* Cartes d'embarquement */
.passes { display: grid; gap: 12px; }
.pass {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  width: 100%; padding: 0; border: 0; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow); color: var(--ink);
  text-align: left; overflow: hidden;
  transition: transform .12s ease;
}
.pass:active { transform: scale(.99); }
.pass-main {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 2px 14px;
  padding: 14px 12px 14px 16px; min-width: 0;
}
.pass-code {
  grid-row: span 2;
  min-width: 2.6ch;
  font: 800 1.65rem/1 var(--f-display); letter-spacing: .01em; color: var(--blue);
}
.pass-title { font: 700 1.08rem/1.25 var(--f-display); overflow-wrap: anywhere; }
.pass-meta { font-size: .84rem; color: var(--ink-2); }
.pass-stub {
  position: relative;
  display: grid; place-items: center; align-content: center; gap: 2px;
  min-width: 88px; padding: 12px 14px;
  border-left: 2px dashed var(--line);
  text-align: center; color: var(--ink-2);
}
.pass-stub::before, .pass-stub::after {
  content: ""; position: absolute; left: -9px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--paper);
}
.pass-stub::before { top: -8px; }
.pass-stub::after { bottom: -8px; }
.stub-big { font: 800 1.35rem/1 var(--f-display); color: var(--ink); }
.pass.is-done .stub-big { color: var(--ok); }
.pass.is-new .stub-big, .pass.is-current .stub-big { color: var(--red); }

/* ───────────── Classement ───────────── */

.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.board-row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow);
}
.board-row.is-me { box-shadow: var(--shadow), inset 0 0 0 2px var(--blue); }
.rank {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  font: 800 1.05rem/1 var(--f-display); color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.rank-1, .rank-2, .rank-3 { border: 2px solid currentColor; transform: rotate(-8deg); }
.rank-1 { color: var(--gold); }
.rank-2 { color: var(--silver); }
.rank-3 { color: var(--bronze); }
.board-who { display: grid; min-width: 0; }
.board-name { font-weight: 800; overflow-wrap: anywhere; }
.board-sub { font-size: .8rem; color: var(--ink-2); }
.board-pts { font: 800 1.3rem/1 var(--f-display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-pts small { font: 600 .75rem var(--f-body); color: var(--ink-2); }
.me-tag {
  margin-left: 8px; padding: 2px 6px; border-radius: 6px;
  background: var(--blue); color: var(--on-accent); font-size: .6rem; vertical-align: 2px;
}
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 8px 14px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--card);
  color: var(--ink); font: 600 .8rem var(--f-mono); letter-spacing: .05em; text-decoration: none; text-transform: uppercase;
}
.tab.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ───────────── Carte d'embarquement (avant de jouer) ───────────── */

.ticket { border-radius: 18px; background: var(--card); box-shadow: var(--shadow); overflow: hidden; }
.ticket-top {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 18px; background: var(--blue); color: var(--on-accent);
}
.ticket-body { display: grid; gap: 4px; padding: 18px; }
.ticket-code { font: 800 clamp(3rem, 18vw, 4.4rem)/.9 var(--f-display); letter-spacing: -.02em; color: var(--blue); }
.ticket-title { margin: 0 0 12px; font: 700 1.4rem/1.2 var(--f-display); }
.ticket-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; margin: 0;
  padding-top: 14px; border-top: 2px dashed var(--line);
}
.ticket-grid dt { font: 600 .66rem/1.2 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.ticket-grid dd { margin: 2px 0 0; font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }

/* ───────────── Partie ───────────── */

.screen-play { min-height: 100dvh; display: flex; flex-direction: column; }
.play-top {
  display: flex; align-items: center; gap: 12px;
  padding-block: calc(env(safe-area-inset-top, 0px) + 10px) 10px;
}
.sheet .play-top { padding-top: 10px; }
.play-title {
  flex: 1; min-width: 0;
  font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.play-code { color: var(--blue); margin-right: 6px; }
.top-score {
  padding: 6px 12px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow);
  font: 700 .9rem var(--f-mono); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.progress { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > span {
  display: block; height: 100%; border-radius: 99px;
  background: repeating-linear-gradient(135deg, var(--red) 0 8px, var(--blue) 8px 16px);
  transition: width .35s ease;
}
.play-main { flex: 1; padding-block: 16px 8px; }

.qcard {
  display: grid; gap: 14px;
  padding: 18px; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow);
}
.qcard-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.qnum { color: var(--ink-3); }
.qimg { margin: 0 -4px; border-radius: 12px; overflow: hidden; background: var(--card-2); }
.qimg img { width: 100%; max-height: 55vh; object-fit: cover; cursor: zoom-in; }
.qimg.is-loading { aspect-ratio: 4 / 3; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.qtext { margin: 0; font: 700 clamp(1.3rem, 5.6vw, 1.6rem)/1.2 var(--f-display); letter-spacing: -.01em; }
.qdesc { margin-top: -6px; color: var(--ink-2); white-space: pre-line; text-wrap: pretty; }
.qprompt { font-size: .88rem; color: var(--ink-2); margin-top: -6px; }
.qdesc + .qprompt { margin-top: -2px; font-size: .82rem; color: var(--ink-3); }

/* Plus ou moins */
.pm { display: grid; gap: 12px; }
.pm-hint { font-weight: 700; color: var(--blue); }
.pm-row { display: flex; gap: 10px; align-items: stretch; }
.pm-row .field { flex: 1; min-width: 0; }
.pm-row .btn { min-height: 58px; }
.pm-count { font: 600 .74rem/1.3 var(--f-mono); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.pm-count.is-over { color: var(--red); }
.pm-hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pm-hist li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px; background: var(--card-2);
  animation: rise .2s ease-out;
}
.pm-try { color: var(--ink-3); }
.pm-guess { font: 700 1.15rem/1.2 var(--f-display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pm-say { font-weight: 800; white-space: nowrap; }
.pm-hist .is-up .pm-say { color: var(--blue); }
.pm-hist .is-down .pm-say { color: var(--amber); }
.pm-hist .is-found { background: var(--ok-bg); }
.pm-hist .is-found .pm-say { color: var(--ok); }
.pm .link { justify-self: start; }

.opts { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 56px; padding: 10px 14px;
  border: 2px solid var(--line); border-radius: 14px; background: var(--card);
  text-align: left; font-weight: 600;
  transition: border-color .15s ease, background-color .15s ease, transform .1s ease;
}
.opt:active:not(:disabled) { transform: scale(.99); }
.opt-key {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--card-2); color: var(--ink-2);
  font: 600 .78rem var(--f-mono);
}
.opts-multi .opt-key { border-radius: 7px; }
.opt-text { min-width: 0; overflow-wrap: anywhere; }
.opt:disabled { cursor: default; color: var(--ink); }
.opt.is-sel { border-color: var(--blue); background: var(--blue-soft); }
.opt.is-sel .opt-key { background: var(--blue); color: var(--on-accent); }
.opt.is-right { border-color: var(--ok); background: var(--ok-bg); }
.opt.is-right .opt-key { background: var(--ok); color: var(--on-accent); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.is-wrong .opt-key { background: var(--bad); color: var(--on-accent); }
.opt.is-missed { border-color: var(--ok); border-style: dashed; }

.tf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf {
  min-height: 84px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--card);
  font: 800 1.4rem var(--f-display);
}
.tf:disabled { cursor: default; color: var(--ink); }
.tf.is-sel { border-color: var(--blue); background: var(--blue-soft); }
.tf.is-right { border-color: var(--ok); background: var(--ok-bg); }
.tf.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.tf.is-missed { border-color: var(--ok); border-style: dashed; }

.num-row { display: flex; align-items: center; gap: 12px; }
.num-row .field { flex: 1; min-width: 0; }
.num-unit { font-weight: 700; color: var(--ink-2); }

.order { display: grid; gap: 14px; }
.order-seq { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.seq-item, .seq-empty {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 50px; padding: 8px 12px; border-radius: 12px;
}
.seq-item { border: 2px solid var(--blue); background: var(--blue-soft); text-align: left; font-weight: 700; }
.seq-item:disabled { cursor: default; color: var(--ink); }
.seq-empty { border: 2px dashed var(--line); }
.seq-num {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--card); font: 600 .8rem var(--f-mono); color: var(--ink-2);
}
.seq-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.seq-x { color: var(--ink-3); }
.seq-item:disabled .seq-x { display: none; }
.seq-item.is-right { border-color: var(--ok); background: var(--ok-bg); }
.seq-item.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.order-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 14px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--card);
  font-weight: 700;
}
.chip-sm { padding: 6px 12px; font-size: .85rem; }

.map-wrap { display: grid; gap: 8px; }
.map-box {
  position: relative; isolation: isolate; z-index: 0;
  height: min(62vh, 380px); border-radius: 14px; overflow: hidden;
  border: 2px solid var(--line); background: var(--card-2);
}
.map-box-sm { height: 280px; }
.map-note { font-size: .88rem; color: var(--ink-2); }
.pin { border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); }
.pin-guess { background: #1E4FA6; }
.pin-target { background: #CE2F3C; }
.map-zone { stroke: #17805A; fill: #17805A; fill-opacity: .16; stroke-width: 2; }
.map-line { stroke: #13203A; stroke-width: 2; }
.leaflet-container { font-family: var(--f-body); }

.feedback { display: grid; gap: 10px; padding: 14px; border-radius: 14px; animation: rise .25s ease-out; }
.feedback.is-ok { background: var(--ok-bg); }
.feedback.is-bad { background: var(--bad-bg); }
.fb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.fb-stamp {
  display: inline-block; padding: 4px 12px;
  border: 3px solid currentColor; border-radius: 8px;
  font: 800 1.2rem/1.1 var(--f-display); text-transform: uppercase; letter-spacing: .03em;
  transform: rotate(-4deg);
  animation: thunk .4s cubic-bezier(.2, 1.5, .4, 1);
}
.is-ok .fb-stamp, .is-ok .fb-pts { color: var(--ok); }
.is-bad .fb-stamp, .is-bad .fb-pts { color: var(--bad); }
.fb-pts { font-size: .9rem; }
.fb-solution { display: grid; gap: 2px; font-weight: 700; overflow-wrap: anywhere; }
.fb-solution .mono { color: var(--ink-2); font-size: .66rem; }
.fb-detail { font-size: .9rem; color: var(--ink-2); }
.fb-story { display: grid; gap: 4px; padding-top: 10px; border-top: 1px dashed color-mix(in srgb, var(--ink) 25%, transparent); }
.fb-story .mono { color: var(--ink-2); font-size: .66rem; }
.fb-story p { white-space: pre-line; text-wrap: pretty; }
@keyframes thunk { from { transform: rotate(-14deg) scale(1.7); opacity: 0; } to { transform: rotate(-4deg) scale(1); opacity: 1; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.actionbar {
  position: sticky; bottom: 0; z-index: 5;
  padding-top: 18px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--paper) 0%, transparent), var(--paper) 45%);
}

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; gap: 12px; align-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: rgba(8, 12, 22, .92); cursor: zoom-out;
}
.lightbox img { max-height: 85vh; width: auto; border-radius: 8px; }
.lightbox-hint { color: #fff; opacity: .7; }

/* ───────────── Fin de partie ───────────── */

.end { justify-items: stretch; }
.postmark-big {
  display: grid; place-items: center; align-content: center; justify-self: center;
  width: min(210px, 62vw); aspect-ratio: 1;
  margin-top: 10px; border-radius: 50%;
  border: 5px double currentColor;
  transform: rotate(-7deg);
  animation: thunk .55s cubic-bezier(.2, 1.5, .4, 1);
}
.postmark-big.tone-good { color: var(--ok); }
.postmark-big.tone-mid { color: var(--blue); }
.postmark-big.tone-low { color: var(--red); }
.postmark-num { font: 800 4.2rem/1 var(--f-display); font-variant-numeric: tabular-nums; }
.postmark-sub, .postmark-code { font: 600 .75rem/1.3 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; }
.end-title { margin: 0; text-align: center; font: 800 1.6rem/1.15 var(--f-display); }
.save-line { text-align: center; font-size: .9rem; color: var(--ink-2); padding: 10px 12px; border-radius: 12px; background: var(--card-2); }
.save-line.is-ok { color: var(--ok); background: var(--ok-bg); }
.save-line.is-warn { background: var(--warn-bg); color: var(--ink); }
.rank-line { text-align: center; font-weight: 700; }
.rank-line:empty { display: none; }
.recap { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recap li {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 12px; border-radius: 12px; background: var(--card);
}
.recap-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 800; color: var(--on-accent); }
.recap .is-ok .recap-mark, .recap li.is-ok .recap-mark { background: var(--ok); }
.recap li.is-bad .recap-mark { background: var(--bad); }
.recap-body { display: grid; gap: 2px; min-width: 0; }
.recap-q { font-weight: 700; overflow-wrap: anywhere; }
.recap-a { font-size: .88rem; color: var(--ink-2); overflow-wrap: anywhere; }
.recap-pts { padding-top: 4px; color: var(--ink-2); }

/* ───────────── Espace créateurs ───────────── */

.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.admin-top .link { text-decoration: none; }
.new-round { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.new-round .grow { flex: 1 1 200px; }

.ed-field, .ed-group { display: grid; gap: 6px; min-width: 0; align-content: start; }
.ed-label { font: 700 .82rem/1.3 var(--f-body); color: var(--ink-2); }
.ed-help { font-size: .8rem; color: var(--ink-3); }
.ed-stack { display: grid; gap: 16px; }
.ed-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.ed-list { display: grid; gap: 8px; }
.ed-row { display: flex; align-items: center; gap: 8px; }
.ed-row .field { flex: 1; min-width: 0; }
.ed-check { display: grid; place-items: center; width: 40px; height: 48px; flex: none; cursor: pointer; }
.ed-check input { width: 22px; height: 22px; accent-color: var(--ok); cursor: pointer; }
.ed-num { flex: none; width: 24px; text-align: center; font: 600 .85rem var(--f-mono); color: var(--ink-3); }
.check-line { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check-line input { width: 20px; height: 20px; accent-color: var(--blue); }
.row-fields { display: flex; gap: 12px; }
.row-fields > :first-child { flex: 1; }
.form-error { padding: 10px 12px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-weight: 700; }

.badge { padding: 4px 8px; border-radius: 6px; font: 600 .64rem/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.badge-on { background: var(--ok-bg); color: var(--ok); }
.badge-off { background: var(--card-2); color: var(--ink-3); }

.round-card { display: grid; gap: 12px; padding: 4px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.round-card.is-open { padding: 4px 14px 14px; }
.round-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  width: 100%; padding: 10px 12px; border: 0; background: none; text-align: left; color: var(--ink);
}
.round-card.is-open .round-head { padding-inline: 0; }
.round-head .pass-code { grid-row: auto; font-size: 1.35rem; }
.round-head-main { display: grid; min-width: 0; }
.round-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.round-edit { padding: 14px; border-radius: 12px; background: var(--card-2); }

.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qrow { display: flex; align-items: center; gap: 8px; }
.qrow-main {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "type pts" "text pts"; gap: 2px 10px; align-items: center;
  padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--card);
  text-align: left; color: var(--ink);
}
.qrow-main:hover { border-color: var(--ink-3); }
.qrow-type { grid-area: type; color: var(--blue); font-size: .62rem; }
.qrow-text { grid-area: text; font-weight: 600; font-size: .95rem; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qrow-main .stamp { grid-area: pts; }
.qrow-move { display: grid; gap: 4px; }

.score-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.score-list li { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 12px; background: var(--card); }
.score-list .grow { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Feuille d'édition plein écran */
.sheet {
  position: fixed; inset: 0; z-index: 50;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-preview { z-index: 60; }
.sheet-head {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.sheet-head-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.sheet-head .link { text-decoration: none; }
.sheet-title { font: 700 1rem var(--f-display); text-align: center; }
.sheet-body { display: grid; gap: 22px; padding-block: 20px 48px; }
.del-q { justify-self: start; }

.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.type-chip {
  display: grid; gap: 2px; align-content: start;
  padding: 10px 12px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--card);
  text-align: left; color: var(--ink);
}
.type-chip strong { font-size: .92rem; line-height: 1.2; }
.type-chip span { font-size: .76rem; color: var(--ink-2); line-height: 1.3; }
.type-chip.is-sel { border-color: var(--blue); background: var(--blue-soft); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg-btn {
  display: grid; gap: 2px; padding: 10px 6px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--card); text-align: center;
}
.seg-btn strong { font-size: .95rem; }
.seg-btn span { font: 600 .7rem var(--f-mono); letter-spacing: .05em; text-transform: uppercase; }
.seg-btn.is-sel { border-color: currentColor; background: var(--card-2); box-shadow: inset 0 0 0 1px currentColor; }

.pill-row { display: flex; gap: 10px; }
.pill { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); font-weight: 800; cursor: pointer; }
.pill input { width: 18px; height: 18px; accent-color: var(--ok); }
.pill:has(input:checked) { border-color: var(--ok); background: var(--ok-bg); }

.photo-box { display: grid; }
.photo-empty {
  display: grid; gap: 2px; justify-items: center;
  padding: 22px 16px; border-radius: 14px;
  border: 2px dashed var(--line); background: var(--card); color: var(--ink);
}
.photo-empty span { font-size: .82rem; color: var(--ink-2); }
.photo-preview { display: grid; gap: 10px; }
.photo-preview img { max-height: 260px; width: 100%; object-fit: cover; border-radius: 12px; }
.map-search { display: flex; gap: 8px; }
.map-search .field { flex: 1; min-width: 0; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }

/* Messages éphémères */
.toast {
  position: fixed; z-index: 200;
  left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  transform: translateX(-50%);
  width: max-content; max-width: min(92vw, 480px);
  padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--paper);
  font-weight: 700; font-size: .92rem; box-shadow: var(--shadow);
  animation: rise .2s ease-out;
  transition: opacity .4s ease;
}
.toast-error { background: var(--bad); color: #fff; }
.toast.is-out { opacity: 0; }

@media (min-width: 640px) {
  .page { padding-top: calc(env(safe-area-inset-top, 0px) + 40px); }
  .type-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
