:root {
  --sea: #0B2239;
  --abyss: #06172A;
  --paper: #EEF2F5;
  --paper-2: #DDE5EC;
  --ink: #13293F;
  --buoy: #F2C230;
  --buoy-ink: #2A2000;
  --muted: #8FA3B8;
  --line: rgba(238, 242, 245, 0.12);
  --glass: rgba(6, 23, 42, 0.86); /* contraste AA du texte secondaire, même sur l'imagerie claire */
  --danger: #FF7A6B;

  --r-commun: #6B7C8F;
  --r-peu-commun: #2F8F6B;
  --r-rare: #2F6FD6;
  --r-epique: #8A4FD8;
  --r-legendaire: #C9971A;
  --r-mythique: #D9468F;
  --holo: conic-gradient(from var(--holo-a, 0deg), #ff8ac8, #ffd36b, #7cf0c5, #74b4ff, #c69cff, #ff8ac8);

  --serif: 'Young Serif', Georgia, serif;
  --sans: 'Schibsted Grotesk', system-ui, sans-serif;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: 2rem;
  --step-4: 2.75rem;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--abyss);
  color: var(--paper);
  font: 400 var(--step-0)/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
#sheet-body:focus { outline: none; }
:focus-visible { outline: 2px solid var(--buoy); outline-offset: 2px; }
a { color: inherit; }

/* ---------- Carte ---------- */
#map { position: fixed; inset: 0; background: var(--abyss); z-index: 0; }
.leaflet-container { background: #0A1727; font: inherit; } /* teinte de l'océan : pas de flash pendant le chargement */
#map-loading { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 30; overflow: hidden; opacity: 0; pointer-events: none; transition: opacity .3s; }
#map-loading.on { opacity: 1; transition-delay: .3s; } /* n'apparaît que si le chargement dure */
#map-loading::before {
  content: ''; position: absolute; inset: 0; width: 40%;
  background: linear-gradient(90deg, transparent, var(--buoy), transparent); animation: slide 1.1s ease-in-out infinite;
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.leaflet-control-attribution {
  background: rgba(6, 23, 42, .6) !important; color: var(--muted) !important; font-size: 10px;
}
.leaflet-control-attribution a { color: var(--paper-2) !important; }
.leaflet-control-zoom { display: none; }
/* Le fond gris Esri est teinté vers le bleu marine de la marque. */
.base-layer { filter: sepia(1) hue-rotate(175deg) saturate(1.9) brightness(.62) contrast(1.15); }
.label-layer { opacity: .7; }
/* Chiffres tabulaires seulement sur les nombres isolés : la police espace aussi la ponctuation en mode tnum. */
.meter-value b, .stat b, .ranking td.num, .stamp-value { font-variant-numeric: tabular-nums; }
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(6, 23, 42, .75) 100%);
}

/* ---------- Marque ---------- */
.brand { display: flex; align-items: center; gap: .55rem; font: 400 var(--step-1)/1 var(--serif); letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; color: var(--paper); flex: none; }
.brand-lg { font-size: var(--step-2); }
.brand-lg .brand-mark { width: 34px; height: 34px; }

.brand-btn { border: 0; background: none; color: inherit; padding: .2rem .3rem; margin: -.2rem -.3rem; border-radius: 10px; }
.brand-btn:hover { background: rgba(238, 242, 245, .06); }
.tabbar { display: none; } /* barre d'onglets : mobile uniquement */
.panel-head { display: block; width: 100%; border: 0; background: none; padding: 0; text-align: left; color: inherit; cursor: default; }
.panel-grip { display: none; }

/* ---------- Boutons ---------- */
.btn {
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.15rem; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; transition: background .15s, transform .1s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--buoy); color: var(--buoy-ink); }
.btn-primary:hover { background: #FFD24A; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--paper); }
.btn-ghost:hover { border-color: rgba(238, 242, 245, .35); }
.btn-danger { background: transparent; border-color: rgba(255, 122, 107, .45); color: var(--danger); }
.btn-danger.confirm { background: var(--danger); color: #2a0703; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Connexion ---------- */
.auth {
  position: fixed; inset: 0; z-index: 20; display: grid; align-items: center;
  padding: 24px clamp(16px, 6vw, 96px);
  background: linear-gradient(90deg, rgba(6, 23, 42, .94) 0%, rgba(6, 23, 42, .7) 46%, transparent 75%);
}
.auth-card { width: min(440px, 100%); }
.auth-title {
  font: 400 clamp(2rem, 4.6vw, 3.4rem)/1.04 var(--serif); letter-spacing: -.02em;
  margin: 2.2rem 0 1rem; text-wrap: balance;
}
.auth-lede { color: var(--paper-2); font-size: var(--step-1); line-height: 1.5; margin: 0 0 2rem; max-width: 36ch; }
.auth-tabs { display: flex; gap: .25rem; padding: 4px; border-radius: 12px; background: rgba(238, 242, 245, .06); margin-bottom: 1.1rem; }
.auth-tab { flex: 1; padding: .6rem; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; }
.auth-tab[aria-selected="true"] { background: var(--paper); color: var(--ink); }
.auth-form { display: grid; gap: .9rem; }
.field { display: grid; gap: .35rem; }
.field span { font-size: var(--step--1); color: var(--muted); font-weight: 500; }
.field input {
  padding: .8rem .9rem; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(6, 23, 42, .6); outline: none; transition: border-color .15s;
}
.field input:focus { border-color: var(--buoy); }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: var(--step--1); }
.auth-rules { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .45rem; color: var(--muted); font-size: var(--step--1); }
.auth-rules strong { color: var(--paper); font-weight: 600; }

/* ---------- Barre supérieure ---------- */
.topbar {
  position: fixed; top: 16px; left: 16px; right: 16px; z-index: 10;
  display: flex; align-items: center; gap: 1.25rem;
  padding: .55rem .6rem .55rem 1rem; border-radius: 16px;
  background: var(--glass); backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--line);
}
.nav { display: flex; gap: .2rem; margin-right: auto; }
.nav-btn {
  border: 0; background: transparent; color: var(--muted); padding: .5rem .8rem;
  border-radius: 9px; font-weight: 500; transition: color .15s, background .15s;
}
.nav-btn:hover { color: var(--paper); }
.nav-btn[aria-current="page"] { color: var(--paper); background: rgba(238, 242, 245, .09); }
.status { display: flex; align-items: center; gap: 1.1rem; }
.meter { display: grid; line-height: 1.1; text-align: right; }
.meter-value { font-size: var(--step-0); color: var(--muted); }
.meter-value b { color: var(--paper); font-weight: 600; }
.meter-label { font-size: 12px; color: var(--muted); }
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: .5rem; border: 1px solid var(--line);
  background: transparent; padding: .3rem .7rem .3rem .3rem; border-radius: 999px; font-weight: 500;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); color: var(--ink); font: 400 13px/1 var(--serif);
}
.user-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: 260px; padding: .9rem;
  background: var(--abyss); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
}
.user-pop-note { margin: 0 0 .8rem; color: var(--muted); font-size: var(--step--1); }

/* ---------- Dock de tirage ---------- */
.dock {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 10;
  display: flex; align-items: center; gap: 1rem; padding: .55rem .55rem .55rem 1.1rem;
  border-radius: 20px; background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--line);
}
.rolls { display: grid; gap: .35rem; }
.pips { display: flex; gap: 4px; }
.pip { width: 9px; height: 18px; border-radius: 3px; background: rgba(238, 242, 245, .14); transition: background .3s; }
.pip.on { background: var(--buoy); }
.rolls-text { font-size: 12px; color: var(--muted); white-space: nowrap; }
.roll-btn {
  display: grid; text-align: left; border: 0; border-radius: 14px; padding: .7rem 1.4rem .65rem;
  background: var(--buoy); color: var(--buoy-ink); min-width: 168px;
  box-shadow: 0 0 0 0 rgba(242, 194, 48, .5); transition: transform .12s, box-shadow .3s, background .15s;
}
.roll-btn:hover:not([disabled]) { background: #FFD24A; box-shadow: 0 0 0 6px rgba(242, 194, 48, .16); }
.roll-btn:active:not([disabled]) { transform: scale(.98); }
.roll-btn[disabled] { background: rgba(238, 242, 245, .12); color: var(--muted); cursor: not-allowed; }
.roll-btn-label { font: 400 var(--step-1)/1.1 var(--serif); }
.precision-btn {
  display: grid; grid-template-columns: auto 1fr; column-gap: .6rem; align-items: center; text-align: left;
  padding: .6rem 1.1rem .55rem .9rem; border-radius: 14px; border: 1.5px solid var(--buoy);
  background: rgba(242, 194, 48, .06); color: var(--paper); transition: background .15s, border-color .15s;
}
.precision-btn svg { grid-row: span 2; width: 22px; height: 22px; color: var(--buoy); }
.precision-btn:hover:not([disabled]) { background: rgba(242, 194, 48, .14); }
.precision-btn[disabled] { border-color: var(--line); background: transparent; color: var(--muted); cursor: not-allowed; }
.precision-btn[disabled] svg { color: var(--muted); }
.roll-btn-sub { font-size: 11px; font-weight: 500; opacity: .75; }

/* ---------- Sondage en cours ---------- */
.probe {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6;
  display: grid; justify-items: center; gap: .3rem; pointer-events: none; text-align: center;
}
.probe-ring {
  width: 120px; height: 120px; border-radius: 50%; border: 1.5px solid rgba(242, 194, 48, .8);
  animation: sonar 1.4s var(--ease) infinite; margin-bottom: 1rem;
}
.probe p { margin: 0; text-shadow: 0 2px 12px rgba(0, 0, 0, .8); }
.probe-coords { color: var(--muted); font-size: var(--step--1); }
@keyframes sonar {
  0% { transform: scale(.3); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ---------- Scène de résultat ---------- */
.stage {
  position: fixed; right: 32px; top: 50%; transform: translateY(-46%); z-index: 9;
  width: 340px; display: grid; gap: 1rem; justify-items: center;
}
.stage.reveal .stamp-wrap { animation: print .9s var(--ease) both; }
.stage.reveal .stage-actions, .stage.reveal .stage-timer { animation: fadein .4s .55s both; }
@keyframes print {
  0% { transform: translateY(40px) rotate(-6deg) scale(.85); opacity: 0; filter: blur(6px); }
  60% { transform: translateY(-4px) rotate(1.5deg) scale(1.02); opacity: 1; filter: blur(0); }
  100% { transform: none; }
}
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
#stage-card { width: 100%; }
.stage-actions { display: flex; gap: .6rem; width: 100%; }
.stage-actions .btn { flex: 1; }
.stage-timer {
  margin: 0; padding: .4rem .8rem; border-radius: 999px; background: var(--glass); backdrop-filter: blur(10px);
  color: var(--paper-2); font-size: var(--step--1);
}
.stage-timer:empty { display: none; }
.stage-timer.urgent { color: var(--danger); }
.stage-note {
  margin: 0; padding: .35rem .8rem; border-radius: 999px; background: var(--glass); backdrop-filter: blur(10px);
  color: var(--buoy); font-size: var(--step--1); font-weight: 600;
}
.free-slot { margin: 0; color: var(--paper); text-decoration: underline; text-underline-offset: 3px; }
.stage.stamped .postmark { animation: cancel .55s .25s var(--ease) both; }
@keyframes cancel {
  0% { transform: rotate(-30deg) scale(1.6); opacity: 0; }
  60% { transform: rotate(-12deg) scale(.94); opacity: 1; color: #B8860B; }
  100% { transform: rotate(-14deg) scale(1); }
}
.stage .btn-ghost { background: var(--glass); backdrop-filter: blur(10px); }
.stage-owned { margin: 0; text-align: center; color: var(--paper-2); }

/* ---------- Timbre ---------- */
.stamp-wrap {
  --ink-c: var(--r-commun);
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45)) drop-shadow(0 2px 3px rgba(0, 0, 0, .3));
  width: 100%; position: relative;
}
.r-commun { --ink-c: var(--r-commun); }
.r-peu-commun { --ink-c: var(--r-peu-commun); }
.r-rare { --ink-c: var(--r-rare); }
.r-epique { --ink-c: var(--r-epique); }
.r-legendaire { --ink-c: var(--r-legendaire); }
.r-mythique { --ink-c: var(--r-mythique); }
.stamp {
  --perf-r: 5px; --perf-g: 15px;
  position: relative; background: var(--paper); color: var(--ink); padding: 12px;
  -webkit-mask:
    linear-gradient(#000 0 0) center / calc(100% - 2 * var(--perf-r)) calc(100% - 2 * var(--perf-r)) no-repeat,
    radial-gradient(var(--perf-r) at var(--perf-r) var(--perf-r), #0000 97%, #000) calc(-1 * var(--perf-r)) calc(-1 * var(--perf-r)) / var(--perf-g) var(--perf-g) round;
  mask:
    linear-gradient(#000 0 0) center / calc(100% - 2 * var(--perf-r)) calc(100% - 2 * var(--perf-r)) no-repeat,
    radial-gradient(var(--perf-r) at var(--perf-r) var(--perf-r), #0000 97%, #000) calc(-1 * var(--perf-r)) calc(-1 * var(--perf-r)) / var(--perf-g) var(--perf-g) round;
}
.stamp-frame {
  position: relative; border: 2px solid var(--ink-c); padding: 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px;
  background: linear-gradient(var(--paper), var(--paper)) padding-box;
}
.r-mythique .stamp-frame { border-color: transparent; background: linear-gradient(var(--paper), var(--paper)) padding-box, var(--holo) border-box; animation: holo 6s linear infinite; }
.r-legendaire .stamp { background: linear-gradient(135deg, #F6EFD9, var(--paper) 40%, #F3E7C2 70%, var(--paper)); }
@property --holo-a { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
@keyframes holo { to { --holo-a: 360deg; } }

.stamp-img { position: relative; aspect-ratio: 4 / 3; background: var(--sea); overflow: hidden; }
.stamp-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.stamp-img::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(6, 23, 42, .35));
}
.r-mythique .stamp-img::before {
  content: ''; position: absolute; inset: 0; z-index: 1; mix-blend-mode: color-dodge; opacity: .35;
  background: linear-gradient(115deg, transparent 30%, #ff8ac8 42%, #7cf0c5 50%, #74b4ff 58%, transparent 70%) 0 0 / 250% 100%;
  animation: sheen 3.5s ease-in-out infinite;
}
@keyframes sheen { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
.stamp-value {
  position: absolute; top: 18px; right: 18px; z-index: 2; min-width: 46px; padding: .25rem .5rem .2rem;
  background: var(--paper); color: var(--ink-c); text-align: center;
  font: 400 var(--step-2)/1 var(--serif); border: 2px solid var(--ink-c);
}
.r-mythique .stamp-value { color: var(--r-mythique); border-color: var(--r-mythique); }
.stamp-value small { display: block; font: 600 9px/1.3 var(--sans); color: var(--ink); opacity: .7; }
.stamp-name {
  margin: 2px 0 0; font: 400 var(--step-2)/1.08 var(--serif); letter-spacing: -.01em; color: var(--ink);
  text-wrap: balance; overflow-wrap: anywhere;
}
.stamp-desc { margin: 0; font-size: var(--step--1); color: #4A5D72; line-height: 1.35; }
.stamp-foot {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding-top: 8px; border-top: 1px solid rgba(19, 41, 63, .15); font-size: 11px; color: #4A5D72;
}
.stamp-rarity { color: var(--ink-c); font-weight: 700; }
.r-mythique .stamp-rarity {
  background: linear-gradient(90deg, #d9468f, #c69cff, #2f8fb0); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stamp-place { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.stamp-place span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flag { font-size: 14px; line-height: 1; }

/* Oblitération */
.postmark {
  position: absolute; right: 7%; top: 47%; z-index: 3; width: 92px; height: 92px; pointer-events: none;
  color: rgba(19, 41, 63, .72); transform: rotate(-14deg); mix-blend-mode: multiply;
}
.postmark text { font: 600 8.6px var(--sans); letter-spacing: .06em; fill: currentColor; }
.postmark .pm-center { font: 400 11px var(--serif); letter-spacing: 0; }

/* Variante compacte */
.stamp-wrap.mini .stamp { --perf-r: 4px; --perf-g: 12px; padding: 9px; }
.stamp-wrap.mini .stamp-frame { padding: 6px; gap: 6px; }
.stamp-wrap.mini .stamp-name { font-size: var(--step-1); }
.stamp-wrap.mini .stamp-value { top: 14px; right: 14px; font-size: var(--step-1); min-width: 36px; }
.stamp-wrap.mini .stamp-value small { display: none; }
.stamp-wrap.mini .stamp-desc { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.stamp-wrap.mini .postmark { width: 70px; height: 70px; top: 44%; }

/* ---------- Feuilles ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 8; overflow-y: auto; overscroll-behavior: contain;
  background: rgba(6, 23, 42, .9); backdrop-filter: blur(10px);
  padding: 104px 16px 140px; animation: fadein .25s both;
}
.sheet-inner { max-width: 1120px; margin: 0 auto; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem 2rem; margin-bottom: 1.6rem; }
.sheet-title { font: 400 var(--step-4)/1 var(--serif); letter-spacing: -.02em; margin: 0; }
.sheet-sub { color: var(--muted); margin: .5rem 0 0; max-width: 60ch; }
.back-link { border: 0; background: none; color: var(--muted); padding: 0; margin-bottom: .8rem; font-weight: 500; }
.back-link:hover { color: var(--paper); }

.stats { display: flex; gap: 2.2rem; flex-wrap: wrap; }
.stat b { display: block; font: 400 var(--step-3)/1 var(--serif); }
.stat span { color: var(--muted); font-size: var(--step--1); }

.spectrum { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: rgba(238, 242, 245, .08); margin: 0 0 1.2rem; }
.spectrum i { display: block; height: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.6rem; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: .45rem; padding: .4rem .75rem; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--paper-2); font-size: var(--step--1); font-weight: 500;
}
.chip[aria-pressed="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-c); }
.r-mythique .dot { background: var(--holo); }
.chip-count { opacity: .6; }
.sort { margin-left: auto; display: flex; gap: .4rem; align-items: center; color: var(--muted); font-size: var(--step--1); }
.sort select {
  background: transparent; border: 1px solid var(--line); border-radius: 8px; color: var(--paper); padding: .35rem .5rem; font: inherit;
}
.sort select option { background: var(--abyss); }

.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 28px 24px; }
.album-item { position: relative; min-width: 0; transition: transform .2s var(--ease); }
.album-item:hover, .album-item:focus-within { transform: translateY(-4px) rotate(-.6deg); }
.album-open { position: absolute; inset: 0; z-index: 4; border: 0; background: transparent; border-radius: 4px; }
.album-open:focus-visible { outline: 2px solid var(--buoy); outline-offset: 4px; }

.empty {
  border: 1.5px dashed var(--line); border-radius: 16px; padding: 3rem 1.5rem; text-align: center; color: var(--muted);
}
.empty h3 { font: 400 var(--step-2)/1.2 var(--serif); color: var(--paper); margin: 0 0 .5rem; }
.empty p { margin: 0 auto 1.2rem; max-width: 42ch; }

/* Classement */
.ranking { width: 100%; border-collapse: collapse; }
.ranking th { text-align: left; font-weight: 500; color: var(--muted); font-size: var(--step--1); padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
.ranking td { padding: .85rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ranking tr.me td { background: rgba(242, 194, 48, .07); }
.ranking .num, .ranking th.num { text-align: right; }
.rank { font: 400 var(--step-1)/1 var(--serif); color: var(--muted); width: 3rem; }
.ranking tr:nth-child(-n+3) .rank { color: var(--buoy); }
.player-btn { display: flex; align-items: center; gap: .6rem; border: 0; background: none; padding: 0; font-weight: 600; }
.player-btn:hover span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: var(--step--1); color: var(--ink-c); font-weight: 600; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-c); }
.r-mythique.badge { color: var(--r-mythique); }
.activity { font-size: var(--step--1); color: var(--muted); }
.activity.warn { color: var(--danger); }
.table-scroll { overflow-x: auto; }

/* ---------- Index ---------- */
.planet {
  margin-top: .4rem;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.2rem 2rem; align-items: end;
  padding: 1.4rem 1.5rem; margin-bottom: 1.4rem; border: 1px solid var(--line); border-radius: 16px;
  background: linear-gradient(135deg, rgba(47, 111, 214, .12), rgba(238, 242, 245, .02) 60%);
}
.planet-total { display: grid; gap: .3rem; }
.planet-total b { font: 400 clamp(2.4rem, 5vw, 3.6rem)/1 var(--serif); letter-spacing: -.02em; }
.planet-total span { color: var(--paper-2); }
.planet-stats { display: flex; gap: 2rem; margin: 0; }
.planet-stats dt { color: var(--muted); font-size: var(--step--1); }
.planet-stats dd { margin: .2rem 0 0; font: 400 var(--step-2)/1 var(--serif); }
.planet-rarity {
  grid-column: 1 / -1; list-style: none; margin: 0; padding: 1rem 0 0; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem 1.2rem; font-size: var(--step--1); color: var(--paper-2);
}
.planet-rarity li { display: grid; grid-template-columns: 10px 1fr; column-gap: .5rem; align-items: center; }
.planet-rarity .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-c); }
.planet-rarity .r-mythique .dot, .planet-rarity li.r-mythique .dot { background: var(--holo); }
.planet-rarity b { grid-column: 2; color: var(--paper); font-weight: 600; }
.planet-note { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 12px; max-width: 80ch; }
.r-null { --ink-c: var(--muted); }
.idx-search {
  display: flex; align-items: center; gap: .7rem; padding: 0 1rem; margin-bottom: 1rem;
  border: 1px solid var(--line); border-radius: 14px; background: rgba(238, 242, 245, .05); transition: border-color .15s;
}
.idx-search:focus-within { border-color: var(--buoy); }
.idx-search svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.idx-search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: .95rem 0; font-size: var(--step-1); }
.idx-search input::placeholder { color: var(--muted); }
.idx-controls { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.idx-controls .sort { margin-left: 0; }
.seg { display: inline-flex; flex-wrap: wrap; padding: 3px; border-radius: 11px; background: rgba(238, 242, 245, .06); }
.seg button { border: 0; background: none; color: var(--muted); padding: .45rem .8rem; border-radius: 8px; font-weight: 500; font-size: var(--step--1); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
.idx-h { display: flex; align-items: baseline; gap: .7rem; margin: 1.6rem 0 .8rem; font: 400 var(--step-2)/1.2 var(--serif); }
.idx-h span { font: 500 var(--step--1) var(--sans); color: var(--muted); }
.idx-note { color: var(--muted); font-size: var(--step--1); margin: -.4rem 0 .8rem; }
.idx-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); transition: opacity .15s; }
.idx-list.loading { opacity: .45; }
.idx-row {
  width: 100%; display: grid; grid-template-columns: 56px minmax(0, 1fr) minmax(0, 150px) 110px 92px 130px; gap: 1rem; align-items: center;
  padding: .6rem .5rem; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left;
}
.idx-row:hover { background: rgba(238, 242, 245, .04); }
.idx-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; background: var(--sea); }
.idx-main { display: grid; min-width: 0; }
.idx-name, .idx-desc, .idx-country { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idx-name { font: 400 var(--step-1)/1.3 var(--serif); }
.idx-desc { color: var(--muted); font-size: var(--step--1); }
.idx-country { color: var(--paper-2); font-size: var(--step--1); }
.idx-views { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.idx-views small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
/* Pastille de l'index : nom propre, « .status » est le conteneur de la barre du haut. */
.idx-status { justify-self: end; max-width: 100%; padding: .25rem .65rem; border-radius: 999px; font-size: var(--step--1); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-available { color: #7FD6B0; background: rgba(47, 143, 107, .16); }
.s-owned { color: var(--paper-2); background: rgba(238, 242, 245, .08); }
.s-reserved { color: var(--buoy); background: rgba(242, 194, 48, .12); }
.idx-empty { padding: 1.4rem .5rem; color: var(--muted); border-bottom: 1px solid var(--line); }
.idx-more { display: flex; margin: 1rem auto 0; }
.idx-skel {
  height: 73px; border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, transparent 30%, rgba(238, 242, 245, .06), transparent 70%) 0 0 / 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Mon compte ---------- */
.account { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.2rem; align-items: start; }
.acc-card { padding: 1.3rem 1.4rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(238, 242, 245, .03); }
.acc-card h2 { margin: 0 0 .8rem; font: 400 var(--step-2)/1.15 var(--serif); }
.acc-form { display: grid; gap: .8rem; }
.acc-form .btn { justify-self: start; }
.acc-note { margin: 0; color: var(--muted); font-size: var(--step--1); max-width: 56ch; }
.acc-card > .acc-note + .acc-form { margin-top: .9rem; }
.acc-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .8rem; }
.acc-danger { border-color: rgba(255, 122, 107, .35); background: rgba(255, 122, 107, .04); }
.acc-danger h2 { color: var(--danger); }
.field input:disabled { opacity: .6; }

/* ---------- Atlas ---------- */
.atlas-panel {
  position: fixed; right: 16px; top: 92px; bottom: 16px; z-index: 7; width: 320px;
  display: flex; flex-direction: column; padding: 1.1rem 1.1rem 0;
  background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 16px;
}
.panel-title { font: 400 var(--step-2)/1.1 var(--serif); margin: 0; }
.panel-sub { color: var(--muted); font-size: var(--step--1); margin: .3rem 0 1rem; }
.feed { list-style: none; margin: 0 -1.1rem; padding: 0 1.1rem 1rem; overflow-y: auto; flex: 1; display: grid; align-content: start; gap: .15rem; }
.feed li { display: grid; grid-template-columns: 10px 1fr; gap: .2rem .7rem; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: var(--step--1); }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-c); margin-top: .4rem; }
.feed .r-mythique .dot, .feed li.r-mythique .dot { background: var(--holo); }
.feed-text { color: var(--paper-2); }
.feed-text b { color: var(--paper); font-weight: 600; }
.feed-place { border: 0; background: none; padding: 0; color: var(--paper); font-family: var(--serif); text-align: left; }
.feed-place:hover { text-decoration: underline; text-underline-offset: 3px; }
.feed-time { grid-column: 2; color: var(--muted); font-size: 12px; }

.legend {
  position: fixed; left: 16px; bottom: 16px; z-index: 5; display: grid; gap: .3rem;
  padding: .7rem .85rem; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); font-size: 12px; color: var(--paper-2);
}
.legend div { display: flex; align-items: center; gap: .5rem; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-c); }
.legend .r-mythique .dot { background: var(--holo); }
.legend b { margin-left: auto; padding-left: 1rem; color: var(--muted); font-weight: 500; }

/* Marqueurs */
.pin { position: relative; width: 16px; height: 16px; }
.pin i { position: absolute; inset: 3px; border-radius: 50%; background: var(--ink-c); border: 2px solid var(--paper); box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.pin.r-mythique i { background: var(--holo); }
.pin.target::before, .pin.target::after {
  content: ''; position: absolute; inset: -22px; border-radius: 50%; border: 2px solid var(--ink-c);
  animation: sonar 1.8s var(--ease) infinite;
}
.pin.target::after { animation-delay: .9s; }
.pin.target.r-mythique::before, .pin.target.r-mythique::after { border-color: #ff8ac8; }
.leaflet-popup-content-wrapper { background: var(--abyss); color: var(--paper); border-radius: 12px; border: 1px solid var(--line); }
.leaflet-popup-tip { background: var(--abyss); }
.leaflet-popup-content { margin: .8rem 1rem; font: var(--step--1)/1.45 var(--sans); }
.popup-title { font: 400 var(--step-1)/1.2 var(--serif); margin: 0 0 .25rem; }
.popup-meta { color: var(--muted); margin: 0; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

/* ---------- Dialogue de détail ---------- */
.detail {
  width: min(880px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line);
  border-radius: 20px; background: var(--abyss); color: var(--paper); overflow: auto;
}
.detail::backdrop { background: rgba(3, 12, 22, .72); backdrop-filter: blur(4px); }
.detail[open] { animation: fadein .25s var(--ease); }
.detail-grid { display: grid; grid-template-columns: 330px 1fr; gap: 2rem; padding: 2rem; }
.detail h2 { font: 400 var(--step-3)/1.05 var(--serif); margin: 0 0 .4rem; letter-spacing: -.015em; text-wrap: balance; }
.detail-sub { color: var(--muted); margin: 0 0 1.3rem; }
.detail-extract { color: var(--paper-2); line-height: 1.65; margin: 0 0 1.5rem; max-width: 62ch; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.5rem; margin: 0 0 1.6rem; }
.facts dt { color: var(--muted); font-size: var(--step--1); }
.facts dd { margin: .15rem 0 0; font-weight: 600; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.detail-close {
  position: sticky; top: 12px; float: right; margin: 12px 12px 0 0; z-index: 2; width: 36px; height: 36px;
  border-radius: 50%; border: 1px solid var(--line); background: var(--abyss); color: var(--paper); font-size: 20px; line-height: 1;
}

/* ---------- Choix du pays ---------- */
.picker {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line);
  border-radius: 20px; background: var(--abyss); color: var(--paper);
}
.picker::backdrop { background: rgba(3, 12, 22, .72); backdrop-filter: blur(4px); }
.picker[open] { animation: fadein .25s var(--ease); }
.picker-inner { display: grid; gap: .8rem; padding: 1.4rem 1.5rem 1.5rem; }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.picker-head h2 { margin: 0; font: 400 var(--step-3)/1.05 var(--serif); letter-spacing: -.015em; }
.picker-head .detail-close { position: static; float: none; margin: 0; flex: none; }
.picker-sub { margin: 0; color: var(--paper-2); max-width: 52ch; }
.picker-search { margin: 0; }
.picker-h { margin: .3rem 0 0; font: 500 var(--step--1) var(--sans); color: var(--muted); }
.picker-h span { opacity: .7; }
.picker-recent { display: flex; flex-wrap: wrap; gap: .4rem; }
.picker-list {
  list-style: none; margin: 0; padding: 2px; max-height: min(38dvh, 320px); overflow-y: auto; overscroll-behavior: contain;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .3rem;
}
.country {
  width: 100%; display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem; min-height: 40px;
  border: 1px solid var(--line); border-radius: 10px; background: transparent; text-align: left; font-size: var(--step--1);
}
.country span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country:hover { border-color: rgba(238, 242, 245, .35); }
.country[aria-pressed="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.picker-recent .country { width: auto; }
.picker-empty { color: var(--muted); padding: .6rem; grid-column: 1 / -1; }

/* ---------- Fusion ---------- */
.fusion {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line);
  border-radius: 20px; background: var(--abyss); color: var(--paper); overflow: auto; overscroll-behavior: contain;
}
.fusion::backdrop { background: rgba(3, 12, 22, .72); backdrop-filter: blur(4px); }
.fusion[open] { animation: fadein .25s var(--ease); }
#fusion-body { padding: 1.4rem 1.5rem 1.5rem; }
.fusion-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 36px; }
.fusion-head h2, .fusion-title { margin: 0; font: 400 var(--step-3)/1.05 var(--serif); letter-spacing: -.015em; text-wrap: balance; }
.fusion-head .detail-close { position: static; float: none; margin: 0; flex: none; }
.fusion-head .back-link { margin: 0; }
.fusion-title { margin-top: .6rem; }
.fusion-sub { margin: .6rem 0 1.2rem; color: var(--paper-2); max-width: 56ch; }
.fusion-open { margin-top: 1rem; display: inline-flex; align-items: center; gap: .5rem; }
.fusion-open svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }

/* Petits timbres de couleur : pleins si possédés, en pointillés s'il en manque */
.slot {
  display: inline-block; width: 13px; height: 17px; border-radius: 2px; flex: none;
  border: 1.5px dashed var(--ink-c); opacity: .55;
}
.slot.on { border: 0; opacity: 1; background: var(--ink-c); box-shadow: inset 0 0 0 2px var(--abyss), 0 0 0 1px var(--ink-c); }
.r-mythique .slot.on { background: var(--holo); box-shadow: inset 0 0 0 2px var(--abyss), 0 0 0 1px var(--r-mythique); }

.recipes { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.recipe {
  width: 100%; display: grid; grid-template-columns: 4.6rem minmax(0, 1fr) auto 7.5rem; align-items: center; gap: 1rem;
  padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: transparent; text-align: left;
  transition: border-color .15s, background .15s;
}
.recipe:not(:disabled) { border-color: rgba(242, 194, 48, .45); }
.recipe:not(:disabled):hover { background: rgba(242, 194, 48, .06); border-color: var(--buoy); }
.recipe:disabled { cursor: default; }
.recipe:disabled .recipe-text, .recipe:disabled .recipe-arrow, .recipe:disabled .recipe-out { opacity: .5; }
.recipe-in { display: flex; gap: 4px; }
.recipe-text b { display: block; font: 400 var(--step-1)/1.2 var(--serif); }
.recipe-text small { color: var(--muted); font-size: var(--step--1); }
.recipe:not(:disabled) .recipe-text small { color: var(--buoy); }
.recipe-arrow { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.recipe-out { display: flex; align-items: center; gap: .5rem; color: var(--ink-c); font-weight: 600; font-size: var(--step--1); }
.r-mythique.recipe-out { color: var(--r-mythique); }

/* Choix des timbres */
.fusion-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 22px 16px; padding: 8px 6px 4px; }
.pick-item { position: relative; min-width: 0; transition: transform .18s var(--ease), opacity .18s; }
.pick { position: absolute; inset: 0; z-index: 4; border: 0; background: transparent; border-radius: 4px; }
.pick:disabled { cursor: not-allowed; }
.pick-item:has(.pick:disabled) { opacity: .4; }
.pick-item.picked { transform: translateY(-4px); }
.pick-item.picked::before {
  content: ''; position: absolute; inset: -6px; border: 2px solid var(--buoy); border-radius: 6px; pointer-events: none;
}
.pick-mark {
  position: absolute; top: -12px; left: -12px; z-index: 5; width: 28px; height: 28px; padding: 5px; border-radius: 50%;
  background: var(--buoy); fill: none; stroke: var(--buoy-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s var(--ease); pointer-events: none;
}
.pick-item.picked .pick-mark { opacity: 1; transform: none; }
.fusion-bar {
  position: sticky; bottom: -1.5rem; z-index: 6; margin: 1.2rem -1.5rem -1.5rem; padding: .9rem 1.5rem 1.2rem;
  display: flex; align-items: center; gap: .6rem 1.2rem; flex-wrap: wrap;
  background: var(--abyss); border-top: 1px solid var(--line);
}
.fusion-count { display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.fusion-slots { display: flex; gap: 4px; }
.fusion-note { margin: 0; color: var(--muted); font-size: var(--step--1); }
.fusion-bar .form-error { margin: 0; }
.fusion-bar .btn { margin-left: auto; }

/* Révélation : les timbres échangés se rejoignent, le nouveau timbre apparaît et reçoit son cachet */
.fusion-reveal { display: grid; justify-items: center; text-align: center; padding-bottom: .4rem; }
.fusion-reveal .fusion-sub { margin-inline: auto; }
.merge { position: relative; height: 0; width: 100%; }
.merge img {
  position: absolute; left: 50%; top: 90px; width: 74px; height: 56px; margin-left: -37px; object-fit: cover;
  border: 3px solid var(--paper); border-radius: 2px; opacity: 0;
  animation: merge .7s var(--ease) both;
}
@keyframes merge {
  0% { opacity: 1; transform: translateX(calc(var(--i) * 96px)) rotate(calc(var(--i) * 6deg)); }
  70% { opacity: 1; transform: translateX(0) scale(.9); }
  100% { opacity: 0; transform: scale(.4); }
}
.reveal-stamp { width: min(300px, 82%); margin-top: .6rem; animation: arrive .5s .55s var(--ease) both; }
@keyframes arrive { from { opacity: 0; transform: scale(.82) rotate(-2deg); } to { opacity: 1; transform: none; } }
.reveal-stamp .postmark { animation: cancel .55s 1.05s var(--ease) both; }
.fusion-reveal .fusion-title { margin-top: 1.4rem; }
.fusion-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; }
.fusion-reveal.still .merge { display: none; }
.fusion-reveal.still .reveal-stamp, .fusion-reveal.still .postmark { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .merge { display: none; }
  .reveal-stamp, .reveal-stamp .postmark, .pick-item { animation: none; transition: none; }
}

/* ---------- Notifications ---------- */
.toasts { position: fixed; top: 92px; left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: .5rem; width: min(440px, calc(100vw - 32px)); }
.toast {
  padding: .8rem 1rem; border-radius: 12px; background: var(--paper); color: var(--ink); font-weight: 500;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4); animation: fadein .25s var(--ease);
}
.toast.error { background: #FFE3DF; color: #5A1209; }

/* ---------- Mobile ---------- */
/* Barre du haut sur une ligne, onglets en bas à portée de pouce, résultats et fenêtres en panneaux.
   Hauteurs en dvh (barre d'adresse mobile), marges pour l'encoche et la barre de geste. */
@media (max-width: 900px) {
  :root {
    --topbar-h: calc(60px + env(safe-area-inset-top));
    --tabbar-h: calc(62px + env(safe-area-inset-bottom));
  }
  .topbar {
    top: calc(8px + env(safe-area-inset-top)); left: 8px; right: 8px; gap: .6rem;
    padding: .35rem .45rem .35rem .75rem; border-radius: 14px;
  }
  .topbar .nav { display: none; }
  .status { margin-left: auto; gap: .8rem; }
  .meter-label { display: none; }
  #user-name { display: none; }
  .user-btn { padding: .2rem; }
  .user-pop { width: min(260px, calc(100vw - 32px)); }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
    height: var(--tabbar-h); padding: 0 4px env(safe-area-inset-bottom);
    background: var(--glass); backdrop-filter: blur(14px) saturate(1.2); border-top: 1px solid var(--line);
  }
  .tab {
    flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: none; color: var(--muted); font-size: 12px; font-weight: 500; letter-spacing: -.01em; padding: 0;
  }
  .tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab[aria-current="page"] { color: var(--buoy); }

  /* Dock de tirage : au-dessus des onglets ; masqué pendant qu'un résultat est affiché */
  .dock {
    left: 8px; right: 8px; bottom: calc(var(--tabbar-h) + 8px); transform: none; width: auto;
    display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .6rem; border-radius: 16px;
  }
  .rolls { grid-column: 1 / -1; display: flex; align-items: center; gap: .7rem; }
  .roll-btn, .precision-btn { min-width: 0; width: 100%; padding: .55rem .8rem; }
  body.stage-open .dock { display: none; }

  /* Résultat d'un tirage : panneau glissé depuis le bas, boutons collés en bas */
  .stage {
    left: 0; right: 0; top: auto; bottom: var(--tabbar-h); transform: none; width: auto; max-width: none; margin: 0;
    display: flex; flex-direction: column; align-items: stretch; gap: .6rem;
    padding: 14px 16px 12px; border-top: 1px solid var(--line); border-radius: 20px 20px 0 0;
    background: var(--glass); backdrop-filter: blur(14px) saturate(1.2);
    max-height: calc(100dvh - var(--tabbar-h) - var(--topbar-h) - 16px); overflow-y: auto; overscroll-behavior: contain;
  }
  .stage .stamp-wrap { width: 100%; max-width: 300px; margin: 0 auto; }
  .stage .stamp-img { aspect-ratio: 16 / 9; }
  .stage .stamp-name { font-size: var(--step-1); }
  .stage-actions { position: sticky; bottom: 0; }
  .stage-timer, .stage-note { align-self: center; text-align: center; }

  .toasts { top: calc(var(--topbar-h) + 6px); bottom: auto; }

  /* Journal de l'Atlas : panneau repliable au-dessus des onglets */
  .atlas-panel {
    top: auto; left: 8px; right: 8px; width: auto; bottom: calc(var(--tabbar-h) + 8px);
    height: auto; max-height: 55dvh; padding: 0 1rem;
  }
  .panel-head { cursor: pointer; padding: .4rem 0 .7rem; }
  .panel-grip { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto .6rem; }
  .atlas-panel .panel-sub { margin-bottom: 0; }
  .atlas-panel .feed { margin: 0 -1rem; padding: 0 1rem .6rem; }
  .atlas-panel.collapsed .feed { display: none; }
  .legend { display: none; }

  /* Feuilles (album, index, classement, compte) : entre la barre du haut et les onglets */
  .sheet { padding: calc(var(--topbar-h) + 16px) 16px calc(var(--tabbar-h) + 28px); }
  .sheet-title { font-size: var(--step-3); }

  /* Fenêtres en plein écran */
  .detail, .picker, .fusion {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0;
  }
  .detail-close { margin: calc(10px + env(safe-area-inset-top)) 10px 0 0; }
  .detail-grid { grid-template-columns: 1fr; padding: 1rem 16px 0; gap: 1.25rem; }
  .detail-grid .stamp-wrap { max-width: 320px; margin: 0 auto; }
  /* Actions de la fiche collées en bas : atteignables sans faire défiler tout le résumé */
  .detail-actions {
    position: sticky; bottom: 0; z-index: 2; margin: 0 -16px; padding: .8rem 16px calc(.8rem + env(safe-area-inset-bottom));
    background: var(--abyss); border-top: 1px solid var(--line);
  }
  .detail-actions .btn { flex: 1 1 auto; }
  .picker-inner {
    height: 100%; display: flex; flex-direction: column; min-width: 0;
    padding: calc(14px + env(safe-area-inset-top)) 16px calc(14px + env(safe-area-inset-bottom));
  }
  .picker-inner > * { min-width: 0; }
  .picker-head h2 { font-size: var(--step-2); }
  #fusion-body { padding: calc(14px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
  .fusion-bar { bottom: calc(-16px - env(safe-area-inset-bottom)); margin: 1rem -16px calc(-16px - env(safe-area-inset-bottom)); padding: .8rem 16px calc(.9rem + env(safe-area-inset-bottom)); }
  .fusion-bar .btn { width: 100%; margin-left: 0; }
  .fusion-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px 12px; }
  .recipe { grid-template-columns: 4.2rem minmax(0, 1fr); gap: .5rem .8rem; padding: .8rem; }
  .recipe-arrow { display: none; }
  .recipe-out { grid-column: 2 / -1; }
  .picker-list { flex: 1; min-height: 0; max-height: none; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  /* iPhone zoome sur tout champ en dessous de 16 px */
  .field input, .idx-search input, .sort select, #picker-q { font-size: 16px; }

  .album { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px 14px; }
  .country { min-height: 44px; }
}

/* Téléphone en paysage : peu de hauteur, on resserre */
@media (max-width: 900px) and (max-height: 520px) {
  :root { --tabbar-h: calc(48px + env(safe-area-inset-bottom)); --topbar-h: calc(52px + env(safe-area-inset-top)); }
  .tab span { display: none; }
  .stage .stamp-img { display: none; }
  .dock { grid-template-columns: auto 1fr 1fr; }
  .rolls { grid-column: auto; flex-direction: column; align-items: flex-start; gap: .2rem; }
  /* Fiche : timbre à gauche, texte et actions à droite */
  .detail-grid { grid-template-columns: minmax(0, 200px) minmax(0, 1fr); align-items: start; }
  .detail-grid .stamp-wrap { max-width: 200px; }
}
@media (max-width: 900px) {
  .account { grid-template-columns: 1fr; }
  .planet { grid-template-columns: 1fr; }
  .planet-stats { gap: 1.4rem; }
  .idx-row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: .2rem .8rem; }
  .idx-thumb { width: 48px; height: 48px; grid-row: span 2; }
  .idx-main { grid-row: span 2; }
  .idx-country, .idx-views { display: none; }
  .idx-row .badge { grid-column: 3; grid-row: 1; justify-self: end; }
  .idx-row .idx-status { grid-column: 3; grid-row: 2; }
}
@media (max-width: 900px) {
  .chip, .seg button, .sort select, .back-link, .btn, .nav-btn { min-height: 44px; }
  .detail-close { width: 44px; height: 44px; }
}
@media (max-width: 520px) {
  .ranking .hide-sm { display: none; }
  .stats { gap: 1.4rem; }
  .facts { grid-template-columns: 1fr 1fr; }
}

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