/* Rumiks — habillage du jeu.
 *
 * Cible principale : un iPad ajouté à l'écran d'accueil, donc sans barre d'adresse ni barre
 * d'onglets. La page occupe exactement la fenêtre, ne défile jamais dans son ensemble, et
 * réserve les marges de sécurité (encoche, indicateur de bas d'écran) avec env(safe-area-*).
 */

:root {
  --felt-center: #1e4a38;
  --felt: #14352a;
  --felt-raised: #1d4a3a;
  --felt-edge: #0d2119;
  --felt-deep: #081711;

  --rack-wood-light: #57402c;
  --rack-wood: #3e2c1e;
  --rack-wood-dark: #27190e;

  --tile-top: #fbf5e8;
  --tile-bottom: #e8dcc2;
  --tile-edge: #8c7a5c;

  --gold: #e0b252;
  --gold-bright: #f3ce7c;
  --alert: #e05c4b;
  --text: #ede7da;
  --text-dim: #cfc7b6;

  --ink-black: #23201c;
  --ink-red: #c0392b;
  --ink-blue: #1f6fa8;
  --ink-orange: #d98014;

  /* Le chevalet tenant sur deux rangées, une tuile n'a plus à se comprimer pour qu'une main de
     quatorze pièces tienne en largeur : elle se cale sur la hauteur de l'écran, avec un plancher
     qui garde une cible tactile atteignable et un plafond qui évite le gigantisme sur grand
     iPad. `--tile-base-w` reste la référence ; le chevalet la réduit s'il le faut. */
  --tile-base-w: clamp(32px, min(7.4vh, (100vw - 2.5rem) / 9), 70px);
  --tile-w: var(--tile-base-w);
  --tile-h: calc(var(--tile-w) / 0.74);
  --tile-w-board: calc(var(--tile-w) * 0.86);
  --tile-h-board: calc(var(--tile-h) * 0.86);

  --radius: 12px;
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  color: var(--text);
  background: var(--felt-deep);
  /* Empêche la loupe de sélection et le zoom par double appui pendant le jeu. */
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#app {
  position: absolute;
  inset: 0;
  /* dvh suit la hauteur réellement visible ; vh sert de repli aux navigateurs plus anciens. */
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 120% at 50% 42%, var(--felt-center) 0%, var(--felt) 48%, var(--felt-edge) 100%);
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen[hidden] {
  display: none;
}

.grow {
  flex: 1;
}

/* ------------------------------------------------------------------ tuiles */

.tile {
  position: relative;
  flex: 0 0 auto;
  width: var(--tile-w);
  height: var(--tile-h);
  border: 1px solid rgba(140, 122, 92, 0.55);
  border-radius: calc(var(--tile-w) * 0.16);
  background: linear-gradient(180deg, var(--tile-top) 0%, var(--tile-bottom) 100%);
  box-shadow: 0 3px 6px rgba(8, 23, 17, 0.55);
  /* Le chiffre et la pastille sont posés en coordonnées plutôt qu'empilés par un conteneur :
     la tuile est un élément à taille fixe, ses deux marques ont une place fixe, et le rendu ne
     dépend plus d'un calcul d'espacement. */
  display: block;
  font-weight: 800;
  font-size: calc(var(--tile-h) * 0.42);
  line-height: 1;
  transition:
    transform 0.22s var(--ease-spring),
    box-shadow 0.22s ease,
    border-color 0.2s ease;
  animation: tile-in 0.24s var(--ease-spring) both;
}

/* Reflet sur l'arête supérieure : c'est lui qui donne l'épaisseur à la tuile. */
.tile::before {
  content: '';
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 22%;
  border-radius: calc(var(--tile-w) * 0.14) calc(var(--tile-w) * 0.14) 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.tile .value {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
}

.tile .dot {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translateX(-50%);
  width: calc(var(--tile-w) * 0.17);
  height: calc(var(--tile-w) * 0.17);
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

/* La pastille suit la taille propre au plateau, plus petite que celle du chevalet. */
.tile.board .dot {
  width: calc(var(--tile-w-board) * 0.17);
  height: calc(var(--tile-w-board) * 0.17);
}

.tile.black { color: var(--ink-black); }
.tile.red { color: var(--ink-red); }
.tile.blue { color: var(--ink-blue); }
.tile.orange { color: var(--ink-orange); }

.tile.joker .value {
  font-size: calc(var(--tile-h) * 0.4);
}

.tile.selected {
  transform: translateY(-10px) scale(1.06);
  border-color: var(--gold);
  border-width: 2px;
  box-shadow: 0 10px 18px rgba(8, 23, 17, 0.7);
}

.tile.playable {
  cursor: grab;
  /* Sans cela, le navigateur interprète le geste comme un défilement et vole la tuile. */
  touch-action: none;
}

/* Une tuile qu'on soulève quitte réellement sa place : elle n'est plus là, et les voisines se
   referment, exactement comme si on l'avait prise sur la table. */
.tile.dragging {
  display: none;
}

/* La tuile portée. Elle vit hors du plateau pour n'être bornée par aucun défilement. */
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  display: flex;
  gap: 3px;
  pointer-events: none;
  filter: drop-shadow(0 14px 20px rgba(8, 23, 17, 0.7));
}

.drag-ghost .tile {
  animation: none;
  transform: scale(1.1);
  border-color: var(--gold);
  border-width: 2px;
}

/* Destination visée. */
.drop-target {
  outline: 2px dashed var(--gold-bright);
  outline-offset: 3px;
  background-color: rgba(224, 178, 82, 0.12);
}

.board.drop-target {
  outline-offset: -6px;
}

/* Repère d'insertion : un liseré doré sur la tuile voisine, qui ne décale rien. */
.tile.insert-before {
  box-shadow: -5px 0 0 -1px var(--gold-bright), 0 3px 6px rgba(8, 23, 17, 0.55);
}

.tile.insert-after {
  box-shadow: 5px 0 0 -1px var(--gold-bright), 0 3px 6px rgba(8, 23, 17, 0.55);
}

.tile.board {
  width: var(--tile-w-board);
  height: var(--tile-h-board);
  font-size: calc(var(--tile-h-board) * 0.42);
}

/* Tuiles posées par les adversaires depuis la dernière action du joueur : un halo doré pulsé
   les signale, pour qu'on voie d'un coup d'œil ce qui a changé sur la table. */
.tile.recent {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 2px rgba(243, 206, 124, 0.65), 0 3px 6px rgba(8, 23, 17, 0.55);
  animation: recent-pulse 1.1s ease-in-out 6;
}

@keyframes recent-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(243, 206, 124, 0.65), 0 3px 6px rgba(8, 23, 17, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(243, 206, 124, 0.5), 0 3px 6px rgba(8, 23, 17, 0.55); }
}

/* La tuile qui vient d'être piochée : quelques pulsations dorées le temps de la repérer dans
   le chevalet fraîchement retrié. */
.tile.drawn {
  border-color: var(--gold-bright);
  animation: drawn-pulse 1s ease-in-out 5;
}

@keyframes drawn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(243, 206, 124, 0), 0 3px 6px rgba(8, 23, 17, 0.55); }
  50% { box-shadow: 0 0 0 5px rgba(243, 206, 124, 0.5), 0 3px 6px rgba(8, 23, 17, 0.55); }
}

/* Joker récupéré sur la table : il attend dans le chevalet et doit être rejoué avant la fin
   du tour. */
.tile.must-play {
  border-color: var(--alert);
  border-width: 2px;
  animation: must-play 0.9s ease-in-out infinite alternate;
}

@keyframes must-play {
  from { box-shadow: 0 0 0 0 rgba(224, 92, 75, 0.55), 0 3px 6px rgba(8, 23, 17, 0.55); }
  to { box-shadow: 0 0 0 4px rgba(224, 92, 75, 0.25), 0 3px 6px rgba(8, 23, 17, 0.55); }
}

@keyframes tile-in {
  from { opacity: 0; transform: scale(0.86); }
  to { opacity: 1; transform: scale(1); }
}

/* ------------------------------------------------------------------ accueil */

#home {
  gap: 0.7rem;
  padding: clamp(0.5rem, 2vh, 1.4rem) clamp(0.8rem, 3vw, 2rem);
  overflow-y: auto;
  /* Le contenu est centré dans la hauteur disponible plutôt qu'étiré : sur un grand iPad, des
     cartes de deux mètres de haut feraient plus vide que généreux. */
  justify-content: center;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Le logo du jeu, fourni en 2x : arrondi pour se fondre dans le feutre. */
.brand-logo {
  display: block;
  width: min(500px, 86vw, 46vh);
  max-width: 100%;
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(8, 23, 17, 0.5);
}

/* Présent pour les lecteurs d'écran, invisible à l'écran. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.section-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--gold);
}

.home-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pills {
  display: flex;
  gap: 0.5rem;
}

.pill {
  min-width: 3rem;
  min-height: 2.75rem;
  padding: 0.6rem 1.1rem;
  border: 1px solid rgba(140, 122, 92, 0.4);
  border-radius: 11px;
  background: var(--felt-raised);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.22s var(--ease-spring), background 0.22s ease, color 0.22s ease;
}

.pill[aria-pressed='true'] {
  background: var(--gold);
  border-color: var(--gold-bright);
  color: var(--felt-deep);
  transform: scale(1.08);
  box-shadow: 0 6px 14px rgba(8, 23, 17, 0.5);
}

/* Le niveau du joueur : il remplace le choix de difficulté, la force des adversaires suivant la
   progression d'une manche gagnée à l'autre. */
.level-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1.1rem;
  border: 2px solid var(--gold);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--felt-raised), var(--felt-center));
  box-shadow: 0 10px 20px rgba(8, 23, 17, 0.55);
}

.level-card h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--gold-bright);
}

.level-card p {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--text-dim);
}

/* Barre d'expérience vers le niveau suivant. */
.xp-bar {
  height: 6px;
  margin: 0.2rem 0;
  border-radius: 3px;
  background: rgba(8, 23, 17, 0.55);
  overflow: hidden;
}

.xp-bar span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-bright));
}

/* ------------------------------------------------------------------ boutons */

.btn {
  min-height: 2.9rem;
  padding: 0.7rem 1.3rem;
  border: 1px solid rgba(140, 122, 92, 0.45);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--felt-raised), var(--felt));
  color: var(--text);
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s var(--ease-spring), filter 0.2s ease;
}

.btn:active { transform: scale(0.95); }

.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-color: var(--gold-bright);
  color: var(--felt-deep);
  box-shadow: 0 6px 16px rgba(8, 23, 17, 0.5);
}

.link {
  border: 0;
  background: none;
  color: var(--gold);
  font: inherit;
  font-weight: 700;
  padding: 0.7rem 0.5rem;
  cursor: pointer;
}

.chip-btn {
  min-height: 2.5rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid rgba(140, 122, 92, 0.3);
  border-radius: 10px;
  background: var(--felt-raised);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(8, 23, 17, 0.4);
  transition: transform 0.15s var(--ease-spring), background 0.22s ease, color 0.22s ease;
}

.chip-btn:active:not(:disabled) { transform: scale(0.93); }

.chip-btn:disabled {
  background: var(--felt-edge);
  color: rgba(207, 199, 182, 0.35);
  box-shadow: none;
  cursor: default;
}

.chip-btn.chip-primary:not(:disabled),
.chip-btn[aria-pressed='true'] {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  border-color: var(--gold-bright);
  color: var(--felt-deep);
}

/* ------------------------------------------------------------------ partie */

.players-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.6rem;
  background: linear-gradient(180deg, var(--felt-edge), var(--felt-deep));
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.players-bar::-webkit-scrollbar { display: none; }

.players {
  display: flex;
  gap: 0.4rem;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(140, 122, 92, 0.3);
  border-radius: 9px;
  font-size: 0.8rem;
  white-space: nowrap;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.player-chip.active {
  border-color: var(--gold);
  color: var(--gold-bright);
  font-weight: 800;
  animation: breathe 1.4s ease-in-out infinite alternate;
}

@keyframes breathe {
  from { background: rgba(224, 178, 82, 0.14); }
  to { background: rgba(224, 178, 82, 0.32); }
}

.player-chip .marker {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tile-edge);
}

.player-chip.opened .marker { background: var(--gold); }

.player-chip .tally {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-dim);
}

.pool {
  font-size: 0.75rem;
  color: var(--text-dim);
  white-space: nowrap;
  margin-right: 0.3rem;
}

.board {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  -webkit-overflow-scrolling: touch;
}

/* Le placement est libre : chaque combinaison vit aux coordonnées choisies par le joueur, les
   nouvelles se rangeant d'elles-mêmes dans les espaces libres. */
.board .meld {
  position: absolute;
}

/* Les enfants absolus n'étirent pas le tapis : la cale invisible lui donne sa hauteur. */
.board-sizer {
  width: 1px;
  pointer-events: none;
}

/* Tant que rien n'est posé, la consigne se place au milieu du tapis plutôt qu'en haut. */
.board.empty {
  display: flex;
  align-content: center;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
}

/* Récapitulatif des coups adverses : il survole le tapis puis s'efface. */
.ai-banner {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: min(92%, 30rem);
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--gold);
  border-radius: 11px;
  background: rgba(8, 23, 17, 0.92);
  color: var(--gold-bright);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  animation: banner-fade 7s ease forwards;
}

@keyframes banner-fade {
  0% { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  6%, 82% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; }
}

.board-empty {
  max-width: 28rem;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.meld {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px;
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(140, 122, 92, 0.35);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--felt-raised), var(--felt));
  scrollbar-width: none;
  transition: border-color 0.25s ease;
  animation: meld-in 0.26s var(--ease-spring) both;
}

.meld::-webkit-scrollbar { display: none; }

.meld.invalid {
  border: 2px solid var(--alert);
}

/* Tout le cadre d'une combinaison est une prise : on l'attrape (poignée, bordure, interstices)
   pour déplacer la série entière et organiser le tapis. Le glissement au doigt exige de retirer
   le défilement au navigateur ; les tuiles le neutralisaient déjà, le tapis se fait défiler
   depuis le feutre. */
.meld {
  cursor: grab;
  touch-action: none;
}

/* Poignée de déplacement : la prise évidente, taillée pour le doigt. */
.meld-handle {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(224, 178, 82, 0.14);
  color: rgba(224, 178, 82, 0.8);
  font-size: 1.05rem;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* La combinaison soulevée reste en place, estompée : on voit d'où elle part. */
.meld.meld-dragging {
  opacity: 0.35;
}


@keyframes meld-in {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.drop-btn {
  flex: 0 0 auto;
  width: calc(var(--tile-w-board) * 0.8);
  height: var(--tile-h-board);
  margin-left: 3px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--felt-deep);
  font: inherit;
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 7px rgba(8, 23, 17, 0.5);
  animation: tile-in 0.2s ease both;
}

.drop-btn:active { transform: scale(0.9); }

.new-meld-zone {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  min-height: calc(var(--tile-h-board) + 10px);
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  background: rgba(29, 74, 58, 0.5);
  color: var(--gold-bright);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  animation: beckon 1.2s ease-in-out infinite alternate;
}

@keyframes beckon {
  from { border-color: rgba(224, 178, 82, 0.45); }
  to { border-color: rgba(243, 206, 124, 1); }
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 1.9rem;
  padding: 0.25rem 0.8rem;
  background: linear-gradient(180deg, var(--felt-deep), var(--felt-edge));
  font-size: 0.78rem;
  color: var(--text-dim);
}

.status.warning { color: var(--alert); }

.status .spinner {
  width: 11px;
  height: 11px;
  border: 2px solid rgba(224, 178, 82, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.status .text {
  animation: status-in 0.24s ease both;
}

@keyframes status-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.actions::-webkit-scrollbar { display: none; }

/* Chevalet : deux rangées, toutes les tuiles visibles d'un coup, aucun défilement. */
.rack {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.6rem;
  background: linear-gradient(180deg, var(--rack-wood-light) 0%, var(--rack-wood) 10%, var(--rack-wood-dark) 100%);
  /* Un liseré clair marque la lèvre du chevalet, comme la baguette de bois. */
  border-top: 2px solid rgba(255, 255, 255, 0.10);
}

.rack-grid {
  /* Une main qui gonfle à force de piocher ne doit pas déborder de l'écran : les tuiles du
     chevalet rétrécissent alors juste ce qu'il faut pour que la rangée tienne. */
  --tile-w: min(
    var(--tile-base-w),
    (100vw - 2.4rem - (var(--rack-columns, 7) - 1) * 4px) / var(--rack-columns, 7)
  );
  --tile-h: calc(var(--tile-w) / 0.74);
  display: grid;
  grid-template-columns: repeat(var(--rack-columns, 7), var(--tile-w));
  gap: 4px;
  justify-content: center;
}

.rack .empty {
  padding: 1.4rem 0;
  font-size: 0.82rem;
  color: var(--tile-bottom);
}

/* ------------------------------------------------------------------ fenêtres */

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 23, 17, 0.72);
  z-index: 10;
  animation: fade-in 0.18s ease both;
}

.modal[hidden] { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: min(38rem, 100%);
  max-height: 86vh;
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1.3rem;
  border: 1px solid rgba(140, 122, 92, 0.4);
  border-radius: 18px;
  background: linear-gradient(180deg, var(--felt-raised), var(--felt));
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
  animation: card-in 0.24s var(--ease-spring) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.modal-card h2 {
  margin: 0 0 0.6rem;
  color: var(--gold-bright);
  font-size: 1.2rem;
}

.modal-body {
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.45;
}

.modal-body h3 {
  margin: 0.8rem 0 0.15rem;
  font-size: 0.85rem;
  color: var(--gold);
}

.modal-body h3:first-child { margin-top: 0; }

.modal-body p { margin: 0; color: var(--text); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding-top: 0.9rem;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0;
}

.score-row .name { flex: 1; font-weight: 700; }
.score-row.winner .name { color: var(--gold-bright); }
.score-row .left { font-size: 0.78rem; color: var(--text-dim); }
.score-row .score { font-weight: 800; min-width: 3rem; text-align: right; }
.score-row .score.positive { color: var(--gold); }
.score-row .score.negative { color: var(--alert); }

/* Détail de l'expérience gagnée, dans le bilan de fin de partie. */
.xp-summary {
  margin-top: 0.6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid rgba(224, 178, 82, 0.35);
  border-radius: 10px;
  background: rgba(8, 23, 17, 0.35);
}

.xp-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.12rem 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.xp-row.total {
  margin-top: 0.2rem;
  padding-top: 0.3rem;
  border-top: 1px solid rgba(224, 178, 82, 0.35);
  font-weight: 800;
  color: var(--gold-bright);
}

/* Annonce de montée de niveau dans le bilan de fin de partie. */
.level-up {
  margin: 0.6rem 0 0;
  font-weight: 700;
  color: var(--gold-bright);
}

/* Sur un écran vraiment étroit ou bas de plafond, on resserre plutôt que de faire défiler. */
@media (max-height: 420px) {
  :root { --tile-w: clamp(28px, min(5.6vh, (100vw - 2rem) / 15), 48px); }
  .brand-logo { width: min(360px, 80vw, 60vh); }
  .level-card p { font-size: 0.75rem; }
}

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