/* =====================================================================
   GÉOMANCE — styles
   Direction : une carte géologique vivante. Chaque terrain a une couleur
   ET une trame de cartographe qui bouge doucement (l'eau coule, le feu
   avance, l'air respire, la terre ne bouge pas), lisible même sans
   distinguer les couleurs. Mobile d'abord, puis tablette et ordinateur.
   ===================================================================== */

:root {
  --bg: #E6E9EF;
  --surface: #F6F7FA;
  --surface-2: #EEF0F5;
  --ink: #1C2133;
  --muted: #586079;
  --line: #C6CCD8;
  --empty: #D5DAE4;
  --empty-line: #BCC3D1;

  --eau: #2C6C9C;
  --feu: #E09B12;
  --terre: #5B7833;
  --air: #A9A2DD;

  --clair: #FFFDF6;
  --clair-rim: #1C2133;
  --sombre: #262A38;
  --sombre-rim: #F2EEE2;
  --clair-edge: #D3CAB0;
  --sombre-edge: #0D1018;
  --slab: #0E111B;

  --glow: #FFC93C;
  --danger: #C23A2E;
  --success: #3E7A2E;
  --mark: #1C2133;
  --last: rgba(255, 255, 255, 0.85);
  --frame: #1C2133;
  --shadow: 0 10px 30px rgba(20, 24, 40, 0.18);

  --radius-s: 6px;
  --radius-m: 12px;
  --radius-l: 18px;
  --font: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --topbar-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141722; --surface: #1D2131; --surface-2: #232839; --ink: #ECEEF5; --muted: #9AA1B7; --line: #333A51;
    --empty: #2A2F43; --empty-line: #3A4159;
    --eau: #3A82B8; --feu: #E6A626; --terre: #6E8D3F; --air: #9B94D4;
    --clair-rim: #141722; --sombre: #0F121B; --sombre-rim: #ECEEF5; --clair-edge: #BCB398; --sombre-edge: #05070C;
    --slab: #05070C; --glow: #FFD45E; --success: #7DBB5E; --mark: #ECEEF5; --last: rgba(255, 255, 255, 0.75);
    --frame: #0B0D14; --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141722; --surface: #1D2131; --surface-2: #232839; --ink: #ECEEF5; --muted: #9AA1B7; --line: #333A51;
  --empty: #2A2F43; --empty-line: #3A4159;
  --eau: #3A82B8; --feu: #E6A626; --terre: #6E8D3F; --air: #9B94D4;
  --clair-rim: #141722; --sombre: #0F121B; --sombre-rim: #ECEEF5; --clair-edge: #BCB398; --sombre-edge: #05070C;
  --slab: #05070C; --glow: #FFD45E; --success: #7DBB5E; --mark: #ECEEF5; --last: rgba(255, 255, 255, 0.75);
  --frame: #0B0D14; --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

/* Thèmes de plateau (débloqués par les succès) */
[data-board-theme="nocturne"] { --eau: #2A5DA8; --feu: #D9773A; --terre: #4C6B4A; --air: #7F79C9; --frame: #070912; --slab: #03040A; }
[data-board-theme="mineral"] { --eau: #4B8C95; --feu: #C98F4B; --terre: #7A6A4F; --air: #B7B3C8; --frame: #2A2622; --slab: #15120F; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }

body {
  overflow-x: clip;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--eau); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 1.7rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }

/* ------------------------------------------------------------------ */
/* Tuiles de terrain (vivantes)                                        */
/* ------------------------------------------------------------------ */

.tile, .swatch, .chip { position: relative; overflow: hidden; }
.t-0 { background-color: var(--empty); }
.t-1 { background-color: var(--eau); }
.t-2 { background-color: var(--feu); }
.t-3 { background-color: var(--terre); }
.t-4 { background-color: var(--air); }

.tile::before, .swatch::before, .chip::before { content: ""; position: absolute; pointer-events: none; }
.t-0::before { inset: 0; background: linear-gradient(45deg, transparent 46%, var(--empty-line) 46% 54%, transparent 54%); }
.t-1::before { inset: -14px 0 0 0; background: repeating-linear-gradient(0deg, transparent 0 5px, rgba(255, 255, 255, 0.26) 5px 7px); }
.t-2::before {
  inset: 0 0 0 -20px;
  background: linear-gradient(135deg, rgba(110, 40, 0, 0.24) 25%, transparent 25% 50%, rgba(110, 40, 0, 0.24) 50% 75%, transparent 75%);
  background-size: 10px 10px;
}
.t-3::before { inset: 0; background: radial-gradient(rgba(20, 25, 10, 0.4) 1.3px, transparent 1.8px); background-size: 7px 7px; }
.t-4::before { inset: -20%; background: repeating-radial-gradient(circle at 50% 50%, transparent 0 4px, rgba(255, 255, 255, 0.48) 4px 5.5px); }

/* Motifs renforcés (daltonisme) */
.strong-patterns .t-1::before { background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(255, 255, 255, 0.55) 4px 7px); }
.strong-patterns .t-2::before { background: linear-gradient(135deg, rgba(60, 20, 0, 0.5) 25%, transparent 25% 50%, rgba(60, 20, 0, 0.5) 50% 75%, transparent 75%); background-size: 10px 10px; }
.strong-patterns .t-3::before { background: radial-gradient(rgba(10, 12, 5, 0.75) 1.8px, transparent 2.3px); background-size: 7px 7px; }
.strong-patterns .t-4::before { background: repeating-radial-gradient(circle at 50% 50%, transparent 0 3.5px, rgba(255, 255, 255, 0.8) 3.5px 5.5px); }

@media (prefers-reduced-motion: no-preference) {
  body:not(.calm) .t-1::before { animation: flow 3.6s linear infinite; animation-delay: var(--d, 0s); }
  body:not(.calm) .t-2::before { animation: burn 1.5s linear infinite, flicker 2.3s steps(4) infinite; animation-delay: var(--d, 0s); }
  body:not(.calm) .t-4::before { animation: breathe 3.2s ease-in-out infinite alternate; animation-delay: var(--d, 0s); }
}
@keyframes flow { to { transform: translateY(7px); } }
@keyframes burn { to { transform: translateX(10px); } }
@keyframes flicker { 0%, 100% { opacity: 1; } 50% { opacity: 0.72; } }
@keyframes breathe { from { transform: scale(0.92); } to { transform: scale(1.15); } }

.swatch { display: inline-block; width: 1.1em; height: 1.1em; border-radius: 3px; vertical-align: -0.18em; margin-inline-end: 0.4em; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }

/* ------------------------------------------------------------------ */
/* Plateau                                                             */
/* ------------------------------------------------------------------ */

.board-wrap { width: min(100%, 62vh, 620px); margin: 0 auto; perspective: 1300px; perspective-origin: 50% 0%; }

.board {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1;
  max-width: 100%;
  gap: 2px;
  padding: 2px;
  background: var(--frame);
  border-radius: 10px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transform-origin: 50% 100%;
  transition: transform 0.7s cubic-bezier(.2, .8, .2, 1), box-shadow 0.7s;
}
.board.relief { transform: rotateX(24deg); box-shadow: 0 9px 0 var(--slab), 0 30px 36px -14px rgba(0, 0, 0, 0.6); }
.board.relief .piece { filter: drop-shadow(0 4px 2px rgba(0, 0, 0, 0.45)); }
.board-wrap:has(> .board.relief) { margin-top: -5%; margin-bottom: 3%; }

.demo-board { width: min(92%, 420px); margin: 0 auto; }
.demo-board.relief { transform: rotateX(30deg); margin-top: -4%; margin-bottom: 6%; }
@media (prefers-reduced-motion: no-preference) {
  body:not(.calm) .demo-board.relief { animation: sway 16s ease-in-out infinite alternate; }
}
@keyframes sway { from { transform: rotateX(30deg) rotateZ(-4deg); } to { transform: rotateX(30deg) rotateZ(4deg); } }

.cell {
  position: relative;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: visible;
  color: inherit;
}
div.cell { cursor: default; }
.cell:focus-visible { outline: 3px solid var(--glow); outline-offset: -3px; z-index: 4; }
.cell.draggable { touch-action: none; cursor: grab; }
.cell > .tile { position: absolute; inset: 0; border-radius: 3px; z-index: 0; }

.coord { position: absolute; z-index: 2; font-size: 9px; font-weight: 700; line-height: 1; color: rgba(0, 0, 0, 0.55); pointer-events: none; }
.coord.file { right: 3px; bottom: 2px; }
.coord.rank { left: 3px; top: 2px; }
.cell:has(.t-1) .coord, .cell:has(.t-3) .coord { color: rgba(255, 255, 255, 0.85); }
.board.no-coords .coord { display: none; }

.piece { position: absolute; inset: 12%; z-index: 2; display: block; pointer-events: none; filter: drop-shadow(0 1.5px 1.5px rgba(0, 0, 0, 0.4)); }
.piece svg { width: 100%; height: 100%; display: block; overflow: visible; }
.cell.moving .piece { z-index: 6; }
.piece.eveille svg { filter: drop-shadow(0 0 3px var(--glow)); }
.cell.dragging .piece { opacity: 0.35; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.45)); }
.drag-ghost svg { width: 100%; height: 100%; display: block; }

.fx { position: absolute; inset: 0; pointer-events: none; }
.fx-under { z-index: 1; }
.fx-over { z-index: 5; overflow: visible; }

/* Marques */
.cell::after, .cell::before { content: none; position: absolute; pointer-events: none; z-index: 3; }
.cell.last > .tile { box-shadow: inset 0 0 0 3px var(--last); }
.cell.sel > .tile { box-shadow: inset 0 0 0 3px var(--mark); }
.cell.sel .piece { transform: scale(1.1); transition: transform 0.15s; }
.cell.target::after { content: ""; inset: 36%; border-radius: 50%; background: var(--mark); opacity: 0.85; box-shadow: 0 0 0 2px var(--surface); }
.cell.preview::after { content: ""; inset: 40%; border-radius: 50%; background: var(--mark); opacity: 0.35; }
.cell.capture::after { content: ""; inset: 4%; border-radius: 50%; border: 3px solid var(--danger); box-shadow: 0 0 0 2px var(--surface), inset 0 0 8px rgba(194, 58, 46, 0.6); }
.cell.drop-over > .tile { box-shadow: inset 0 0 0 4px var(--glow); }
.cell.swap-from > .tile { outline: 3px dashed var(--mark); outline-offset: -5px; }
.cell.swap-to::after { content: ""; inset: 33%; border-radius: 3px; background: var(--mark); opacity: 0.85; box-shadow: 0 0 0 2px var(--surface); }
.cell.block > .tile { box-shadow: inset 0 0 0 3px var(--glow), inset 0 0 14px rgba(255, 201, 60, 0.55); }
.cell.placeable > .tile { box-shadow: inset 0 0 0 2px var(--muted); }
.cell.danger > .tile { box-shadow: inset 0 0 0 3px var(--danger); }
.cell.danger .piece { animation: alarm 0.9s ease-in-out infinite; }
.cell.threat .piece::after { content: ""; position: absolute; inset: -8%; border-radius: 50%; border: 2px solid var(--danger); animation: pulse-ring 1.6s ease-out infinite; }
.cell.hint::before { content: ""; inset: -2px; border-radius: 6px; box-shadow: 0 0 0 3px var(--glow), 0 0 18px 2px var(--glow); animation: glow-pulse 1.1s ease-in-out infinite alternate; }
.cell.hint-to::after { content: ""; inset: 30%; border-radius: 50%; background: var(--glow); box-shadow: 0 0 12px var(--glow); }
.board.waiting .cell { cursor: default; }

@keyframes pulse-ring { from { transform: scale(0.9); opacity: 0.9; } to { transform: scale(1.25); opacity: 0; } }
@keyframes glow-pulse { from { opacity: 0.55; } to { opacity: 1; } }
@keyframes alarm { 0%, 100% { filter: drop-shadow(0 0 0 transparent); } 50% { filter: drop-shadow(0 0 7px var(--danger)); } }

/* Effets */
.ghost-tile, .ghost-piece { position: absolute; border-radius: 3px; }
.ghost-piece svg { width: 100%; height: 100%; display: block; }
.vortex-ghost { position: absolute; transform-origin: 50% 50%; }
.vortex-ghost > .tile { position: absolute; border-radius: 3px; }
.swirl {
  position: absolute;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent, var(--air) 15%, transparent 30%, var(--eau) 45%, transparent 60%, var(--feu) 75%, transparent 90%);
  -webkit-mask: radial-gradient(circle, transparent 36%, #000 40%, #000 60%, transparent 66%);
  mask: radial-gradient(circle, transparent 36%, #000 40%, #000 60%, transparent 66%);
}
.particle { position: absolute; border-radius: 50%; }
.particle.shard { border-radius: 2px; }
.particle.star { clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); border-radius: 0; }
.ripple { position: absolute; border: 3px solid; border-radius: 50%; }
.banner {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 10px 18px; border-radius: 14px; background: rgba(14, 17, 27, 0.82); color: #fff;
  font-weight: 800; font-stretch: 80%; font-variation-settings: "wdth" 80; font-size: clamp(1.3rem, 6vw, 2.3rem);
  letter-spacing: -0.01em; white-space: nowrap; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.banner.glow, .banner.win { color: var(--glow); }

/* ------------------------------------------------------------------ */
/* Barre du haut et écrans                                             */
/* ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
}
.brand { display: flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 800; font-size: 1.1rem; cursor: pointer; padding: 6px 4px; }
.brand img { border-radius: 7px; }
.top-tools { display: flex; align-items: center; gap: 4px; }
.account-chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 650; border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; min-height: 40px; max-width: 220px; }
.account-chip .avatar { width: 30px; height: 30px; }
.account-chip .avatar b { font-size: 0.85rem; }
.account-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-chip .chip-elo { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }

.screen {
  margin: 0 auto;
  padding-block: 16px max(32px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.screen.home { max-width: 1180px; }
.screen.game { max-width: 1240px; padding-top: 8px; }
.screen.page, .screen.lobby { max-width: 760px; }

/* ------------------------------------------------------------------ */
/* Accueil                                                             */
/* ------------------------------------------------------------------ */

.hero { display: grid; gap: 14px; padding: 4px 0 22px; }
.hero-text { display: grid; gap: 14px; align-content: center; }
.wordmark {
  font-size: clamp(3.4rem, 17vw, 7.5rem);
  font-weight: 800;
  font-stretch: 75%;
  font-variation-settings: "wdth" 75, "opsz" 96;
  letter-spacing: -0.035em;
  line-height: 0.88;
  background: linear-gradient(90deg, var(--eau) 0 25%, var(--feu) 25% 50%, var(--terre) 50% 75%, var(--air) 75% 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-bottom: 0.06em;
}
.tagline { margin: 0; font-size: 1.12rem; max-width: 36ch; }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 480px; }
.demo { margin: 6px 0 0; display: grid; gap: 8px; }
.demo figcaption { text-align: center; color: var(--muted); font-size: 0.85rem; min-height: 1.3em; }

.home-grid { display: grid; gap: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  padding: 18px 16px 16px;
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}
.card-online { border-color: color-mix(in srgb, var(--eau) 55%, var(--line)); box-shadow: inset 0 3px 0 var(--eau); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-desc { margin: 0; color: var(--muted); }
.card-status { margin: 0; font-weight: 650; }
.card-note { margin: 0; color: var(--muted); font-size: 0.9rem; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 25%, transparent); }

.online-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.join-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.join-form input, .modal input, .modal select, .invite-box input {
  font: inherit; min-height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); padding: 8px 12px; min-width: 0; width: 100%;
}
.join-form input { text-transform: uppercase; letter-spacing: 0.15em; font-weight: 700; }

.field { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.field legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.bot-options summary { cursor: pointer; font-weight: 650; padding: 4px 0; }
.bot-options[open] { display: grid; gap: 12px; }

.levels { display: grid; gap: 6px; }
.level {
  display: grid; grid-template-columns: 20px 40px 1fr; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-s); border: 1px solid var(--line); cursor: pointer;
}
.level input { accent-color: var(--ink); width: 18px; height: 18px; margin: 0; }
.level strong { display: block; font-weight: 700; }
.level small { color: var(--muted); display: block; line-height: 1.3; }
.level .rank { font-weight: 500; color: var(--muted); margin-inline-start: 6px; font-size: 0.88rem; }
.level:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.avatar {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 50%; overflow: hidden; flex: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line);
}
.avatar .tile { position: absolute; inset: 0; }
.avatar.all .tile { background: conic-gradient(var(--eau) 0 25%, var(--feu) 0 50%, var(--terre) 0 75%, var(--air) 0); }
.avatar.all .tile::before { content: none; }
.avatar b { position: relative; z-index: 1; font-size: 1.05rem; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--bg); border-radius: 10px; }
.segmented label { position: relative; cursor: pointer; min-width: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: grid; place-content: center; text-align: center; min-height: 44px; padding: 6px; border-radius: 7px; font-weight: 650; font-size: 0.95rem; line-height: 1.2; }
.segmented b { font-weight: 700; }
.segmented small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--muted); }
.segmented input:checked + span { background: var(--ink); color: var(--surface); }
.segmented input:checked + span small { color: inherit; opacity: 0.75; }
.segmented input:focus-visible + span { outline: 3px solid var(--eau); outline-offset: 1px; }
.segmented input:disabled + span { opacity: 0.4; cursor: not-allowed; }

.mini-ranking { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.mini-ranking li, .ranking-list li {
  display: grid; grid-template-columns: 2.2em 32px 1fr auto; align-items: center; gap: 10px;
  padding: 6px 4px; border-bottom: 1px solid var(--line); min-width: 0;
}
.mini-ranking .avatar, .ranking-list .avatar, .live-list .avatar { width: 32px; height: 32px; }
.mini-ranking .avatar b, .ranking-list .avatar b, .live-list .avatar b { font-size: 0.85rem; }
.rk { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); text-align: end; }
.rk-name { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-name small { color: var(--muted); font-weight: 500; margin-inline-start: 6px; }
.rk-score { font-variant-numeric: tabular-nums; font-weight: 700; }
.ranking-list { list-style: none; margin: 14px 0 0; padding: 0; }
.ranking-list li.me { background: color-mix(in srgb, var(--glow) 18%, transparent); border-radius: 8px; }
.empty-note { color: var(--muted); margin: 6px 0; }

.live-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.live-list li { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.live-list .vs { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 650; }
.live-list .vs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-list .meta { color: var(--muted); font-size: 0.85rem; }
.live-list.big li { padding: 12px; }

.rating { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 14px; }
.rating .elo { grid-row: span 2; font-size: 2.4rem; font-weight: 800; font-stretch: 80%; font-variation-settings: "wdth" 80; line-height: 1; font-variant-numeric: tabular-nums; }
.rating strong { font-size: 1.02rem; }
.rating span { color: var(--muted); font-size: 0.9rem; }
.league { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.league::before { content: ""; width: 12px; height: 12px; border-radius: 3px; transform: rotate(45deg); background: var(--league, var(--muted)); }
.league-sable { --league: #C9B27C; } .league-argile { --league: #B8734C; } .league-pierre { --league: #8A8F99; }
.league-cristal { --league: #6FC3DF; } .league-magma { --league: #E2552E; } .league-etoile { --league: var(--glow); }

.badges-box summary { cursor: pointer; font-weight: 650; padding: 6px 0; }
.badges { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.badge { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; padding: 10px; background: var(--bg); border-radius: 10px; min-width: 0; }
.badge .medal { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--line); color: var(--muted); font-weight: 800; }
.badge.on .medal { background: var(--glow); color: #3a2a00; }
.badge strong { display: block; font-size: 0.88rem; line-height: 1.2; }
.badge small { display: block; font-size: 0.75rem; color: var(--muted); line-height: 1.25; }
.badge:not(.on) strong { color: var(--muted); }

.learn { margin-top: 30px; display: grid; gap: 12px; }
.terrains { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.terrain-card { display: grid; grid-template-columns: 1fr; justify-items: start; gap: 10px; align-items: center; padding: 10px; background: var(--surface); border-radius: var(--radius-m); border: 1px solid var(--line); min-width: 0; }
.terrain-card h3 { font-size: 1rem; }
.terrain-card p { margin: 2px 0 0; font-size: 0.84rem; color: var(--muted); line-height: 1.3; }
.mini { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; width: 64px; height: 64px; background: var(--line); border-radius: 4px; overflow: hidden; }
.mini i { position: relative; }
.mini i:not([class*="t-"]) { background-color: var(--surface); }
.mini i.reach::after { content: ""; position: absolute; inset: 32%; border-radius: 50%; background: var(--ink); }
.mini i.origin::after { content: ""; position: absolute; inset: 16%; border-radius: 50%; background: var(--clair); box-shadow: 0 0 0 1.5px var(--clair-rim); }

.powers { display: grid; gap: 10px; }
.power { display: grid; grid-template-columns: 72px 1fr; gap: 14px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.power p { margin: 3px 0 0; font-size: 0.9rem; color: var(--muted); line-height: 1.35; }
.power-art { width: 72px; height: 72px; position: relative; }
.power-art .tile { position: absolute; border-radius: 4px; }
.swap-art .tile { top: 20px; width: 32px; height: 32px; }
.swap-art .tile:first-child { left: 2px; }
.swap-art .tile:last-child { left: 38px; }
.vortex-art { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 4px; }
.vortex-art .tile { position: relative; }
.eveil-art { display: grid; place-items: center; }
.eveil-star { width: 52px; height: 52px; border-radius: 50%; background: var(--clair); box-shadow: 0 0 0 2px var(--clair-rim), 0 0 0 5px var(--glow), 0 0 18px var(--glow); position: relative; }
.eveil-star::after { content: ""; position: absolute; inset: 20%; background: var(--glow); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); }
@media (prefers-reduced-motion: no-preference) {
  body:not(.calm) .swap-art .tile:first-child { animation: swap-a 3s ease-in-out infinite; }
  body:not(.calm) .swap-art .tile:last-child { animation: swap-b 3s ease-in-out infinite; }
  body:not(.calm) .vortex-art { animation: spin-steps 4s cubic-bezier(.6, 0, .2, 1) infinite; }
  body:not(.calm) .eveil-star { animation: glow-pulse 1.4s ease-in-out infinite alternate; }
}
@keyframes swap-a { 0%, 30% { transform: none; } 50% { transform: translate(18px, -14px) scale(1.1); } 70%, 100% { transform: translateX(36px); } }
@keyframes swap-b { 0%, 30% { transform: none; } 50% { transform: translate(-18px, 14px) scale(1.1); } 70%, 100% { transform: translateX(-36px); } }
@keyframes spin-steps { 0%, 20% { transform: rotate(0); } 45%, 70% { transform: rotate(90deg); } 95%, 100% { transform: rotate(180deg); } }

.foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; color: var(--muted); font-size: 0.9rem; }
.foot-links { display: flex; flex-wrap: wrap; gap: 0 18px; }
.foot-links .link { padding: 8px 0; color: var(--muted); }
.copyright, .install-ios { margin: 0; }
.link { font: inherit; background: none; border: 0; padding: 10px 0; text-align: start; color: var(--ink); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

/* ------------------------------------------------------------------ */
/* Boutons                                                             */
/* ------------------------------------------------------------------ */

.btn {
  font: inherit; font-weight: 650; min-height: 44px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; color: var(--ink); background: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; line-height: 1.2;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-wide { width: 100%; }
.btn-primary { background: var(--ink); color: var(--surface); font-size: 1.02rem; }
.btn-secondary { background: var(--surface); border-color: var(--line); }
.card .btn-secondary { background: var(--bg); }
.btn-ghost { padding-inline: 10px; }
.btn-danger { background: var(--danger); color: #fff; }
@media (hover: hover) {
  .btn-primary:not(:disabled):hover { filter: brightness(1.12); }
  .btn-secondary:not(:disabled):hover { border-color: var(--muted); }
  .btn-ghost:not(:disabled):hover { background: color-mix(in srgb, var(--line) 45%, transparent); }
}
.icon-btn { width: 44px; padding: 0; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .spk { fill: currentColor; }
.icon-btn[aria-pressed="true"] .cross { display: none; }
.icon-btn[aria-pressed="false"] .waves { display: none; }
.icon-btn.text-btn { width: auto; padding: 0 10px; font-weight: 800; font-size: 0.9rem; letter-spacing: 0.02em; }
.icon-btn.text-btn[aria-pressed="false"] { opacity: 0.5; }

/* ------------------------------------------------------------------ */
/* Partie                                                              */
/* ------------------------------------------------------------------ */

.game-layout { display: grid; gap: 4px; }
.game-main { display: grid; gap: 8px; align-content: start; }
.game-side { display: grid; gap: 0; align-content: start; min-width: 0; }

.player-bar {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  width: min(100%, 62vh, 620px); margin: 0 auto; min-height: 44px;
}
.player-bar .avatar { width: 36px; height: 36px; }
.player-bar .avatar b { font-size: 0.9rem; }
.pb-name { min-width: 0; line-height: 1.2; }
.pb-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-name small { color: var(--muted); font-variant-numeric: tabular-nums; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-name .presence { font-size: 0.75rem; margin-inline-start: 6px; }
.pb-name .presence.off { color: var(--danger); }
.clock {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.25rem; padding: 4px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); min-width: 4.4em; text-align: center;
}
.clock.running { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.clock.low { background: var(--danger); color: #fff; border-color: var(--danger); animation: glow-pulse 0.6s ease-in-out infinite alternate; }
.pb-info { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.game-bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; }
.bar-tools { display: flex; align-items: center; gap: 2px; }
.match { text-align: center; font-size: 0.88rem; color: var(--muted); line-height: 1.25; min-width: 0; }
.match strong { color: var(--ink); }

.opponent { display: flex; align-items: center; gap: 12px; margin: 8px 0; min-height: 48px; }
.opponent-text { display: grid; min-width: 0; line-height: 1.3; }
.bot-line { color: var(--muted); font-size: 0.92rem; }
.bot-line .dots::after { content: "…"; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; text-align: start; overflow: hidden; vertical-align: bottom; }
@keyframes dots { 0% { width: 0; } 100% { width: 1.2em; } }
.opponent.thinking .avatar { animation: think 1.2s ease-in-out infinite; }
@keyframes think { 50% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--glow); } }

.balance { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; margin-bottom: 6px; }
.balance-track { position: relative; height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.balance-track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: var(--bg); }
.balance-fill { height: 100%; width: 50%; background: var(--ink); border-radius: 5px 0 0 5px; transition: width 0.8s cubic-bezier(.2, .8, .2, 1); }
.balance-label { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 9.5em; text-align: end; }

.status { margin: 10px 0 2px; min-height: 1.6em; font-size: 1.08rem; font-weight: 700; }
.status.alert { color: var(--danger); }
.status.win { color: var(--success); }
.hint { min-height: 2.6em; margin: 2px 0 10px; font-size: 0.92rem; color: var(--muted); }

.controls { margin-bottom: 10px; display: grid; gap: 8px; }
.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile-btn {
  position: relative; font: inherit; border: 2px solid transparent; border-radius: 10px; padding: 0 0 6px;
  background: var(--surface); color: var(--ink); cursor: pointer; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); min-width: 0;
}
.tile-btn .chip { display: block; height: 34px; }
.tile-btn strong { display: block; font-size: 0.9rem; margin-top: 4px; }
.tile-btn small { display: block; font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile-btn kbd { position: absolute; top: 4px; inset-inline-end: 6px; font: inherit; font-size: 0.7rem; color: #fff; opacity: 0.8; }
.tile-btn[aria-checked="true"] { border-color: var(--ink); }
.tile-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.mode { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.mode span { font-size: 0.92rem; }
.mode small { display: inline; font-size: 0.8rem; }
.vortex-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.reactions { display: flex; gap: 6px; justify-content: space-between; margin-bottom: 10px; }
.react-btn { flex: 1; min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 1.2rem; cursor: pointer; }
.react-btn:disabled { opacity: 0.4; }
.reaction-pop {
  position: fixed; left: 50%; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px) + 12px); transform: translateX(-50%);
  z-index: 60; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; box-shadow: var(--shadow); font-weight: 650; display: flex; gap: 8px; align-items: center;
}
.reaction-pop .emo { font-size: 1.4rem; }

.scores { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; font-size: 0.85rem; }
.scores .score { min-width: 9.5em; }
.score { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; line-height: 1.25; min-width: 0; }
.score span { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.score.turn { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.game-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.special-bar { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; margin: 0 0 12px; }

.replay-bar { display: grid; gap: 10px; margin: 6px 0; }
.replay-controls { display: flex; gap: 6px; justify-content: center; }
.replay-bar input[type="range"] { width: 100%; accent-color: var(--ink); }
.rp-progress { margin: 0; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.replay-actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.analysis { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.analysis-chart { width: 100%; height: 96px; display: block; cursor: pointer; overflow: visible; }
.analysis-text { margin: 8px 0 0; font-size: 0.88rem; color: var(--muted); }

.history { margin-top: 14px; }
.history summary { cursor: pointer; font-weight: 650; padding: 8px 0; }
.history ol { margin: 0; padding: 0; padding-inline-start: 2.6em; max-height: 240px; overflow: auto; font-variant-numeric: tabular-nums; font-size: 0.9rem; columns: 2; }
.rules-link { display: block; margin-top: 6px; }

/* ------------------------------------------------------------------ */
/* Recherche, pages                                                    */
/* ------------------------------------------------------------------ */

.lobby-box { min-height: calc(100vh - var(--topbar-h) - 80px); display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; }
.lobby-desc { margin: 0; color: var(--muted); max-width: 40ch; }
.lobby-timer { margin: 0; font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.vortex-loader { width: 96px; height: 96px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.vortex-loader .tile { border-radius: 8px; }
@media (prefers-reduced-motion: no-preference) { body:not(.calm) .vortex-loader { animation: spin-steps 2.4s cubic-bezier(.6, 0, .2, 1) infinite; } }
.invite-box { display: grid; gap: 10px; width: min(100%, 420px); }
.invite-code { margin: 0; font-size: 2.6rem; font-weight: 800; letter-spacing: 0.2em; font-variant-numeric: tabular-nums; }
.invite-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.page-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.tabs { margin-bottom: 4px; }

.profile-head { display: grid; grid-template-columns: 64px 1fr; gap: 14px; align-items: center; margin-bottom: 16px; }
.profile-head .avatar { width: 64px; height: 64px; }
.profile-head .avatar b { font-size: 1.6rem; }
.profile-head h2 { font-size: 1.5rem; }
.profile-head p { margin: 2px 0 0; color: var(--muted); }
.profile-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat span { display: block; color: var(--muted); font-size: 0.82rem; }
.stat strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.rating-chart { width: 100%; height: 140px; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.section-title { margin: 20px 0 8px; font-size: 1.05rem; }
.game-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.game-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.res { font-weight: 800; font-size: 0.85rem; padding: 2px 8px; border-radius: 6px; }
.res.win { background: color-mix(in srgb, var(--success) 22%, transparent); color: var(--success); }
.res.loss { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.res.draw { background: var(--surface-2); color: var(--muted); }
.delta { font-variant-numeric: tabular-nums; font-weight: 700; }
.delta.up { color: var(--success); } .delta.down { color: var(--danger); }
.profile-actions { display: grid; gap: 8px; margin-top: 20px; }

/* ------------------------------------------------------------------ */
/* Fenêtres                                                            */
/* ------------------------------------------------------------------ */

dialog { color: var(--ink); background: var(--surface); border: 1px solid var(--line); padding: 0; }
dialog::backdrop { background: rgba(10, 12, 20, 0.6); }

.sheet { width: min(640px, 100vw); max-width: 100vw; height: min(88vh, 900px); max-height: 100vh; margin: auto auto 0; border-radius: 16px 16px 0 0; }
.sheet[open] { display: grid; grid-template-rows: auto 1fr; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.sheet-body { overflow: auto; padding: 4px 18px max(28px, env(safe-area-inset-bottom, 0px)); }

.prose h3 { margin: 22px 0 6px; }
.prose p, .prose li, .prose dd { max-width: 68ch; }
.prose ul, .prose ol { padding-inline-start: 1.2em; padding-left: unset; }
.prose li { margin: 4px 0; }
.terrain-rules dt { font-weight: 700; margin-top: 10px; }
.terrain-rules dd { margin: 2px 0 0; margin-inline-start: 1.5em; }

.modal { width: min(460px, calc(100vw - 32px)); border-radius: 18px; padding: 20px; max-height: calc(100vh - 32px); overflow: auto; }
.modal h2 { margin-bottom: 8px; font-size: 1.5rem; }
.modal p { margin: 0 0 14px; color: var(--muted); }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.modal-actions.single { grid-template-columns: 1fr; }
.modal-actions .span-2 { grid-column: 1 / -1; }
.field-label { display: block; font-weight: 650; margin: 10px 0 6px; }
.small-note { font-size: 0.85rem; }
.form-error { color: var(--danger) !important; min-height: 1.2em; margin: 8px 0 0 !important; font-weight: 600; }

.auth-buttons { display: grid; gap: 8px; margin-bottom: 12px; }
.btn-provider { width: 100%; justify-content: flex-start; border: 1px solid var(--line); background: var(--bg); }
.prov-ico { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; }
.google .prov-ico { background: #4285F4; }
.facebook .prov-ico { background: #1877F2; }
.apple .prov-ico { background: #000; }
.apple .prov-ico::before { content: ""; width: 12px; height: 14px; background: #fff; border-radius: 50% 50% 45% 45%; }

.element-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.element-pick label { cursor: pointer; display: grid; justify-items: center; gap: 4px; font-size: 0.85rem; }
.element-pick input { position: absolute; opacity: 0; pointer-events: none; }
.element-pick .chip { width: 48px; height: 48px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.element-pick input:checked + .chip { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.element-pick input:focus-visible + .chip { outline: 3px solid var(--eau); }

.settings-body { display: grid; gap: 4px; padding-top: 12px; }
.setting { display: grid; grid-template-columns: 1fr minmax(0, 1.2fr); align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.setting.column { grid-template-columns: 1fr; }
.setting.switch { grid-template-columns: 1fr auto; }
.setting input[type="range"] { width: 100%; accent-color: var(--ink); }
.setting input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--ink); }
.shortcuts { margin: 0; color: var(--muted); font-weight: 400; font-size: 0.9rem; }
.themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.theme-opt { border: 2px solid var(--line); border-radius: 12px; padding: 8px; background: var(--bg); color: var(--ink); font: inherit; cursor: pointer; display: grid; gap: 6px; text-align: center; }
.theme-opt[aria-pressed="true"] { border-color: var(--ink); }
.theme-opt:disabled { opacity: 0.5; cursor: not-allowed; }
.theme-opt .swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; height: 28px; border-radius: 6px; overflow: hidden; }
.theme-opt small { color: var(--muted); font-size: 0.72rem; line-height: 1.2; }

.end-stats { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0 0 16px; padding: 12px 14px; background: var(--bg); border-radius: 10px; font-variant-numeric: tabular-nums; }
.end-stats:empty { display: none; }
.end-stats dt { color: var(--muted); }
.end-stats dd { margin: 0; font-weight: 700; text-align: end; }
.end-rating { font-weight: 700; color: var(--ink) !important; }
.share { display: grid; gap: 8px; margin: 0 0 14px; }
.share pre { margin: 0; padding: 12px 14px; background: var(--bg); border-radius: 10px; white-space: pre-wrap; word-break: break-word; font-family: var(--font); font-size: 0.95rem; line-height: 1.45; user-select: all; }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px); transform: translateX(-50%); z-index: 80;
  display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: center; width: min(420px, calc(100vw - 32px));
  padding: 10px 14px; border-radius: 14px; background: var(--ink); color: var(--surface); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.toast.plain { grid-template-columns: 1fr; }
.toast .medal { width: 36px; height: 36px; border-radius: 50%; background: var(--glow); color: #3a2a00; display: grid; place-items: center; font-weight: 800; }
.toast small { display: block; opacity: 0.75; font-size: 0.8rem; }
.toast strong { display: block; }


/* Ajustements de l'interface v4 */
.player-bar .avatar { transition: box-shadow 0.25s; }
.player-bar.turn .avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }
.player-bar.turn .pb-name strong { color: var(--ink); }
.player-bar:not(.turn) .pb-name strong { color: color-mix(in srgb, var(--ink) 75%, var(--muted)); }
@media (hover: none) { .tile-btn kbd { display: none; } }
.live-list li > div { display: grid; gap: 4px; min-width: 0; }
.live-list .vs small, .game-list .meta { color: var(--muted); font-weight: 500; }
.game-list li { cursor: pointer; }
.ranking-list li, .mini-ranking li { cursor: pointer; }
@media (hover: hover) {
  .ranking-list li:hover, .mini-ranking li:hover, .game-list li:hover { background: color-mix(in srgb, var(--line) 35%, transparent); border-radius: 8px; }
}
.rating .elo + .league { font-size: 1.02rem; }
.lobby-box h1 { font-size: 1.6rem; }
.history li[aria-current="step"] { font-weight: 800; }
.game-side[data-mode="online"] .hint:empty, .game-side[data-mode="spectate"] .hint:empty { display: none; }

/* ------------------------------------------------------------------ */
/* Tablettes et ordinateurs                                            */
/* ------------------------------------------------------------------ */

@media (min-width: 700px) {
  .hero-actions { max-width: 420px; }
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-online { grid-row: span 2; }
    .terrains { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .terrain-card { grid-template-columns: 1fr; justify-items: start; }
  .powers { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .power { grid-template-columns: 1fr; }
  .sheet { margin: auto; border-radius: 18px; }
  .board-wrap, .player-bar { width: min(100%, 64vh, 640px); }
}

@media (min-width: 980px) {
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 32px; padding: 18px 0 36px; }
  .wordmark { font-size: clamp(4rem, 8.5vw, 7.5rem); }
  .home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .card-online { grid-column: span 1; grid-row: span 2; }
  .card-bot { grid-row: span 2; }

  .game-layout { grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
  .game-main { position: sticky; top: calc(var(--topbar-h) + 12px); }
  .board-wrap, .player-bar { width: min(100%, calc(100vh - var(--topbar-h) - 150px), 760px); }
  .game-side { padding-top: 4px; }
}


.mini-ranking li.empty-note, .ranking-list li.empty-note, .live-list li.empty-note, .game-list li.empty-note { display: block; border: 0; cursor: default; }

/* Partie sur téléphone et tablette en portrait : plateau et commandes à portée
   de pouce, sans faire défiler. Les deux colonnes deviennent une seule pile ordonnée. */
@media (max-width: 979px) {
  body[data-screen="game"] .topbar { display: none; }
  .screen.game { padding-top: max(6px, env(safe-area-inset-top, 0px)); }
  .game-layout { display: flex; flex-direction: column; gap: 6px; }
  .game-main, .game-side { display: contents; }
  .game-bar { order: 1; }
  #bar-top { order: 2; }
  .board-wrap { order: 3; }
  #bar-bottom { order: 4; }
  .status { order: 5; margin: 4px 0 0; }
  #special-bar, #build-controls, #play-controls, #replay-bar { order: 6; margin-bottom: 0; }
  .hint { order: 7; margin: 0; min-height: 0; }
  #reactions { order: 8; margin: 0; }
  .opponent { order: 9; margin: 2px 0; }
  .balance { order: 10; margin: 0; }
  .scores { order: 11; margin: 0; }
  .game-actions { order: 12; }
  .history { order: 13; margin-top: 0; }
  .rules-link { order: 14; }
  .game-bar, .game-side > * { width: min(100%, 640px); margin-left: auto; margin-right: auto; }
  .game-side > .board-wrap { width: auto; }
}
#game-settings { display: none; }
@media (max-width: 979px) { #game-settings { display: inline-flex; } }

/* Téléphone en paysage : plateau à gauche, commandes à droite */
@media (orientation: landscape) and (max-height: 560px) and (min-width: 600px) {
  .topbar { position: static; }
  .game-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 42%); gap: 16px; align-items: start; }
  .game-main, .game-side { display: grid; }
  .game-side > * { width: auto; }
  .status, .hint, #reactions, .opponent, .balance, .scores { margin: 4px 0; }
  .board-wrap, .player-bar { width: min(100%, calc(100vh - 140px)); }
  .player-bar { min-height: 36px; }
  .player-bar .avatar { width: 30px; height: 30px; }
  .pb-info { font-size: 0.75rem; }
  .board.relief { transform: rotateX(14deg); }
}

@media (max-width: 380px) {
  .terrains { grid-template-columns: 1fr; }
  .terrain-card { grid-template-columns: 64px 1fr; }
  .game-actions { grid-template-columns: 1fr 1fr; }
  .game-actions #resign { grid-column: 1 / -1; }
  .hero-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body.calm .board, body.calm .balance-fill { transition: none; }

/* Pages légales */
.legal { max-width: 760px; }
.legal h1 { font-size: clamp(1.7rem, 6vw, 2.4rem); margin: 8px 0 4px; }
.legal h2 { margin: 26px 0 8px; font-size: 1.15rem; }
.legal ol, .legal ul { padding-inline-start: 1.3em; }
.legal li { margin: 6px 0; }
.segmented.mode label > span { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: wrap; }
.segmented.mode label > span span { display: inline; min-height: 0; padding: 0; }

/* Arabe : écriture de droite à gauche. Le plateau garde son orientation
   (colonnes a à h de gauche à droite), comme un échiquier dans un livre arabe. */
html[lang="ar"] { --font: "Noto Sans Arabic", "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; }
html[lang="ar"] body { line-height: 1.65; }
html[lang="ar"] .wordmark, html[lang="ar"] .brand, html[lang="ar"] .invite-code, html[lang="ar"] .clock { font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif; }
.board, .board-wrap, .demo-board, .mini, .vortex-loader, .power-art, .analysis-chart, .rating-chart, .clock, .invite-code, #invite-link, .join-form input { direction: ltr; }
.wordmark { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .wordmark { text-align: right; }
[dir="rtl"] .join-form input { text-align: right; }
[dir="rtl"] .join-form input:not(:placeholder-shown) { text-align: left; }
[dir="rtl"] .banner { letter-spacing: 0; }
[dir="rtl"] .bot-line .dots::after { content: "…"; }
html[lang="ar"] .join-form input { letter-spacing: 0.08em; }
html[lang="ar"] .segmented small, html[lang="ar"] .tile-btn small { font-size: 0.78rem; }

/* Choix de la langue dans la barre du haut */
.lang-pick { position: relative; display: inline-flex; align-items: center; }
.lang-pick select {
  appearance: none; -webkit-appearance: none; font: inherit; font-weight: 750; font-size: 0.9rem; color: var(--ink);
  background: transparent; border: 1px solid var(--line); border-radius: 999px; min-height: 36px; padding: 4px 12px; cursor: pointer;
}
.lang-pick select:focus-visible { outline: 3px solid var(--eau); outline-offset: 2px; }
@media (max-width: 380px) { .account-chip .chip-elo { display: none; } }
.legal [lang="ar"] { font-family: "Noto Sans Arabic", var(--font); line-height: 1.7; }
.score strong { direction: ltr; unicode-bidi: isolate; display: inline-block; }
