/* Style propre à la page de menu (index.html). Le commun est dans celeste-ui.css. */

/* Le menu tient sur un écran : pas de défilement ni de sélection de texte.
   (Pas dans celeste-ui.css : les pages de jeu, elles, doivent défiler.) */
body { overflow: hidden; user-select: none; padding: 0; display: block; min-height: 0; }

/* ===== Mouvements du décor selon l'écran (et le jeu choisi) ===== */
body[data-screen="title"] #mountain { transform: scale(1); }
body[data-screen="files"] #mountain { transform: scale(1.2) translateX(-5%); }
body[data-screen="files"] #moon { transform: translate(-4vw, 2vh) scale(.9); }
/* Chaque jeu a « son » endroit sur la montagne, comme les chapitres du jeu */
body[data-screen="modes"][data-game="techs"] #mountain { transform: scale(1.5) translate(2.5%, 10.6%); }
body[data-screen="modes"][data-game="connections"] #mountain { transform: scale(2) translate(-23.5%, 47%); }
body[data-screen="modes"][data-game="celestedle"] #mountain { transform: scale(2.2) translate(-13%, 40%); }
body[data-screen="modes"] #moon { transform: translate(-8vw, 6vh) scale(.75); opacity: .7; }
body[data-screen="options"] #mountain { transform: scale(1.3) translateX(4%); }
body[data-screen="options"] #dim { opacity: .45; }
body[data-screen="options"] #moon { opacity: .4; }

/* Le drapeau du jeu choisi grandit un peu (depuis le pied de son mât) */
.game-flag, #summit-flag { transition: transform .4s var(--ease-out); transform-origin: 10% 100%; }
#summit-flag { transform-origin: 7% 96%; }
body[data-screen="modes"][data-game="techs"] .game-flag[data-game="techs"],
body[data-screen="modes"][data-game="connections"] .game-flag[data-game="connections"] { transform: scale(1.35); }
body[data-screen="modes"][data-game="celestedle"] #summit-flag { transform: scale(1.15); }

/* ===== Écrans ===== */
.screen { position: fixed; inset: 0; display: none; padding: 32px; }
body[data-screen="title"] #title,
body[data-screen="files"] #files,
body[data-screen="modes"] #modes,
body[data-screen="options"] #options { display: block; animation: fade .4s ease-out; }
body.perf .screen { animation-duration: .15s !important; }
body.perf .book { box-shadow: 0 8px 0 var(--paper-dark); }
body.perf .slot, body.perf .stub { transition: none; animation: none !important; }
/* Fondu seul (sans déplacement) : moins de travail pendant le zoom de la montagne */
@keyframes fade { from { opacity: 0; } }

/* Aide clavier en bas à droite, comme les boutons du jeu */
.hints { position: fixed; right: 24px; bottom: 18px; display: flex; gap: 18px; font-size: 15px; z-index: 5; pointer-events: none; }
.hints b { display: inline-block; min-width: 26px; padding: 2px 6px; margin-right: 6px; border-radius: 6px; background: #fff; color: #111; text-align: center; text-shadow: none; font-weight: normal; }

/* ===== Titre ===== */
#title { text-align: center; cursor: pointer; }
#title h1 { margin-top: 14vh; font-size: clamp(36px, 10.5vw, 104px); letter-spacing: 2px; }
#title .tagline { margin-top: 10px; font-size: clamp(14px, 2vw, 20px); opacity: .9; }
#title .ver { position: fixed; left: 24px; bottom: 18px; font-size: 14px; opacity: .6; }

/* Touche « C » de l'aide en bas à droite : rond blanc percé d'un C */
.press-disc {
  display: inline-block; width: 26px; height: 26px; margin-right: 8px; vertical-align: middle; border-radius: 50%; background: #fff;
  --c-mask:
    conic-gradient(from 45deg, #000 0 90deg, transparent 0),
    radial-gradient(circle closest-side, #000 30%, transparent 31% 58%, #000 59%);
  -webkit-mask: var(--c-mask);
  mask: var(--c-mask);
}
.hints .blink { display: flex; align-items: center; animation: blink 1.2s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ===== Sélection de fichier (profil) ===== */
#files h2, #options h2 { font-size: 34px; margin-bottom: 26px; }
/* Tickets dans le style de l'écran de fichiers de Celeste, tout en CSS :
   papier à encoches, contour à l'encre, scotch, talon perforé, tampons.
   Tailles en % ou en em de la largeur du ticket (--card-w). */
.slots { --card-w: min(640px, 62vw); --halo: #f1ecf7; --ink-line: #2f2b45; --mark: #2f2b45; display: flex; flex-direction: column; align-items: center; gap: calc(var(--card-w) * .05); }
.slot { position: relative; width: var(--card-w); font-size: calc(var(--card-w) / 25); transition: transform .3s var(--ease-out); cursor: pointer; }
/* Ticket choisi : il glisse à gauche et son talon sort de derrière */
/* Ticket choisi : il grossit un peu ; s'il a un talon, il glisse aussi à gauche */
.slot.selected { transform: scale(1.05); }
.slot.selected.has-stub { transform: translateX(-42%) scale(1.03); }
/* Tickets en retrait : un peu assombris (une opacité laisserait voir le décor au travers) */
.slot:not(.selected) .card { filter: brightness(.82); }
#files.open .slot { cursor: default; }
#files.open .slot.selected { animation: lift .3s var(--ease-out); }
@keyframes lift { from { translate: 0 1.2em; } }

/* Forme du papier : le contour (filter) est sur .shape, la découpe (mask)
   sur son ::before. Le filtre passe après la découpe et suit donc la forme. */
.shape { position: absolute; inset: 0; pointer-events: none;
  filter: drop-shadow(2px 0 0 var(--ink-line)) drop-shadow(-2px 0 0 var(--ink-line)) drop-shadow(0 2px 0 var(--ink-line)) drop-shadow(0 -2px 0 var(--ink-line)) drop-shadow(0 .3em .4em rgba(0,0,0,.35)); }
.shape::before { content: ""; position: absolute; inset: 0; border-radius: 3px; }

/* Les tickets restent en papier clair : c'est la référence directe à l'écran de fichiers du jeu */
.card { position: relative; z-index: 1; aspect-ratio: 800 / 300; color: #3d3a58; isolation: isolate; }
.card > * { z-index: 1; }
.card > .shape { z-index: 0; }
.card .shape::before {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255,255,255,.6), transparent 55%),
    linear-gradient(105deg, #e3e8f5 0%, #e9e4f4 45%, #f2e1eb 100%);
  -webkit-mask: radial-gradient(circle 1.05em at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat, radial-gradient(circle 1.05em at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat;
  mask: radial-gradient(circle 1.05em at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat, radial-gradient(circle 1.05em at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat; }
/* Petits traits à l'encre dans les coins, comme sur le ticket du jeu */
.card .shape::after { content: ""; position: absolute; inset: 6% 5%; opacity: .7; transform: skewX(-18deg);
  background:
    repeating-linear-gradient(90deg, var(--mark) 0 2px, transparent 2px 6px, var(--mark) 6px 7px, transparent 7px 13px) left top / 1.4em .4em no-repeat,
    repeating-linear-gradient(90deg, var(--mark) 0 1px, transparent 1px 7px, var(--mark) 7px 9px, transparent 9px 12px) right top / 1.7em .3em no-repeat,
    repeating-linear-gradient(90deg, var(--mark) 0 2px, transparent 2px 8px, var(--mark) 8px 9px, transparent 9px 14px) left bottom / 1.9em .45em no-repeat,
    repeating-linear-gradient(90deg, var(--mark) 0 1px, transparent 1px 5px, var(--mark) 5px 7px, transparent 7px 12px) right bottom / 1.3em .3em no-repeat; }

/* Ticket doré : tous les tampons gagnés, comme une sauvegarde complète du jeu.
   Papier doré, contour bronze, et un reflet qui passe de temps en temps. */
.slot.golden { --halo: #f5d97a; --ink-line: #7a5512; --mark: #7a5512; }
.slot.golden .card { color: #4a3208; }
.slot.golden .card .shape::before {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(255, 250, 220, .8), transparent 55%),
    linear-gradient(105deg, #f7dd8a 0%, #eec85a 45%, #f5d97a 70%, #dcae3c 100%);
}
.slot.golden .card .sub { color: #7a5512; }
.slot.golden .stub > .shape::before {
  background: radial-gradient(ellipse at 70% 20%, #fff6d0, transparent 60%), linear-gradient(170deg, #f8e6a8, #efd27a 60%, #f4dc8e);
}
.slot.golden .card::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 240, .75) 48%, transparent 60%) -150% 0 / 60% 100% no-repeat;
  -webkit-mask: radial-gradient(circle 1.05em at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat, radial-gradient(circle 1.05em at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat;
  mask: radial-gradient(circle 1.05em at 0 50%, #0000 97%, #000) left / 51% 100% no-repeat, radial-gradient(circle 1.05em at 100% 50%, #0000 97%, #000) right / 51% 100% no-repeat;
  animation: golden-shine 4s ease-in-out infinite;
}
@keyframes golden-shine { 0%, 60% { background-position: -150% 0; } 100% { background-position: 250% 0; } }
body.perf .slot.golden .card::after { animation: none; display: none; }
@media (prefers-reduced-motion: reduce) { .slot.golden .card::after { display: none; } }

/* Tampons (dessin SVG de js/stamps.js), un peu de travers, fondus dans le papier */
.card .stamps { position: absolute; inset: 0; }
/* Au survol, un tampon passe devant et grossit pour qu'on le lise */
.card:has(.stamp:hover) .stamps { z-index: 3; }
/* Le texte du ticket laisse passer la souris jusqu'aux tampons (sauf le champ du renommage) */
.card .body { pointer-events: none; }
.card .body input { pointer-events: auto; }
.stamp { position: absolute; aspect-ratio: 1; opacity: .95; mix-blend-mode: multiply; transition: transform .15s, opacity .15s; }
.stamp:hover { transform: scale(1.9); opacity: 1; mix-blend-mode: normal; z-index: 2; }
.stamp > span { position: absolute; inset: 0; }
.stamp-full { opacity: 0; }
.stamp:hover .stamp-small { opacity: 0; }
.stamp:hover .stamp-full { opacity: 1; }
.stamp:hover svg { background: radial-gradient(circle, #f6f2fb 66%, transparent 67%); border-radius: 50%; }
.stamp svg, .stamp-badge svg { display: block; width: 100%; height: 100%; overflow: visible; font-family: "Renogare", sans-serif; }

.card .portrait { position: absolute; left: 6.6%; top: 12%; width: 25.6%; aspect-ratio: 1; background: var(--player-color); display: grid; place-items: center; overflow: hidden; }
.card .portrait img { width: 92%; height: 92%; object-fit: contain; image-rendering: pixelated; }
.slot.empty .card .portrait img { width: 62%; height: 62%; }
/* Scotch translucide sur deux coins du portrait, bouts dentelés */
.tape { position: absolute; width: 11%; height: 7%; rotate: -34deg;
  background: linear-gradient(100deg, rgba(196,232,238,.8), rgba(165,212,224,.6) 42%, rgba(255,255,255,.85) 47%, rgba(165,212,224,.6) 53%, rgba(196,232,238,.75));
  border-block: 1px solid rgba(80,130,145,.5);
  clip-path: polygon(0 0, 100% 0, 96% 25%, 100% 50%, 96% 75%, 100% 100%, 0 100%, 4% 75%, 0 50%, 4% 25%); }
.tape.tl { left: 1.2%; top: 8%; }
.tape.br { left: 26.6%; top: 77%; }

.card .body { position: absolute; left: 35%; right: 9%; top: 8%; bottom: 8%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1em; text-align: center; }
.card .name { position: relative; z-index: 1; text-shadow: 0 0 .12em var(--halo), 0 0 .25em var(--halo), 0 0 .4em var(--halo), 0 0 .55em var(--halo); max-width: 100%; font-size: 1.75em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .sub { font-size: 1.2em; color: #6e6a8a; }
.card .sub.small { font-size: .8em; line-height: 1.3; max-width: 22em; }
.card input { font: inherit; font-size: .85em; width: 100%; max-width: 18em; margin-top: .4em; padding: .3em .5em; border: 2px solid #b8b2cc; border-radius: 6px; background: #fff; color: #2b2335; user-select: text; }

/* « 🍓 × 176 » : chiffres blancs à contour sombre */
.counter { display: inline-flex; align-items: center; gap: .1em; font-size: 1.9em; line-height: 1; color: #fff;
  text-shadow: .06em 0 var(--ink-line), -.06em 0 var(--ink-line), 0 .06em var(--ink-line), 0 -.06em var(--ink-line), .045em .045em var(--ink-line), -.045em -.045em var(--ink-line), .045em -.045em var(--ink-line), -.045em .045em var(--ink-line); }
.counter img { height: 1.2em; width: auto; margin-right: .15em; image-rendering: pixelated; }
.counter .times { font-size: .75em; }

/* Talon : papier blanc perforé à droite, derrière le ticket. Caché sous le
   ticket tant qu'il n'est pas choisi. */
.stub { position: absolute; z-index: 0; left: 94%; top: 8%; height: 84%; aspect-ratio: 840 / 300; color: #3d3a58;
  padding: 4% 6% 4% 13%; display: grid; grid-template-columns: 1fr auto; grid-template-rows: 1fr auto; align-items: start;
  transform: translateX(-90%); opacity: 0; transition: transform .3s var(--ease-out), opacity .2s; pointer-events: none; }
.slot.selected .stub { transform: none; opacity: 1; pointer-events: auto; }
.stub > .shape { filter: drop-shadow(0 .25em .35em rgba(0,0,0,.3)); }
.stub > .shape::before { border-radius: 0;
  background: radial-gradient(ellipse at 70% 20%, #fff, transparent 60%), linear-gradient(170deg, #f3f3f7, #e9e8ef 60%, #efecf2);
  -webkit-mask: linear-gradient(#000 0 0) left / calc(100% - .3em) 100% no-repeat, radial-gradient(circle .17em at 100% 50%, #0000 95%, #000) right / .3em .42em repeat-y;
  mask: linear-gradient(#000 0 0) left / calc(100% - .3em) 100% no-repeat, radial-gradient(circle .17em at 100% 50%, #0000 95%, #000) right / .3em .42em repeat-y; }
.stub > :not(.shape) { position: relative; }
.stub .gems { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 1.7em); gap: .35em 1.1em; justify-content: start; align-content: center; height: 100%; }
.stub .gem { width: 1.7em; height: 1.7em; display: grid; place-items: center;
  filter: drop-shadow(1px 0 0 var(--ink-line)) drop-shadow(-1px 0 0 var(--ink-line)) drop-shadow(0 1px 0 var(--ink-line)) drop-shadow(0 -1px 0 var(--ink-line)); }
/* Cœur de cristal : bleu en A-Side, rouge en B-Side */
.stub :is(.heart, .dot) { width: 100%; aspect-ratio: 1;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.85) 0 9%, transparent 10%), linear-gradient(160deg, var(--gem-light), var(--gem));
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-1 -2.5 26 25'%3E%3Cpath d='M12 21C5 15 0 11 0 6.2A6 6 0 0 1 12 4a6 6 0 0 1 12 2.2C24 11 19 15 12 21z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-1 -2.5 26 25'%3E%3Cpath d='M12 21C5 15 0 11 0 6.2A6 6 0 0 1 12 4a6 6 0 0 1 12 2.2C24 11 19 15 12 21z'/%3E%3C/svg%3E") center / contain no-repeat; }
/* Pas encore gagné aujourd'hui : cœur vide, pâle */
.stub .dot { background: #e4e1ec; }
.stub .gem:has(.dot) { opacity: .55; }
.stub .heart.a { --gem: #1d74d8; --gem-light: #5fb2ff; }
.stub .heart.b { --gem: #c8204e; --gem-light: #ff6b8e; }
.stub .streak { display: flex; align-items: center; gap: .3em; font-size: 1.1em; }
.stub .streak img { height: 1.3em; image-rendering: pixelated; }
.stub-bottom { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.stub-bottom .counter { font-size: 1.6em; }
.stub .best { font-size: 1.3em; color: #8a87a3; }
.stub-note { grid-column: 1 / -1; font-size: .8em; line-height: 1.3; }
.stub-note.warn { font-size: .95em; color: #a52d3e; }
.stub-note.warn strong { font-size: 1.2em; }
#files .file-actions li.danger:not(.selected) { color: #ff8a98; }
.stub .code { grid-column: 1 / -1; align-self: end; padding: .3em .5em; border-radius: 4px; background: rgba(61,58,88,.08); font-family: ui-monospace, monospace; font-size: .7em; user-select: all; word-break: break-all; }

#files .file-actions { width: min(780px, 100%); margin-top: 30px; font-size: 30px; }
#files .file-actions li { justify-content: center; }
#files .file-actions li.selected { transform: scale(1.08); }

/* ===== Sélection des modes (sélection de chapitre) ===== */
.icons { position: absolute; left: 4vw; top: 6vh; display: flex; gap: 22px; align-items: flex-end; }
.icon { width: 92px; height: 92px; padding: 0; border-radius: 14px; background: rgba(255,255,255,.12); border: 3px solid rgba(255,255,255,.35); display: grid; place-items: center;
  transition: all .25s var(--ease-out); cursor: pointer; }
.icon img { width: 80%; height: 80%; object-fit: contain; image-rendering: pixelated; }
.icon.selected { width: 132px; height: 132px; background: rgba(255,255,255,.25); border-color: #fff; transform: translateY(-6px) rotate(-3deg); box-shadow: 0 0 0 4px rgba(255,255,255,.15); }
.icon .badge { position: absolute; transform: translate(34px, -34px); font-size: 18px; }
.mode-label { position: absolute; left: 4vw; top: calc(6vh + 160px); font-size: 22px; opacity: .9; }

.book { position: absolute; right: 5vw; top: 12vh; width: min(460px, 90vw); background: var(--paper); color: var(--ink); border-radius: 8px;
  box-shadow: 0 8px 0 var(--paper-dark), 0 18px 40px rgba(0,0,0,.55); padding: 26px 28px 30px; transform: rotate(1.5deg); }
/* Le livre prend la couleur du côté choisi (A bleu, B rouge) */
.book { --tint: var(--side-a); border: 3px solid color-mix(in srgb, var(--tint) 45%, #000);
  background: linear-gradient(160deg, color-mix(in srgb, var(--tint) 14%, var(--paper)), var(--paper) 65%); }
.book:has(.climb.b) { --tint: var(--side-b); }
.book h3 { color: color-mix(in srgb, var(--tint) 45%, #fff); }
.book .chapter { font-size: 15px; letter-spacing: 3px; opacity: .6; }
.book h3 { font-size: 40px; margin: 4px 0 10px; }
.book .desc { font-size: 15px; line-height: 1.45; opacity: .85; min-height: 44px; }
.book .today { margin-top: 12px; font-size: 15px; min-height: 20px; }
.book .next { margin-top: 4px; font-size: 13px; opacity: .7; }
.book .next span { font-variant-numeric: tabular-nums; }
.book .today.won { color: #7fe08a; }
.book .today.lost { color: #ff7aa8; }
.tabs { position: absolute; top: -34px; right: 24px; display: flex; gap: 6px; }
.tab { border: none; padding: 8px 14px 14px; border-radius: 6px 6px 0 0; font-size: 15px; color: #fff; cursor: pointer; transform: translateY(6px); transition: transform .15s; }
.tab.a { background: var(--side-a); }
.tab.b { background: var(--side-b); }
.tab.active { transform: translateY(0); }
.book .record { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 20px; }
.book .record div { background: rgba(0,0,0,.25); border-radius: 6px; padding: 10px 8px; text-align: center; font-size: 13px; }
.book .record strong { display: block; font-size: 22px; margin-bottom: 2px; }
.book .record-title { grid-column: 1 / -1; background: none !important; padding: 0 !important; text-align: left !important; opacity: .6; letter-spacing: 2px; }
.climb { display: block; margin: 0 auto; font-size: 26px; border: none; padding: 10px 30px; border-radius: 6px; cursor: pointer; color: #fff; }
.climb.a { background: var(--side-a); box-shadow: 0 5px 0 #3b7bb3; }
.climb.b { background: var(--side-b); box-shadow: 0 5px 0 #a52d3e; }
.climb:active { transform: translateY(3px); box-shadow: none; }
.corner { position: absolute; left: 4vw; right: 4vw; bottom: 9vh; display: flex; flex-wrap: wrap; gap: 14px; }
.corner button { font-size: 18px; color: #fff; background: rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.4); border-radius: 8px; padding: 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.corner button img { width: 26px; height: 26px; image-rendering: pixelated; }

/* ===== Options ===== */
#options h2 { text-align: center; margin-top: 6vh; }
.menu { list-style: none; width: min(620px, 92vw); margin: 0 auto; font-size: 26px; }
.menu li { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; cursor: pointer; transition: transform .1s; }
.menu li.selected { transform: translateX(10px); }
.menu .value::before { content: "◂ "; opacity: .5; }
.menu .value::after { content: " ▸"; opacity: .5; }
.menu li.selected .value::before, .menu li.selected .value::after { opacity: 1; }
.menu li.sep { height: 18px; padding: 0; pointer-events: none; }
/* Longue liste : elle défile sur les petits écrans */
#options { overflow-y: auto; padding-bottom: 64px; scroll-padding-bottom: 64px; }

/* ===== Journal ===== */
/* ===== Journal : un carnet comme celui du jeu =====
   Papier crème ligné avec une marge, onglets marque-page sur le bord droit,
   et on tourne les pages (← →). En papier clair, comme les tickets : c'est
   une référence directe au jeu. */
.journal-wrap { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(5, 4, 20, .6); }
.journal-wrap[hidden] { display: none; }
.journal {
  --j-ink: #3a3350; --j-soft: #7d7592; --j-line: rgba(90, 120, 170, .18);
  position: relative; width: min(700px, calc(100% - 40px)); min-height: min(600px, 88vh); max-height: 88vh;
  display: flex; flex-direction: column; padding: 30px 34px 18px 58px; color: var(--j-ink); border-radius: 4px 10px 10px 4px;
  background:
    linear-gradient(90deg, transparent 40px, rgba(214, 80, 90, .45) 40px 42px, transparent 42px),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--j-line) 31px 32px),
    linear-gradient(160deg, #f6eedb, #efe4c9);
  box-shadow: -6px 0 0 #8b5a3c, -10px 0 0 #6d4530, 0 18px 40px rgba(0, 0, 0, .55);
  transform: rotate(-1deg); animation: fade .3s ease-out;
}
/* Onglets marque-page qui dépassent du bord droit */
/* La colonne ne dépasse jamais le bas du livre : sur un écran peu haut, les
   onglets se resserrent (le texte trop long est coupé par « … ») */
.journal-tabs { position: absolute; top: 24px; bottom: 16px; right: -38px; display: flex; flex-direction: column; gap: 5px; pointer-events: none; }
.journal-tab {
  flex: 0 1 auto; min-height: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; pointer-events: auto;
  width: 42px; padding: 10px 0; border: none; border-radius: 0 8px 8px 0; cursor: pointer; writing-mode: vertical-rl;
  font-size: 13px; letter-spacing: .5px; color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, .4);
  background: var(--tab, #8a7fb0); filter: brightness(.82); transform: translateX(-6px); transition: transform .15s, filter .15s;
}
.journal-tab:nth-child(1) { --tab: #d1566a; }
.journal-tab:nth-child(2) { --tab: #c79a3a; }
.journal-tab:nth-child(3) { --tab: #4f9fdc; }
.journal-tab:nth-child(4) { --tab: #e0a63a; }
.journal-tab:nth-child(5) { --tab: #5fae6a; }
.journal-tab.active, .journal-tab:hover { filter: none; transform: none; }
/* Écran peu haut : onglets plus petits */
@media (max-height: 640px) and (min-width: 701px) { .journal-tab { font-size: 11px; padding: 7px 0; letter-spacing: 0; } }
.journal-close { position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border: none; border-radius: 50%; background: rgba(58, 51, 80, .12); color: var(--j-ink); cursor: pointer; font-size: 16px; }
.journal-page { flex: 1; overflow: auto; padding-bottom: 22px;
  -webkit-mask: linear-gradient(#000 calc(100% - 26px), transparent); mask: linear-gradient(#000 calc(100% - 26px), transparent); }
.journal-page.turn { animation: page-turn .25s ease-out; }
@keyframes page-turn { from { opacity: 0; transform: translateX(14px); } }
.journal-page h3 { font-size: 30px; line-height: 32px; margin-bottom: 14px; }
.journal-foot { display: flex; justify-content: center; align-items: center; gap: 18px; margin-top: 10px; font-size: 14px; color: var(--j-soft); }
.journal-foot button { border: none; background: none; color: var(--j-ink); font-size: 20px; cursor: pointer; padding: 0 6px; }
.journal-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.journal-table th { font-size: 12px; letter-spacing: 1px; color: var(--j-soft); font-weight: normal; padding: 0 6px 8px; text-align: center; }
.journal-table th img { width: 26px; height: 26px; object-fit: contain; image-rendering: pixelated; }
.journal-table td { height: 32px; padding: 0 6px; text-align: center; }
.journal-table td:first-child, .journal-table th:first-child { text-align: left; white-space: nowrap; }
.journal-table .side { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 8px; background: var(--side-a); }
.journal-table .side.b { background: var(--side-b); }
.journal-table .game-icon { width: 30px; height: 22px; object-fit: contain; image-rendering: pixelated; vertical-align: -5px; margin-right: 6px; }
.journal-table.board td.rank { width: 44px; color: var(--j-soft); }
.journal-table.board th:nth-child(2), .journal-table.board td.who { text-align: left; }
.journal-table .who { display: flex; align-items: center; gap: 8px; height: 32px; }
.journal-table .avatar { width: 24px; height: 24px; border-radius: 5px; background: var(--player-color, #ccc); display: grid; place-items: center; flex: none; }
.journal-table .avatar img { width: 20px; height: 20px; object-fit: contain; image-rendering: pixelated; }
.journal-table tr.me td { background: rgba(255, 214, 90, .35); }
.journal-empty { color: var(--j-soft); font-style: italic; padding: 8px 0; white-space: normal !important; }
.journal-note { margin-top: 12px; font-size: 13px; line-height: 1.5; color: var(--j-soft); }
.journal-warn { color: #b0405a; }
/* Page Stamps : un tampon par achievement, encré s'il est gagné */
.stamps-count { margin: -8px 0 10px; }
.stamp-list { display: grid; gap: 4px; }
.stamp-row { display: grid; grid-template-columns: 84px 1fr 24px; align-items: center; gap: 14px; min-height: 88px; }
.stamp-badge { position: relative; width: 80px; height: 80px; opacity: .22; filter: grayscale(1); transform: rotate(-8deg); }
.stamp-row.earned .stamp-badge { opacity: .85; filter: none; }
.stamp-badge.secret { display: grid; place-items: center; border: 3px dashed currentColor; border-radius: 50%; font-size: 34px; opacity: .3; }
.stamp-text { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--j-soft); }
.stamp-text strong { font-size: 16px; color: var(--j-ink); }
.stamp-row:not(.earned) .stamp-text strong { color: var(--j-soft); }
.stamp-bar { position: relative; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.stamp-bar i { flex: 0 0 120px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #5fae6a var(--p), rgba(58, 51, 80, .15) var(--p)); }
.stamp-state { font-size: 20px; color: #3f9a4d; }

/* Page Today : choix du jeu et du côté */
.journal-picker { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.journal-picker .pick { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 4px; border: 2px solid transparent; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--j-ink); background: rgba(58, 51, 80, .08); }
.journal-picker .pick img { width: 30px; height: 22px; object-fit: contain; image-rendering: pixelated; }
.journal-picker .pick.active.a { border-color: var(--side-a); background: rgba(90, 168, 232, .18); }
.journal-picker .pick.active.b { border-color: var(--side-b); background: rgba(224, 71, 91, .15); }

/* Fenêtres de la page de jeu ouvertes dans le menu : au-dessus de tout */
.rules-modal { user-select: text; }

/* Toasts de toast.js, à la façon du menu */
.toast-notification { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 50; padding: 10px 18px; border-radius: 8px; background: rgba(0,0,0,.8); color: #fff; font-size: 16px; }

@media (max-width: 700px) {
  #title h1 { margin-top: 20vh; }
  #moon { top: 3vh; }
  .screen { padding: 18px; }
  /* Téléphone : le talon passe sous le ticket au lieu de sortir à droite */
  .slots { --card-w: 92vw; }
  .slot.selected.has-stub { transform: scale(1.03); }
  .stub { position: relative; left: auto; top: auto; height: auto; width: 92%; margin: -3% auto 0; transform: none; display: none; }
  .slot.selected .stub { display: grid; }
  .slot.has-stub { display: flex; flex-direction: column-reverse; }
  #files .file-actions { font-size: 22px; }
  .icons { gap: 10px; top: 12px; }
  .icon { width: 64px; height: 64px; }
  .icon.selected { width: 84px; height: 84px; }
  .mode-label { display: none; }
  .book { top: auto; bottom: 16vh; right: 50%; transform: translateX(50%); padding: 22px 20px 24px; }
  .book h3 { font-size: 30px; }
  .corner { bottom: 3vh; gap: 8px; }
  .corner button { font-size: 14px; padding: 6px 10px; }
  .corner button img { width: 20px; height: 20px; }
  .hints { display: none; }
  body[data-screen="title"] .hints { display: flex; left: 0; right: 0; justify-content: center; bottom: 8vh; }
  .menu { font-size: 20px; }
  /* Le livre couvre le milieu de l'écran : la caméra cadre le drapeau du jeu
     en haut à droite, à la place de la lune (cachée sur cet écran).
     Pied du mât visé : 90px du bord droit, 170px du haut. --fx / --fy : écart
     du pied au centre du dessin et sa hauteur, en vh (le dessin fait 75vh). */
  body[data-screen="modes"][data-game] #mountain { transform: scale(var(--s)) translate(calc((50vw - 90px) / var(--s) - var(--fx)), calc((170px - 100vh) / var(--s) + 100vh - var(--fy))); }
  body[data-screen="modes"][data-game="celestedle"] #mountain { --s: 1.7; --fx: 10.714vh; --fy: 52vh; }
  body[data-screen="modes"][data-game="techs"] #mountain { --s: 3; --fx: -25.714vh; --fy: 70vh; }
  body[data-screen="modes"][data-game="connections"] #mountain { --s: 2.4; --fx: 25.714vh; --fy: 44.286vh; }
  body[data-screen="modes"] #moon { opacity: 0; }
  /* Le drapeau passe derrière les réglages : décor plus sombre */
  body[data-screen="options"] #dim { opacity: .72; }
  /* Carnet sur téléphone : onglets en haut, à l'horizontale, et moins de colonnes */
  .journal { width: 100%; padding: 16px 12px 12px 40px; transform: none; }
  .journal-tabs { position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; margin: 0 34px 10px 0; }
  .journal-tab { width: auto; padding: 5px 9px; writing-mode: horizontal-tb; border-radius: 6px; font-size: 12px; transform: none; }
  .journal-page h3 { font-size: 22px; }
  .journal-table { font-size: 13px; }
  .journal-table .game-icon { display: none; }
  .journal-table:not(.board, .chapters) :is(th, td):is(:nth-child(2), :nth-child(6)) { display: none; }
  .journal-table.chapters td { white-space: nowrap; font-size: 12px; padding: 0 3px; }
  /* Livre : le chapitre tient sur deux lignes (titre et barre) */
  .book-climb { margin-top: 8px; }
  .book-climb > span:last-child { display: none; }
  .journal-table.board :is(th, td):nth-child(4) { display: none; }
}

/* ===== Carte postale (accueil, API en panne) =====
   Comme les cartes postales qui ouvrent les chapitres du jeu : papier
   clair, timbre dentelé, cachet de la poste, texte à gauche. */
.postcard-wrap { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(5, 4, 20, .7); }
.postcard-wrap[hidden] { display: none; }
.postcard {
  position: relative; width: min(680px, 100%); max-height: 92vh; overflow: auto; padding: 30px 36px 24px; color: #3a3350;
  background: linear-gradient(160deg, #f7f0de, #eee2c6); border-radius: 6px;
  box-shadow: 0 0 0 6px #fbf6ea, 0 0 0 7px rgba(58, 51, 80, .25), 0 22px 50px rgba(0, 0, 0, .6);
  transform: rotate(-1.5deg); animation: postcard-in .5s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes postcard-in { from { opacity: 0; transform: translateY(40px) rotate(-6deg) scale(.95); } }
/* Timbre : bord dentelé par un masque de petits ronds */
.postcard-stamp {
  float: right; width: 92px; height: 108px; margin: -6px -8px 10px 18px; padding: 10px; display: grid; place-items: center;
  background: #d1566a; transform: rotate(4deg);
  -webkit-mask: radial-gradient(circle 5px at 50% 50%, transparent 98%, #000) -5px -5px / 12px 12px, linear-gradient(#000 0 0) center / calc(100% - 10px) calc(100% - 10px) no-repeat;
  mask: radial-gradient(circle 5px at 50% 50%, transparent 98%, #000) -5px -5px / 12px 12px, linear-gradient(#000 0 0) center / calc(100% - 10px) calc(100% - 10px) no-repeat;
}
.postcard.down .postcard-stamp { background: #4f9fdc; }
.postcard-stamp img { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; }
/* Cachet : cercle et lignes ondulées à l'encre, par-dessus le coin du timbre */
.postcard-postmark {
  position: absolute; top: 74px; right: 92px; width: 110px; height: 56px; opacity: .35; pointer-events: none; transform: rotate(-12deg);
  background:
    radial-gradient(circle at 26px 28px, transparent 20px, #3a3350 21px 23px, transparent 24px),
    repeating-linear-gradient(180deg, transparent 0 9px, #3a3350 9px 11px) 56px 8px / 54px 40px no-repeat;
}
.postcard-text h2 { font-size: 28px; margin-bottom: 12px; color: #3a3350; }
.postcard-text p, .postcard-text li { font-size: 15px; line-height: 1.55; }
/* Note à part, plus discrète (comment la mise à jour a été faite) */
.postcard-text .postcard-note { margin-top: 12px; padding: 8px 12px; border-left: 3px solid rgba(58, 51, 80, .3); font-size: 13.5px; font-style: italic; color: #5a5370; }
.postcard-text p + p, .postcard-text ul + p { margin-top: 10px; }
.postcard-text ul { margin: 8px 0 0 18px; display: grid; gap: 4px; }
.postcard-sign { text-align: right; font-style: italic; }
.postcard-btn {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 18px; padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer;
  font-size: 17px; color: #fff; background: #3a3350;
}
.postcard-btn .press-disc { width: 20px; height: 20px; }
.postcard-btn:hover { background: #52496e; }
@media (max-width: 700px) {
  .postcard { padding: 22px 20px 18px; transform: none; }
  .postcard-stamp { width: 70px; height: 84px; }
  .postcard-stamp img { width: 48px; height: 48px; }
  .postcard-postmark { display: none; }
  .postcard-text h2 { font-size: 22px; }
}

/* ===== Écrans peu hauts (portable 1280 × 600…) : le livre se tasse pour ne
   pas passer sous l'aide clavier ===== */
@media (max-height: 700px) and (min-width: 701px) {
  .book { top: 44px; padding: 16px 24px 18px; }
  .book h3 { font-size: 32px; margin: 2px 0 6px; }
  .book .desc { font-size: 14px; line-height: 1.35; }
  .book .today { margin-top: 8px; }
  .book .record { gap: 8px; margin: 10px 0 12px; }
  .book .record div { padding: 6px 8px; }
  .climb { font-size: 22px; padding: 8px 26px; }
  .icons { top: 4vh; }
  .icon.selected { width: 108px; height: 108px; }
  .mode-label { top: calc(4vh + 130px); }
  .corner { bottom: 64px; }
  #options h2 { margin-top: 2vh; margin-bottom: 14px; }
  .menu { font-size: 22px; }
  .menu li { padding: 6px 0; }
}

/* ===== Focus clavier (Tab) : même contour jaune partout dans le menu ===== */
:is(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid var(--hl-b); outline-offset: 3px; }

/* Téléphone peu haut : icônes des jeux plus petites, pour ne pas toucher le livre */
@media (max-width: 700px) and (max-height: 760px) {
  .icons { top: 2vh; }
  .icon { width: 50px; height: 50px; }
  .icon.selected { width: 62px; height: 62px; }
  .book { bottom: 15vh; padding: 16px 18px 18px; }
  .book .record { margin: 10px 0 12px; }
}

/* ===== Tampon tout juste gagné : il s'abat sur le ticket ===== */
.stamp.fresh { animation: stamp-in .32s cubic-bezier(.3, 1.4, .5, 1) var(--stamp-delay, .25s) both; }
@keyframes stamp-in {
  0% { opacity: 0; scale: 2.6; }
  60% { opacity: 1; scale: .92; }
  100% { opacity: .95; scale: 1; }
}
body.perf .stamp.fresh { animation: none; }
@media (prefers-reduced-motion: reduce) { .stamp.fresh { animation: none; } }

/* ===== Fiche d'un autre joueur : son ticket, par-dessus le menu ===== */
#player-card { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 22px; padding: 16px; background: rgba(5, 4, 20, .72); cursor: pointer; animation: fade .2s ease-out; }
#player-card[hidden] { display: none; }
#player-card .slots { --card-w: min(520px, 50vw); }
/* Le talon sort à droite : on recentre l'ensemble ticket + talon */
#player-card .slot { margin-right: calc(var(--card-w) * .72); transform: none !important; }
.player-card-hint { font-size: 14px; opacity: .7; }
.journal-table tr.clickable { cursor: pointer; }
.journal-table tr.clickable:hover td { background: rgba(61, 58, 88, .08); }
@media (max-width: 700px) {
  #player-card .slots { --card-w: 92vw; }
  #player-card .slot { margin-right: 0; }
}

/* ===== Chapitres (js/chapters.js) =====
   Sentier en pointillé sur la montagne, sept repères, repère au chapitre
   en cours ; dans le livre, le chapitre et l'avancée vers le suivant. */
.trail { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.trail-path { fill: none; stroke: rgba(255, 255, 255, .34); stroke-width: 3; stroke-dasharray: 2 9; stroke-linecap: round; stroke-linejoin: round; }
.trail-path.walked { stroke: #ffd98a; stroke-width: 3.5; }
.trail-mark circle { fill: #24204a; stroke: rgba(255, 255, 255, .4); stroke-width: 2.5; }
.trail-mark text { font-family: "Renogare", sans-serif; font-size: 15px; fill: rgba(255, 255, 255, .6); paint-order: stroke; stroke: #16142f; stroke-width: 4px; stroke-linejoin: round; }
.trail-mark.done circle { fill: #ffd98a; stroke: #7a5512; }
.trail-mark.done text, .trail-mark.here text { fill: #ffe9bd; }
.trail-mark.here circle { fill: #ff9d4a; stroke: #fff; }
/* Repère de la carte du jeu : Madeline court dans l'épingle (10 images) */
.trail-camp { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .45)); }
.marker-frames { animation: marker-run .9s steps(10) infinite; }
@keyframes marker-run { to { transform: translateX(-3000px); } }
body.perf .marker-frames { animation: none; }
@media (prefers-reduced-motion: reduce) { .marker-frames { animation: none; } }
@media (prefers-reduced-motion: reduce) { .trail-camp { animation: none; } }

.book-climb { display: grid; gap: 4px; margin-top: 12px; font-size: 13px; }
.book-climb[hidden] { display: none; }
.book-climb strong { font-size: 15px; font-weight: normal; color: #ffd98a; }
.book-climb .bar { height: 8px; border-radius: 4px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.book-climb .bar i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #ff9d4a, #ffd98a); }
.book-climb > span:last-child { opacity: .75; }

/* Page Climb du journal : chapitres pas encore atteints estompés, chapitre en cours surligné */
.journal-table.chapters tr.ahead td { opacity: .45; }
.journal-table.chapters tr.here td { background: rgba(255, 157, 74, .16); }
.journal-table.chapters tr.here td:first-child::after { content: " ⛺"; }

/* ===== Annonce d'un nouveau chapitre ===== */
/* Carte postale : même papier que celle d'accueil, timbre à la couleur débloquée */
.chapter-postcard .postcard-stamp img { width: 70px; height: 70px; }
.chapter-kicker { font-size: 13px !important; letter-spacing: .18em; text-transform: uppercase; color: #8a7f9e; margin-bottom: 2px; }
.chapter-postcard h2 { font-size: 34px; }
.chapter-unlocks { list-style: none; margin-left: 0 !important; }
.chapter-unlocks li { display: flex; align-items: center; gap: 10px; }
.unlock-avatar { width: 34px; height: 34px; padding: 3px; overflow: hidden; background: rgba(58, 51, 80, .1); border-radius: 6px; flex: none; }
.unlock-avatar img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.unlock-swatch { width: 22px; height: 22px; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 2px #fbf6ea, 0 0 0 3px rgba(58, 51, 80, .35); }
/* Caméra : la montagne entière le temps que le repère monte */
body.chapter-cam #mountain { transform: scale(1) !important; transition-duration: 1.4s; }
/* Téléphone : le dessin (171vh de large) déborde ; on centre le trajet du
   repère (--cam-x, posé par menu.js) */
@media (max-width: 700px) { body.chapter-cam #mountain { transform: translateX(var(--cam-x, 0)) !important; } }
body.chapter-cam :is(#files, #modes, #options, .hints, .book) { opacity: 0; transition: opacity .5s; pointer-events: none; }
/* Le nouveau bout de sentier se trace, le repère le suit */
.trail-reveal { fill: none; stroke: #fff; stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: trail-reveal 1.8s .3s ease-in-out forwards; }
@keyframes trail-reveal { to { stroke-dashoffset: 0; } }
.trail-camp-move { animation: camp-move 1.8s .3s ease-in-out backwards; }
@keyframes camp-move { from { transform: translate(var(--dx), var(--dy)); } }
.trail.advancing .trail-mark.here circle { animation: mark-pop .5s 2s ease-out backwards; transform-box: fill-box; transform-origin: center; }
@keyframes mark-pop { from { transform: scale(0); } 60% { transform: scale(1.6); } }
body.perf :is(.trail-reveal, .trail-camp-move, .trail.advancing .trail-mark.here circle) { animation-duration: .01s; animation-delay: 0s; }
@media (prefers-reduced-motion: reduce) { :is(.trail-reveal, .trail-camp-move, .trail.advancing .trail-mark.here circle) { animation-duration: .01s; animation-delay: 0s; } }

/* Fiche d'un joueur : chapitre atteint, drapeau au sommet */
.card .chapter-line { display: flex; align-items: center; gap: .3em; font-size: 1em; }
.card .chapter-line.summit { color: #b7791f; }
/* Petit drapeau rouge, celui du sommet de la montagne */
.card .summit-flag { width: .8em; height: 1.1em; flex: none; background: linear-gradient(#3a3350 0 0) 0 0 / 2px 100% no-repeat, linear-gradient(#e0485e 0 0) 2px 0 / calc(100% - 2px) 55% no-repeat; }
.card .moon-mark { height: 1.2em; image-rendering: pixelated; }
.stub .stub-stamps .trophy { margin-left: .6em; white-space: nowrap; }
.stub .trophy-icon { height: 1.1em; vertical-align: -.2em; image-rendering: pixelated; }
.stub .stub-stamps { font-size: .85em; color: #8a87a3; align-self: center; }

/* Farewell, sur la Lune : repère sur le croissant, repère une fois atteint */
.moon-camp { position: absolute; left: 22%; top: 58%; width: 34%; display: grid; justify-items: center; pointer-events: none; }
.moon-camp .marker-sprite { display: none; width: 100%; aspect-ratio: 1; background: url("assets/menu/marker-run.png") 0 0 / 1000% 100% no-repeat; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .45)); animation: marker-sheet .9s steps(10) infinite; }
@keyframes marker-sheet { to { background-position: 111.111% 0; } }
body.perf .moon-camp .marker-sprite { animation: none; }
.moon-camp i { font-style: normal; font-family: "Renogare", sans-serif; font-size: clamp(11px, 1vw, 15px); color: #ffe9bd; paint-order: stroke; -webkit-text-stroke: 3px #16142f; }
.moon-camp.ahead { opacity: .45; }
.moon-camp.here .marker-sprite { display: block; }
.moon-camp.arriving .marker-sprite { animation: mark-pop .6s 2s ease-out backwards, marker-sheet .9s steps(10) infinite; }
.trail-path.to-moon { stroke-dasharray: 2 12; opacity: .7; }
/* Le repère monte jusqu'à la lune, puis la quitte pour s'y poser */
.trail-camp.leaving { animation: camp-leave .3s 2.1s forwards; }
@keyframes camp-leave { to { opacity: 0; } }


/* ===== Carte ===== */
/* La caméra recule (chapter-cam) ; noms des chapitres et fiche en bas */
.trail-name { display: none; font-family: "Renogare", sans-serif; font-size: 17px; fill: #fff; paint-order: stroke; stroke: #16142f; stroke-width: 5px; stroke-linejoin: round; }
body.map-open .trail-name { display: block; }
body.map-open .trail-mark:not(.focus) .trail-name { opacity: .55; font-size: 14px; }
.trail-mark.focus circle { r: 11; stroke: #fff; stroke-width: 3.5; }
.trail-mark.focus .trail-name { fill: #ffd98a; }
#moon.map-focus .moon-camp { opacity: 1; }
#moon.map-focus .moon-camp i { color: #ffd98a; }
.map-panel {
  position: fixed; right: 4vw; bottom: 5vh; z-index: 25; width: min(480px, calc(100% - 32px));
  display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; gap: 8px; padding: 16px 18px; color: #3a3350;
  background: linear-gradient(160deg, #f7f0de, #eee2c6); border-radius: 6px;
  box-shadow: 0 0 0 5px #fbf6ea, 0 0 0 6px rgba(58, 51, 80, .25), 0 18px 40px rgba(0, 0, 0, .55);
  animation: postcard-in .4s cubic-bezier(.2, .9, .3, 1.15);
}
.map-panel[hidden] { display: none; }
.map-panel h2 { font-size: 26px; color: #3a3350; margin-bottom: 4px; }
.map-panel p { font-size: 14px; line-height: 1.5; }
.map-stats { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.map-icon { height: 1.3em; image-rendering: pixelated; }
.map-icon + .map-icon, .map-stats .map-icon:nth-of-type(2) { margin-left: 10px; }
.map-here { color: #b45309; }
.map-reward { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.map-arrow { font-size: 34px; line-height: 1; color: #3a3350; background: none; border: none; cursor: pointer; }
.map-arrow:disabled { opacity: .2; cursor: default; }
.map-close { position: absolute; top: 4px; right: 8px; font-size: 22px; color: #3a3350; background: none; border: none; cursor: pointer; }
body.map-open .corner { opacity: 0; pointer-events: none; }
body.map-open #moon, body.chapter-cam #moon { opacity: 1 !important; }
@media (max-width: 700px) {
  .map-panel { right: 16px; bottom: 3vh; grid-template-columns: 24px 1fr 24px; padding: 14px 10px; }
  .map-panel h2 { font-size: 22px; }
}
/* Repère de la carte : image lisse (pas du pixel art), agrandie un peu */
#to-map img { image-rendering: auto; transform: scale(1.15); }
.moon-camp i { font-size: clamp(13px, 1.3vw, 18px); }

/* Le sentier, les repères et l'épingle ne se montrent que sur la carte et
   pendant l'annonce d'un chapitre (body.chapter-cam) : ailleurs, le décor seul */
.trail, .moon-camp { transition: opacity .6s; }
body:not(.chapter-cam) :is(.trail, .moon-camp) { opacity: 0; }

/* ===== Duels : fenêtre du menu ===== */
.duel-lobby { width: min(620px, 100%); transform: rotate(-.8deg); }
.duel-lobby h2 { font-size: 32px; margin-bottom: 6px; }
.duel-lobby h3 { font-size: 18px; margin: 18px 0 8px; color: #3a3350; }
.duel-lobby-intro { font-size: 14px; line-height: 1.5; }
.duel-create { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.duel-create .postcard-btn { margin: 0 0 0 auto; }
.duel-choice { display: flex; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 2px rgba(58, 51, 80, .25); }
.duel-choice button { padding: 7px 12px; border: none; background: rgba(58, 51, 80, .06); color: #3a3350; font: inherit; font-size: 14px; cursor: pointer; }
.duel-choice button[aria-pressed="true"] { background: #3a3350; color: #fff; }
.duel-rooms { list-style: none; display: grid; gap: 6px; max-height: 40vh; overflow: auto; }
.duel-room { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; background: rgba(58, 51, 80, .07); }
.duel-room .avatar { width: 34px; height: 34px; border-radius: 6px; background: var(--player-color); display: grid; place-items: center; flex: none; overflow: hidden; }
.duel-room .avatar img { width: 88%; height: 88%; object-fit: contain; image-rendering: pixelated; }
.duel-room-who { display: grid; flex: 1; min-width: 0; }
.duel-room-who small { font-size: 12px; opacity: .7; }
.duel-room .postcard-btn.small { margin: 0; padding: 6px 14px; font-size: 14px; text-decoration: none; }
.duel-empty { font-size: 14px; opacity: .7; padding: 6px 2px; }
#to-duel img { object-fit: cover; border-radius: 4px; }

/* ===== Téléphone : l'écran des jeux défile, de haut en bas =====
   Avant, chaque bloc était posé en absolu depuis le bas de l'écran : sur un
   téléphone peu haut, le haut du livre (et ses onglets A-Side / B-Side)
   sortait de l'écran, et les boutons du bas recouvraient « Climb ».
   Ici : les jeux, le livre, puis les boutons, dans une colonne qui défile.
   Aussi pour un téléphone tenu à l'horizontale (écran peu haut). */
@media (max-width: 700px), (max-height: 500px) {
  body[data-screen="modes"] #modes {
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
    padding: 14px 12px calc(24px + env(safe-area-inset-bottom));
  }
  #modes .icons { position: static; flex: none; justify-content: center; }
  /* Place pour les onglets, qui dépassent au-dessus du livre */
  #modes .book { position: relative; top: auto; right: auto; bottom: auto; transform: none; flex: none; width: 100%; max-width: 460px; margin-top: 36px; }
  #modes .tabs { right: auto; left: 50%; transform: translateX(-50%); }
  #modes .tab { white-space: nowrap; }
  #modes .corner { position: static; flex: none; justify-content: center; }
  #modes .mode-label { display: none; }
  /* Aide clavier : rien à faire sur un écran tactile, et elle couvrirait
     les boutons (sauf le « Start » de l'écran titre) */
  body:not([data-screen="title"]) .hints { display: none; }
}
@media (hover: none) and (pointer: coarse) {
  body:not([data-screen="title"]) .hints { display: none; }
}
