/* =========================================================
   Tokens — clair (parchemin) / sombre (nuit lapis)
   ========================================================= */
:root {
  --bg: #f5efe3;
  --glow: rgba(15, 124, 115, 0.1);
  --surface: #fffcf6;
  --surface2: #f3ecdf;
  --sunken: #f8f3ea;
  --line: #e4d9c5;
  --line2: #cdbd9f;
  --ink: #1a2036;
  --ink2: #3b4259;
  --muted: #6c6f7f;
  --accent: #0f7c73;
  --accent-ink: #ffffff;
  --accent-soft: rgba(15, 124, 115, 0.09);
  --gold: #a8731b;
  --gold2: #d9a441;
  --cta-ink: #1f1608;
  --ok: #1d9564;
  --okbg: rgba(29, 149, 100, 0.11);
  --ko: #cf4a3a;
  --kobg: rgba(207, 74, 58, 0.09);
  --l1: #3aa676;
  --l2: #3d8fd0;
  --l3: #d48a2c;
  --l4: #d24a62;
  --hero1: #16295a;
  --hero2: #0d1a3a;
  --shadow: 0 1px 2px rgba(26, 32, 54, 0.05), 0 10px 30px -16px rgba(26, 32, 54, 0.22);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23a8731b' stroke-opacity='.09'%3E%3Crect x='22' y='22' width='28' height='28'/%3E%3Crect x='22' y='22' width='28' height='28' transform='rotate(45 36 36)'/%3E%3Cpath d='M0 36h6M66 36h6M36 0v6M36 66v6'/%3E%3C/g%3E%3C/svg%3E");
  --r: 20px;
  --r-sm: 12px;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1020;
    --glow: rgba(60, 196, 181, 0.09);
    --surface: #111a2e;
    --surface2: #18233c;
    --sunken: #0d1528;
    --line: #233050;
    --line2: #34446c;
    --ink: #f2ecdf;
    --ink2: #cdd2df;
    --muted: #8e9ab3;
    --accent: #3cc4b5;
    --accent-ink: #04201d;
    --accent-soft: rgba(60, 196, 181, 0.11);
    --gold: #e3b55c;
    --gold2: #f6d690;
    --cta-ink: #1d1407;
    --ok: #43c98f;
    --okbg: rgba(67, 201, 143, 0.13);
    --ko: #f06b5c;
    --kobg: rgba(240, 107, 92, 0.13);
    --hero1: #17295a;
    --hero2: #0e1936;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 14px 36px -18px rgba(0, 0, 0, 0.75);
    --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23e3b55c' stroke-opacity='.05'%3E%3Crect x='22' y='22' width='28' height='28'/%3E%3Crect x='22' y='22' width='28' height='28' transform='rotate(45 36 36)'/%3E%3Cpath d='M0 36h6M66 36h6M36 0v6M36 66v6'/%3E%3C/g%3E%3C/svg%3E");
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a1020;
  --glow: rgba(60, 196, 181, 0.09);
  --surface: #111a2e;
  --surface2: #18233c;
  --sunken: #0d1528;
  --line: #233050;
  --line2: #34446c;
  --ink: #f2ecdf;
  --ink2: #cdd2df;
  --muted: #8e9ab3;
  --accent: #3cc4b5;
  --accent-ink: #04201d;
  --accent-soft: rgba(60, 196, 181, 0.11);
  --gold: #e3b55c;
  --gold2: #f6d690;
  --cta-ink: #1d1407;
  --ok: #43c98f;
  --okbg: rgba(67, 201, 143, 0.13);
  --ko: #f06b5c;
  --kobg: rgba(240, 107, 92, 0.13);
  --hero1: #17295a;
  --hero2: #0e1936;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 14px 36px -18px rgba(0, 0, 0, 0.75);
  --pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72' viewBox='0 0 72 72'%3E%3Cg fill='none' stroke='%23e3b55c' stroke-opacity='.05'%3E%3Crect x='22' y='22' width='28' height='28'/%3E%3Crect x='22' y='22' width='28' height='28' transform='rotate(45 36 36)'/%3E%3Cpath d='M0 36h6M66 36h6M36 0v6M36 66v6'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: dark;
}
@media (min-width: 720px) {
  :root {
    --gutter: 28px;
  }
}

/* =========================================================
   Base
   ========================================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(1100px 560px at 50% -180px, var(--glow), transparent 70%),
    var(--pattern);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}
input,
select {
  font: inherit;
  color: var(--ink);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.hidden {
  display: none !important;
}
h1,
h2,
h3 {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.15;
}
.ico {
  width: 18px;
  height: 18px;
  flex: none;
}
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter) 56px;
}

/* App bar */
.appbar {
  position: sticky;
  top: 0;
  z-index: 15;
  /* fond presque opaque : le flou (coûteux au défilement) n'est gardé que sur grand écran */
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
}
@media (min-width: 960px) and (hover: hover) {
  .appbar {
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
  }
}
.appbar-in {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.logo svg {
  width: 28px;
  height: 28px;
  color: var(--gold);
  flex: none;
}
.logo b {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.logo small {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 520px) {
  .logo small {
    display: none;
  }
}
.iconbtn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink2);
  transition: border-color 0.15s;
}
.iconbtn:hover {
  border-color: var(--line2);
}
.iconbtn svg {
  width: 18px;
  height: 18px;
}
[data-theme="dark"] .i-moon,
[data-theme="light"] .i-sun {
  display: none;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
@media (min-width: 720px) {
  .card {
    padding: 26px;
  }
}
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.card h2 {
  font-size: 25px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.step {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: Inter, sans-serif;
  font-size: 13px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}
.sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}
.count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--r-sm);
  padding: 11px 18px;
  min-height: 44px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--ink);
  transition:
    border-color 0.15s,
    filter 0.15s,
    transform 0.15s,
    box-shadow 0.15s;
}
.btn:hover {
  border-color: var(--line2);
}
.btn.gold {
  background: linear-gradient(180deg, var(--gold2), var(--gold));
  color: var(--cta-ink);
  border: none;
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--gold) 80%, transparent);
}
.btn.gold:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}
.btn.big {
  width: 100%;
  padding: 15px 18px;
  min-height: 54px;
  font-size: 16.5px;
  border-radius: 14px;
}
.btn.big svg {
  width: 20px;
  height: 20px;
}
.btn.sm {
  min-height: 38px;
  padding: 7px 14px;
  font-size: 14px;
}
.btn.ghost {
  background: transparent;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.linkbtn {
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
}
.linkbtn:hover:not(:disabled) {
  color: var(--ink);
}
.linkbtn:disabled {
  cursor: default;
  text-decoration: none;
}

/* =========================================================
   Accueil / réglages
   ========================================================= */
.setup {
  display: grid;
  gap: 16px;
  padding-top: 18px;
}
.col-side,
.col-main {
  display: grid;
  gap: 16px;
  min-width: 0;
  align-content: start;
}
@media (min-width: 960px) {
  .setup {
    grid-template-columns: minmax(330px, 400px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    padding-top: 30px;
  }
}
@media (min-width: 960px) and (min-height: 820px) {
  .col-side {
    position: sticky;
    top: 86px;
  }
}

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--r);
  padding: 28px 24px 24px;
  color: #f4ecdc;
  background: linear-gradient(155deg, var(--hero1), var(--hero2));
  border: 1px solid rgba(227, 181, 92, 0.22);
  box-shadow: var(--shadow);
}
.hero .deco {
  position: absolute;
  right: -60px;
  top: -50px;
  width: 240px;
  height: 240px;
  color: #e3b55c;
  opacity: 0.13;
  z-index: -1;
}
.hero .ar {
  font-family: Amiri, serif;
  font-size: 22px;
  color: #e9c274;
  line-height: 1.2;
}
.hero h1 {
  font-size: clamp(46px, 9vw, 64px);
  font-weight: 700;
  line-height: 1;
  margin: 6px 0 10px;
  background: linear-gradient(180deg, #f8dc9c, #d9a441);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero p {
  color: rgba(244, 236, 220, 0.78);
  font-size: 14.5px;
  max-width: 46ch;
}
.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}
.hero-tags span {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f4ecdc;
}

/* Joueurs */
.players {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.pchip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  background: var(--surface2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 4px 4px 12px;
  font-weight: 600;
  font-size: 14px;
}
.pchip button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  display: grid;
  place-items: center;
  flex: none;
}
.pchip button:hover {
  background: var(--line);
  color: var(--ink);
}
.addrow {
  display: flex;
  gap: 8px;
}
.field-input,
.addrow input,
.genrow select,
.genrow input {
  width: 100%;
  min-width: 0;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  outline: none;
  font-size: 16px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.addrow input {
  flex: 1;
}
.addrow input:focus,
.genrow select:focus,
.genrow input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.genrow select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8f9f' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.genrow select option {
  background: var(--surface);
  color: var(--ink);
}

/* Barre de lancement */
.startbar {
  display: grid;
  gap: 10px;
}
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink2);
}
.summary span {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
@media (max-width: 959px) {
  .setup {
    padding-bottom: 120px;
  }
  .startbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 12;
    gap: 8px;
    padding: 10px var(--gutter) calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 97%, transparent);
    border-top: 1px solid var(--line);
    box-shadow: 0 -12px 30px -20px rgba(0, 0, 0, 0.45);
  }
  .startbar > * {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
  }
  .summary {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .summary::-webkit-scrollbar {
    display: none;
  }
  .summary span {
    background: var(--surface2);
  }
}

/* Champs de réglage */
.fields > .field {
  padding: 18px 0;
  border-top: 1px dashed var(--line);
}
.fields > .field:first-child {
  border-top: none;
  padding-top: 6px;
}
.fields > .field:last-child {
  padding-bottom: 0;
}
.label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}
.label em {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.label .acts {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  display: flex;
  gap: 10px;
}

.seg {
  display: grid;
  gap: 8px;
}
.seg.c2 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.seg.c4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.seg.c5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
@media (max-width: 560px) {
  .seg.c4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #livesSeg .opt span {
    display: none;
  }
}
.opt {
  position: relative;
  min-height: 48px;
  border: 1px solid var(--line);
  background: var(--sunken);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  text-align: left;
  transition:
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}
.opt b {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
}
.opt span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.4;
}
.opt:hover {
  border-color: var(--line2);
}
.opt.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.opt.on b {
  color: var(--ink);
}
.opt:not(.small) {
  padding-right: 38px;
}
.opt:not(.small)::after {
  content: "";
  position: absolute;
  top: 12px;
  right: 12px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--line2);
  transition:
    border-color 0.15s,
    background-color 0.15s,
    color 0.15s,
    box-shadow 0.15s;
}
.opt:not(.small).on::after {
  border-color: var(--accent);
  background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E")
    center/11px no-repeat;
}
.opt b .ico {
  color: var(--accent);
}
.opt.small {
  text-align: center;
  padding: 11px 6px;
}
.opt.small b {
  justify-content: center;
}
.lvdot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c);
  flex: none;
}

.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--sunken);
  border-radius: 999px;
  padding: 7px 8px 7px 13px;
  font-size: 14px;
  font-weight: 500;
  transition:
    border-color 0.15s,
    background-color 0.15s,
    color 0.15s,
    box-shadow 0.15s;
}
.cat-chip:hover {
  border-color: var(--line2);
}
.cat-chip .cn {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface2);
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 700;
}
.cat-chip.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.cat-chip.on .cn {
  background: var(--accent);
  color: var(--accent-ink);
}
.cat-chip.zero:not(.on) {
  opacity: 0.5;
}

.status {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
  min-height: 18px;
}
.status:empty {
  min-height: 0;
  margin-top: 0;
}
.status.err {
  color: var(--ko);
}

/* Banque */
.bankgrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
@media (max-width: 560px) {
  .bankgrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.bankcell {
  position: relative;
  overflow: hidden;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px 11px;
}
.bankcell::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--c, var(--accent));
}
.bankcell .n {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.05;
}
.bankcell .t {
  font-size: 12px;
  color: var(--muted);
}
.ai-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 4px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.genrow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.genrow #genCat,
.genrow input,
.genrow .btn {
  grid-column: 1/-1;
}
@media (min-width: 720px) {
  .genrow {
    grid-template-columns: minmax(0, 1fr) 92px minmax(0, 1.4fr);
  }
  .genrow #genCat {
    grid-column: auto;
  }
  .genrow input {
    grid-column: 1/3;
  }
  .genrow .btn {
    grid-column: 3;
  }
}
/* Génération IA sans choix de niveau ni de thème : nombre + thème libre + bouton */
.genrow.simple {
  grid-template-columns: 92px minmax(0, 1fr);
}
.genrow.simple input {
  grid-column: auto;
}
@media (min-width: 720px) {
  .genrow.simple {
    grid-template-columns: 92px minmax(0, 1fr) auto;
  }
  .genrow.simple .btn {
    grid-column: auto;
  }
}
.banklinks {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.aitag {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--l2);
  border: 1px solid color-mix(in srgb, var(--l2) 45%, transparent);
  border-radius: 999px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
  letter-spacing: 0.04em;
}
.foot {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 4px 0;
}
.foot kbd {
  font:
    600 11.5px Inter,
    sans-serif;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
}
@media (hover: none) {
  .foot {
    display: none;
  }
}

/* =========================================================
   Partie
   ========================================================= */
.game {
  padding-top: 16px;
}
@media (min-width: 960px) {
  .game {
    padding-top: 26px;
  }
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.topbar .meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
@media (max-width: 420px) {
  #modePill {
    display: none;
  }
}
.pill {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  color: var(--ink2);
  background: var(--surface);
  white-space: nowrap;
}
.pill.lv {
  color: #0a0f1c;
  border-color: transparent;
}
.lv-facile {
  background: var(--l1);
}
.lv-moyen {
  background: var(--l2);
}
.lv-difficile {
  background: var(--l3);
}
.lv-extreme {
  background: var(--l4);
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.board {
  min-width: 0;
}
.board-h {
  display: none;
}
.strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter));
  padding: 2px var(--gutter) 4px;
}
.strip::-webkit-scrollbar {
  display: none;
}
.ps {
  flex: 0 0 auto;
  min-width: 132px;
  max-width: 200px;
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    opacity 0.2s;
}
.ps .nm {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}
.ps .nm .dot {
  width: 9px;
  height: 9px;
}
.ps .sc {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
}
.ps .sc strong {
  color: var(--ink);
  font-family: "EB Garamond", Georgia, serif;
  font-size: 22px;
  line-height: 1;
}
.ps.cur {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 10px 24px -14px var(--accent);
}
.ps.out {
  opacity: 0.4;
  filter: grayscale(1);
}
.ps.danger {
  border-color: var(--ko);
}
.hearts {
  color: var(--ko);
  font-size: 12px;
  letter-spacing: 1px;
  margin-top: 3px;
}
.hearts .lost {
  color: var(--line2);
}
.jk {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.jk.used {
  opacity: 0.45;
  text-decoration: line-through;
  color: var(--muted);
}
@media (min-width: 980px) {
  .game-grid {
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
  }
  .board {
    position: sticky;
    top: 86px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px;
    box-shadow: var(--shadow);
  }
  .board-h {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 2px 4px 10px;
  }
  .strip {
    flex-direction: column;
    overflow: visible;
    margin: 0;
    padding: 0;
    max-height: calc(100vh - 170px);
    overflow-y: auto;
  }
  .ps {
    max-width: none;
    min-width: 0;
    background: var(--sunken);
  }
}

.qcard {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.qcard::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}
@media (min-width: 720px) {
  .qcard {
    padding: 32px 34px 28px;
  }
}
.qhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.turn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
.turn b {
  color: var(--ink);
  font-size: 16px;
}
.cat {
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent-soft);
  padding: 5px 10px;
  border-radius: 999px;
}
.qtext {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 500;
  font-size: clamp(23px, 1.6vw + 16px, 33px);
  line-height: 1.25;
  margin: 2px 0 22px;
  text-wrap: pretty;
}
.timer {
  height: 6px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  margin: -6px 0 20px;
}
.timer i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transform-origin: left;
  transition: background 0.3s;
}
.timer.low i {
  background: var(--ko);
}
.answers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 700px) {
  .answers {
    grid-template-columns: 1fr 1fr;
  }
}
.ans {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 62px;
  font-size: 15.5px;
  font-weight: 500;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.15s,
    opacity 0.2s;
}
.ans .ar {
  font-family: "Amiri", "Traditional Arabic", "Noto Naskh Arabic", serif;
  font-weight: 700;
  font-size: 1.45em;
  line-height: 1.5;
}
.ans .ar.long {
  font-size: 1.2em;
  line-height: 1.7;
}
.ans .k {
  flex: 0 0 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--accent);
  transition:
    border-color 0.15s,
    background-color 0.15s,
    color 0.15s,
    box-shadow 0.15s;
}
@media (hover: hover) {
  .ans:hover:not(:disabled) {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-1px);
  }
}
.ans:active:not(:disabled) {
  transform: scale(0.99);
}
.ans:disabled {
  cursor: default;
}
.ans.gone {
  opacity: 0.15;
  pointer-events: none;
}
.ans.right {
  border-color: var(--ok);
  background: var(--okbg);
}
.ans.right .k {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.ans.wrong {
  border-color: var(--ko);
  background: var(--kobg);
}
.ans.wrong .k {
  background: var(--ko);
  border-color: var(--ko);
  color: #fff;
}
.ans.dim {
  opacity: 0.45;
}
/* Plusieurs bonnes réponses : réponses cochées, bonnes réponses oubliées */
.ans.picked {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.ans.picked .k {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ans.missed {
  border-style: dashed;
  opacity: 1;
}
.ans.missed .k {
  background: var(--surface);
  color: var(--ok);
}
.multibar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.multibar span {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}
.multibar .btn {
  margin-left: auto;
}

.tools {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.tools .hint {
  font-size: 12.5px;
  color: var(--muted);
  margin-left: auto;
}
@media (max-width: 520px) {
  .tools .hint {
    margin-left: 0;
    width: 100%;
  }
  .tools .jbtn {
    flex: 1;
  }
}
.jbtn {
  min-height: 42px;
  border: 1px dashed var(--line2);
  border-radius: 12px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 14px;
  color: var(--gold);
  transition:
    border-color 0.15s,
    background-color 0.15s,
    color 0.15s,
    box-shadow 0.15s;
}
.jbtn:hover:not(:disabled) {
  border-style: solid;
  border-color: var(--gold);
  background: color-mix(in srgb, var(--gold) 9%, transparent);
}
.jbtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.reveal {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  animation: up 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes up {
  from {
    opacity: 0;
    transform: translateY(calc(14px * var(--mv)));
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.verdict {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "EB Garamond", Georgia, serif;
  font-size: clamp(22px, 3vw, 27px);
  font-weight: 700;
  margin-bottom: 8px;
  line-height: 1.2;
}
.verdict::before {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font:
    800 15px Inter,
    sans-serif;
  color: #fff;
}
.verdict.ok {
  color: var(--ok);
}
.verdict.ok::before {
  content: "✓";
  background: var(--ok);
}
.verdict.ko {
  color: var(--ko);
}
.verdict.ko::before {
  content: "✕";
  background: var(--ko);
}
.goodans {
  font-size: 15.5px;
  margin-bottom: 10px;
}
.goodans b {
  color: var(--ink);
  background: var(--okbg);
  border-radius: 6px;
  padding: 1px 7px;
}
.expl {
  font-size: 15px;
  color: var(--ink2);
  margin-bottom: 14px;
}
.fun {
  background: color-mix(in srgb, var(--gold) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 28%, transparent);
  border-left: 3px solid var(--gold);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14.5px;
}
.fun b {
  display: block;
  color: var(--gold);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 3px;
}
.revfoot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}
@media (max-width: 560px) {
  .revfoot {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .revfoot .btn {
    width: 100%;
    min-height: 52px;
  }
  .revfoot .linkbtn {
    text-align: center;
  }
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 10px;
  color: var(--muted);
  text-align: center;
}
.spin {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  animation: sp 1s linear infinite;
}
@keyframes sp {
  to {
    transform: rotate(360deg);
  }
}

/* =========================================================
   Fin de partie
   ========================================================= */
.endwrap {
  max-width: 720px;
  margin: 0 auto;
  padding-top: 22px;
}
@media (min-width: 960px) {
  .endwrap {
    padding-top: 40px;
  }
}
.podium {
  text-align: center;
  padding: 6px 0 8px;
}
.podium .crown {
  width: 92px;
  height: 92px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 46px;
  line-height: 1;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--gold) 22%, transparent),
    transparent 70%
  );
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
}
.podium h2 {
  font-size: clamp(30px, 6vw, 42px);
  color: var(--gold);
  margin: 14px 0 4px;
  font-weight: 700;
}
.podium p {
  color: var(--muted);
}
.rank {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}
.rrow {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--sunken);
}
.rrow.first {
  border-color: color-mix(in srgb, var(--gold) 60%, transparent);
  background: color-mix(in srgb, var(--gold) 9%, var(--sunken));
}
.rrow .r {
  font-family: "EB Garamond", Georgia, serif;
  font-weight: 700;
  font-size: 24px;
  color: var(--gold);
  text-align: center;
  line-height: 1;
}
.who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.who > div {
  min-width: 0;
}
.who b {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.who small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.st {
  display: flex;
  gap: 16px;
  align-items: baseline;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.st strong {
  font-family: "EB Garamond", Georgia, serif;
  font-size: 24px;
  color: var(--ink);
  line-height: 1;
  margin-right: 3px;
}
@media (max-width: 520px) {
  .rrow {
    grid-template-columns: 30px minmax(0, 1fr);
  }
  .st {
    grid-column: 2;
    gap: 12px;
    flex-wrap: wrap;
  }
}
.endbtns {
  display: flex;
  gap: 10px;
  margin-top: 22px;
}
.endbtns .btn {
  flex: 1;
}

/* Toast & modale */
.toast {
  position: fixed;
  left: 50%;
  top: calc(14px + env(safe-area-inset-top));
  /* cachée : remontée hors de l'écran ET invisible (sinon son bord dépasse en haut) */
  transform: translateX(-50%) translateY(calc(-100% - 40px));
  visibility: hidden;
  z-index: 40;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--ink);
  padding: 11px 18px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 14px;
  transition:
    transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2),
    visibility 0s linear 0.35s;
  box-shadow: 0 14px 40px -12px rgba(0, 0, 0, 0.45);
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  visibility: visible;
  transition:
    transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2),
    visibility 0s;
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 8, 16, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: fade 0.2s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.modal .box {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  animation: up 0.25s ease;
}
.modal h3 {
  font-size: 23px;
  margin-bottom: 6px;
}
.modal p {
  color: var(--muted);
  font-size: 14.5px;
  margin-bottom: 18px;
}
.modal .row {
  display: flex;
  gap: 10px;
}
.modal .row .btn {
  flex: 1;
}
@media (max-width: 520px) {
  .modal {
    place-items: end center;
    padding: 0;
  }
  .modal .box {
    max-width: none;
    border-radius: 22px 22px 0 0;
    padding: 22px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  }
}
/* --mv règle l'amplitude des mouvements : 1 normalement, 0 si l'appareil demande moins
   d'animations. Dans ce cas on garde les fondus (rien ne bouge, rien ne tremble). */
:root {
  --mv: 1;
}
@media (prefers-reduced-motion: reduce) {
  :root {
    --mv: 0;
  }
  .ans.wrong,
  .tinput.shake,
  .hearts.hurt,
  .confetti {
    animation: none !important;
  }
  .confetti {
    display: none;
  }
}

/* =========================================================
   Questions « tableau » (cases à remplir)
   ========================================================= */
.tablebox {
  display: grid;
  gap: 12px;
}
.tbl {
  display: grid;
  gap: 6px;
}
.tbl.multi {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.trow,
.thead {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.tbl.clues .trow,
.tbl.clues .thead {
  grid-template-columns: 32px minmax(0, 1fr) minmax(0, 1.2fr);
}
.trow {
  min-height: 50px;
  padding: 6px 12px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--sunken);
  transition:
    border-color 0.2s,
    background 0.2s;
}
.thead {
  padding: 0 12px 0 8px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.tnum {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--accent);
}
.tclue {
  font-weight: 600;
  color: var(--ink2);
}
.tval {
  font-weight: 600;
  font-size: 15.5px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.trow.empty .tval::before {
  content: "";
  display: block;
  height: 2px;
  border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--line2) 0 8px, transparent 8px 14px);
}
.trow.found {
  border-color: var(--ok);
  background: var(--okbg);
}
.trow.found .tnum {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.trow.found .tval::after {
  content: " ✓";
  color: var(--ok);
}
.trow.missed {
  border-color: color-mix(in srgb, var(--ko) 55%, transparent);
  background: var(--kobg);
}
.trow.missed .tnum {
  color: var(--ko);
}
.trow.missed .tval {
  color: var(--ko);
}
.trow.pop {
  animation: tpop 0.45s ease;
}
@keyframes tpop {
  0% {
    transform: scale(calc(1 - 0.03 * var(--mv)));
  }
  50% {
    transform: scale(calc(1 + 0.025 * var(--mv)));
  }
  100% {
    transform: none;
  }
}
.tinput {
  display: flex;
  gap: 8px;
}
.tinput input {
  flex: 1;
}
.tinput.shake {
  animation: tshake 0.35s;
}
@keyframes tshake {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}
.tfoot {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tcount {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.tlog {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.tlog span {
  font-size: 12.5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tlog .ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 45%, transparent);
}
.tlog .non {
  color: var(--ko);
  border-color: color-mix(in srgb, var(--ko) 40%, transparent);
}
/* Tableau chacun son tour : qui a trouvé chaque case */
.thint {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
}
.thint b {
  color: var(--accent);
}
.tby {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}
.tby i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
.trow.by .tval::after {
  content: none;
}
.tlog b {
  font-weight: 700;
  color: var(--ink2);
}
.tlog .pass {
  font-style: italic;
}
.goodans .dot {
  margin: 0 3px 0 4px;
}
/* Sur téléphone, les grands tableaux passent sur deux colonnes plus compactes */
@media (max-width: 520px) {
  .tbl.multi {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tbl.multi .trow {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 7px;
    min-height: 44px;
    padding: 5px 8px 5px 6px;
  }
  .tbl.multi .tnum {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    font-size: 11px;
  }
  .tbl.multi .tval {
    font-size: 13.5px;
  }
}

/* =========================================================
   Questions orales (réponse à voix haute, validée par l'hôte)
   ========================================================= */
.oralbox {
  display: grid;
  gap: 12px;
}
.oral-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent);
  font-weight: 600;
  font-size: 15.5px;
}
.oral-hint svg {
  width: 26px;
  height: 26px;
  flex: none;
  color: var(--accent);
}
.expected {
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
  border-left: 3px solid var(--gold);
}
.expected b {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin-bottom: 4px;
}
.expected span {
  font-size: 16px;
  font-weight: 600;
  white-space: pre-line;
}
.judge {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.judge .btn {
  min-height: 56px;
  font-size: 16px;
}
.btn.judge-ok {
  background: var(--okbg);
  border-color: var(--ok);
  color: var(--ok);
}
.btn.judge-ko {
  background: var(--kobg);
  border-color: var(--ko);
  color: var(--ko);
}
.btn.judge-ok:hover {
  background: var(--ok);
  color: #fff;
}
.btn.judge-ko:hover {
  background: var(--ko);
  color: #fff;
}

/* =========================================================
   Animations — légères : uniquement transform et opacity
   (gérées par la carte graphique, désactivées si l'appareil
   demande moins d'animations)
   ========================================================= */
@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(calc(14px * var(--mv)));
  }
}
.view-in,
.row-in {
  animation: viewIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* Nouvelle question : le contenu arrive en douceur, les réponses en cascade */
@keyframes qswap {
  from {
    opacity: 0;
    transform: translateY(calc(18px * var(--mv)));
  }
}
.swap .qhead,
.swap .qtext,
.swap .ans,
.swap .trow,
.swap .oral-hint,
.swap .tools {
  animation: qswap 0.46s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.swap .qtext {
  animation-delay: 0.03s;
}
.swap .ans:nth-child(1),
.swap .trow:nth-child(1),
.swap .oral-hint {
  animation-delay: 0.08s;
}
.swap .ans:nth-child(2),
.swap .trow:nth-child(2) {
  animation-delay: 0.12s;
}
.swap .ans:nth-child(3),
.swap .trow:nth-child(3) {
  animation-delay: 0.16s;
}
.swap .ans:nth-child(4),
.swap .trow:nth-child(n + 4) {
  animation-delay: 0.2s;
}
.swap .tools {
  animation-delay: 0.24s;
}

/* « Au tour de … » : bandeau bref au changement de joueur */
.turnflash {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.turnflash.show {
  visibility: visible;
  animation: flashBg 1.3s ease both;
}
.turnflash span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--c, var(--accent));
  box-shadow: 0 14px 34px -16px var(--c, var(--accent));
  font-weight: 700;
  font-size: clamp(16px, 2.4vw, 20px);
  max-width: calc(100% - 32px);
}
.turnflash i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
  background: var(--c, var(--accent));
}
.turnflash.show span {
  animation: flashPill 1.3s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes flashBg {
  0% {
    opacity: 0;
  }
  12%,
  68% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
@keyframes flashPill {
  0% {
    opacity: 0;
    transform: scale(calc(1 - 0.18 * var(--mv)));
  }
  16% {
    opacity: 1;
    transform: scale(1);
  }
  68% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translateY(calc(-14px * var(--mv)));
  }
}

/* Classement : le joueur dont c'est le tour, les points gagnés */
.ps {
  position: relative;
  transition:
    border-color 0.25s,
    box-shadow 0.25s,
    opacity 0.25s;
}
.ps.turn-in {
  animation: psIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes psIn {
  45% {
    transform: scale(calc(1 + 0.07 * var(--mv)));
  }
}
.ps strong {
  display: inline-block;
}
.ps strong.bump {
  animation: bump 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
@keyframes bump {
  40% {
    transform: scale(calc(1 + 0.45 * var(--mv)));
  }
}
.ps .plus {
  position: absolute;
  right: 12px;
  top: 8px;
  font-weight: 800;
  font-size: 14px;
  color: var(--ok);
  pointer-events: none;
  animation: floatUp 0.9s ease-out forwards;
}
@keyframes floatUp {
  from {
    opacity: 0;
    transform: translateY(calc(6px * var(--mv)));
  }
  20% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateY(calc(-26px * var(--mv)));
  }
}

/* Résultat : la bonne réponse rebondit, la mauvaise tremble */
.ans.right {
  animation: apop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.ans.wrong {
  animation: ashake 0.4s;
}
@keyframes apop {
  40% {
    transform: scale(calc(1 + 0.04 * var(--mv)));
  }
}
@keyframes ashake {
  20%,
  60% {
    transform: translateX(-5px);
  }
  40%,
  80% {
    transform: translateX(5px);
  }
}
.verdict::before {
  animation: vpop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.5);
}
@keyframes vpop {
  from {
    opacity: 0;
    transform: scale(calc(1 - 0.6 * var(--mv)));
  }
}
.timer i {
  will-change: transform;
}
/* repère pour centrer le joueur en cours dans le classement défilant (mobile) */
.strip {
  position: relative;
}

/* =========================================================
   Animations en plus (toujours légères)
   ========================================================= */

/* Retour au toucher : boutons et options s'enfoncent légèrement */
.btn,
.opt,
.cat-chip,
.jbtn,
.iconbtn {
  transition-property: border-color, background-color, color, box-shadow, transform, filter;
  transition-duration: 0.15s;
}
.btn:active:not(:disabled),
.opt:active,
.cat-chip:active,
.jbtn:active:not(:disabled),
.iconbtn:active {
  transform: scale(calc(1 - 0.03 * var(--mv)));
}

/* Option choisie : la coche apparaît avec un petit rebond */
.opt.on:not(.small)::after,
.cat-chip.on .cn {
  animation: checkPop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.5);
}
@keyframes checkPop {
  from {
    opacity: 0;
    transform: scale(calc(1 - 0.5 * var(--mv)));
  }
}

/* Nouveau tour : une barre à la couleur du joueur traverse le haut de la carte */
.qcard::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 4px;
  z-index: 1;
  background: var(--pc, var(--accent));
  transform: scaleX(0);
  transform-origin: left;
}
.qcard.turnbar::after {
  animation: barIn 0.8s cubic-bezier(0.6, 0, 0.2, 1) forwards;
}
@keyframes barIn {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* « À toi de jouer ! » respire trois fois */
.turn .you {
  display: inline-block;
  animation: youPulse 1s ease-in-out 3;
}
@keyframes youPulse {
  50% {
    opacity: 0.6;
    transform: scale(calc(1 + 0.06 * var(--mv)));
  }
}

/* Vie perdue : les cœurs tremblent */
.hearts {
  display: inline-block;
}
.hearts.hurt {
  animation: hurt 0.6s ease;
}
@keyframes hurt {
  15%,
  45% {
    transform: translateX(-4px) scale(1.15);
  }
  30%,
  60% {
    transform: translateX(4px) scale(1.15);
  }
}

/* Fin du chrono : la barre clignote doucement */
.timer.low i {
  animation: lowPulse 0.5s ease-in-out infinite alternate;
}
@keyframes lowPulse {
  to {
    opacity: 0.5;
  }
}

/* Tableau, question orale : apparition du résultat */
.reveal .goodans,
.reveal .expl,
.reveal .fun,
.reveal .revfoot {
  animation: up 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.reveal .goodans {
  animation-delay: 0.08s;
}
.reveal .expl {
  animation-delay: 0.14s;
}
.reveal .fun {
  animation-delay: 0.2s;
}
.reveal .revfoot {
  animation-delay: 0.26s;
}

/* Fin de partie : trophée qui tombe, classement en cascade, confettis */
.podium .crown {
  animation: crownDrop 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
@keyframes crownDrop {
  from {
    opacity: 0;
    transform: translateY(calc(-40px * var(--mv))) scale(calc(1 - 0.4 * var(--mv)));
  }
}
.podium h2,
.podium p {
  animation: up 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s both;
}
.rrow {
  animation: up 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.confetti {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  overflow: hidden;
}
.confetti i {
  position: absolute;
  top: -20px;
  left: var(--x);
  width: 8px;
  height: 13px;
  border-radius: 2px;
  background: var(--c);
  opacity: 0;
  animation: fall var(--d) cubic-bezier(0.25, 0.6, 0.4, 1) var(--w) forwards;
}
@keyframes fall {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0);
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), 105vh) rotate(var(--r));
  }
}
/* titre de fin de partie centré (les titres de carte sont en flex) */
.podium h2 {
  justify-content: center;
  text-align: center;
}

/* Écran unique : lien vers la relecture des questions */
.revlink {
  display: inline-block;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.revlink:hover {
  text-decoration: underline;
}

/* Tableau « entre » : [ ? ]  la sourate donnée  [ ? ] */
.tbl.between {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}
.tbox,
.tmid {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 118px;
  padding: 14px 10px;
  border-radius: 16px;
  text-align: center;
  min-width: 0;
}
.tbox {
  border: 2px dashed var(--line2);
  background: var(--sunken);
  transition:
    border-color 0.2s,
    background 0.2s;
}
.tbox b,
.tmid b {
  font-family: "EB Garamond", Georgia, serif;
  font-size: clamp(18px, 3.2vw, 26px);
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.tbox.empty b {
  font-size: 44px;
  color: var(--muted);
  opacity: 0.7;
}
.tbox.found {
  border-style: solid;
  border-color: var(--ok);
  background: var(--okbg);
}
.tbox.missed {
  border-style: solid;
  border-color: color-mix(in srgb, var(--ko) 55%, transparent);
  background: var(--kobg);
}
.tbox.missed b {
  color: var(--ko);
}
.tbox.pop {
  animation: tpop 0.45s ease;
}
.tmid {
  border: 2px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 10%, transparent);
}
.tmid b {
  color: var(--gold);
}
.tcap {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
@media (max-width: 520px) {
  .tbl.between {
    gap: 6px;
  }
  .tbox,
  .tmid {
    min-height: 96px;
    padding: 10px 5px;
    border-radius: 13px;
  }
  .tcap {
    font-size: 9.5px;
    letter-spacing: 0.04em;
  }
}

/* Tableau « apres » / « avant » : Al-Qiyāma → [ ? ]  ou  [ ? ] → Al-Kahf */
.tbl.pair {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}
.tarrow {
  align-self: center;
  font-size: 30px;
  font-weight: 700;
  color: var(--muted);
}
@media (max-width: 520px) {
  .tbl.pair {
    gap: 6px;
  }
  .tarrow {
    font-size: 22px;
  }
}

/* Question sur plusieurs lignes : citation en arabe, puis sa traduction */
.qtext .qar {
  display: block;
  margin: 14px 0 4px;
  padding: 12px 16px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--gold) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
  font-family: "Amiri", "Traditional Arabic", "Noto Naskh Arabic", serif;
  font-weight: 700;
  font-size: 1.15em;
  line-height: 1.9;
  word-spacing: 0.3em; /* mots bien séparés : on ne confond pas deux mots collés */
  text-align: center;
  color: var(--gold);
}
/* Sur téléphone : le verset de l'encadré un peu plus grand (pas les réponses) */
@media (max-width: 699px) {
  .qtext .qar {
    font-size: 1.42em;
    line-height: 2.1; /* lignes bien séparées quand le verset passe sur deux lignes */
    word-spacing: 0.35em;
    padding: 10px 10px;
  }
}
.qtext .qsub {
  display: block;
  margin-top: 8px;
  font-size: 0.68em;
  font-style: italic;
  line-height: 1.4;
  text-align: center;
  color: var(--ink2);
}

/* ---------- Points choisis par l'animateur & bonus de récitation ---------- */
.qtags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pts-pill { font-size: 12px; font-weight: 800; letter-spacing: .04em; padding: 5px 10px; border-radius: 999px;
  color: var(--gold); border: 1px solid var(--gold); }
.bonus-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; padding: 5px 10px 5px 8px;
  border-radius: 999px; color: #1a1408; background: linear-gradient(180deg, #f8dc9c, #e3b55c); box-shadow: 0 2px 10px rgba(227, 181, 92, .35); }
.bonus-chip svg { width: 14px; height: 14px; }
.ptsbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; padding: 10px 12px;
  border-radius: 14px; border: 1px dashed var(--gold); font-size: 14px; font-weight: 600; }
.ptsbtns { display: flex; gap: 6px; }
.ptsbtns button { width: 38px; height: 38px; border-radius: 10px; font: inherit; font-weight: 800; cursor: pointer;
  color: inherit; background: transparent; border: 1px solid rgba(127, 127, 127, .45); }
.ptsbtns button.on { color: #1a1408; background: linear-gradient(180deg, #f8dc9c, #e3b55c); border-color: transparent; }
.bonusbox { margin: 12px 0 4px; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(227, 181, 92, .5);
  background: rgba(227, 181, 92, .09); }
.bonusbox.ok { border-color: rgba(63, 191, 134, .6); background: rgba(63, 191, 134, .12); }
.bonusbox.no { opacity: .75; }
.bonus-t { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; }
.bonus-t svg { flex: none; width: 20px; height: 20px; margin-top: 2px; color: var(--gold); }
.bonus-ref { margin-top: 6px; font-size: 14px; opacity: .9; }
.bonus-ref a { color: var(--gold); }
.bonusbox .judge { margin-top: 10px; }

/* Bonus « dans quel verset ? » (tableaux) et ajustement des scores à la fin */
.tablebox .bonusbox { margin: 0 0 12px; }
.rank.noanim .rrow { animation: none; }
.adj { display: inline-flex; gap: 6px; }
.adj button { min-width: 40px; height: 32px; padding: 0 8px; border-radius: 9px; font: inherit; font-weight: 800; cursor: pointer;
  color: inherit; background: transparent; border: 1px solid rgba(127, 127, 127, .45); }
.adj button:hover { border-color: var(--gold); color: var(--gold); }
.adj-hint { margin: 0 0 10px; font-size: 13.5px; opacity: .8; text-align: center; }

.bonusbox .bonus-pts { margin: 10px 0 0; }

/* Mode « Tous en même temps » (Culture G) */
.ps.done .nm::after { content: "✓"; margin-left: auto; font-weight: 800; color: #3fbf86; }
.ens-res { margin-top: 6px; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.ens-res .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 2px 0 6px; }

/* Image d'une question (floutée pendant la question, nette avec les résultats) */
.qimg { display: block; max-width: min(100%, 420px); max-height: 52vh; margin: 12px auto 4px; border-radius: 12px;
  border: 1px solid var(--line); object-fit: contain; }

/* Le joueur renonce au bonus */
.bonusbox.renonce { opacity: .75; }
.bonusbox .bonus-skip { margin-top: 10px; width: 100%; }
