@charset "UTF-8";
/* Accueil et sélection des stages, accordés aux cinq lieux.
   Les matières (cadre, plaque, panneau, accent) sont celles de la partie : les
   variables de css/game.css valent aussi pour .page[data-realm]. Aucun de ces
   écrans ne défile : ils occupent exactement la fenêtre. */

/* ---- La barre du haut : celle d'une partie ------------------------------------ */
.game-topbar.menu-topbar {
  flex: none;
  z-index: 3;
  gap: 16px;
  padding-left: calc(24px + env(safe-area-inset-left));
  padding-right: calc(24px + env(safe-area-inset-right));
}
.menu-topbar .game-location {
  min-width: 0;
}
.menu-topbar .game-location-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu-topbar .game-actions {
  align-items: center;
}
.menu-topbar .profile-button {
  min-height: 38px;
  height: 38px;
  max-width: 34vw;
}
.menu-topbar .profile-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* The accent of the realm draws the lower edge of the bar, in the menus as
   during a stage. The dungeon keeps its own line of embers. */
:is(.game-page, .page)[data-realm]:not([data-realm="dungeon"]) .game-topbar {
  border-bottom-color: color-mix(in srgb, var(--accent) 55%, #79b1aa55);
}
@media (max-width: 1100px) {
  .game-topbar.menu-topbar {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
}
@media (max-width: 600px) {
  .menu-topbar .profile-button {
    padding: 0 10px;
  }
  .menu-topbar .profile-button span {
    display: none;
  }
}
/* On a phone held sideways the bar of a stage floats over the board; the bar
   of the menus stays a bar, only thinner. */
@media (max-height: 500px) and (orientation: landscape) {
  .game-topbar.menu-topbar {
    position: relative;
    height: 42px;
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
    background: linear-gradient(180deg, #0c1314eb, #172224c9 75%, #090c0dd9);
    border-bottom: 3px double #79b1aa88;
    box-shadow: 0 4px 24px #0006;
  }
  .menu-topbar .game-location {
    display: flex;
  }
  .menu-topbar .game-actions .icon-button {
    height: 34px;
  }
  .menu-topbar .profile-button {
    height: 34px;
    min-height: 34px;
  }
}

/* ---- Les sceaux des cinq lieux --------------------------------------------------- */
.realm-seals {
  display: flex;
  justify-content: center;
}
.realm-seal[data-realm="village"] { --seal: #97f0e4; }
.realm-seal[data-realm="castle"] { --seal: #8fb4ff; }
.realm-seal[data-realm="crypt"] { --seal: #5fc9a8; }
.realm-seal[data-realm="temple"] { --seal: #b69cf0; }
.realm-seal[data-realm="dungeon"] { --seal: #94fff1; }
.realm-seal {
  --size: 48px;
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 7px;
  min-width: calc(var(--size) + 12px);
  padding: 4px 0 0;
  color: #c9e8e4;
  transition:
    transform 0.2s cubic-bezier(0.22, 0.75, 0.3, 1),
    color 0.2s ease;
}
/* A thin mark tracks the won stages without enclosing the illustration. */
.realm-seal-ring {
  position: absolute;
  top: calc(var(--size) + 2px);
  left: 50%;
  width: calc(var(--size) * .8);
  height: 2px;
  translate: -50% 0;
  border-radius: 2px;
  background: linear-gradient(to right, var(--seal) calc(var(--won) * 100%), #90b3ae55 0);
  transition: filter 0.25s ease;
}
.realm-seal .realm-seal-illustration {
  width: var(--size);
  height: var(--size);
  filter: drop-shadow(0 3px 5px #000c);
  transition: filter 0.25s ease;
}
.realm-seal-name {
  font: 600 12px/1.2 var(--display);
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 10px #000;
}
.realm-seal-lock {
  position: absolute;
  top: calc(var(--size) - 14px);
  left: calc(50% + var(--size) / 2 - 16px);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #0a1214;
  border: 1.5px solid #618b85;
}
.realm-seal-lock svg {
  width: 13px;
  height: 13px;
}
.realm-seal.locked .realm-seal-illustration {
  filter: saturate(.72) brightness(.78) drop-shadow(0 3px 5px #000c);
}
.realm-seal:hover,
.realm-seal:focus-visible {
  transform: translateY(-3px);
  color: #e8fffc;
}
.realm-seal:hover .realm-seal-illustration,
.realm-seal:focus-visible .realm-seal-illustration,
.realm-seal.active .realm-seal-illustration {
  filter: drop-shadow(0 3px 5px #000c) drop-shadow(0 0 12px var(--seal));
}
.realm-seal:hover .realm-seal-ring,
.realm-seal.active .realm-seal-ring {
  filter: drop-shadow(0 0 6px var(--seal));
}
.realm-seal:focus-visible {
  outline: 0;
}
.realm-seal:focus-visible .realm-seal-ring {
  box-shadow: 0 0 0 2px var(--gold-bright);
}

/* ---- Accueil : le sanctuaire et son portail --------------------------------------- */
.home {
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.home .home-main {
  flex: 1 1 auto;
  min-height: 0;
  padding: clamp(6px, 2.6vh, 36px) 24px clamp(6px, 2vh, 28px);
}
.home .home-title {
  font-size: clamp(36px, min(5.6vw, 8.5vh), 84px);
  letter-spacing: 0.055em;
}
.home .home-subtitle {
  margin: clamp(6px, 2vh, 19px) 0 clamp(6px, 2vh, 22px);
}
.home .title-rule {
  margin-bottom: 0;
}
.home .home-primary-actions {
  margin-top: clamp(10px, 3.4vh, 31px);
}
.home .home-primary-actions .button {
  min-height: clamp(44px, 6.4vh, 60px);
}
.home .journey-progress {
  margin-top: clamp(4px, 1.4vh, 14px);
}
.home .home-bottom {
  flex: none;
  width: 100%;
  padding: 0 40px calc(clamp(8px, 2.6vh, 25px) + env(safe-area-inset-bottom));
}
.home-seals {
  gap: clamp(10px, 2vw, 24px);
  margin-top: clamp(12px, 3.6vh, 34px);
}
.home-seals .realm-seal {
  --size: clamp(42px, min(7.6vh, 12vw), 70px);
  min-width: calc(var(--size) + 12px);
  padding-top: 0;
}
.home-seals .realm-seal:hover .realm-seal-illustration,
.home-seals .realm-seal:focus-visible .realm-seal-illustration {
  filter: brightness(1.12) drop-shadow(0 3px 7px #000c) drop-shadow(0 0 8px var(--seal));
}
.home-seals .realm-seal-lock {
  top: calc(var(--size) - 16px);
  left: calc(50% + var(--size) / 2 - 14px);
  width: 18px;
  height: 18px;
  border-radius: 4px;
}
/* The portal breathes the colour of the realm under the pointer. */
.home[data-portal="village"] { --portal: #9efff2; }
.home[data-portal="castle"] { --portal: #6f98ff; }
.home[data-portal="crypt"] { --portal: #4fe0b8; }
.home[data-portal="temple"] { --portal: #b292ff; }
.home[data-portal="dungeon"] { --portal: #8afff0; }
.portal-glow {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle min(44vw, 52vh) at 50% 47%,
    color-mix(in srgb, var(--portal, #9efff2) 30%, transparent),
    color-mix(in srgb, var(--portal, #9efff2) 10%, transparent) 55%,
    transparent 100%
  );
  transition: opacity 0.45s ease;
}
.home[data-portal] .portal-glow {
  opacity: 1;
}
.home .journey-progress {
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 10px;
  row-gap: 0;
}
.home .home-nav .button {
  white-space: nowrap;
}
@media (max-width: 1000px) {
  .home .home-nav .button {
    padding-inline: 20px;
    gap: 8px;
  }
}
@media (max-width: 640px) {
  .home-seals {
    gap: 10px;
  }
  .home-seals .realm-seal-name {
    display: none;
  }
  .home .home-nav {
    flex-wrap: wrap;
    gap: 8px;
  }
  .home .home-nav .button {
    flex: 1 1 40%;
    padding-inline: 10px;
  }
}
@media (max-height: 600px) {
  .home-seals .realm-seal-name {
    display: none;
  }
  .home .home-nav {
    padding: 6px 0;
  }
  .home .home-nav button {
    min-height: 38px;
  }
}
@media (max-height: 540px) {
  .home .journey-progress {
    display: none;
  }
  .home .home-bottom {
    padding-inline: 16px;
  }
}
@media (max-height: 420px) {
  .home .title-rule {
    display: none;
  }
}

/* ---- Sélection des stages : le lieu en plein écran --------------------------------- */
.stages-screen {
  --node: clamp(44px, 7.4vh, 66px);
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #050707;
  padding-top: env(safe-area-inset-top);
}
.stages-screen .storage-warning {
  flex: none;
}
/* The illustration of the realm, unveiled; only a vignette frames it. */
.realm-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--scene-image) center / cover no-repeat;
}
.realm-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 75% at 55% 55%, transparent 45%, #05070794 100%),
    linear-gradient(180deg, #05070780 0%, #05070700 24%, #05070700 68%, #050707b8 100%);
}
.realm-scene {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  touch-action: pinch-zoom;
}
.realm-journey {
  position: absolute;
  inset: 0;
}

/* The cartouche: the name of the realm on its own panel, framed as the HUD. */
.realm-cartouche {
  position: absolute;
  left: clamp(12px, 2.4vw, 44px);
  top: clamp(10px, 2.4vh, 30px);
  z-index: 3;
  width: min(400px, 30vw);
  padding: clamp(6px, 1.4vh, 14px) clamp(10px, 1.3vw, 18px);
  border: 12px solid transparent;
  border-image: var(--frame-src) 24 / 12px var(--frame-repeat);
  background: var(--panel) padding-box;
  box-shadow:
    0 12px 30px #000a,
    var(--panel-glow);
}
.realm-cartouche .eyebrow {
  color: var(--label);
}
.realm-cartouche h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 4px;
  font-size: clamp(24px, 4.4vh, 40px);
  line-height: 1.05;
  color: var(--title);
  text-shadow:
    0 0 18px color-mix(in srgb, var(--accent) 35%, transparent),
    0 3px 10px #000;
}
.realm-cartouche-emblem {
  flex: none;
  width: 1.3em;
  height: 1.3em;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--accent) 70%, transparent)) drop-shadow(0 2px 3px #000);
}
.realm-motto {
  font: italic 16px/1.4 var(--serif);
  color: var(--label);
}
.realm-description {
  margin-top: 4px;
  font: 15px/1.5 var(--serif);
  color: var(--detail);
}
.realm-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: clamp(6px, 1.2vh, 12px);
  padding-top: clamp(6px, 1.2vh, 10px);
  border-top: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  font: 600 12px var(--display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--value);
}
.realm-stats .num {
  font-family: var(--display);
}
.realm-wall {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.realm-wall svg {
  width: 15px;
  height: 15px;
}

/* ---- Le chemin ------------------------------------------------------------------ */
.realm-path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.realm-path path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.realm-path-reveal {
  stroke: #fff;
  stroke-width: 80px;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
}
.realm-path-shadow {
  stroke: #000;
  stroke-opacity: 0.5;
  stroke-width: 9px;
}
.realm-path-trim {
  stroke: var(--path-trim, transparent);
  stroke-width: var(--path-trim-width, 0);
  stroke-dasharray: var(--path-trim-dash, none);
}
.realm-path-line {
  stroke: var(--path-color);
  stroke-opacity: 0.85;
  stroke-width: var(--path-width, 3px);
  stroke-dasharray: var(--path-dash, 1 10);
}
.realm-path-done {
  stroke: var(--path-done);
  stroke-width: 4px;
  filter: drop-shadow(0 0 5px var(--node-glow));
}
.realm-spark {
  opacity: 0;
}
.realm-spark-halo {
  fill: var(--node-glow);
  opacity: 0.4;
}
.realm-spark-core {
  fill: #fffbe8;
}

/* ---- Les médaillons, dans la matière du lieu -------------------------------------- */
.stage-nodes {
  margin: 0;
  padding: 0;
  list-style: none;
}
.stage-stop {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 2;
  display: grid;
  justify-items: center;
  gap: 6px;
  width: 150px;
  translate: -50% calc(var(--node) / -2);
}
.stage-stop.current {
  z-index: 3;
}
.stage-node {
  --ring: max(3px, calc(var(--node) * 0.075));
  position: relative;
  width: var(--node);
  height: var(--node);
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: var(--ring) solid transparent;
  background:
    var(--node-core) padding-box,
    var(--node-ring) border-box;
  box-shadow:
    0 0 0 1.5px #000c,
    0 7px 16px #000d,
    inset 0 0 12px #000b;
  transition:
    transform 0.18s cubic-bezier(0.22, 0.75, 0.3, 1),
    box-shadow 0.2s ease,
    filter 0.2s ease;
}
/* A blade of light crosses the ring when the medallion is pointed at. */
.stage-node::after {
  content: "";
  position: absolute;
  inset: calc(var(--ring) * -1);
  border-radius: 50%;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 38%, #fff8 50%, transparent 62%) 160% 0 / 260% 100% no-repeat;
  opacity: 0;
}
.stage-node-number {
  position: relative;
  font: 600 calc(var(--node) * 0.4) / 1 var(--numeric);
  color: var(--node-ink);
  text-shadow: 0 2px 2px #000;
}
.stage-node.done {
  box-shadow:
    0 0 0 1.5px #000c,
    0 7px 16px #000d,
    inset 0 0 14px color-mix(in srgb, var(--node-glow) 50%, transparent),
    0 0 14px color-mix(in srgb, var(--node-glow) 30%, transparent);
}
.stage-node.current {
  box-shadow:
    0 0 0 1.5px #000c,
    0 7px 16px #000d,
    inset 0 0 14px color-mix(in srgb, var(--node-glow) 45%, transparent),
    0 0 26px var(--node-glow);
}
.stage-node:hover:not(:disabled),
.stage-node:focus-visible {
  transform: translateY(-3px) scale(1.12);
  box-shadow:
    0 0 0 1.5px #000c,
    0 0 28px var(--node-glow),
    0 12px 18px #000d,
    inset 0 0 14px color-mix(in srgb, var(--node-glow) 50%, transparent);
}
.stage-node:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 5px;
}
/* Locked, a medallion keeps the material of its realm, only dimmed. */
.stage-node.locked,
.stage-node:disabled {
  opacity: 1;
  filter: saturate(0.5) brightness(0.6);
  cursor: not-allowed;
}
.stage-node-cup,
.stage-node-lock {
  position: absolute;
  top: calc(var(--ring) * -1 - 12px);
  right: calc(var(--ring) * -1 - 12px);
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #0c181a;
  border: 1.5px solid #618b85;
  box-shadow: 0 2px 4px #000a;
}
.stage-node-cup svg,
.stage-node-lock svg {
  width: 22px;
  height: 22px;
}
.stage-node.gold .stage-node-cup {
  border-color: #adfff4;
}
.stage-node.silver .stage-node-cup {
  border-color: #e3edf6;
}
.stage-node.silver .stage-node-cup svg {
  filter: grayscale(1) brightness(1.3);
}
.stage-node.bronze .stage-node-cup {
  border-color: #96e0d6;
}
.stage-node.bronze .stage-node-cup svg {
  filter: sepia(0.6) saturate(1.1) brightness(0.85);
}
.stage-node-name {
  max-width: 142px;
  padding: 1px 8px;
  font: 600 12px/1.35 var(--display);
  letter-spacing: 0.05em;
  text-align: center;
  color: var(--title);
  background: #06090ac9;
  border-radius: 3px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
  text-shadow: 0 1px 2px #000;
}
.stage-stop:has(.locked) .stage-node-name {
  color: #8da3a0;
  box-shadow: 0 0 0 1px #0006;
}
/* Long location names need room at the end of the horizontal journey. */
@media (orientation: landscape) {
  .stage-stop:last-child .stage-node-name {
    transform: translateX(-20px);
  }
}
/* The stage that awaits: rings spreading from it, the emblem of the realm
   floating above like a pennant. */
.stage-ripple {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--node);
  height: var(--node);
  translate: -50% 0;
  pointer-events: none;
}
.stage-ripple::before,
.stage-ripple::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--node-glow);
}
.stage-pennant {
  position: absolute;
  bottom: 100%;
  left: 50%;
  z-index: 1;
  width: calc(var(--node) * 0.62);
  height: calc(var(--node) * 0.62);
  translate: -50% -2px;
  pointer-events: none;
  filter: drop-shadow(0 0 8px var(--node-glow)) drop-shadow(0 3px 3px #000);
}
.stage-pennant::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% -1px;
  width: 0;
  height: 0;
  border: 5px solid transparent;
  border-top: 7px solid var(--node-glow);
  filter: drop-shadow(0 0 4px var(--node-glow));
}

/* Jardins suspendus : nacre et lueurs de la surface. */
.stages-screen[data-realm="village"] {
  --node-ring:
    repeating-linear-gradient(35deg, #0000 0 3px, #1c353a1a 3px 5px),
    conic-gradient(from 210deg, #c9f7f1, #82c2ba 18%, #38666e 36%, #9edcd4 55%, #498e85 76%, #c9f7f1);
  --node-core: radial-gradient(circle at 42% 34%, #3e676e, #182b2e 62%, #0a1315);
  --node-ink: #e6fffc;
  --node-glow: #97f0e4;
  --path-color: #abe8e0;
  --path-width: 3.5px;
  --path-dash: 11 6;
  --path-trim: #1c353a;
  --path-trim-width: 7px;
  --path-trim-dash: 11 6;
  --path-done: #b6fff5;
}
/* Route des Épaves : bronze et courants bleus. */
.stages-screen[data-realm="castle"] {
  --node-ring: conic-gradient(from 210deg, #dffffb, #8ed9cf 18%, #23525a 38%, #b2f0e8 56%, #398a7f 78%, #dffffb);
  --node-core: radial-gradient(circle at 42% 34%, #36549a, #16244d 60%, #080d1f);
  --node-ink: #e3fffb;
  --node-glow: #8fb4ff;
  --path-color: #abe6de;
  --path-width: 3.2px;
  --path-dash: 1 10;
  --path-done: #cbfff8;
}
/* Crypte : bronze vert-de-gris et pierre moussue, une trace fantomatique. */
.stages-screen[data-realm="crypt"] {
  --node-ring:
    radial-gradient(circle at 24% 80%, #5d8a45aa 0 12%, transparent 26%),
    radial-gradient(circle at 80% 18%, #5d8a4577 0 8%, transparent 18%),
    conic-gradient(from 200deg, #bfe6d2, #5f9c84 20%, #22463a 40%, #8fc4ad 58%, #2f5a4a 78%, #bfe6d2);
  --node-core: radial-gradient(circle at 42% 34%, #4a5a54, #1d2724 60%, #0b100f);
  --node-ink: #e8fff6;
  --node-glow: #5fc9a8;
  --path-color: #b4eedb;
  --path-width: 3px;
  --path-dash: 1 13;
  --path-trim: #5fc9a824;
  --path-trim-width: 12px;
  --path-done: #9ff0d4;
}
/* Temple : argent, lapis et violet, une constellation. */
.stages-screen[data-realm="temple"] {
  --node-ring: conic-gradient(from 210deg, #ffffff, #b5bdd2 18%, #4a4f66 38%, #e4e8f4 56%, #6a7088 78%, #ffffff);
  --node-core:
    radial-gradient(circle at 70% 28%, #fff 0 1px, transparent 1.8px),
    radial-gradient(circle at 26% 66%, #e7deff 0 0.8px, transparent 1.5px),
    radial-gradient(circle at 60% 78%, #cfc2ff 0 0.7px, transparent 1.3px),
    radial-gradient(circle at 42% 34%, #4c3e8a, #221a4a 60%, #0c0a1c);
  --node-ink: #f6f2ff;
  --node-glow: #b69cf0;
  --path-color: #ece6ff;
  --path-width: 3.5px;
  --path-dash: 0 15;
  --path-trim: #c9b8ffcc;
  --path-trim-width: 7px;
  --path-trim-dash: 0 45;
  --path-done: #e2d8ff;
}
/* Fond qui respire : basalte et pulsations turquoise. */
.stages-screen[data-realm="dungeon"] {
  --node-ring:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cg fill='%23d6cbc3' stroke='%23140f0d' stroke-width='.8'%3E%3Ccircle cx='92.7' cy='67.7' r='2.6'/%3E%3Ccircle cx='67.7' cy='92.7' r='2.6'/%3E%3Ccircle cx='32.3' cy='92.7' r='2.6'/%3E%3Ccircle cx='7.3' cy='67.7' r='2.6'/%3E%3Ccircle cx='7.3' cy='32.3' r='2.6'/%3E%3Ccircle cx='32.3' cy='7.3' r='2.6'/%3E%3Ccircle cx='67.7' cy='7.3' r='2.6'/%3E%3Ccircle cx='92.7' cy='32.3' r='2.6'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat,
    conic-gradient(from 210deg, #9a908a, #41494a 18%, #161211 38%, #6e787a 56%, #23292a 78%, #9a908a);
  --node-core:
    radial-gradient(circle at 50% 60%, #8afff040, transparent 62%),
    radial-gradient(circle at 42% 34%, #25525a, #11262a 60%, #120605);
  --node-ink: #e8fffc;
  --node-glow: #94fff1;
  --path-color: #7a8a88;
  --path-width: 4px;
  --path-dash: 8 5;
  --path-trim: #8afff050;
  --path-trim-width: 11px;
  --path-done: #9ffff2;
}

/* ---- Le dock : retour, les cinq sceaux et la fiche du stage ------------------------ */
.realm-dock {
  position: relative;
  z-index: 3;
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(10px, 2vw, 28px);
  width: min(1480px, calc(100% - 24px));
  margin: 0 auto;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  border: 12px solid transparent;
  border-bottom: 0;
  border-image: var(--frame-src) 24 24 0 24 / 12px 12px 0 12px var(--frame-repeat);
  background: var(--panel) padding-box;
  box-shadow:
    0 -8px 28px #0008,
    var(--panel-glow);
}
.dock-back {
  justify-self: start;
}
.dock-seals {
  gap: clamp(8px, 1.4vw, 20px);
}
.dock-seals .realm-seal {
  --size: clamp(34px, 5.2vh, 48px);
}
.dock-seals .realm-seal-name {
  display: none;
}
.dock-seals .realm-seal.active {
  transform: translateY(-4px) scale(1.12);
}
.realm-dock .stage-caption {
  justify-self: end;
  display: grid;
  gap: 1px;
  min-width: 0;
  width: min(100%, 340px);
  padding: 3px 12px;
  border: 7px solid transparent;
  border-image: var(--plate-src) 8 fill / 7px stretch;
  font: 15px/1.3 var(--serif);
  color: var(--detail);
  text-shadow: 0 1px 2px #000;
}
.realm-dock .stage-caption strong {
  font: 600 14px/1.3 var(--display);
  color: var(--title);
}
@media (min-width: 1100px) and (min-height: 760px) {
  .dock-seals .realm-seal-name {
    display: block;
  }
}
@media (max-width: 900px) {
  .dock-back span {
    display: none;
  }
}

/* ---- Le grimoire : les familles rencontrées, en pages -------------------------------
   L'écran ne défile jamais : les familles d'un lieu se répartissent en pages
   que l'on tourne (‹ ›, flèches, glissé au doigt). Une famille pas encore
   rencontrée n'y figure pas. */
.grimoire-screen {
  --icon: clamp(40px, min(7.4vh, 6.2vw), 84px);
  height: 100dvh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #050707;
  padding-top: env(safe-area-inset-top);
}
.grimoire-screen .storage-warning {
  position: relative;
  z-index: 3;
  flex: none;
}
.grimoire-book {
  position: relative;
  z-index: 2;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: min(1480px, calc(100% - 24px));
  margin: clamp(8px, 2vh, 22px) auto clamp(8px, 1.6vh, 16px);
  padding: clamp(8px, 1.8vh, 20px) clamp(12px, 2vw, 28px);
  border: 12px solid transparent;
  border-image: var(--frame-src) 24 / 12px var(--frame-repeat);
  background: var(--panel) padding-box;
  box-shadow:
    0 12px 30px #000a,
    var(--panel-glow);
  touch-action: pinch-zoom;
}
.grimoire-head {
  flex: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px clamp(14px, 2.4vw, 36px);
  padding-bottom: clamp(6px, 1.4vh, 14px);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.grimoire-title .eyebrow {
  color: var(--label);
}
.grimoire-title h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 0;
  font-size: clamp(24px, 4.4vh, 40px);
  line-height: 1.05;
  white-space: nowrap;
  color: var(--title);
  text-shadow:
    0 0 18px color-mix(in srgb, var(--accent) 35%, transparent),
    0 3px 10px #000;
}
.grimoire-lede {
  max-width: 620px;
  font: 15px/1.5 var(--serif);
  color: var(--detail);
}
.grimoire-stats {
  font: 600 12px var(--display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--value);
}
.grimoire-stats .num {
  font-family: var(--display);
}
.grimoire-leaves {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  margin-top: clamp(8px, 1.8vh, 18px);
  overflow: clip;
}
.grimoire-page {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--icon) * 3 + 110px)), 1fr));
  grid-auto-rows: var(--card-h, auto);
  align-content: start;
  gap: clamp(8px, 1.6vh, 16px) clamp(10px, 1.4vw, 18px);
}
.grimoire-empty {
  margin: clamp(12px, 6vh, 60px) auto 0;
  max-width: 460px;
  text-align: center;
  font: italic 16px/1.5 var(--serif);
  color: var(--detail);
}
.grimoire-screen .family-entry {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.1vh, 12px);
  min-width: 0;
  padding: clamp(8px, 1.4vh, 14px) clamp(10px, 1vw, 16px);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 13%, transparent), #0c1314c9);
  box-shadow:
    inset 0 1px #c1fff710,
    0 6px 18px #0005;
}
.grimoire-screen .family-entry.mastered {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow:
    inset 0 1px #c1fff718,
    0 0 18px #8ed9cf22,
    0 6px 18px #0005;
}
.family-entry h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  min-width: 0;
  font-size: clamp(15px, 2.1vh, 19px);
  color: var(--title);
}
.family-entry h3 small {
  flex: none;
  font: 600 12px var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--label);
}
.mastered-seal {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--value);
}
.mastered-seal svg.glyph {
  width: 14px;
  height: 14px;
}
.family-objects {
  display: flex;
  gap: 8px;
}
.family-object {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.family-object-art {
  position: relative;
  display: block;
  width: var(--icon);
  margin: 0 auto 6px;
}
.family-object-art .artifact-icon {
  display: block;
  width: var(--icon);
  height: var(--icon);
  margin: 0;
  background: radial-gradient(ellipse, #3e6b7355, #101718f2);
  border: 1px solid #60a49b5c;
  box-shadow: inset 0 0 9px #0007;
}
.family-object-art .variant-glyph {
  left: 4px;
  bottom: 4px;
}
.family-object small {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font: 14px/1.3 var(--serif);
  color: var(--detail);
}
/* The dock: back, the seals of the open realms, the pages. */
.grimoire-dock .book-pager {
  justify-self: end;
}
.grimoire-dock .book-pager[hidden] {
  display: none;
}
.dock-seals .realm-seal:disabled {
  cursor: default;
  transform: none;
}
@media (max-width: 1100px) {
  .grimoire-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .grimoire-lede {
    grid-row: 2;
    grid-column: 1 / -1;
  }
}
@media (max-height: 719px) {
  .grimoire-lede {
    display: none;
  }
}
@media (max-width: 520px) {
  .grimoire-head {
    grid-template-columns: minmax(0, 1fr);
  }
  .grimoire-stats {
    white-space: normal;
  }
  .grimoire-lede {
    display: none;
  }
}
/* Upright, the pages come under the seals. */
@media (orientation: portrait) {
  .grimoire-dock .book-pager {
    grid-column: 1 / -1;
    justify-self: center;
  }
}
/* A phone held sideways: one line of title, cards laid flat. */
@media (max-height: 540px) and (orientation: landscape) {
  .stage-node-cup,
  .stage-node-lock {
    width: 28px;
    height: 28px;
  }
  .stage-node-cup svg,
  .stage-node-lock svg {
    width: 19px;
    height: 19px;
  }
  .grimoire-screen {
    --icon: 40px;
  }
  .grimoire-book {
    margin: 6px auto;
    padding: 4px 10px 6px;
    border-width: 9px;
    border-image-width: 9px;
  }
  .grimoire-head {
    align-items: center;
    padding-bottom: 4px;
  }
  .grimoire-title .eyebrow {
    display: none;
  }
  .grimoire-title h1 {
    margin: 0;
    font-size: 22px;
  }
  .grimoire-leaves {
    margin-top: 6px;
  }
  .grimoire-page {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
    gap: 6px 10px;
  }
  .grimoire-screen .family-entry {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 5px 8px 5px 12px;
  }
  .family-entry h3 {
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 15px;
  }
  .family-entry h3 small {
    font-size: 12px;
  }
  .family-objects {
    flex: none;
    gap: 6px;
  }
  .family-object {
    flex: none;
  }
  .family-object-art {
    margin: 0;
  }
  .family-object small {
    display: none;
  }
}

/* ---- Écrans moyens : la devise suffit --------------------------------------------- */
@media (max-height: 719px) {
  .realm-description,
  .realm-cartouche .realm-total {
    display: none;
  }
}
@media (max-width: 899px) and (orientation: landscape) {
  .stage-node-name {
    display: none;
  }
}

/* ---- Écrans bas (téléphone en paysage) : noms dans la fiche ------------------------ */
@media (max-height: 540px) and (orientation: landscape) {
  .stage-node-cup,
  .stage-node-lock {
    width: 28px;
    height: 28px;
  }
  .stage-node-cup svg,
  .stage-node-lock svg {
    width: 19px;
    height: 19px;
  }
  .stages-screen {
    --node: clamp(32px, 11vh, 44px);
  }
  .stage-node-name,
  .realm-motto {
    display: none;
  }
  .realm-cartouche {
    top: 8px;
    width: min(290px, 34vw);
    padding: 3px 10px 5px;
    border-width: 9px;
    border-image-width: 9px;
  }
  .realm-cartouche .realm-total,
  .realm-cartouche .realm-stat-word {
    display: none;
  }
  .realm-stats {
    flex-wrap: nowrap;
    white-space: nowrap;
  }
  .realm-cartouche h1 {
    margin: 2px 0 0;
    font-size: 22px;
  }
  .realm-stats {
    margin-top: 4px;
    padding-top: 4px;
    gap: 2px 10px;
  }
  .realm-dock {
    grid-template-columns: auto auto minmax(0, 1fr);
    padding: 3px 10px calc(3px + env(safe-area-inset-bottom));
    border-width: 9px 9px 0;
    border-image-width: 9px 9px 0 9px;
  }
  .realm-dock .stage-caption {
    width: min(100%, 420px);
  }
  .dock-seals .realm-seal {
    --size: 30px;
  }
  .realm-dock .stage-caption {
    display: block;
    padding: 1px 10px;
    font-size: 13px;
  }
  .realm-dock .stage-caption strong {
    display: block;
    font-size: 13px;
  }
  .realm-dock .stage-caption span + span::before {
    content: " · ";
  }
  .stage-pennant {
    width: 24px;
    height: 24px;
  }
}

@media (max-height: 400px) and (orientation: landscape) {
  .realm-cartouche .eyebrow,
  .stage-pennant {
    display: none;
  }
}

/* ---- Portrait : le chemin serpente vers le haut ------------------------------------ */
@media (orientation: portrait) {
  .stages-screen {
    --node: clamp(40px, 5.2vh, 60px);
  }
  .realm-scene {
    display: flex;
    flex-direction: column;
  }
  .realm-cartouche {
    position: relative;
    left: auto;
    top: auto;
    flex: none;
    width: auto;
    margin: 10px 12px 0;
  }
  .realm-journey {
    position: relative;
    inset: auto;
    flex: 1 1 auto;
    min-height: 0;
  }
  .stage-stop {
    left: var(--tx);
    top: var(--ty);
    width: 136px;
  }
  .stage-node-name {
    max-width: 132px;
  }
  .stage-stop:first-child .stage-node-name {
    position: absolute;
    left: calc(50% + var(--node) / 2 + 8px);
    top: 0;
    width: 132px;
  }
  /* Upright, the pennant flies on the outer side of its medallion. */
  .stage-pennant {
    bottom: auto;
    top: calc(var(--node) / 2);
    left: auto;
    right: calc(50% + var(--node) / 2 + 10px);
    translate: 0 -50%;
  }
  .stage-stop.east .stage-pennant {
    right: auto;
    left: calc(50% + var(--node) / 2 + 10px);
  }
  .stage-pennant::after {
    display: none;
  }
  .realm-dock {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 6px;
  }
  .dock-seals {
    justify-self: center;
  }
  .realm-dock .stage-caption {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: auto;
  }
}
@media (orientation: portrait) and (max-width: 600px) {
  .realm-description {
    display: none;
  }
  .realm-cartouche .realm-total {
    display: none;
  }
  .realm-dock .stage-caption {
    padding: 1px 10px;
    font-size: 14px;
  }
  .realm-dock .stage-caption span + span::before {
    content: " · ";
  }
  .realm-dock .stage-caption {
    display: block;
  }
  .realm-dock .stage-caption strong {
    display: block;
  }
  .realm-cartouche {
    padding: 4px 10px 6px;
    border-width: 9px;
    border-image-width: 9px;
  }
  .realm-cartouche h1 {
    font-size: 24px;
  }
  .realm-motto {
    font-size: 15px;
  }
  .dock-seals .realm-seal {
    --size: 34px;
  }
  .dock-seals {
    gap: 8px;
  }
}

/* ---- Le flash d'un stage qui s'ouvre ------------------------------------------------ */
.portal-flash {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  overflow: hidden;
}
.portal-flash::before {
  content: "";
  position: absolute;
  left: var(--fx);
  top: var(--fy);
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  background: radial-gradient(circle, #fffdf4 0, var(--flash) 30%, color-mix(in srgb, var(--flash) 35%, transparent) 55%, transparent 72%);
  opacity: 0;
}
.portal-flash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--fx) var(--fy), color-mix(in srgb, var(--flash) 55%, #fff) 0, color-mix(in srgb, var(--flash) 30%, transparent) 40%, transparent 85%);
  opacity: 0;
}
/* A phone upright and small: the stops are close, their names live in the
   caption at the foot of the map. */
@media (orientation: portrait) and (max-height: 799px), (orientation: portrait) and (max-width: 600px) {
  .stage-node-name {
    display: none;
  }
}

/* ---- Le tutoriel : six chapitres, puis le film par-dessus le menu --------- */
.tutorial-chapters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tutorial-chapter {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 2.2em auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 10px;
  text-align: left;
  color: var(--text);
  background: linear-gradient(#172224e6, #0d1415e6);
  border: var(--frame-border);
  border-radius: 4px;
  box-shadow: var(--frame-inset);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.tutorial-chapter:hover,
.tutorial-chapter:focus-visible {
  border-color: var(--gold-bright);
  box-shadow: var(--frame-inset), 0 0 18px #adfff444;
  transform: translateY(-1px);
}
.tutorial-chapter-numeral {
  font: 600 15px var(--display);
  letter-spacing: 0.06em;
  text-align: center;
  color: var(--gold);
}
.tutorial-chapter .tile-plaque,
.tutorial-chapter .tile-medallion,
.tutorial-chapter .tile-copper,
.tutorial-chapter .tile-bare {
  width: 44px;
  height: 44px;
}
.tutorial-chapter-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.tutorial-chapter-text strong {
  font: 600 14px var(--display);
  letter-spacing: 0.08em;
  color: #c4f0ea;
}
.tutorial-chapter-text small {
  font: 14px / 1.3 var(--serif);
  color: var(--muted);
}
.tutorial-chapter-time {
  font-size: 14px;
  color: var(--faint);
}
@media (max-width: 640px) {
  .tutorial-chapters {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .tutorial-chapter {
    grid-template-columns: 1.5em 32px minmax(0, 1fr) auto;
    gap: 3px 6px;
    padding: 7px 8px;
  }
  .tutorial-chapter-text { display: contents; }
  .tutorial-chapter-text strong { grid-column: 3; grid-row: 1; }
  .tutorial-chapter-text small { grid-column: 3 / -1; grid-row: 2; }
  .tutorial-chapter-time { grid-column: 4; grid-row: 1; }
  .tutorial-chapter-numeral { grid-column: 1; grid-row: 1 / span 2; }
  .tutorial-chapter > .tile-plaque,
  .tutorial-chapter > .tile-medallion,
  .tutorial-chapter > .tile-copper,
  .tutorial-chapter > .tile-bare {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 32px;
    height: 32px;
  }
}
@media (max-height: 540px) {
  .tutorial-chapters {
    gap: 6px;
  }
  .tutorial-chapter {
    padding: 4px 12px 4px 8px;
  }
  .tutorial-chapter-text small {
    display: none;
  }
  .tutorial-chapter .tile-plaque,
  .tutorial-chapter .tile-medallion,
  .tutorial-chapter .tile-copper,
  .tutorial-chapter .tile-bare {
    width: 36px;
    height: 36px;
  }
}
/* The film fills the window; it shows once it says it is ready. */
.theatre {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: #030505;
  animation: fade-in 0.3s ease-out both;
}
.theatre::before {
  content: "✧";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 34px;
  color: var(--gold-bright);
  text-shadow: 0 0 24px #a4fff3;
  animation: theatre-wait 1.2s ease-in-out infinite alternate;
}
.theatre-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #030505;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.theatre.ready .theatre-frame {
  opacity: 1;
}
@keyframes theatre-wait {
  from { opacity: 0.35; transform: translate(-50%, -50%) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

/* The bathymetric path descends continuously within each of the five strata. */
.stage-stop { width:var(--node); }
.stage-node-name { position:absolute; right:calc(100% + 12px); top:0; width:clamp(100px,15vw,220px); max-width:none; text-align:right; font-size:14px; line-height:1.15; }
.stage-stop:nth-child(even) .stage-node-name { right:auto; left:calc(100% + 12px); text-align:left; }
.stage-depth { position:absolute; right:calc(100% + 12px); top:calc(var(--node) * .64); white-space:nowrap; font-size:14px; color:#b4e4df; text-shadow:0 2px 4px #000; }
.stage-stop:nth-child(even) .stage-depth { right:auto; left:calc(100% + 12px); }
.stage-depth b { display:inline-block; margin-left:5px; font:10px var(--display); color:#e8dbc0; }
.stage-node.encounter-mini { border-radius:35% 35% 50% 50%; box-shadow:0 0 0 2px #b5b28199,0 0 17px #50babb44; }
.stage-node.encounter-boss { border-radius:23%; box-shadow:0 0 0 2px #d2c48b,0 0 23px #54d8c966; }
.encounter-boss .stage-node-number::after { content:"♜"; position:absolute; top:-13px; left:50%; translate:-50% 0; font-size:12px; color:#e6d4a3; }
.stages-screen[data-enter="next"] .realm-journey { animation:abyss-descend .55s ease both; }
.stages-screen[data-enter="prev"] .realm-journey { animation:abyss-rise .55s ease both; }
@keyframes abyss-descend { from { opacity:0; transform:translateY(28px); } to { opacity:1; transform:none; } }
@keyframes abyss-rise { from { opacity:0; transform:translateY(-28px); } to { opacity:1; transform:none; } }
@media (orientation:portrait) {
  .stage-stop { width:var(--node); }
  .stage-node-name, .stage-stop:first-child .stage-node-name { display:none; }
  .stage-depth { right:calc(100% + 7px); top:calc(var(--node) * .3); font-size:13px; }
  .stage-stop:nth-child(even) .stage-depth { left:calc(100% + 7px); }
  .stage-depth b { display:block; margin:2px 0 0; text-align:center; }
}
@media (max-height:540px) and (orientation:landscape) {
  .stage-depth { top:calc(var(--node) * .24); font-size:13px; }
  .stage-depth b { font-size:9px; }
}
@media (prefers-reduced-motion:reduce) {
  .stages-screen .realm-journey { animation:none !important; }
}

@media (max-width:1200px) and (orientation:landscape) { .stage-node-name { display:none; } }

@media (max-height:540px) and (orientation:landscape) { .stage-pennant { display:none; } }
