@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%, #71789c55);
}
@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, #090b1eeb, #121531c9 75%, #070818d9);
    border-bottom: 3px double #71789c88;
    box-shadow: 0 4px 24px #00000066;
  }
  .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: #f0d8ab; }
.realm-seal[data-realm="castle"] { --seal: #8fb4ff; }
.realm-seal[data-realm="crypt"] { --seal: #abcaf1; }
.realm-seal[data-realm="temple"] { --seal: #b69cf0; }
.realm-seal[data-realm="dungeon"] { --seal: #ffe5b4; }
.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: #e8d1a6;
  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%), #737a9e55 0);
  transition: filter 0.25s ease;
}
.realm-seal .realm-seal-illustration {
  width: var(--size);
  height: var(--size);
  filter: drop-shadow(0 3px 5px #000000cc);
  transition: filter 0.25s ease;
}
.realm-seal-name {
  font: 600 12px/1.2 var(--display);
  letter-spacing: 0.025em;
  white-space: normal;
  text-align: center;
  max-width: 150px;
  overflow-wrap: anywhere;
  text-shadow: 0 1px 3px #000000, 0 0 10px #000000;
}
.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: #080a1c;
  border: 1.5px solid #595f7a;
}
.realm-seal-lock svg {
  width: 13px;
  height: 13px;
}
.realm-seal.locked .realm-seal-illustration {
  filter: saturate(.72) brightness(.78) drop-shadow(0 3px 5px #000000cc);
}
.realm-seal:hover,
.realm-seal:focus-visible {
  transform: translateY(-3px);
  color: #ffe5b4;
}
.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 #000000cc) 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;
  width: min(58%, 930px);
  margin-left: 3vw;
  padding: clamp(6px, 2.6vh, 36px) 24px clamp(6px, 2vh, 28px);
  align-items: flex-start;
  text-align: left;
}
.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);
  width: 100%;
  justify-content: flex-start;
}
.home-seals .realm-seal {
  --size: clamp(42px, min(7.6vh, 12vw), 70px);
  min-width: calc(var(--size) + 12px);
  padding-top: 0;
  flex: 1 1 0;
  min-width: 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 #000000cc) 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: #ffe5b4; }
.home[data-portal="castle"] { --portal: #6f98ff; }
.home[data-portal="crypt"] { --portal: #abcaf1; }
.home[data-portal="temple"] { --portal: #b292ff; }
.home[data-portal="dungeon"] { --portal: #c297f2; }
.portal-glow {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle min(34vw, 48vh) at 73% 47%,
    color-mix(in srgb, var(--portal, #ffe5b4) 30%, transparent),
    color-mix(in srgb, var(--portal, #ffe5b4) 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: flex-start;
  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 .home-main { width: 100%; margin-left: 0; align-items: center; text-align: center; background: linear-gradient(90deg, #070b2199, #070b2122); }
  .home-seals, .home .journey-progress { justify-content: center; }
  .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%;
    min-width: 0;
    padding: 8px 10px;
    white-space: normal;
    line-height: 1.35;
  }
}
@media (min-width: 641px) and (max-width: 1050px) {
  .home .home-main { width: 66%; margin-left: 0; padding-inline: 22px; }
  .home .home-primary-actions { flex-direction: column; align-items: stretch; }
}
@media (min-width: 641px) and (max-height: 520px) {
  .home .home-main { width: 78%; margin-left: 0; }
  .home .home-primary-actions { flex-direction: row; }
}
@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;
  }
}

@media (orientation: portrait) {
  .home .home-main {
    width: 100%;
    margin-left: 0;
    align-items: center;
    text-align: center;
    background: linear-gradient(90deg, #070b2155, #070b2199, #070b2155);
  }
  .home-seals,
  .home .journey-progress { justify-content: center; }
  .home .home-nav { flex-wrap: wrap; gap: 10px; }
  .home .home-nav .button { flex: 1 1 40%; min-width: 0; padding-inline: 12px; }
}

/* ---- 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: #030411;
  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%, #03041194 100%),
    linear-gradient(180deg, #03041180 0%, #03041100 24%, #03041100 68%, #030411b8 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(500px, 38vw);
  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 #000000aa,
    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(21px, 2.7vh, 29px);
  line-height: 1.12;
  color: var(--title);
  text-shadow:
    0 0 18px color-mix(in srgb, var(--accent) 35%, transparent),
    0 3px 10px #000000;
}
.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 #000000);
}
.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: #ffffff;
  stroke-width: 80px;
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
}
.realm-path-shadow {
  stroke: #000000;
  stroke-opacity: 0.3;
  stroke-width: 4px;
}
.realm-path-trim {
  stroke: var(--path-trim, transparent);
  stroke-width: 0;
  stroke-dasharray: var(--path-trim-dash, none);
}
.realm-path-line {
  stroke: var(--path-color);
  stroke-opacity: 0.85;
  stroke-width: 1.4px;
  stroke-dasharray: none;
}
.realm-path-done {
  stroke: var(--path-done);
  stroke-width: 2px;
  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: #a1c4ff;
}

/* ---- 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 #000000cc,
    0 7px 16px #000000dd,
    inset 0 0 12px #000000bb;
  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%, #ffffff88 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 #000000;
}
.stage-node.done {
  box-shadow:
    0 0 0 1.5px #000000cc,
    0 7px 16px #000000dd,
    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 #000000cc,
    0 7px 16px #000000dd,
    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: none;
  box-shadow:
    0 0 0 1.5px #000000cc,
    0 0 28px var(--node-glow),
    0 12px 18px #000000dd,
    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: #0a0c20;
  border: 1.5px solid #595f7a;
  box-shadow: 0 2px 4px #000000aa;
}
.stage-node-cup svg,
.stage-node-lock svg {
  width: 22px;
  height: 22px;
}
.stage-node.gold .stage-node-cup {
  border-color: #ffe5b4;
}
.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: #e0caa1;
}
.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: #050614c9;
  border-radius: 3px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 28%, transparent);
  text-shadow: 0 1px 2px #000000;
}
.stage-stop:has(.locked) .stage-node-name {
  color: #b7bfdc;
  box-shadow: 0 0 0 1px #8292bf33;
}
/* 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 and a small orbital emblem
   beside the medallion, clear of the realm title panel. */
.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: auto;
  top: calc(var(--node) / 2);
  left: calc(50% + var(--node) / 2 + 12px);
  z-index: 1;
  width: calc(var(--node) * 0.62);
  height: calc(var(--node) * 0.62);
  translate: 0 -50%;
  pointer-events: none;
  filter: drop-shadow(0 0 8px var(--node-glow)) drop-shadow(0 3px 3px #000000);
}
.stage-pennant::after {
  content: none;
  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));
}

@media (orientation: landscape) {
  .stage-stop:last-child .stage-pennant {
    left: auto;
    right: calc(50% + var(--node) / 2 + 12px);
  }
}

/* Aube sidérale : verre nocturne et poussière d’or sur les orbites. */
.stages-screen[data-realm="village"] {
  --node-ring:
    repeating-linear-gradient(35deg, #00000000 0 3px, #171c3e1a 3px 5px),
    conic-gradient(from 210deg, #f7deaf, #c2b08e 18%, #2e3872 36%, #dcc69e 55%, #5b617d 76%, #f7deaf);
  --node-core: radial-gradient(circle at 42% 34%, #323c7b, #141735 62%, #080a1c);
  --node-ink: #ffe5b4;
  --node-glow: #f0d8ab;
  --path-color: #e8d1a6;
  --path-width: 3.5px;
  --path-dash: 11 6;
  --path-trim: #181c3f;
  --path-trim-width: 7px;
  --path-trim-dash: 11 6;
  --path-done: #ffe5b4;
}
/* Anneaux du Serment : or stellaire et marbre indigo. */
.stages-screen[data-realm="castle"] {
  --node-ring: conic-gradient(from 210deg, #ffe5b4, #d9c49d 18%, #242b5a 38%, #f0d8ab 56%, #585e79 78%, #ffe5b4);
  --node-core: radial-gradient(circle at 42% 34%, #36549a, #1c2148 60%, #0b0d21);
  --node-ink: #ffe5b4;
  --node-glow: #8fb4ff;
  --path-color: #e6cfa5;
  --path-width: 3.2px;
  --path-dash: 1 10;
  --path-done: #ffe5b4;
}
/* Reliquaire des Lunes : argent opalin et reflets de marée bleue. */
.stages-screen[data-realm="crypt"] {
  --node-ring:
    radial-gradient(circle at 24% 80%, #abcaf166 0 12%, transparent 26%),
    radial-gradient(circle at 80% 18%, #e8edff44 0 8%, transparent 18%),
    conic-gradient(from 200deg, #91b1e6, #8aa8d5 20%, #262d5f 40%, #d8e3ff 58%, #313b78 78%, #91b1e6);
  --node-core: radial-gradient(circle at 42% 34%, #374286, #171c3e 60%, #090b1e);
  --node-ink: #edf4ff;
  --node-glow: #abcaf1;
  --path-color: #c9ddff;
  --path-width: 3px;
  --path-dash: 1 13;
  --path-trim: #abcaf124;
  --path-trim-width: 12px;
  --path-done: #e8edff;
}
/* Zodiaque intérieur : argent, lapis et violet, une constellation. */
.stages-screen[data-realm="temple"] {
  --node-ring: conic-gradient(from 210deg, #ffffff, #b5bdd2 18%, #364185 38%, #e4e8f4 56%, #6a7088 78%, #ffffff);
  --node-core:
    radial-gradient(circle at 70% 28%, #ffffff 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, #1a1f44 60%, #0a0c1f);
  --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;
}
/* Constellations vivantes : obsidienne violette et membranes d’aurore. */
.stages-screen[data-realm="dungeon"] {
  --node-ring:
    radial-gradient(circle at 50% 5%, #e8edff 0 1.5px, transparent 2px),
    radial-gradient(circle at 95% 50%, #e8edff 0 1.5px, transparent 2px),
    radial-gradient(circle at 50% 95%, #e8edff 0 1.5px, transparent 2px),
    radial-gradient(circle at 5% 50%, #e8edff 0 1.5px, transparent 2px),
    conic-gradient(from 210deg, #bd9fea, #544076 18%, #15122c 38%, #d8c8f2 56%, #362653 78%, #bd9fea);
  --node-core:
    radial-gradient(circle at 50% 60%, #ad7cec44, transparent 62%),
    radial-gradient(circle at 42% 34%, #30224b, #140e2d 60%, #070719);
  --node-ink: #ede4ff;
  --node-glow: #c297f2;
  --path-color: #c6afd9;
  --path-width: 4px;
  --path-dash: 8 5;
  --path-trim: #ad7cec50;
  --path-trim-width: 11px;
  --path-done: #e8d9ff;
}

/* ---- 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 #00000088,
    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 #000000;
}
.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: #030411;
  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 #000000aa,
    var(--panel-glow);
  touch-action: pinch-zoom;
}
.grimoire-head {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) 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 { min-width: 0; }
.grimoire-title .eyebrow {
  color: var(--label);
}
.grimoire-title h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 0;
  font-size: clamp(20px, 2.9vh, 30px);
  line-height: 1.12;
  white-space: normal;
  text-wrap: balance;
  color: var(--title);
  text-shadow:
    0 0 18px color-mix(in srgb, var(--accent) 35%, transparent),
    0 3px 10px #000000;
}
.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), #090b1ec9);
  box-shadow:
    inset 0 1px #ffe5b410,
    0 6px 18px #00000055;
}
.grimoire-screen .family-entry.mastered {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow:
    inset 0 1px #ffe5b418,
    0 0 18px #d9c49d22,
    0 6px 18px #00000055;
}
.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);
  overflow-wrap: anywhere;
  color: var(--title);
}
.family-entry h3 small {
  flex: none;
  white-space: nowrap;
  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, #343f8055, #0c0f25f2);
  border: 1px solid #6970905c;
  box-shadow: inset 0 0 9px #00000077;
}
.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%, 300px), 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 (min-width: 900px) and (max-width: 1100px) and (orientation: landscape) {
  .stage-node-name { max-width: 112px; padding-inline: 5px; letter-spacing: .02em; }
}
@media (max-width: 899px) and (orientation: landscape) {
  .stage-node-name {
    display: none;
  }
}

@media (max-width: 1300px) and (orientation: landscape) {
  .realm-description { 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(350px, 42vw);
    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: clamp(14px, 4.1vh, 19px);
  }
  .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,
  .realm-cartouche .realm-stats,
  .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,
  .stage-stop:first-child .stage-node-name {
    position: absolute;
    right: calc(50% + var(--node) / 2 + 12px);
    left: auto;
    top: calc(var(--node) / 2);
    transform: translateY(-50%);
    width: 142px;
    max-width: 142px;
  }
  .stage-stop.east .stage-node-name {
    left: calc(50% + var(--node) / 2 + 12px);
    right: auto;
  }
  /* Upright, the emblem faces the constellation while the title stays outside. */
  .stage-pennant {
    bottom: auto;
    top: calc(var(--node) / 2);
    right: auto;
    left: calc(50% + var(--node) / 2 + 10px);
    translate: 0 -50%;
  }
  .stage-stop.east .stage-pennant {
    left: auto;
    right: 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%, #ffffff) 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(#121531e6, #0a0c20e6);
  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 #ffe5b444;
  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: #f0d8ab;
}
.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: #02030e;
  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 #ffe5b4;
  animation: theatre-wait 1.2s ease-in-out infinite alternate;
}
.theatre-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #02030e;
  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); }
}
