/* Structure et composants. Toutes les couleurs, polices et matières viennent du thème
   actif (src/themes/<id>.css) ; les valeurs ci-dessous ne servent qu'avant son chargement. */

:root {
  --font-ui: system-ui, sans-serif; --font-title: Georgia, serif; --font-tile: Georgia, serif; --tile-weight: 700;
  --bg: #2A1A10; --bar: #1d120b; --ink: #F3E9D2; --mute: #C9B48E; --line: rgba(255,255,255,.15);
  --surface: #1C3A2E; --overlay: rgba(0,0,0,.6); --panel: rgba(0,0,0,.2); --panel-border: 1px solid var(--line); --panel-shadow: none;
  --radius: 8px; --accent: #C9A227; --on-accent: #2A1A10; --accent-text: #E3C15A; --you: #3F7A5E;
  --ok: #7BC47F; --on-ok: #10240F; --ok-text: #9BD59E; --bad: #E0705F; --on-bad: #2A0D08; --chipbg: rgba(0,0,0,.2);
  --frame: #3B2416; --frame-pad: 8px; --board-radius: 8px; --board-shadow: none; --gridline: #2C4A3B; --gap: 2px;
  --cell: #1F4D3A; --cell-ink: #E9DEC4; --cell-radius: 2px;
  --tw: #9E2F25; --tw-ink: #fff; --dw: #C87A64; --dw-ink: #000; --tl: #2B6382; --tl-ink: #fff; --dl: #7FB2C9; --dl-ink: #000; --star: #000;
  --tile: #F4EBD6; --tile-ink: #2A1A10; --tile-radius: 4px; --tile-border: none; --tile-inset: 1px; --tile-shadow: none;
  --blank: #E2C5BC; --last: 0 0 0 2px var(--accent); --temp: #FFF8E8; --temp-ink: #2A1A10;
  --rack: #3B2416; --rack-shadow: none; --rack-border: none; --btn: rgba(0,0,0,.2); --btn-border: 1px solid var(--line); --btn-shadow: none;
  --av-radius: 50%; --av-border: none;
  --rt: clamp(34px, calc((100vw - 64px) / 7), 54px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, .cell:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
svg { width: 18px; height: 18px; flex: none; }

/* fond d'ambiance du thème, fixe derrière le jeu */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--bg-image, none) center / cover no-repeat; opacity: var(--bg-image-opacity, 1); }

.app { min-height: 100%; display: grid; grid-template-rows: auto 1fr; }

/* --- barre du haut --- */
.topbar { display: flex; align-items: center; gap: 14px; padding: calc(8px + env(safe-area-inset-top, 0px)) 16px 8px; background: var(--bar); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: baseline; font-family: var(--font-title); font-size: 24px; letter-spacing: .01em; background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; }
/* Le K du logo est une lettre du mot (même police, même taille, même ligne de base) ; la tuile est
   un fond dessiné derrière, décalé vers le bas : le score se loge sous la ligne des lettres. */
.logo-k { position: relative; z-index: 0; display: inline-block; margin-left: .05em; padding: 0 .2em 0 .08em; color: var(--tile-ink); }
.logo-k::before { content: ""; position: absolute; z-index: -1; left: 0; right: 0; top: -.03em; bottom: -.14em; background: var(--tile); background-blend-mode: var(--tile-blend, normal); border: var(--tile-border); border-radius: max(var(--tile-radius), .08em); box-shadow: var(--tile-shadow); }
.logo-k small { position: absolute; right: 5%; bottom: -9%; font-family: var(--font-ui); font-size: max(.22em, 7px); font-weight: 700; line-height: 1; letter-spacing: 0; }
/* la lettre se décale à gauche pour laisser la place au score (K vaut 10 en français) */
.mode { color: var(--mute); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn, .ibtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 14px;
  border-radius: var(--radius); background: var(--btn); border: var(--btn-border); box-shadow: var(--btn-shadow);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; touch-action: manipulation;
}
.ibtn { width: 42px; padding: 0; color: var(--mute); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:hover:not(:disabled), .ibtn:hover { filter: brightness(1.08); }

/* --- disposition --- */
.layout {
  display: grid; gap: 16px; padding: 14px 16px 24px; width: 100%; max-width: 1560px; margin: 0 auto;
  grid-template-columns: 250px minmax(0, 1fr) 250px; grid-template-areas: "left play right"; align-items: start;
}
.side-left { grid-area: left; } .side-right { grid-area: right; } .play { grid-area: play; }
.side { display: grid; gap: 12px; min-width: 0; }
.panel { background: var(--panel); border: var(--panel-border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--panel-shadow); min-width: 0; }
.ptitle { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); margin: 0 0 8px; font-weight: 700; }

.play { display: grid; gap: 10px; justify-items: center; min-width: 0; }
.board-area { position: relative; width: 100%; display: grid; justify-items: center; }
.board-wrap { width: 100%; display: grid; justify-items: center; }
.board-wrap.zoomed { width: min(100%, calc(100dvh - 330px)); aspect-ratio: 1; overflow: auto; justify-items: start; align-items: start; overscroll-behavior: contain; border-radius: var(--board-radius); touch-action: pan-x pan-y; }
.board-wrap.zoomed .board { width: 190%; min-width: 0; touch-action: pan-x pan-y; }
.zoom-btn { display: none; position: absolute; right: 6px; bottom: 6px; z-index: 5; background: var(--surface); color: var(--ink); box-shadow: 0 4px 12px rgba(0,0,0,.3); }
.zoom-btn[aria-pressed="true"] { color: var(--accent-text); }
.tile.temp { touch-action: none; }
.board {
  container-type: inline-size; position: relative;
  width: min(100%, calc(100dvh - 290px)); min-width: min(100%, 300px); aspect-ratio: 1;
  background: var(--frame); padding: var(--frame-pad); border-radius: var(--board-radius); box-shadow: var(--board-shadow);
  touch-action: manipulation; user-select: none;
}
.grid { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); grid-template-rows: repeat(15, minmax(0, 1fr)); gap: var(--gap); width: 100%; height: 100%; background: var(--gridline); }

@media (max-width: 1180px) {
  .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "play play" "left right"; }
  .board { width: min(100%, calc(100dvh - 330px), 760px); }
}
@media (max-width: 700px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "play" "left" "right"; padding: 8px 8px 24px; gap: 12px; }
  .board { width: 100%; }
  .topbar { padding-inline: 10px; gap: 8px; }
  .mode { display: none; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { width: 42px; padding: 0; }
}

/* --- cases --- */
.cell {
  position: relative; display: grid; place-items: center; color: var(--cell-ink);
  /* texture continue sur tout le plateau : chaque case montre sa portion de l'image */
  background-color: var(--cell); background-image: var(--cell-tex, none); background-size: 1500% 1500%;
  background-position: calc(var(--c, 0) * 100% / 14) calc(var(--r, 0) * 100% / 14); background-blend-mode: var(--cell-blend, normal); border-radius: var(--cell-radius); line-height: 1; text-align: center; font-weight: 700; cursor: pointer; }
.cell .pl { font-size: 1.5cqi; display: grid; gap: .12em; letter-spacing: .03em; pointer-events: none; }
.cell .pl > i { font-style: normal; font-size: .9em; }
.cell .pl.long > b { font-size: .8em; letter-spacing: 0; }
.cell.tw { background-color: var(--tw); color: var(--tw-ink); }
.cell.dw, .cell.star { background-color: var(--dw); color: var(--dw-ink); }
.cell.tl { background-color: var(--tl); color: var(--tl-ink); }
.cell.dl { background-color: var(--dl); color: var(--dl-ink); }
.cell.star svg { width: 58%; height: 58%; color: var(--star); }
.cell .dots { display: flex; gap: 2px; justify-content: center; }
.cell .dots i { width: .5cqi; height: .5cqi; min-width: 3px; min-height: 3px; border-radius: 50%; background: currentColor; }
.cell.target { outline: 2px solid var(--accent-text); outline-offset: -2px; z-index: 2; }
.cell.cursor { outline: 2px solid var(--accent-text); outline-offset: -2px; z-index: 2; animation: pulse 1.2s ease-in-out infinite; }
.cell.cursor::after { content: "▶"; position: absolute; right: 4%; top: 50%; transform: translateY(-50%); font-size: 2.2cqi; color: var(--accent-text); line-height: 1; text-shadow: 0 0 3px var(--cell); }
.cell.cursor[data-dir="V"]::after { content: "▼"; right: auto; left: 50%; top: auto; bottom: 4%; transform: translateX(-50%); }
@keyframes pulse { 50% { outline-color: transparent; } }
@container (max-width: 520px) {
  .cell .pl { font-size: 2.3cqi; }
  .cell .pl > i { display: none; }
}

/* --- tuiles --- */
.tile {
  position: absolute; inset: var(--tile-inset); display: grid; place-items: center; z-index: 1;
  background: var(--tile); background-blend-mode: var(--tile-blend, normal); color: var(--tile-ink); border-radius: var(--tile-radius); box-shadow: var(--tile-shadow); border: var(--tile-border);
  font-family: var(--font-tile); font-weight: var(--tile-weight);
}
.tile .L { font-size: 4.3cqi; line-height: 1; transform: translateY(-.04em); }
.tile .v { position: absolute; right: 9%; bottom: 6%; font-size: 1.75cqi; font-family: var(--font-ui); font-weight: 700; opacity: .85; }
.tile.blank { background: var(--blank); background-blend-mode: var(--tile-blend, normal); }
.tile.blank .v { display: none; }
.tile.last { box-shadow: var(--tile-shadow), var(--last); }
.tile.temp { background: var(--temp); background-blend-mode: var(--tile-blend, normal); color: var(--temp-ink); transform: translateY(-5%); box-shadow: var(--tile-shadow), 0 0 0 2px var(--ok); cursor: grab; }
.tile.temp.bad { box-shadow: var(--tile-shadow), 0 0 0 2px var(--bad); }
.tile.temp.neutral { box-shadow: var(--tile-shadow), 0 0 0 2px var(--accent-text); }
.tile.drop { animation: drop .32s cubic-bezier(.3, 1.4, .5, 1) both; animation-delay: var(--d, 0s); }
.tile.temp.snap { animation: snap .28s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes snap { 0% { transform: translateY(-5%) scale(1.22); } 55% { transform: translateY(-5%) scale(.93); } 100% { transform: translateY(-5%) scale(1); } }
@keyframes drop { from { transform: translateY(-40%) scale(1.25); opacity: 0; } to { transform: none; opacity: 1; } }

.bubble {
  position: absolute; z-index: 4; transform: translate(-15%, -55%); pointer-events: none;
  font-family: var(--font-title); font-size: max(13px, 3.1cqi); padding: .25em .6em; border-radius: 99px; white-space: nowrap;
  background: var(--ok); color: var(--on-ok); box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.bubble.bad { background: var(--bad); color: var(--on-bad); }

.hint-chips { display: none; gap: 6px; overflow-x: auto; max-width: 100%; padding: 2px 2px 6px; scrollbar-width: thin; }
.hint-chips button { flex: none; display: flex; gap: 8px; align-items: baseline; padding: 6px 12px; border-radius: 99px; background: var(--btn); border: var(--btn-border); cursor: pointer; }
.hint-chips button[aria-pressed="true"] { outline: 2px solid var(--accent-text); outline-offset: -1px; }
.hint-chips .w { font-family: var(--font-tile); font-weight: 700; letter-spacing: .05em; }
.hint-chips .s { font-weight: 700; color: var(--accent-text); font-variant-numeric: tabular-nums; }

/* --- chevalet --- */
.rackbar { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.rack { display: flex; gap: 6px; padding: 8px 10px; background: var(--rack); border-radius: var(--radius); box-shadow: var(--rack-shadow); border: var(--rack-border); min-height: calc(var(--rt) + 16px); touch-action: none; }
.rtile { position: relative; width: var(--rt); height: var(--rt); container-type: inline-size; border: 0; padding: 0; background: none; cursor: grab; touch-action: none; }
.rtile .tile { inset: 0; transition: transform .12s; }
.rtile .tile .L { font-size: 58cqi; }
.rtile .tile .v { font-size: 22cqi; }
.rtile.used { cursor: default; }
.rtile.used .tile { visibility: hidden; }
.rtile.used::after { content: ""; position: absolute; inset: 0; border: 2px dashed var(--line); border-radius: var(--tile-radius); }
.rtile.selected .tile { transform: translateY(-18%); box-shadow: var(--tile-shadow), 0 0 0 2px var(--accent-text); }
.rtile.picked .tile { transform: translateY(-14%); box-shadow: var(--tile-shadow), 0 0 0 3px var(--bad); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

@media (max-width: 700px) {
  .rackbar { gap: 8px; }
  .actions { display: grid; grid-template-columns: repeat(5, 1fr) 1.6fr; width: 100%; gap: 5px; }
  .actions .btn { flex-direction: column; gap: 2px; font-size: 10px; min-height: 52px; padding: 0 2px; }
  .actions .btn.primary { flex-direction: row; font-size: 14px; }
}

.drag-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; width: var(--gw, 48px); height: var(--gw, 48px); container-type: inline-size; transform: translate(-50%, -60%) scale(1.08); filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .35)); }
.drag-ghost .tile { inset: 0; }
.drag-ghost .tile .L { font-size: 58cqi; }
.drag-ghost .tile .v { font-size: 22cqi; }

.status { min-height: 26px; font-size: 14px; color: var(--mute); text-align: center; display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.status .word { font-family: var(--font-tile); font-weight: 700; letter-spacing: .08em; color: var(--ink); }
.status .ok { color: var(--ok-text); font-weight: 700; }
.status .bad { color: var(--bad); font-weight: 600; }
.thinking::after { content: "…"; display: inline-block; animation: blink 1s steps(4) infinite; width: 1em; text-align: left; }
@keyframes blink { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 -10% 0 0); } }

/* --- joueurs --- */
.player { display: grid; grid-template-columns: 50px 1fr auto; gap: 12px; align-items: center; }
.player + .player { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.avatar { width: 50px; height: 50px; border-radius: var(--av-radius); overflow: hidden; background: var(--you); display: grid; place-items: center; font-family: var(--font-title); font-size: 21px; color: var(--ink); border: var(--av-border); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pname { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.player.turn .pname::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 30%, transparent); }
.psub { font-size: 12px; color: var(--mute); }
.pscore { font-family: var(--font-title); font-size: 28px; font-variant-numeric: tabular-nums; }

.scorestrip { display: none; width: 100%; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.scorestrip .sp { display: flex; gap: 9px; align-items: center; background: var(--panel); border: var(--panel-border); border-radius: var(--radius); padding: 6px 9px; box-shadow: var(--panel-shadow); min-width: 0; }
.scorestrip .sp.r { flex-direction: row-reverse; text-align: right; }
.scorestrip .sp.turn { outline: 2px solid var(--ok); outline-offset: -2px; }
.scorestrip .avatar { width: 38px; height: 38px; font-size: 16px; flex: none; }
.scorestrip .pscore { font-size: 22px; line-height: 1; }
.scorestrip .pname { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scorestrip .bagc { display: grid; justify-items: center; font-size: 11px; color: var(--mute); }
.scorestrip .bagc svg { color: var(--accent-text); width: 20px; height: 20px; }
.scorestrip .bagc b { font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
/* langue du jeu de la partie : fixée à la création, indépendante de la langue de l'interface */
.game-lang { flex: none; font-size: 11px; font-weight: 700; letter-spacing: .08em; padding: 3px 7px; border-radius: 6px; border: 1px solid var(--accent-text); color: var(--accent-text); line-height: 1; }
@media (max-width: 1180px) {
  .scorestrip { display: grid; } #players { display: none; }
  .zoom-btn { display: inline-flex; }
  .hint-chips:not([hidden]) { display: flex; }
}

/* --- historique, indices, lettres --- */
.hist, .hints { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: 13px; max-height: 340px; overflow-y: auto; }
.hist li { display: grid; grid-template-columns: 54px 1fr auto; gap: 8px; padding: 6px 2px; border-bottom: 1px dashed var(--line); }
.hist li:last-child { border-bottom: 0; }
.hist .who { font-size: 11px; color: var(--mute); align-self: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .w { font-family: var(--font-tile); letter-spacing: .05em; font-weight: 700; overflow-wrap: anywhere; }
.hist .s { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent-text); }
.hist .note { color: var(--mute); font-style: italic; }
.hist .empty { display: block; color: var(--mute); border: 0; }
.hints button { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 8px 6px; background: none; border: 0; border-bottom: 1px dashed var(--line); text-align: left; cursor: pointer; }
.hints button:hover, .hints button[aria-pressed="true"] { background: var(--chipbg); }
.hints .w { font-family: var(--font-tile); font-weight: 700; letter-spacing: .05em; }
.hints .s { font-weight: 700; color: var(--accent-text); font-variant-numeric: tabular-nums; }
.unseen { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.unseen div { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; padding: 3px 5px; border-radius: 4px; background: var(--chipbg); }
.unseen b { font-family: var(--font-tile); }
.unseen span { color: var(--mute); font-variant-numeric: tabular-nums; font-size: 11px; }
.unseen .zero { opacity: .3; }

/* --- fenêtres --- */
.modal { border: 0; padding: 0; background: none; color: var(--ink); max-width: min(560px, calc(100vw - 24px)); width: 100%; }
.modal::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
.modal-card { background: var(--surface); border: var(--panel-border); border-radius: calc(var(--radius) + 4px); box-shadow: 0 30px 60px rgba(0, 0, 0, .4); padding: 18px 20px; display: grid; gap: 14px; max-height: calc(100dvh - 40px); overflow-y: auto; font-family: var(--font-ui); }
.modal-card.small { max-width: 420px; margin: 0 auto; }
.modal-card h2 { margin: 0; font-family: var(--font-title); font-size: 24px; font-weight: 600; }
.modal-card p { margin: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.hint-text { color: var(--mute); font-size: 14px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--mute); }
.field input { font: inherit; font-size: 16px; color: var(--ink); background: var(--chipbg); border: var(--btn-border); border-radius: var(--radius); padding: 10px 12px; }
.personas { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.personas legend { font-size: 13px; color: var(--mute); margin-bottom: 6px; }
.persona { display: grid; grid-template-columns: auto auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--radius); border: var(--btn-border); background: var(--btn); cursor: pointer; }
.persona:has(input:checked) { outline: 2px solid var(--accent-text); outline-offset: -1px; }
.persona input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.persona b { font-size: 15px; }
.persona small { display: block; color: var(--mute); font-size: 12.5px; }
.lvl { display: flex; gap: 3px; }
.lvl i { width: 6px; height: 14px; border-radius: 2px; background: var(--line); }
.lvl i.on { background: var(--accent-text); }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.theme-card { display: grid; gap: 8px; padding: 10px; border-radius: var(--radius); border: var(--btn-border); background: var(--btn); text-align: left; cursor: pointer; }
.theme-card[aria-pressed="true"] { outline: 2px solid var(--accent-text); outline-offset: -1px; }
.theme-card .sw { display: flex; height: 34px; border-radius: 6px; overflow: hidden; }
.theme-card .sw i { flex: 1; }
.theme-card b { font-size: 14px; }
.theme-card small { color: var(--mute); font-size: 12px; }
.alphabet { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.alphabet button { position: relative; height: 46px; border: 0; padding: 0; background: none; container-type: inline-size; cursor: pointer; }
.alphabet .tile { inset: 0; }
.alphabet .tile .L { font-size: 56cqi; }
.exchange-rack { justify-content: center; flex-wrap: wrap; }
.final { display: grid; gap: 8px; }
.final .row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 8px 10px; border-radius: var(--radius); background: var(--chipbg); }
.final .row.win { outline: 2px solid var(--accent-text); outline-offset: -2px; }
.final .adj { color: var(--mute); font-size: 13px; font-variant-numeric: tabular-nums; }
.final .pscore { font-size: 26px; }

/* --- écran titre --- */
.home { position: fixed; inset: 0; z-index: 30; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(400px, 1fr); background: var(--bg); color: var(--ink); overflow-y: auto; }
.home-art { position: relative; background: var(--keyart, var(--frame)) center / cover no-repeat; min-height: 100%; }
.home-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 55%, var(--home-fade, rgba(0,0,0,.35))); }
.home-panel { display: grid; align-content: center; gap: 22px; padding: calc(32px + env(safe-area-inset-top, 0px)) clamp(24px, 5vw, 72px) calc(32px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-left: var(--panel-border); }
.home-logo { margin: 0; padding-bottom: .18em; /* la tuile du K déborde sous la ligne : place réservée */ display: flex; align-items: baseline; font-family: var(--font-title); font-weight: 400; font-size: clamp(60px, 8vw, 104px); line-height: 1; letter-spacing: .01em; }
.home-tag { margin: -8px 0 0; font-size: 18px; color: var(--mute); }
/* partie précédente : sous les modes, en retrait */
.home-section { margin: 0; font-family: var(--font-ui); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--mute); }
.home-menu { display: grid; gap: 10px; }
.btn.big { min-height: 54px; font-size: 16px; justify-content: flex-start; padding: 0 20px; }
.btn.big.primary { justify-content: center; }
.home-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); font-weight: 700; }
.home-theme-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.home-theme-list button { display: grid; gap: 6px; padding: 8px; border-radius: var(--radius); border: var(--btn-border); background: var(--btn); color: var(--ink); text-align: left; cursor: pointer; font-size: 13px; font-weight: 600; }
.home-theme-list button[aria-pressed="true"] { outline: 2px solid var(--accent-text); outline-offset: -1px; }
.home-theme-list .sw { display: flex; height: 18px; border-radius: 4px; overflow: hidden; }
.home-theme-list .sw i { flex: 1; }
.home-foot { margin: 0; font-size: 12px; color: var(--mute); }
/* langues : choix segmenté (écran titre) */
.set-block .home-label small { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .85; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.seg button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 6px 10px; border-radius: var(--radius); border: var(--btn-border); background: var(--btn); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.seg [aria-pressed="true"] { outline: 2px solid var(--accent-text); outline-offset: -1px; }
.seg .code { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--accent-text); }

.linkbtn { border: 0; padding: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.linkbtn:hover { color: var(--ink); }
.home-theme-list .code, .theme-card .code { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--mute); }
.ibtn.lang-btn { width: auto; padding: 0 8px; gap: 4px; }
.ibtn.lang-btn span { font-size: 12px; font-weight: 700; letter-spacing: .06em; }
/* téléphones : la barre du haut (logo, langue du jeu, 5 boutons) doit tenir sans élargir la page */
@media (max-width: 420px) {
  .topbar { gap: 6px; padding-inline: 8px; }
  .top-actions { gap: 4px; }
  .top-actions .ibtn, .top-actions .btn { width: 38px; }
  .ibtn.lang-btn { width: auto; padding: 0 7px; }
  .logo { white-space: nowrap; flex: none; }
  .ibtn.lang-btn svg { display: none; }
}
@media (max-width: 380px) { /* 7 boutons : on resserre encore */
  .topbar { gap: 4px; padding-inline: 6px; }
  .top-actions { gap: 3px; }
  .top-actions .ibtn, .top-actions .btn { width: 33px; }
  .ibtn.lang-btn { padding: 0 5px; }
  .logo { font-size: 20px; }
}
@media (max-width: 860px) {
  .home { grid-template-columns: minmax(0, 1fr); grid-template-rows: clamp(72px, 13vh, 150px) auto; }
  .home-art { background-position: center 22%; }
  .home-art::after { background: linear-gradient(180deg, transparent 60%, var(--home-fade, rgba(0,0,0,.35))); }
  .home-panel { border-left: 0; border-top: var(--panel-border); align-content: start; gap: 13px; padding-top: 14px; padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .home-logo { font-size: 46px; }
  .home-tag { font-size: 14px; }
  .home-head { grid-template-columns: auto minmax(0, 1fr); align-items: end; column-gap: 16px; }
  .home-head .home-tag { padding-bottom: 6px; }
  .home-continue { padding: 11px 14px; gap: 12px; }
  .hc-text > b { font-size: 18px; }
  /* petites cartes : pictogramme + nom (le détail est dans l'aide du mode) */
  .mode-card:not(.featured) { grid-template-columns: minmax(0, 1fr); align-content: start; min-height: 0; padding: 10px 12px; gap: 6px; }
  .mode-card:not(.featured) small { display: none; }
  .mode-card:not(.featured) .mode-ico { width: 40px; height: 40px; }
  .mode-card:not(.featured) .mode-ico svg { width: 25px; height: 25px; }
  .mode-card:not(.featured) b { font-size: 14.5px; line-height: 1.2; }
  .mode-card.featured { min-height: 76px; padding: 10px 12px; }
  /* barre fixe en bas d'écran, comme dans les jeux mobiles */
  .home-nav { position: fixed; z-index: 2; left: 0; right: 0; bottom: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: var(--panel-border); box-shadow: 0 -6px 18px rgba(0, 0, 0, .18); }
  .home-nav button { flex-direction: column; gap: 2px; font-size: 11px; min-height: 52px; }
}

.rules-body { display: grid; gap: 14px; }
.rules section { display: grid; gap: 6px; }
.rules h3 { margin: 0; font-family: var(--font-title); font-size: 18px; font-weight: 600; }
.rules p, .rules ul { margin: 0; font-size: 14.5px; line-height: 1.5; max-width: 62ch; }
.rules ul { padding-left: 1.2em; display: grid; gap: 4px; }

/* --- modes de jeu et progression (phase 5) --- */
.lvl-chip { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.avatar.target { background: var(--chipbg); color: var(--accent-text); }
.avatar.target svg { width: 55%; height: 55%; }
.hist .top { display: block; font-family: var(--font-ui); font-weight: 400; font-size: 11px; color: var(--mute); letter-spacing: 0; }
.coach-panel p { margin: 0 0 6px; font-size: 13.5px; line-height: 1.45; }
.coach-panel .coach-ok b { color: var(--ok-text); }
.coach-panel .muted { color: var(--mute); font-size: 12.5px; }
.final .row small { font-size: .55em; color: var(--mute); }
.final.compact { gap: 4px; }
.final.compact .row { padding: 4px 10px; grid-template-columns: 58px 1fr auto auto; }
.final.compact .pscore { font-size: 18px; }
.end-reward { display: grid; gap: 10px; padding: 12px; border-radius: var(--radius); background: var(--chipbg); }
.xp-line { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; align-items: center; font-size: 14px; }
.xp-line b { font-family: var(--font-title); font-size: 20px; color: var(--accent-text); }
.xpbar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; min-width: 80px; }
.xpbar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.share-text { width: 100%; font: 13px/1.5 ui-monospace, Consolas, monospace; color: var(--ink); background: var(--chipbg); border: var(--btn-border); border-radius: var(--radius); padding: 8px 10px; resize: none; }
.level-box { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.level-box small { color: var(--mute); font-size: 12.5px; }
.level-box .xpbar { margin: 6px 0 4px; }
.lvl-big { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-family: var(--font-title); font-size: 28px; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.stat-grid div { display: grid; gap: 1px; padding: 8px 10px; border-radius: var(--radius); background: var(--chipbg); }
/* compte en ligne (profil) */
.account-box { display: grid; gap: 8px; padding: 12px; border-radius: var(--radius); border: var(--btn-border); }
.account-box h3 { margin: 0; }
.account-box p { margin: 0; font-size: 13.5px; line-height: 1.45; }
.account-box .muted { color: var(--mute); font-size: 12.5px; }
.account-row { display: flex; gap: 8px; flex-wrap: wrap; }
.google-slot { min-height: 44px; display: flex; align-items: center; }
/* le bouton Google est une page claire : même palette que lui, sinon le navigateur peint un fond blanc opaque */
.google-slot iframe { color-scheme: light; }
.google-slot:empty { display: none; }
.account-or { text-align: center; color: var(--mute); font-size: 12.5px; }
.account-box a { color: inherit; }
.account-row input { flex: 1 1 160px; min-width: 0; font: inherit; font-size: 16px; color: var(--ink); background: var(--chipbg); border: var(--btn-border); border-radius: var(--radius); padding: 8px 10px; }
.account-msg { min-height: 1.2em; font-size: 13px; }
.account-msg.bad { color: var(--bad, #d9534f); }
.account-msg.ok { color: var(--good, var(--accent-text)); }
.btn.danger { color: var(--bad, #d9534f); }
.account-row .btn.danger { margin-left: auto; }
.stat-grid span { font-size: 11.5px; color: var(--mute); }
.stat-grid b { font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.badge-grid.small { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.badge { display: grid; justify-items: center; text-align: center; gap: 4px; padding: 10px 8px; border-radius: var(--radius); background: var(--chipbg); opacity: .45; filter: grayscale(1); }
.badge.on { opacity: 1; filter: none; }
.badge b { font-size: 13px; }
.badge small { font-size: 11.5px; color: var(--mute); line-height: 1.3; }
.medal { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; font-family: var(--font-title); font-weight: 700; font-size: 18px; color: #3A2606;
  background: radial-gradient(circle at 35% 30%, #FFF3B8, #E8B931 45%, #A87A12 100%); box-shadow: inset 0 0 0 3px rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.2), 0 3px 8px rgba(0,0,0,.3); }
.medal { position: relative; overflow: hidden; }
.medal img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; transform: scale(1.18); }

/* --- effets (phase 4) --- */
.fly { position: fixed; z-index: 90; pointer-events: none; transform: translate(-50%, -50%); font-family: var(--font-title); font-size: 26px; font-weight: 700; color: var(--on-ok); background: var(--ok); padding: .15em .55em; border-radius: 99px; box-shadow: 0 8px 24px rgba(0,0,0,.3); white-space: nowrap; }
.fly.big { font-size: 34px; background: var(--accent); color: var(--on-accent); }
.banner { position: fixed; left: 50%; top: 42%; z-index: 95; pointer-events: none; transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 4px; padding: 18px 34px; border-radius: calc(var(--radius) + 8px); background: var(--surface); border: var(--panel-border); box-shadow: 0 30px 80px rgba(0,0,0,.45); text-align: center; }
.banner b { font-family: var(--font-title); font-size: clamp(34px, 8vw, 64px); line-height: 1; color: var(--accent-text); letter-spacing: .01em; }
.banner small { font-size: 16px; font-weight: 700; color: var(--ink); }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 94; pointer-events: none; }
.avatar img { transition: filter .4s, transform .4s; transform-origin: 50% 80%; }
.avatar.mood-thinking img { animation: think 1.6s ease-in-out infinite; }
.avatar.mood-happy img { animation: hop .5s cubic-bezier(.3, 1.5, .5, 1) 2; }
.avatar.mood-sad img { filter: grayscale(.7) brightness(.85); transform: rotate(-8deg) translateY(4%); }
.avatar.mood-happy { box-shadow: 0 0 0 3px var(--ok); }
/* avec de vraies expressions, l'image porte l'émotion : on garde seulement un léger mouvement */
.avatar.expr.mood-sad img { filter: none; transform: none; }
.avatar.expr.mood-thinking img { animation-duration: 2.4s; }
@keyframes think { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg) translateY(-3%); } }
@keyframes hop { 0%, 100% { transform: none; } 45% { transform: translateY(-14%) scale(1.06); } }

/* centrée sur toute la largeur (left: 50% + translate ne laissait que la moitié de l'écran au texte) */
.update-bar { position: fixed; left: 12px; right: 12px; margin: 0 auto; width: fit-content; top: calc(10px + env(safe-area-inset-top, 0px)); z-index: 60; display: flex; gap: 12px; align-items: center; padding: 8px 8px 8px 16px; border-radius: 99px; background: var(--surface); color: var(--ink); border: var(--panel-border); box-shadow: 0 12px 30px rgba(0,0,0,.35); font-size: 14px; max-width: calc(100vw - 24px); }
.update-bar .btn { min-height: 36px; flex: none; }
.update-bar > span { min-width: 0; line-height: 1.3; }
@media (max-width: 420px) { .update-bar { border-radius: 18px; font-size: 13.5px; } }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50; background: var(--surface); color: var(--ink); border: var(--panel-border); border-radius: 99px; padding: 10px 18px; box-shadow: 0 12px 30px rgba(0, 0, 0, .35); font-weight: 600; max-width: calc(100vw - 32px); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Classement du Défi du jour */
.modal-card.ranking { max-width: 460px; margin: 0 auto; }
.ranking-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: min(52vh, 460px); overflow: auto; }
.ranking-list li { display: grid; grid-template-columns: 2.4em 1fr auto 3.6em; align-items: baseline; gap: 8px; padding: 7px 10px; border-radius: var(--radius); background: var(--chipbg); }
.ranking-list li.me { outline: 2px solid var(--accent-text); outline-offset: -2px; }
.ranking-list li.gap, .ranking-list li.empty { display: block; background: none; text-align: center; color: var(--mute); }
.ranking-list .rk { font-weight: 700; color: var(--accent-text); text-align: right; }
.ranking-list b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-list small { color: var(--mute); font-size: 12px; }
.ranking-list .pscore { text-align: right; font-weight: 700; }

/* ---------- écran titre : navigation, action principale, cartes des modes ---------- */
.home-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.home-nav button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 6px; border: 0; border-radius: var(--radius); background: none; color: var(--mute); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.home-nav button:hover, .home-nav button:focus-visible { color: var(--ink); background: var(--chipbg); }
.nav-ico { position: relative; display: inline-grid; place-items: center; }
.nav-ico svg { width: 22px; height: 22px; }
.nav-ico .lvl-chip { position: absolute; right: -12px; top: -7px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 10.5px; }
.home-head { display: grid; row-gap: 4px; } /* l'écart logo / slogan du mobile reste celui du @media */
.home-head .home-tag { margin: 0; }

.home-continue { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; width: 100%; padding: 14px 18px; border: 0; border-radius: calc(var(--radius) + 4px); background: var(--accent); color: var(--on-accent); text-align: left; font: inherit; cursor: pointer; box-shadow: var(--btn-shadow), 0 8px 22px rgba(0, 0, 0, .22); transition: transform .15s ease, filter .15s ease; }
.home-continue:hover { filter: brightness(1.06); transform: translateY(-1px); }
.home-continue:active { transform: translateY(1px); }
.home-continue .mode-ico { background: rgba(255, 255, 255, .18); color: inherit; }
.hc-text { display: grid; gap: 2px; min-width: 0; }
.hc-text > b { font-size: 20px; font-family: var(--font-title); font-weight: 600; }
#homeResume { display: grid; font-size: 12.5px; opacity: .9; }
#homeResume span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#homeResume .hc-score { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.hc-go { width: 30px; height: 30px; }

.home-play { display: grid; gap: 10px; }
.home-play-head { display: flex; align-items: center; justify-content: space-between; }
.glang-chip { min-width: 44px; min-height: 30px; padding: 2px 10px; border-radius: 99px; border: var(--btn-border); background: var(--chipbg); color: var(--accent-text); font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .08em; cursor: pointer; }
.home-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mode-card { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; padding: 12px 14px; min-height: 76px; border-radius: calc(var(--radius) + 2px); background: var(--btn); border: var(--btn-border); box-shadow: var(--btn-shadow); color: var(--ink); text-align: left; font: inherit; cursor: pointer; transition: transform .15s ease, filter .15s ease; }
.mode-card:hover { filter: brightness(1.07); transform: translateY(-2px); }
.mode-card:active { transform: translateY(0); }
.mode-card .mc-text { display: grid; gap: 2px; min-width: 0; }
.mode-card b { font-size: 15.5px; }
.mode-card small { font-size: 12px; color: var(--mute); line-height: 1.3; }
.mode-slot { position: relative; display: grid; }
.mode-slot.featured { grid-column: 1 / -1; }
.mode-card.featured { min-height: 88px; }
.mode-card.featured b { font-size: 18px; }
.mode-card.hot { outline: 2px solid var(--mc, var(--accent)); outline-offset: -2px; }
.mc-chip { position: absolute; right: 10px; top: 10px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--chipbg); color: var(--accent-text); font-variant-numeric: tabular-nums; }
.mode-card.hot .mc-chip { background: var(--accent); color: var(--on-accent); }
.mode-card.done .mc-chip { color: var(--good, var(--accent-text)); }

/* pictogrammes : pastille de la couleur repère du mode (les thèmes l'habillent : --icon-*) */
.mode-ico { --mc: var(--accent); display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: var(--icon-radius, 12px); background: color-mix(in srgb, var(--mc) var(--icon-tint, 22%), transparent); color: var(--mc); }
.mode-ico svg { width: 28px; height: 28px; stroke-width: var(--icon-stroke, 1.8); overflow: visible; }
.mode-card.featured .mode-ico { width: 56px; height: 56px; }
.mode-card.featured .mode-ico svg { width: 34px; height: 34px; }
[data-mode="classic"] { --mc: var(--mc-classic, #d0583f); }
[data-mode="training"] { --mc: var(--mc-training, #3f9d62); }
[data-mode="daily"] { --mc: var(--mc-daily, #d9a52b); }
[data-mode="duplicate"] { --mc: var(--mc-duplicate, #3f7fd0); }
[data-mode="puzzle"] { --mc: var(--mc-puzzle, #9a5bd0); }
.mode-card.hot { --mc: var(--mc-daily, #d9a52b); }

.home-last { margin: 0; font-size: 12.5px; color: var(--mute); }

/* panneau Réglages */
.modal-card.settings { max-width: 520px; margin: 0 auto; }
.set-block { display: grid; gap: 8px; }
#setSound [aria-pressed="true"] { outline: 2px solid var(--accent-text); outline-offset: -1px; }

@media (max-width: 380px) {
  .home-modes { gap: 8px; }
  .mode-card:not(.featured) .mode-ico { width: 34px; height: 34px; }
  .mode-card:not(.featured) .mode-ico svg { width: 22px; height: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .mode-card, .home-continue { transition: none; }
  .mode-card:hover, .home-continue:hover { transform: none; }
}

/* grand écran : petites cartes en colonne (pictogramme au-dessus du texte) */
@media (min-width: 861px) {
  .mode-card:not(.featured) { grid-template-columns: minmax(0, 1fr); align-content: start; gap: 8px; }
  .nav-ico:has(.lvl-chip) { margin-right: 10px; }
  .home-nav { order: -1; } /* en haut du panneau ; dernière dans l'ordre du clavier */
}
.home-foot a { color: inherit; }

/* bouton « ? » de chaque carte : coin bas droit, cible de 36 px */
.mode-help { position: absolute; right: 4px; bottom: 4px; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--mute); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.mode-help::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; border: 1.5px solid currentColor; opacity: .7; }
.mode-help:hover, .mode-help:focus-visible { color: var(--accent-text); }
.mode-card { padding-right: 34px; }

/* aide : onglets et fiches des modes */
.rules-tabs { margin-top: -4px; }
.rules-modes { display: grid; gap: 12px; max-height: min(60vh, 560px); overflow: auto; padding: 2px; }
.mode-sheet { display: grid; gap: 8px; padding: 14px; border-radius: calc(var(--radius) + 2px); background: var(--chipbg); border: 1px solid transparent; scroll-margin-top: 4px; }
.mode-sheet.focus { border-color: var(--mc, var(--accent)); }
.mode-sheet header { display: flex; align-items: center; gap: 12px; }
.mode-sheet h3 { margin: 0; font-family: var(--font-title); font-size: 20px; font-weight: 600; }
.ms-pitch { margin: 0; line-height: 1.45; }
.mode-sheet dl { margin: 0; display: grid; gap: 6px; }
.mode-sheet dl div { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 10px; font-size: 13.5px; line-height: 1.4; }
.mode-sheet dt { color: var(--mute); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding-top: 1px; }
.mode-sheet dd { margin: 0; }
@media (max-width: 420px) { .mode-sheet dl div { grid-template-columns: minmax(0, 1fr); gap: 1px; } }
/* petites cartes : « ? » en haut à droite, en face du pictogramme */
.mode-slot:not(.featured) .mode-help { top: 4px; bottom: auto; }
.mode-slot:not(.featured) .mode-card { padding-right: 12px; }
.mode-slot:not(.featured) .mc-chip { top: 12px; right: 42px; }

/* finitions : arrivée en cascade, reflet du bouton principal, focus clavier */
.home:not([hidden]) .mode-slot { animation: card-in .32s ease both; }
.home:not([hidden]) .mode-slot:nth-child(1) { animation-delay: .04s; }
.home:not([hidden]) .mode-slot:nth-child(2) { animation-delay: .08s; }
.home:not([hidden]) .mode-slot:nth-child(3) { animation-delay: .12s; }
.home:not([hidden]) .mode-slot:nth-child(4) { animation-delay: .16s; }
.home:not([hidden]) .mode-slot:nth-child(5) { animation-delay: .2s; }
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } }
.home-continue { position: relative; overflow: hidden; }
.home-continue::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, .22) 50%, transparent 60%); transform: translateX(-100%); animation: shine 4.5s ease-in-out 1.2s infinite; pointer-events: none; }
@keyframes shine { 0%, 70% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
.mode-card:focus-visible, .home-continue:focus-visible, .mode-help:focus-visible, .home-nav button:focus-visible, .glang-chip:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .home:not([hidden]) .home-continue, .home:not([hidden]) .mode-slot { animation: none; }
  .home-continue::after { animation: none; display: none; }
}

/* Continuer + abandon côte à côte (le drapeau ne prend pas de hauteur en plus) */
.home-current { display: flex; gap: 6px; align-items: stretch; }
.home-current .home-continue { flex: 1; min-width: 0; }
.home-abandon { flex: none; width: 52px; display: grid; place-items: center; border: 0; border-radius: calc(var(--radius) + 4px); background: color-mix(in srgb, var(--accent) 70%, #000); color: var(--on-accent); cursor: pointer; box-shadow: var(--btn-shadow); transition: filter .15s ease; }
.home-abandon svg { width: 22px; height: 22px; }
.home-abandon:hover { filter: brightness(1.12); }
.home-abandon:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }
.home:not([hidden]) .home-current { animation: card-in .32s ease both; }
@media (prefers-reduced-motion: reduce) { .home:not([hidden]) .home-current { animation: none; } }
@media (max-width: 860px) {
  .home-abandon { width: 44px; }
  .home-continue { gap: 10px; padding: 10px 12px; }
  .home-continue .mode-ico { width: 38px; height: 38px; }
  .home-continue .mode-ico svg { width: 24px; height: 24px; }
  .hc-go { width: 22px; height: 22px; }
  #homeResume span { white-space: normal; } /* adversaire et score lisibles en entier */
}

/* coach : montrer le meilleur coup sur le plateau */
.coach-show { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; margin: 2px 0 8px; padding: 6px 12px; font-size: 13px; }
.coach-show svg { width: 18px; height: 18px; }
.coach-show[aria-pressed="true"] { outline: 2px solid var(--accent-text); outline-offset: -1px; }
.grid.coach-preview .cell .tile:not(.coach-ghost) { opacity: .45; filter: saturate(.6); }
.tile.coach-ghost { z-index: 2; outline: 3px solid var(--accent); outline-offset: -1px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent), 0 0 18px color-mix(in srgb, var(--accent) 70%, transparent); animation: coach-pulse .9s ease-in-out infinite alternate; }
@keyframes coach-pulse { to { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 20%, transparent), 0 0 26px var(--accent); } }
.coach-caption { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); z-index: 5; padding: 6px 12px; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 700; white-space: nowrap; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .tile.coach-ghost { animation: none; } }
.coach-caption.low { top: auto; bottom: 6px; }

/* ---------- parties en ligne ---------- */
.home-online { display: grid; gap: 10px; }
.online-dot { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--accent); color: var(--on-accent); }
.online-list { display: grid; gap: 6px; }
.online-list .hint-text { margin: 0; }
.online-row { display: flex; gap: 6px; align-items: stretch; }
.online-open { flex: 1; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--btn); border: var(--btn-border); color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.online-open .mode-ico { width: 34px; height: 34px; }
.online-open .mode-ico svg { width: 21px; height: 21px; }
.or-text { display: grid; min-width: 0; }
.or-text b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.or-text small { font-size: 12px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.or-score { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.online-row.turn .online-open { outline: 2px solid var(--accent-text); outline-offset: -2px; }
.online-row.turn .or-text small { color: var(--accent-text); font-weight: 700; }
.online-row.ended { opacity: .7; }
.or-share { flex: none; font-size: 12.5px; padding: 0 10px; }
.online-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.online-actions .btn { justify-content: center; font-size: 13.5px; }
.nbadge { position: absolute; right: -4px; top: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
#btnMenu { position: relative; }
.seg-2l button { display: grid; gap: 2px; text-align: center; padding: 8px; }
.seg-2l small { font-size: 11.5px; font-weight: 500; color: var(--mute); }
.online-bot { width: 100%; font: inherit; font-size: 14px; padding: 9px 10px; border-radius: var(--radius); border: var(--btn-border); background: var(--chipbg); color: var(--ink); }
.online-msg { color: var(--bad, #d9534f); }
.invite-code { font-family: var(--font-title); font-size: 40px; letter-spacing: .18em; text-align: center; padding: 8px; border-radius: var(--radius); background: var(--chipbg); user-select: all; }
.invite-link { width: 100%; font: inherit; font-size: 13px; padding: 8px 10px; border-radius: var(--radius); border: var(--btn-border); background: var(--chipbg); color: var(--mute); }
.online-banner { position: fixed; left: 12px; right: 12px; margin: 0 auto; width: fit-content; max-width: calc(100vw - 24px); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 61; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 18px; background: var(--surface); color: var(--ink); border: var(--panel-border); box-shadow: 0 12px 30px rgba(0, 0, 0, .35); font-size: 14px; font-weight: 600; }
.online-banner > span { min-width: 0; }
.online-banner .btn { flex: none; min-height: 36px; }
@media (max-width: 860px) { .online-banner { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); } }

/* pendule des parties en ligne ; joueur sorti (abandon, partie à plusieurs) */
.clock { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 99px; background: var(--chipbg); color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 11.5px; }
.scorestrip .clock { margin: 2px 0 0; font-size: 11px; }
.clock.low { background: var(--bad, #d9534f); color: #fff; animation: clock-low 1s steps(2) infinite; }
@keyframes clock-low { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .clock.low { animation: none; } }
.player.out, .sp.out { opacity: .5; }
.scorestrip.many { grid-template-columns: repeat(var(--n), minmax(0, 1fr)) auto; gap: 5px; }
.scorestrip.many .sp { gap: 6px; padding: 5px 6px; }
.scorestrip.many .avatar { width: 28px; height: 28px; font-size: 13px; }
.scorestrip.many .pscore { font-size: 18px; }

/* réactions (parties en ligne) */
#btnEmote .emo { font-size: 17px; line-height: 1; }
.emote-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.emote-grid button { display: grid; justify-items: center; gap: 4px; padding: 10px 6px; border-radius: var(--radius); border: var(--btn-border); background: var(--btn); color: var(--ink); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.emote-grid .emo { font-size: 30px; line-height: 1; }
.emote-pop { position: fixed; z-index: 70; transform: translate(-50%, -60%); font-size: 34px; pointer-events: none; animation: emote-pop 2.6s ease forwards; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35)); }
@keyframes emote-pop { 0% { opacity: 0; transform: translate(-50%, -20%) scale(.4); } 12% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); } 22% { transform: translate(-50%, -80%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -130%); } }
@media (prefers-reduced-motion: reduce) { .emote-pop { animation: none; transform: translate(-50%, -90%); } }

/* historique des parties en ligne */
.online-history { justify-self: center; font-size: 13px; }
.modal-card.history { max-width: 520px; margin: 0 auto; }
.history-list { display: grid; gap: 10px; max-height: min(64vh, 600px); overflow: auto; padding: 2px; }
.hist-game { display: grid; gap: 8px; padding: 12px 14px; border-radius: calc(var(--radius) + 2px); background: var(--chipbg); border-left: 4px solid var(--mute); }
.hist-game.won { border-left-color: var(--ok, #3f9d62); }
.hist-game.lost { border-left-color: var(--bad, #d9534f); }
.hist-game.draw { border-left-color: var(--accent); }
.hist-game header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hist-game header small { color: var(--mute); font-size: 12px; }
.hist-game ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.hist-game li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; align-items: baseline; }
.hist-game li.out { opacity: .6; }
.hp-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-name small { font-weight: 400; color: var(--mute); }
.hp-score { font-variant-numeric: tabular-nums; font-size: 17px; }
.hp-stats { grid-column: 1 / -1; color: var(--mute); font-size: 12px; }

/* classement en ligne : ligues */
.league-chip { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--chipbg); color: var(--ink); white-space: nowrap; }
.league-chip[data-league="bronze"] { background: #8c5a3c; color: #fff; }
.league-chip[data-league="argent"] { background: #9aa4ad; color: #1d2228; }
.league-chip[data-league="or"] { background: #d9a52b; color: #2a1d05; }
.league-chip[data-league="platine"] { background: #5fb3b3; color: #0e2a2a; }
.league-chip[data-league="diamant"] { background: #5b8def; color: #fff; }
.league-chip[data-league="maitre"] { background: #9a5bd0; color: #fff; }
.home-play-head .league-chip { margin-left: auto; margin-right: 6px; }
.online-match { width: 100%; justify-content: center; min-height: 48px; font-size: 15px; }
.online-open.static { cursor: default; }
.match-wait { display: grid; justify-items: center; gap: 8px; padding: 12px 0; }
.match-wait p { margin: 0; text-align: center; }
.match-time { font-family: var(--font-title); font-size: 28px; font-variant-numeric: tabular-nums; }
.match-spin { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--chipbg); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.match-spin.small { width: 26px; height: 26px; border-width: 3px; margin: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .match-spin { animation-duration: 3s; } }
.ranking-list .league-chip { font-size: 10.5px; }
.hist-rank { margin: 0; font-size: 12.5px; font-weight: 700; color: var(--accent-text); }

/* répliques des adversaires : bulle sous l'avatar */
.say-bubble { position: fixed; z-index: 65; max-width: min(280px, calc(100vw - 16px)); padding: 9px 13px; border-radius: 14px; background: var(--surface); color: var(--ink); border: var(--panel-border); box-shadow: 0 10px 26px rgba(0, 0, 0, .3); font-size: 13.5px; font-weight: 600; line-height: 1.35; pointer-events: none; animation: say-in .25s ease both; }
.say-bubble::before { content: ""; position: absolute; top: -7px; left: calc(var(--tip, 24px) - 7px); width: 12px; height: 12px; background: inherit; border-left: var(--panel-border); border-top: var(--panel-border); transform: rotate(45deg); }
.say-bubble.out { opacity: 0; transform: translateY(-4px); transition: opacity .4s ease, transform .4s ease; }
@keyframes say-in { from { opacity: 0; transform: translateY(6px) scale(.96); } }
@media (prefers-reduced-motion: reduce) { .say-bubble { animation: none; } .say-bubble.out { transition: none; } }
.end-quote { margin: 0; padding: 10px 14px; border-radius: var(--radius); background: var(--chipbg); font-style: italic; display: grid; gap: 2px; }
.end-quote small { font-style: normal; color: var(--mute); font-size: 12px; }

/* fenêtre « nouvelle partie » : portrait de chaque adversaire */
.persona-face { width: 46px; height: 46px; border-radius: var(--icon-radius, 12px); object-fit: cover; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); }

/* portrait du joueur : profil, sélecteur, menu */
.me-pic { position: relative; width: 64px; height: 64px; padding: 0; border: var(--av-border); border-radius: var(--av-radius); background: var(--you); cursor: pointer; display: grid; place-items: center; color: var(--ink); }
.me-pic img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.me-initial { font-family: var(--font-title); font-size: 28px; }
.me-pic .lvl-big { position: absolute; right: -8px; bottom: -8px; width: 28px; height: 28px; font-size: 14px; box-shadow: 0 0 0 2px var(--surface); }
.me-pic .me-edit { position: absolute; left: -6px; top: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); color: var(--ink); font-size: 12px; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); }
.me-pic:hover, .me-pic:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.av-tabs { margin: 6px 0 12px; flex-wrap: wrap; }
.av-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.av-pick { aspect-ratio: 1; padding: 0; border: 2px solid transparent; border-radius: var(--av-radius); background: var(--chipbg); cursor: pointer; overflow: hidden; display: grid; place-items: center; color: var(--ink); }
.av-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-pick span { font-family: var(--font-title); font-size: 24px; }
.av-pick[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.av-pick:hover { transform: translateY(-1px); }
.nav-pic { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; display: block; }
.about-box { display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: var(--chipbg); margin-bottom: 8px; }
.about-box div { display: grid; gap: 2px; }
.about-box b { font-family: var(--font-title); font-size: 20px; }
.about-box small { color: var(--mute); font-size: 12px; }
.about-logo { width: 46px; height: 46px; border-radius: 8px; display: grid; place-items: center; background: var(--tile, #F4EBD6); color: var(--tile-ink, #2A1A10); font-family: var(--font-title); font-size: 26px; font-weight: 700; box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.about-text { margin: 4px 0 0; line-height: 1.5; }
.about-links { margin: 0; font-size: 13px; }
.home-sign { justify-self: end; margin-top: -8px; padding: 2px 4px; border: 0; background: none; color: var(--mute); font: inherit; font-size: 11.5px; font-style: italic; opacity: .75; cursor: pointer; }
.home-sign:hover, .home-sign:focus-visible { opacity: 1; text-decoration: underline; }
