/* Interface « Modern » des pages de jeu (voir REDESIGN.md). Tout est rangé
   sous html.ui-modern : sans cette classe, la page reste exactement
   l'interface Classic. La classe est posée par un script dans le <head> et
   par js/interface.js (option « Modern Interface »).

   Principe : le décor du menu (ciel, lune, montagne) et, devant, un HUD
   sobre comme celui du jeu en partie : bandeaux et panneaux noirs
   translucides, sans contour coloré, textes blancs à ombre simple. Les
   seules couleurs vives sont celles du jeu (cases du tableau, A/B-Side).
   Sur les panneaux, on change les variables de style.css (--text-main,
   --bg-card…) : le contenu suit tout seul. */

html.ui-modern {
  --m-sky-top: #0b0a24;
  --m-sky-mid: #2a1a4f;
  --m-sky-low: #6a3a7a;
  --m-panel: rgba(10, 8, 26, .72);
  --m-panel-solid: #1b1730;
  --m-chip: rgba(0, 0, 0, .5);
  --m-line: rgba(255, 255, 255, .1);
  --m-text: #f1edfb;
  --m-muted: #a9a3c4;
  --m-hl-a: #84ff54;
  --m-side-a: #5aa8e8;
  --m-side-b: #e0475b;
  --m-shadow: 0 2px 0 rgba(0, 0, 0, .55);
  /* Contour « menu du jeu », réservé au titre et au menu pause */
  --m-outline-big: 3px 0 #000, -3px 0 #000, 0 3px #000, 0 -3px #000, 2px 2px #000, -2px -2px #000, 2px -2px #000, -2px 2px #000;
  /* Onglets et boutons choisis de style.css */
  --color-indigo: #5aa8e8;
  --color-indigo-hover: #4b92cf;

  /* Le fond d'écran Classic (thème Celeste compris) laisse place au décor */
  & body { background: var(--m-sky-top) !important; background-image: none !important; color: var(--m-text); }
  & body, & button, & input, & select, & textarea { font-family: "Renogare", "Segoe UI", sans-serif; }

  /* Panneau : fenêtres, suggestions, messages */
  & .rules-content, & .bug-modal-content, & .suggestions-box, & .win-message, & .lose-message, & .memorial-message, & #active-hints-container > * {
    --bg-card: var(--m-panel-solid);
    --bg-input: rgba(0, 0, 0, .35);
    --text-main: var(--m-text);
    --text-muted: var(--m-muted);
    background: var(--m-panel-solid) !important;
    color: var(--m-text) !important;
    border: 1px solid var(--m-line) !important;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .45) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ===== Décor ===== */
#modern-scene, #modern-nav, #modern-hint, #modern-pause, #modern-side { display: none; }
html.ui-modern {
  & #modern-scene {
    display: block; position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
    background: linear-gradient(180deg, var(--m-sky-top) 0%, var(--m-sky-mid) 55%, var(--m-sky-low) 100%);
  }
  & .m-stars {
    position: absolute; inset: 0; opacity: .8;
    background-image:
      radial-gradient(1px 1px at 10% 20%, #fff 50%, transparent 51%),
      radial-gradient(1px 1px at 30% 8%, #fff 50%, transparent 51%),
      radial-gradient(2px 2px at 55% 15%, #fff 50%, transparent 51%),
      radial-gradient(1px 1px at 70% 30%, #fff 50%, transparent 51%),
      radial-gradient(1px 1px at 85% 12%, #fff 50%, transparent 51%),
      radial-gradient(2px 2px at 92% 40%, #fff 50%, transparent 51%),
      radial-gradient(1px 1px at 20% 45%, #fff 50%, transparent 51%),
      radial-gradient(1px 1px at 45% 35%, #fff 50%, transparent 51%),
      radial-gradient(1px 1px at 63% 5%, #fff 50%, transparent 51%),
      radial-gradient(2px 2px at 5% 33%, #fff 50%, transparent 51%);
  }
  /* Même croissant que le menu, plus petit */
  & .m-moon {
    --size: clamp(60px, 8vw, 110px);
    --crescent: radial-gradient(circle at 72% 28%, transparent 0 50%, #000 51%);
    position: absolute; top: calc(4vh + 50px); right: 5vw; width: var(--size); aspect-ratio: 1; opacity: .85;
  }
  & .m-moon-glow, & .m-moon-body { position: absolute; inset: 0; border-radius: 50%; -webkit-mask: var(--crescent); mask: var(--crescent); }
  & .m-moon-glow { background: #d9d0ff; transform: scale(1.06); filter: blur(calc(var(--size) * .1)); opacity: .5; }
  & .m-moon-body { background: radial-gradient(circle at 35% 60%, #fff, #f4f0ff 60%, #cfc6ef); }
  /* Montagne du menu, en bas et assombrie : le jeu reste lisible devant */
  & .m-mountain {
    position: absolute; left: 50%; bottom: 0; translate: -50% 0;
    width: max(100%, calc(55vh * 1600 / 700)); aspect-ratio: 1600 / 700; opacity: .6;
  }
  & .m-mountain img { display: block; width: 100%; height: 100%; }
  /* Grand écran : la montagne est agrandie et décalée pour que le sommet et
     son drapeau sortent à droite de la colonne de jeu (mât à 450px du centre),
     au lieu de passer sous le champ de saisie et le tableau. */
  @media (min-width: 1100px) {
    & .m-mountain { --mw: max(calc((100vw + 900px) / 1.125), calc(55vh * 1600 / 700)); width: var(--mw); translate: calc(-50% + 450px - var(--mw) * .0625) 25%; }
  }
  /* Écran étroit : le sommet reste derrière le jeu, on l'estompe */
  @media (max-width: 1099px) {
    & .m-mountain { opacity: .4; }
    & .m-flag { opacity: .45; }
  }
  /* Drapeau du sommet, placé en % du dessin (x 896 → 954, y 164 → 256) */
  & .m-flag { position: absolute; left: calc(896 / 1600 * 100%); top: calc(164 / 700 * 100%); width: calc(58 / 1600 * 100%); height: calc(92 / 700 * 100%); overflow: visible; }
  & .m-cloth { fill: #e0475b; transform-box: fill-box; transform-origin: 0% 50%; animation: m-wave 1.4s ease-in-out infinite alternate; }
  & #modern-scene::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 40%, rgba(11, 10, 36, .6)); }
}

/* ===== Navigation du haut : Menu, Pause, Rules, Rankings ===== */
html.ui-modern {
  & #modern-nav { display: flex; gap: 6px; position: absolute; top: 14px; left: 16px; right: 16px; z-index: 50; }
  & #modern-nav a, & #modern-nav button {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: none; border-radius: 8px; cursor: pointer;
    background: var(--m-chip); color: var(--m-text); text-decoration: none; font-size: 15px; text-shadow: var(--m-shadow);
    transition: background .12s;
  }
  & #modern-nav a:hover, & #modern-nav button:hover, & #modern-nav a:focus-visible, & #modern-nav button:focus-visible { background: rgba(255, 255, 255, .14); }
  & #modern-nav img { width: 20px; height: 20px; object-fit: contain; image-rendering: pixelated; }
  & #modern-nav .m-gap { flex: 1; }
  & .m-pause-icon { font-size: 11px; letter-spacing: -2px; }

  /* Aide clavier en bas à droite, comme dans le menu (option Keyboard hints) */
  & #modern-hint { display: flex; align-items: center; gap: 6px; position: fixed; right: 20px; bottom: 16px; z-index: 40; font-size: 14px; color: var(--m-muted); text-shadow: var(--m-shadow); pointer-events: none; }
  & #modern-hint b { padding: 1px 6px; border-radius: 5px; background: rgba(255, 255, 255, .85); color: #111; text-shadow: none; font-weight: normal; }
  &.no-key-hints #modern-hint { display: none; }
}

/* ===== Le jeu seul : le reste vit dans le menu ===== */
html.ui-modern {
  & #left-sidebar-column, & #right-sidebar-column, & #top-actions, & #game-tabs, & .quick-links, & #site-footer { display: none !important; }
  & #layout-wrapper { display: block; }
  & #main-content-column { margin: 0 auto; padding-top: 48px; }
  & #main-content-column h1 {
    margin: 6px 0 0; font-size: clamp(2.4rem, 5.5vw, 3.8rem); letter-spacing: 2px;
    background: none; -webkit-text-fill-color: #fff; color: #fff; text-shadow: 0 4px 0 rgba(0, 0, 0, .45);
  }
  /* Côté joué, sous le titre : un point bleu (A-Side) ou rouge (B-Side) */
  & #modern-side {
    display: flex; align-items: center; justify-content: center; align-self: center; gap: 8px; margin: 0 0 14px; font-size: 14px; letter-spacing: 3px; text-transform: uppercase;
    color: var(--m-muted); text-shadow: var(--m-shadow);
  }
  & #modern-side::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--m-side-a); }
  & #modern-side[data-mode="hard"]::before { background: var(--m-side-b); }
  & .hard-rules { color: var(--m-muted); text-shadow: var(--m-shadow); }
}

/* ===== HUD : essais, temps, indices, abandon ===== */
html.ui-modern {
  & #game-status { background: none !important; border: none !important; box-shadow: none !important; }
  & #game-status button, & #game-status .tries-badge {
    background: var(--m-chip) !important; color: var(--m-text) !important;
    border: none !important; border-radius: 8px; box-shadow: none !important; text-shadow: var(--m-shadow);
    transition: background .12s;
  }
  & #game-status button:hover:not(:disabled) { background: rgba(255, 255, 255, .14) !important; }
  & #game-status button:disabled { opacity: .5; }
}

/* ===== Zone de jeu : saisie et tableau des essais ===== */
html.ui-modern {
  & #game-container { background: none !important; border-color: transparent !important; box-shadow: none !important; backdrop-filter: none !important; }

  & #element-input {
    background: var(--m-chip) !important; color: var(--m-text) !important;
    border: 2px solid var(--m-line) !important; border-radius: 10px; box-shadow: none !important;
  }
  & #element-input::placeholder { color: var(--m-muted); }
  & #element-input:focus { border-color: rgba(255, 255, 255, .35) !important; box-shadow: none !important; }
  & #guess-btn img { filter: drop-shadow(var(--m-shadow)); }
  & .suggestion-item { color: var(--m-text); border-color: var(--m-line) !important; }
  & .suggestion-item:hover, & .suggestion-item.selected { background: rgba(255, 255, 255, .08) !important; color: var(--m-text) !important; }

  /* Tableau : couleurs du jeu, sans bordure ; les cases fausses en rouge
     (rose en mode daltonien) */
  & #guesses-table th { color: var(--m-muted); text-shadow: var(--m-shadow); border-bottom-color: transparent !important; }
  & #guesses-table { border-spacing: 4px 6px; }
  & #guesses-table td { border: none !important; border-radius: 8px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
  & #guesses-table td.wrong { background: rgba(214, 48, 64, .72) !important; color: #fff !important; }
  & body.colorblind #guesses-table td.wrong { background: rgba(204, 121, 167, .6) !important; }
  /* La case du nom reste sombre : le rouge est pour les catégories */
  & #guesses-table td.wrong:first-child { background: rgba(10, 8, 26, .65) !important; color: var(--m-text) !important; }
}

/* ===== Messages, fenêtres ===== */
html.ui-modern {
  & .win-message h2, & .win-message h3, & .lose-message h2, & .lose-message h3,
  & .rules-content h2, & .rules-content h3, & .rules-content h4, & .modal-title {
    color: #fff !important; -webkit-text-fill-color: currentColor; background: none; text-shadow: none;
  }
  & .rules-modal { background: rgba(5, 4, 15, .7); backdrop-filter: none; }
  & .rules-content p, & .rules-content li, & .rules-content label, & .rules-content td, & .rules-content th { color: var(--m-text); }
  & .rules-content hr, & .options-separator { border-color: var(--m-line) !important; background: var(--m-line); }
  & .rules-content input, & .rules-content select, & .rules-content textarea {
    background: rgba(0, 0, 0, .35) !important; color: var(--m-text) !important; border: 1px solid var(--m-line) !important; border-radius: 8px;
  }
  & .close-modal-btn { color: var(--m-muted) !important; }
  & .close-modal-btn:hover { color: #fff !important; }
  /* L'option Celeste Theme ne concerne que l'interface Classic */
  & .option-classic-only, & .option-classic-only + .options-separator { display: none; }

  & .btn-primary, & .btn-secondary { border: none !important; border-radius: 8px; box-shadow: none !important; text-shadow: none; }
  & .btn-primary { background: var(--m-side-a) !important; color: #fff !important; }
  & .btn-primary:hover { background: #4b92cf !important; }
  & .btn-secondary { background: rgba(255, 255, 255, .08) !important; color: var(--m-text) !important; }
}

/* ===== Règles : des fiches par rubrique ===== */
html.ui-modern {
  & :is(#rules-modal, #cx-rules-modal) .rules-content { width: min(940px, 94vw); max-width: none; padding: 28px 30px; }
  & :is(#rules-modal, #cx-rules-modal) .rules-content-static > h2 { font-size: 1.8rem; margin-bottom: 6px; }
  & :is(#rules-modal, #cx-rules-modal) .rules-content-static > p { color: var(--m-muted); font-size: 1rem; margin-bottom: 18px; }
  /* Deux colonnes de fiches, chacune d'un bloc */
  & .m-rules-grid { columns: 2 340px; column-gap: 14px; }
  & .m-rule {
    break-inside: avoid; margin: 0 0 14px; padding: 14px 16px; border-radius: 10px;
    background: rgba(255, 255, 255, .045); border: 1px solid var(--m-line);
  }
  & .m-rule h4 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-size: 1.05rem; color: #fff; letter-spacing: 1px; text-transform: uppercase; }
  & .m-rule h4 img { width: 26px; height: 26px; object-fit: contain; image-rendering: pixelated; }
  & .m-rule p, & .m-rule li { font-size: .9rem; line-height: 1.5; color: var(--m-text); }
  & .m-rule p + p { margin-top: 8px; }
  & .m-rule ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
  & .m-rule li { position: relative; padding-left: 14px; }
  & .m-rule li::before { content: ""; position: absolute; left: 0; top: .55em; width: 5px; height: 5px; border-radius: 50%; background: var(--m-muted); }
  & .m-rule strong { color: #fff; }
  & .m-rule ul + p { margin-top: 10px; color: var(--m-muted); }
  /* Légende des couleurs : des pastilles comme les cases du tableau */
  & .m-rule .rules-color-list li { display: flex; align-items: center; gap: 8px; padding-left: 0; }
  & .m-rule .rules-color-list li::before { display: none; }
  & .m-rule .color-box { flex: none; width: 22px; height: 22px; border-radius: 6px; border: none !important; }
}

/* ===== Menu pause, façon Celeste ===== */
html.ui-modern {
  & #modern-pause:not([hidden]) {
    display: flex; flex-direction: column; justify-content: center; position: fixed; inset: 0; z-index: 3000;
    padding-left: max(8vw, 24px); background: rgba(5, 4, 15, .8); animation: m-fade .15s ease-out;
  }
  & #modern-pause h2 { font-size: clamp(28px, 4vw, 44px); margin-bottom: 18px; color: #fff; -webkit-text-fill-color: currentColor; background: none; text-shadow: var(--m-outline-big); letter-spacing: 2px; }
  & #modern-pause ul { list-style: none; padding: 0; margin: 0; }
  & #modern-pause li { width: fit-content; padding: 7px 0; font-size: clamp(22px, 3vw, 34px); cursor: pointer; color: #fff; text-shadow: var(--m-outline-big); transition: transform .1s; }
  & #modern-pause li.selected { transform: translateX(14px); animation: m-hl .25s steps(1) infinite; }
  /* Options : le réglage à gauche, sa valeur à droite, comme dans le menu */
  & #modern-pause li:has(.value) { display: flex; justify-content: space-between; gap: 24px; width: min(600px, 84vw); }
  & #modern-pause .value { white-space: nowrap; flex-shrink: 0; }
  & #modern-pause li:has(.value), & #modern-pause li:has(.value) ~ li { font-size: clamp(18px, 2.6vw, 30px); }
  & #modern-pause .value::before { content: "◂ "; opacity: .5; }
  & #modern-pause .value::after { content: " ▸"; opacity: .5; }
  & #modern-pause li.selected .value::before, & #modern-pause li.selected .value::after { opacity: 1; }
  & #modern-pause ul { max-height: 80vh; overflow-y: auto; padding-right: 20px; }
}
@keyframes m-fade { from { opacity: 0; } }
@keyframes m-wave { 0% { transform: skewY(-6deg) scaleX(1); } 100% { transform: skewY(5deg) scaleX(.86); } }
@media (prefers-reduced-motion: reduce) { html.ui-modern .m-cloth { animation: none; } }
@keyframes m-hl { 0% { color: #84ff54; } 50% { color: #fcff59; } }

@media (max-width: 700px) {
  html.ui-modern {
    & #modern-nav { top: 8px; left: 8px; right: 8px; gap: 4px; }
    & #modern-nav a, & #modern-nav button { padding: 6px 8px; font-size: 13px; }
    & #modern-nav .m-label { display: none; }
    /* Indices restants : pastille sur l'icône (le texte du bouton est caché) */
    & #hint-btn { position: relative; }
    & #hint-btn[data-left]:not(:disabled)::after { content: attr(data-left); position: absolute; top: -6px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--m-side-a); color: #fff; font-size: 12px; line-height: 18px; text-align: center; }
    & #modern-hint { display: none; }
    /* Sur téléphone, la lune gênerait les titres longs (« Connections ») */
    & .m-moon { display: none; }
    & #guesses-table { border-spacing: 3px 5px; }
    & :is(#rules-modal, #cx-rules-modal) .rules-content { padding: 22px 16px; }
  }
}

/* ===== Ciel selon l'heure (js/sky.js, <html data-sky>) =====
   Fixe les couleurs du ciel du menu (--sky-*) et des pages de jeu
   (--m-sky-*). La nuit garde les couleurs par défaut. */
html[data-sky="dawn"] { --sky-top: #232a63; --sky-mid: #8c4f8a; --sky-low: #f0a07a; --m-sky-top: #232a63; --m-sky-mid: #8c4f8a; --m-sky-low: #f0a07a; }
html[data-sky="day"] { --sky-top: #3a6db5; --sky-mid: #6f9fd8; --sky-low: #bcd3ee; --m-sky-top: #3a6db5; --m-sky-mid: #6f9fd8; --m-sky-low: #bcd3ee; }
html[data-sky="dusk"] { --sky-top: #1f1c55; --sky-mid: #7f3c76; --sky-low: #ee8a5c; --m-sky-top: #1f1c55; --m-sky-mid: #7f3c76; --m-sky-low: #ee8a5c; }
/* Étoiles : moins nombreuses à l'aube et au crépuscule, absentes le jour */
html[data-sky="dawn"] #stars, html[data-sky="dusk"] #stars { filter: opacity(.45); }
html[data-sky="dawn"] .m-stars, html[data-sky="dusk"] .m-stars { opacity: .35; }
html[data-sky="day"] :is(#stars, .m-stars, .moon-star, .snow) { display: none; }
/* Le jour, la lune reste là, pâle et sans halo */
html[data-sky="day"] :is(.moon-glow, .m-moon-glow) { display: none; }
html[data-sky="day"] :is(.moon-body, .m-moon-body) { opacity: .55; }
/* Page de jeu en journée : montagne plus opaque (sinon délavée sur le ciel
   clair) et en-têtes du tableau en blanc */
/* Ciel bleu : le drapeau bleu de Techs fonce pour rester visible */
html[data-sky="day"] .game-flag[data-game="techs"] { --flag-color: #2456c8 !important; }
html.ui-modern[data-sky="day"] .m-mountain { opacity: .9; }
html.ui-modern[data-sky="day"] #guesses-table th, html.ui-modern[data-sky="day"] #modern-side { color: #fff; }

/* ===== Connections ===== */
html.ui-modern {
  & .cx-header { align-items: center; text-align: center; }
  & .cx-header #modern-side { align-self: center; }
  /* Rules est déjà en haut de la page ; reste « Suggest a new tag » */
  & #cx-rules-btn { display: none !important; }
  & .cx-subtitle, & .cx-note { color: var(--m-muted) !important; text-shadow: var(--m-shadow); }
  & #main-content-column .action-btn, & .cx-mistakes, & .segmented {
    background: var(--m-chip) !important; color: var(--m-text) !important; border: none !important; border-radius: 8px;
    box-shadow: none !important; text-shadow: var(--m-shadow);
  }
  & #main-content-column .action-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .14) !important; }
  & .segmented button[aria-pressed="true"] { background: var(--m-side-a) !important; color: #fff !important; }
  /* Tuiles : bandeaux sombres comme le HUD ; choisies en bleu (A-Side) */
  & .cx-tile { border: 2px solid var(--m-line); border-radius: 10px; color: var(--m-text); text-shadow: var(--m-shadow); }
  & .cx-tile:not([aria-pressed="true"]) { background: rgba(10, 8, 26, .62); }
  & .cx-tile:hover { border-color: rgba(255, 255, 255, .35); }
  & .cx-tile[aria-pressed="true"] { background: var(--m-side-a); border-color: #fff; }
  & .cx-panel { background: var(--m-panel) !important; border: 1px solid var(--m-line) !important; border-radius: 12px; color: var(--m-text); }
  & .cx-panel h2 { color: #fff !important; -webkit-text-fill-color: currentColor; background: none; }
  & .cx-panel th { color: var(--m-muted) !important; border-color: var(--m-line) !important; }
  & .cx-panel td { border-color: var(--m-line) !important; }
}

/* ===== Écran de fin, façon « chapitre terminé » (interface.js) ===== */
#modern-end { display: none; }
html.ui-modern #modern-end:not([hidden]) {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 2500; padding: 16px;
  background: rgba(5, 4, 15, .78); animation: m-fade .25s ease-out;
}
html.ui-modern {
  & .m-end-card {
    position: relative; width: min(480px, 100%); padding: 26px 28px 24px; text-align: center; color: var(--m-text);
    background: var(--m-panel-solid); border: 1px solid var(--m-line); border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
    animation: m-end-rise .45s cubic-bezier(.2, .8, .2, 1);
  }
  & .m-end-kicker { font-size: 13px; letter-spacing: 3px; text-transform: uppercase; color: var(--m-muted); }
  & .m-end-emblem { width: 76px; height: 76px; margin: 10px auto 2px; display: grid; place-items: center; animation: m-end-bounce .7s .15s cubic-bezier(.3, 1.6, .5, 1) both; }
  & .m-end-emblem img { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .45)); }
  & .m-end-card.won .m-end-emblem { background: radial-gradient(circle, rgba(255, 214, 90, .35), transparent 70%); }
  & .m-end-card h2 {
    margin: 4px 0 14px; font-size: clamp(30px, 6vw, 42px); letter-spacing: 1px; color: #fff; -webkit-text-fill-color: currentColor; background: none;
    text-shadow: var(--m-outline-big);
  }
  & .m-end-card.won h2 { color: #ffd65a; }
  & .m-end-answer { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 16px; }
  & .m-end-label { font-size: 13px; color: var(--m-muted); }
  & .m-end-frame { width: 84px; height: 84px; display: grid; place-items: center; border-radius: 12px; background: rgba(255, 255, 255, .06); border: 1px solid var(--m-line); }
  & .m-end-frame img { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
  & .m-end-answer b { font-size: 20px; color: #fff; }
  /* Essais, indices, temps : ils arrivent l'un après l'autre */
  & .m-end-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
  & .m-end-stat {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 10px; background: var(--m-chip);
    animation: m-end-pop .35s calc(.35s + var(--i) * .12s) ease-out both;
  }
  & .m-end-stat img { width: 28px; height: 28px; object-fit: contain; image-rendering: pixelated; }
  & .m-end-stat strong { font-size: 24px; color: #fff; font-variant-numeric: tabular-nums; }
  & .m-end-stat span { font-size: 12px; color: var(--m-muted); }
  & .m-end-next { font-size: 13px; color: var(--m-muted); margin-bottom: 16px; }
  & .m-end-next-time { font-variant-numeric: tabular-nums; color: var(--m-text); }
  & .m-end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
  & .m-end-btn {
    padding: 9px 16px; border: none; border-radius: 9px; cursor: pointer; font: inherit; font-size: 15px; text-decoration: none;
    background: rgba(255, 255, 255, .08); color: var(--m-text);
  }
  & .m-end-btn:hover, & .m-end-btn:focus-visible { background: rgba(255, 255, 255, .16); }
  & .m-end-btn.primary { background: var(--m-side-a); color: #fff; }
  & .m-end-btn.primary:hover { background: #4b92cf; }
}
@keyframes m-end-rise { from { opacity: 0; transform: translateY(30px) scale(.96); } }
@keyframes m-end-bounce { from { opacity: 0; transform: scale(.3) translateY(20px); } }
@keyframes m-end-pop { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  html.ui-modern :is(.m-end-card, .m-end-emblem, .m-end-stat) { animation: none; }
}

/* Mode performance (option du menu, html.perf) : décor sans flou ni
   animation sur les pages de jeu */
html.ui-modern.perf .m-moon-glow { display: none; }
html.ui-modern.perf :is(.m-cloth, .m-end-card, .m-end-emblem, .m-end-stat, #modern-pause, #modern-end) { animation: none !important; }
