@charset "UTF-8";
/* Écran de jeu : HUD, plateau, sac, ressources, effets et mises en page.
   Trois plans de valeur : le décor, flouté et assombri ; le plateau, sombre ;
   les objets sur leurs plaques, la surface la plus claire. */

/* ---- Identité des lieux ------------------------------------------------------
   La grammaire du jeu ne change jamais (plaque carrée = payant, médaillon rond =
   gratuit, or = pièces et score, cramoisi = danger). Chaque lieu redéfinit ses
   matières et son accent au travers de ces variables. La carte des stages et
   le grimoire (.page) reçoivent exactement les mêmes. */
.game-page,
.page {
  --frame-src: url("../assets/ui/frame.svg");
  --frame-repeat: stretch;
  --plate-src: url("../assets/ui/plate.svg");
  --panel: linear-gradient(90deg, #111d1ff2, #182b2eee 48%, #111d1ff2);
  --panel-glow: none;
  --button-bg: linear-gradient(135deg, #23373bf2, #101a1cf2);
  --button-bg-hover: linear-gradient(135deg, #335257f2, #17272af2);
  --board-bg: #090c0d;
  --accent: #9ce3da;
  --label: #b9dcd7;
  --title: #d4f6f1;
  --value: #cffff9;
  --detail: #aecdc9;
  --gauge: linear-gradient(90deg, #468a81, #bef7f0);
  --kbd-bg: linear-gradient(#cbf3ee, #7eb8b0);
  --slot-bg: radial-gradient(ellipse at 50% 100%, #466f7666, #11191be8), var(--basalt);
  --slot-border: #7db2ab66;
  --slot-filled-bg: radial-gradient(ellipse, #3b717a4d, #10191b);
  --slot-filled-border: #97d5cd;
}
/* Les Jardins suspendus : nacre, pierre marine et reflets de surface. */
.game-page[data-realm="village"],
.page[data-realm="village"] {
  --frame-src: url("../assets/ui/frame-village.svg");
  --plate-src: url("../assets/ui/plate-village.svg");
  --panel:
    repeating-linear-gradient(0deg, rgba(203, 255, 248, 0.025) 0 1px, transparent 1px 5px),
    linear-gradient(90deg, #18292cf2, #20393dee 48%, #18292cf2);
  --panel-glow: inset 0 -14px 16px -14px rgba(175, 255, 244, 0.35);
  --button-bg: linear-gradient(160deg, #2c454af2, #112022f2);
  --button-bg-hover: linear-gradient(160deg, #395b61f2, #182b2ef2);
  --board-bg: #040708;
  --accent: #91e8dd;
  --label: #afede5;
  --title: #ddfdf9;
  --value: #e6fffc;
  --detail: #b2d9d4;
  --gauge: linear-gradient(90deg, #449a8f, #b6fff5);
  --slot-bg: radial-gradient(ellipse at 50% 100%, #4d8a8255, #101c1ee8), linear-gradient(#20363a, #0e181a);
  --slot-border: #5c9a9266;
  --slot-filled-bg: radial-gradient(ellipse at 50% 100%, rgba(175, 255, 244, 0.25), transparent 70%), linear-gradient(#2c454a, #101c1e);
  --slot-filled-border: #91e8ddaa;
}
/* La Route des Épaves : bronze patiné et bleu des courants. */
.game-page[data-realm="castle"],
.page[data-realm="castle"] {
  --frame-src: url("../assets/ui/frame-castle.svg");
  --plate-src: url("../assets/ui/plate-castle.svg");
  --panel:
    radial-gradient(ellipse 70% 120% at 50% 0, rgba(91, 143, 224, 0.12), transparent 70%),
    linear-gradient(90deg, #121a2ef2, #1b2644ee 48%, #121a2ef2);
  --panel-glow: inset 0 -14px 16px -14px rgba(120, 160, 240, 0.35);
  --button-bg: linear-gradient(160deg, #22304ff2, #0f1528f2);
  --button-bg-hover: linear-gradient(160deg, #2e4068f2, #151d36f2);
  --board-bg: #090b0b;
  --accent: #5b8fe0;
  --label: #abe6de;
  --title: #daf6f2;
  --value: #e3fffb;
  --detail: #b9c6e6;
  --gauge: linear-gradient(90deg, #2c4c96, #8fb4ff);
  --slot-bg: radial-gradient(ellipse at 50% 100%, rgba(91, 143, 224, 0.2), transparent 65%), linear-gradient(#17272a, #091112);
  --slot-border: #48727a66;
  --slot-filled-bg: radial-gradient(ellipse at 50% 100%, rgba(120, 160, 240, 0.28), transparent 70%), linear-gradient(#1a3135, #0b1315);
  --slot-filled-border: #8ed9cf;
}
/* La Nuit vivante : pierre sombre, vert-de-gris et bioluminescence. */
.game-page[data-realm="crypt"],
.page[data-realm="crypt"] {
  --kbd-bg: linear-gradient(#d8f0e4, #6f9a88);
  --frame-src: url("../assets/ui/frame-crypt.svg");
  --frame-repeat: round;
  --plate-src: url("../assets/ui/plate-crypt.svg");
  --panel:
    radial-gradient(ellipse 60% 140% at 50% 120%, rgba(95, 201, 168, 0.12), transparent 70%),
    linear-gradient(180deg, #1d2423f5, #141a19f5);
  --panel-glow: inset 0 -14px 16px -14px rgba(95, 201, 168, 0.4);
  --button-bg: linear-gradient(160deg, #36403df2, #171d1cf2);
  --button-bg-hover: linear-gradient(160deg, #46524ff2, #1e2625f2);
  --board-bg: #050807;
  --accent: #5fc9a8;
  --label: #8fd6be;
  --title: #dcf2ea;
  --value: #eefaf5;
  --detail: #a9c8bd;
  --gauge: linear-gradient(90deg, #2a7a62, #9ff0d4);
  --slot-bg: radial-gradient(ellipse at 50% 100%, rgba(95, 201, 168, 0.14), transparent 62%), linear-gradient(#2b3230, #121716);
  --slot-border: #52605a;
  --slot-filled-bg: radial-gradient(ellipse at 50% 100%, rgba(95, 201, 168, 0.28), transparent 70%), linear-gradient(#36403d, #161c1b);
  --slot-filled-border: #5fc9a8aa;
  --basalt: linear-gradient(160deg, #3d4643, #1d2322 50%, #2d3533);
}
/* Les Cathédrales de Sel : ardoise, argent et résonances violettes. */
.game-page[data-realm="temple"],
.page[data-realm="temple"] {
  --kbd-bg: linear-gradient(#f4f6fc, #9aa3b8);
  --frame-src: url("../assets/ui/frame-temple.svg");
  --plate-src: url("../assets/ui/plate-temple.svg");
  --panel:
    radial-gradient(ellipse 70% 120% at 50% 0, rgba(182, 156, 240, 0.12), transparent 70%),
    linear-gradient(90deg, #181827f2, #232238ee 48%, #181827f2);
  --panel-glow: inset 0 -14px 16px -14px rgba(182, 156, 240, 0.4);
  --button-bg: linear-gradient(160deg, #2f3144f2, #15161ff2);
  --button-bg-hover: linear-gradient(160deg, #3d405af2, #1c1d2af2);
  --board-bg: #07080c;
  --accent: #b69cf0;
  --label: #c8bcf2;
  --title: #eee8ff;
  --value: #f6f2ff;
  --detail: #b8b7d6;
  --gauge: linear-gradient(90deg, #6a52b8, #e2d8ff);
  --slot-bg: radial-gradient(ellipse at 50% 100%, rgba(182, 156, 240, 0.14), transparent 62%), linear-gradient(#262838, #10111a);
  --slot-border: #4f5268;
  --slot-filled-bg: radial-gradient(ellipse at 50% 100%, rgba(182, 156, 240, 0.28), transparent 70%), linear-gradient(#303348, #13141d);
  --slot-filled-border: #b69cf0aa;
  --basalt: linear-gradient(160deg, #383b4f, #1a1b26 50%, #2a2c3c);
}
/* Shared realm touches: the top bar, the carousel and the icons of the HUD. */
.game-page[data-realm] .game-location-name,
.page[data-realm] .game-location-name {
  color: var(--title);
}
.game-page[data-realm] .game-location-name small,
.page[data-realm] .game-location-name small {
  color: var(--label);
}
.game-page[data-realm] .realm-emblem-mini,
.page[data-realm] .realm-emblem-mini {
  filter: drop-shadow(0 0 6px var(--accent));
}

/* ---- Le Fond qui respire : les profondeurs vivantes ---------------------------------
   Basalte, nacre et lumière turquoise. Le cramoisi est
   réservé au danger. */
.game-page[data-realm="dungeon"],
.page[data-realm="dungeon"] {
  --kbd-bg: linear-gradient(#d6fffa, #7dc9bf);
  --frame-src: url("../assets/ui/frame-dungeon.svg");
  --frame-repeat: round;
  --plate-src: url("../assets/ui/plate-dungeon.svg");
  --panel:
    radial-gradient(ellipse 60% 140% at 50% 120%, rgba(138, 255, 240, 0.16), transparent 70%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 6px),
    linear-gradient(180deg, #1c2021f5, #111414f5 72%, #10181af5);
  --panel-glow: inset 0 -14px 16px -14px rgba(138, 255, 240, 0.5);
  --button-bg:
    radial-gradient(ellipse 90% 60% at 50% 115%, rgba(138, 255, 240, 0.16), transparent 70%),
    linear-gradient(165deg, #33393af2, #16191af2);
  --button-bg-hover:
    radial-gradient(ellipse 90% 70% at 50% 115%, rgba(148, 255, 241, 0.3), transparent 70%),
    linear-gradient(165deg, #444c4df2, #1d2223f2);
  --board-bg: #070505;
  --accent: #94fff1;
  --label: #a5f2e8;
  --title: #dcfffa;
  --value: #e8fffc;
  --detail: #b7d9d5;
  --gauge: linear-gradient(90deg, #389a8d, #99fff1);
  --slot-bg:
    radial-gradient(ellipse at 50% 120%, rgba(138, 255, 240, 0.16), transparent 62%),
    linear-gradient(#24292a, #121010);
  --slot-border: #444c4d;
  --slot-filled-bg:
    radial-gradient(ellipse at 50% 110%, rgba(142, 255, 240, 0.32), transparent 70%),
    linear-gradient(#303637, #131617);
  --slot-filled-border: #94fff1aa;
  --basalt:
    repeating-linear-gradient(90deg, #ffffff06 0 1px, transparent 1px 7px),
    linear-gradient(160deg, #2f3637, #181b1c 50%, #23292a);
}
.game-page[data-realm="dungeon"] .game-topbar,
.page[data-realm="dungeon"] .game-topbar {
  background: linear-gradient(180deg, #111516f2, #171c1de0 75%, #0a0d0de8);
  border-bottom: 2px solid #2f383a;
  box-shadow:
    0 1px 0 rgba(148, 255, 241, 0.4),
    0 4px 24px #000a;
}
.game-page[data-realm="dungeon"] .game-location-name,
.page[data-realm="dungeon"] .game-location-name {
  color: #dcfffa;
}
.game-page[data-realm="dungeon"] .game-location-name small,
.page[data-realm="dungeon"] .game-location-name small {
  color: #a5d9d2;
}
.game-page[data-realm="dungeon"] .game-actions .icon-button,
.page[data-realm="dungeon"] .game-actions .icon-button {
  border-color: #505b5d;
  box-shadow:
    inset 0 0 0 2px #0b0d0d,
    inset 0 0 0 3px rgba(148, 255, 241, 0.25),
    0 3px 7px #0006;
}
.game-page[data-realm="dungeon"] .family-focus {
  border-color: #42565a;
}
.game-page[data-realm="dungeon"] .family-focus-item .artifact-icon {
  background: radial-gradient(ellipse at 50% 90%, rgba(138, 255, 240, 0.2), #151110 72%);
  border-color: #505b5d;
}
.game-page[data-realm="dungeon"] .trio-badge:not(.done) {
  border-color: #56757a;
  color: #a6c9c4;
}
/* The forge glows under the board. */
.game-page[data-realm="dungeon"] .board-frame {
  box-shadow:
    0 14px 40px #000c,
    0 18px 50px -20px rgba(138, 255, 240, 0.35);
}

/* ---- Carte-titre et emblème d'un lieu --------------------------------------- */
.realm-emblem-mini {
  width: 30px;
  height: 30px;
  margin-right: -4px;
  filter: drop-shadow(0 0 6px rgba(138, 255, 240, 0.45));
}
.realm-card {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  pointer-events: none;
  text-align: center;
  /* An ellipse of shadow with soft edges, no hard band across the board. */
  background: radial-gradient(ellipse 46% 44% at 50% 50%, rgba(4, 7, 8, 0.9) 35%, rgba(4, 7, 8, 0.62) 62%, rgba(4, 7, 8, 0) 100%);
  animation: realm-card 2.3s ease both;
}
.realm-card-emblem {
  width: 98px;
  height: 98px;
  filter: drop-shadow(0 0 20px rgba(138, 255, 240, 0.6));
  animation: realm-emblem 0.75s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}
.realm-card strong {
  font: 600 46px var(--display);
  letter-spacing: 0.14em;
  color: var(--title);
  text-shadow:
    0 0 26px rgba(138, 255, 240, 0.6),
    0 3px 4px #000;
  animation: realm-title 0.9s ease-out 0.1s both;
}
.realm-card-sub {
  font: 600 13px var(--display);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--label);
}
.realm-card-motto {
  margin-top: 2px;
  font: 18px var(--serif);
  color: var(--detail);
}
@keyframes realm-card {
  0% {
    opacity: 0;
  }
  12%,
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-12px);
  }
}
@keyframes realm-emblem {
  from {
    opacity: 0;
    transform: scale(0.4) rotate(-25deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes realm-title {
  from {
    opacity: 0;
    letter-spacing: 0.5em;
  }
  to {
    opacity: 1;
    letter-spacing: 0.14em;
  }
}

/* ---- Scène ---------------------------------------------------------------- */
.game-page:before {
  background:
    radial-gradient(ellipse 80% 75% at 50% 50%, rgba(5, 8, 8, 0.12), rgba(4, 5, 5, 0.55)),
    linear-gradient(#090c0d90, #0a101138 30%, #0c141540 75%, #070808c0);
}
.game-topbar {
  height: 48px;
}
.game-location .brand {
  font-size: 16px;
}
.game-location .brand-mark {
  font-size: 24px;
}
.game-location-name {
  font-size: 15px;
}
.game-location-name small {
  font: 12px var(--display);
  letter-spacing: 0.08em;
}
.game-location-name small .num {
  font-size: 14px;
}
.game-actions .icon-button {
  width: 42px;
  height: 38px;
}
.game-actions svg.glyph {
  width: 21px;
  height: 21px;
}
.game-table {
  width: min(clamp(1500px, 70vw, 2100px), calc((100dvh - 322px) * 20 / 7), calc(100vw - 100px));
}
@media (max-width: 1100px) {
  .game-table {
    width: min(calc((100dvh - 322px) * 20 / 7), calc(100vw - 64px));
  }
}
.game-footer {
  position: absolute;
  left: 14px;
  bottom: 6px;
  padding: 0;
  z-index: 2;
  font-size: 12px;
}

/* ---- HUD ------------------------------------------------------------------ */
.game-hud {
  grid-template-columns: 1fr 1.15fr 2.4fr 1fr 1fr;
  height: 108px;
  gap: 10px;
  margin: 0 12px;
  padding: 2px 6px 0;
  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 #0006,
    var(--panel-glow);
}
.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}
.hud-stat .label {
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--label);
}
.hud-stat .value,
.game-hud .value {
  font: 500 28px/1.02 var(--numeric);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--value);
  text-shadow: 0 2px 3px #000;
  white-space: nowrap;
}
/* The time is the vital reading: it dominates. The score is only a result. */
.hud-time .value,
.game-hud .hud-time .value {
  font-size: 38px;
  font-weight: 600;
}
.hud-score .value,
.game-hud .hud-score .value {
  font-size: 24px;
}
.hud-time-readout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}
.hud-thaw {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--ice);
  border-radius: 8px;
  color: var(--ice);
  background: #17384a;
  box-shadow: 0 0 10px #7fdfff55;
  cursor: pointer;
}
.hud-thaw[hidden] {
  display: none;
}
.hud-thaw:hover,
.hud-thaw:focus-visible {
  background: #275772;
  outline: 2px solid var(--ice);
  outline-offset: 2px;
}
.hud-thaw svg.glyph {
  width: 17px;
  height: 17px;
  fill: currentColor;
  stroke: currentColor;
}
.hud-stat .detail {
  margin: 0;
  min-height: 17px;
  font: 14px/1.2 var(--serif);
  color: var(--detail);
  white-space: nowrap;
}
.cup-gauge,
.time-gauge,
.count-gauge {
  position: relative;
  display: block;
  width: min(128px, 82%);
  height: 6px;
  background: #060a0b;
  border: 1px solid #33575d;
  border-radius: 3px;
}
.cup-gauge i,
.time-gauge i,
.count-gauge i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, #65a89f, #bffff7);
  transition: width 0.35s ease;
}
.cup-gauge b {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 3px;
  margin-left: -1.5px;
  border-radius: 1px;
  background: #1f363a;
  box-shadow: 0 0 0 1px #060a0b;
}
.cup-gauge b.bronze {
  left: 50%;
}
.cup-gauge b.silver {
  left: 75%;
}
.cup-gauge b.gold {
  left: 100%;
}
.cup-gauge.bronze b.bronze {
  background: #96e0d6;
  box-shadow: 0 0 6px #96e0d6;
}
.cup-gauge.silver b.silver {
  background: #e3edf6;
  box-shadow: 0 0 6px #e3edf6;
}
.cup-gauge.gold b.gold {
  background: #adfff4;
  box-shadow: 0 0 8px #adfff4;
}
#hud-time.danger {
  color: #ff4b62;
  text-shadow:
    0 0 16px rgba(255, 59, 92, 0.75),
    0 2px 3px #000;
}
.hud-time.is-urgent .time-gauge i {
  background: var(--danger);
}
.hud-time.is-frozen .value {
  color: var(--ice);
  text-shadow:
    0 0 14px rgba(160, 230, 255, 0.85),
    0 2px 3px #000;
}
.hud-time.is-frozen .time-gauge i {
  background: linear-gradient(90deg, #6fc3e6, #d9f6ff);
}
.hud-time .detail {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ice);
}
.hud-time .detail svg.glyph {
  width: 15px;
  height: 15px;
  stroke: var(--ice);
  filter: none;
  stroke-width: 2;
}
.hud-trios .value,
.hud-pairs .value {
  font-size: 28px;
}
.time-gauge i,
.count-gauge i {
  background: var(--gauge);
}

/* Family in focus: its three objects, the pair of each, the trio of all. */
.family-focus {
  gap: 4px;
  padding: 0 2px;
}
.family-focus .icon-button {
  width: 34px;
  height: 64px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.family-focus-title {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-bottom: 5px;
  font: 600 14px var(--display);
  letter-spacing: 0.06em;
  color: var(--title);
}
.family-focus-title small {
  font: 14px var(--numeric);
  font-variant-numeric: lining-nums tabular-nums;
  color: #a1c3bf;
}
.family-focus-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.family-focus-item {
  position: relative;
}
.family-focus-item .artifact-icon {
  width: 56px;
  height: 56px;
}
.family-focus-item.pair-done .artifact-icon {
  border-color: #aef0e7;
  box-shadow:
    inset 0 0 9px #0007,
    0 0 10px #aef0e766;
}
.family-focus-item .variant-glyph {
  left: 2px;
  bottom: 2px;
}
.pair-mark {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #0f1a1c;
  border: 1.5px solid #44686e;
}
.pair-done .pair-mark {
  background: radial-gradient(circle at 40% 35%, #d4fff9, #78c2b8);
  border-color: #e1fffb;
}
/* The trio still to gather: three dotted objects, in the dashed medallion. */
.trio-badge:not(.done) svg.glyph {
  width: 18px;
  height: 18px;
  stroke: #a0c9c4;
  stroke-width: 2;
  filter: none;
}
.pair-mark svg.glyph,
.trio-badge svg.glyph {
  width: 13px;
  height: 13px;
  stroke: #12262a;
  stroke-width: 3.2;
  filter: none;
}
.trio-badge {
  display: grid;
  place-items: center;
  align-content: center;
  width: 58px;
  height: 58px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1.5px dashed #53777d;
  font: 600 12px var(--display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8fb1ad;
}
.trio-badge.done {
  border: 2px solid #e1fffb;
  background: radial-gradient(circle at 40% 35%, #d4fff9, #6db8ae);
  color: #12262a;
  box-shadow: 0 0 12px #aef0e790;
}
.trio-badge.done span {
  font-size: 12px;
  line-height: 1;
}
/* ---- Plateau et sac --------------------------------------------------------- */
.board-frame {
  padding: 0;
  border: 14px solid transparent;
  border-image: var(--frame-src) 24 / 14px var(--frame-repeat);
  background: var(--board-bg);
  box-shadow: 0 14px 40px #000b;
}
.board-frame:before,
.board-frame:after {
  display: none;
}
#board {
  box-shadow: 0 0 0 1px #000;
}
/* Shortcuts are pressed while the board has focus: its ring stays discreet,
   the arrow keys draw their own cursor on the cell. */
#board:focus-visible {
  outline: 1px solid rgba(225, 255, 251, 0.35);
  outline-offset: -2px;
}
.bag-meter {
  position: relative;
  z-index: 3;
  width: max-content;
  margin: -15px 30px -13px auto;
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 0 10px;
  border: 7px solid transparent;
  border-image: var(--plate-src) 8 fill / 7px stretch;
  font: 600 12px var(--display);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--label);
  text-shadow: 0 1px 1px #000;
}
.bag-meter b {
  font: 700 16px var(--numeric);
  letter-spacing: 0;
  color: #e5fffc;
}
.bag-meter .num:last-child {
  font-size: 14px;
  letter-spacing: 0;
}
.bag-meter.warn,
.bag-meter.warn b {
  color: #aefff4;
}
.bag-meter.danger,
.bag-meter.danger b {
  color: #ff8a9a;
}
.bag-meter.danger b {
  color: #ff5a70;
}
.bag-slots {
  gap: 5px;
  margin-top: 12px;
}
.game-page .bag-slot {
  background: var(--slot-bg);
  border-color: var(--slot-border);
}
.game-page .bag-slot.filled {
  background: var(--slot-filled-bg);
  border-color: var(--slot-filled-border);
}
.bag-slot {
  height: clamp(38px, 4vw, 58px);
}
.bag-slot.incoming .artifact-icon,
.bag-slot.incoming .variant-glyph {
  opacity: 0;
}
.bag-slots.warn .bag-slot:not(.filled) {
  border-color: #9dfff2aa;
  box-shadow:
    inset 0 3px 8px #000a,
    inset 0 0 0 1px #9dfff255;
}
.bag-slots.danger .bag-slot:not(.filled) {
  border-color: var(--danger);
  box-shadow:
    inset 0 3px 8px #000a,
    inset 0 0 14px rgba(255, 59, 92, 0.4);
}
/* A run in the order of the family card: a gold thread beneath, worth double. */
.game-page .bag-slot.ordered {
  border-color: #bffff7;
  background: radial-gradient(ellipse at 50% 100%, #71c8bd66, #10191b);
  box-shadow:
    inset 0 3px 8px #000a,
    inset 0 -4px 0 #98f5e9,
    0 0 14px #adfff488;
  animation: ordered-glow 1.6s ease-in-out infinite;
}
/* Colour variants also carry a shape: never colour alone. */
.variant-glyph {
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 12px;
  height: 12px;
  pointer-events: none;
  background: center / contain no-repeat;
}
.variant-glyph.diamond {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 .8 10.4 6 6 11.2 1.6 6Z' fill='%23ef4a5e' stroke='%23120a04' stroke-width='1.3'/%3E%3C/svg%3E");
}
.variant-glyph.circle {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='4.6' fill='%233fc47a' stroke='%23120a04' stroke-width='1.3'/%3E%3C/svg%3E");
}
.variant-glyph.triangle {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M6 1 11.2 10.4H.8Z' fill='%235b96f5' stroke='%23120a04' stroke-width='1.3'/%3E%3C/svg%3E");
}

/* ---- Ressources ----------------------------------------------------------- */
.resource-bar {
  gap: 8px;
  margin: 12px 0 0;
}
.resource-button,
.resource-display {
  min-height: 54px;
  max-width: 230px;
  padding: 3px 12px;
  gap: 10px;
  border: 7px solid transparent;
  border-image: var(--frame-src) 24 / 7px var(--frame-repeat);
  background: var(--button-bg) padding-box;
  box-shadow: 0 3px 8px #0007;
}
.resource-button:hover:not([aria-disabled="true"]) {
  background: var(--button-bg-hover) padding-box;
  box-shadow: 0 0 14px #80c7be44;
}
.resource-text .resource-label {
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--label);
}
.resource-text .resource-value {
  font: 600 24px/1 var(--numeric);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--value);
}
.resource-button .artifact-icon,
.resource-display .artifact-icon {
  width: 34px;
  height: 34px;
}
.resource-button[aria-disabled="true"] {
  cursor: default;
}
/* Three readable states: nothing to use, available, running. */
/* Empty: desaturated but still legible, the icon is the only clue on a phone. */
.is-empty .artifact-icon {
  filter: grayscale(0.85) brightness(0.95);
  opacity: 0.62;
}
.is-empty .resource-value {
  color: #9eb3b0;
}
.resource-display.is-empty[data-resource="gold"] .resource-value {
  color: var(--danger-soft);
}
/* Ready: only a glowing ring. Active (inventory running): a filled plate. */
.resource-button.is-ready {
  box-shadow:
    0 0 0 1px #cbfff8,
    0 0 14px #adfff488;
}
.resource-button.is-ready .artifact-icon {
  filter: drop-shadow(0 0 7px #bffff7);
}
.resource-button.is-active {
  background:
    linear-gradient(180deg, rgba(219, 255, 250, 0.28), transparent 45%),
    radial-gradient(ellipse at 30% 50%, #4fa095f2, #23444af2) padding-box;
  box-shadow:
    0 0 18px #aaf3e970,
    inset 0 0 14px #cbfff840;
}
.resource-button.is-active .artifact-icon {
  filter: drop-shadow(0 0 8px #bffff7);
}
.resource-button.is-active .resource-value {
  font: 700 14px var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e5fffc;
}
.resource-button kbd {
  position: absolute;
  top: 2px;
  right: 3px;
  bottom: auto;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  display: grid;
  place-items: center;
  font: 700 12px/1 var(--display);
  color: #12262a;
  background: var(--kbd-bg);
  border: 1px solid #1c363b;
  border-radius: 3px;
  box-shadow: 0 2px 0 #1c363b;
}
@media (hover: none) {
  .resource-button kbd {
    display: none;
  }
}
.mult-badge {
  position: absolute;
  top: -13px;
  right: 12px;
  padding: 0 7px;
  font: 700 16px/1.3 var(--numeric);
  color: #10262a;
  background: linear-gradient(#e1fffb, #8de0d5);
  border: 1px solid #ecfffc;
  border-radius: 10px;
  box-shadow:
    0 0 12px #adfff4aa,
    0 2px 3px #000a;
}
.mult-badge[hidden] {
  display: none;
}
.gear-sockets {
  display: flex;
  gap: 5px;
}
.gear-sockets i {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid #618b85;
  background: #091112;
}
.gear-sockets.one i:first-child {
  background: radial-gradient(circle at 40% 35%, #d4fff9, #6db8ae);
  border-color: #e1fffb;
  box-shadow: 0 0 8px #a9f0e7;
}

/* Nothing on the game screen is selectable text: a double tap or a long
   press never selects the HUD nor opens a callout on the board. */
.game-page {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  padding-top: env(safe-area-inset-top);
}
.game-topbar {
  padding-left: calc(28px + env(safe-area-inset-left));
  padding-right: calc(28px + env(safe-area-inset-right));
}

/* ---- Effets d'interface ---------------------------------------------------- */
#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
}
.fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.fx-sprite {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}
.fx-sprite .artifact-icon {
  width: 100%;
  height: 100%;
}
.fx-flying {
  filter: drop-shadow(0 0 9px rgba(192, 255, 247, 0.8)) drop-shadow(0 7px 7px rgba(0, 0, 0, 0.6));
}
.fx-ghost {
  filter: drop-shadow(0 0 10px #b6fff5) brightness(1.25);
}
.fx-text {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  font: 700 22px var(--numeric);
  font-variant-numeric: lining-nums tabular-nums;
  color: #e1fffb;
  text-shadow:
    0 0 10px rgba(175, 255, 244, 0.85),
    0 2px 2px #000;
  will-change: transform, opacity;
}
.fx-text.cost {
  font-size: 19px;
  color: #ffc2b6;
  text-shadow:
    0 0 8px rgba(255, 80, 80, 0.55),
    0 2px 2px #000;
}
.fx-text.score {
  font-size: 28px;
}
.fx-text.big {
  font-size: 34px;
}
.fx-text.banner {
  padding: 2px 16px;
  font: 600 16px var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e5fffc;
  border: 8px solid transparent;
  border-image: url("../assets/ui/plate.svg") 8 fill / 8px stretch;
}
.fx-text.score.ordered {
  font-size: 42px;
  color: #d8fffa;
  text-shadow:
    0 0 14px rgba(164, 255, 243, 0.95),
    0 0 32px rgba(148, 255, 241, 0.6),
    0 2px 2px #000;
}
.fx-text.banner.ordered {
  font-size: 15px;
  color: #eafffc;
  text-shadow: 0 0 10px rgba(164, 255, 243, 0.9);
}
.fx-tip {
  position: absolute;
  max-width: 290px;
  padding: 9px 14px;
  font: 16px/1.4 var(--serif);
  color: #def3f0;
  background: #152224f5;
  border: 1px solid #80b8b1;
  border-radius: 4px;
  box-shadow: 0 8px 24px #000c;
  transition: opacity 0.22s ease;
}
.fx-tip:after {
  content: "";
  position: absolute;
  left: var(--arrow, 50%);
  bottom: -7px;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background: inherit;
  border-right: 1px solid #80b8b1;
  border-bottom: 1px solid #80b8b1;
  transform: rotate(45deg);
}
.fx-tip.below:after {
  top: -7px;
  bottom: auto;
  transform: rotate(225deg);
}
.fx-tip.error {
  background: #2c1014f5;
  border-color: var(--danger);
}
.fx-tip.error:after {
  border-color: var(--danger);
}
.fx-tip.leaving {
  opacity: 0;
}

/* ---- Très grands écrans : l'interface grandit avec le plateau --------------- */
@media (min-width: 2200px) and (min-height: 1200px) {
  .game-hud {
    height: 134px;
  }
  .hud-stat .label,
  .resource-text .resource-label {
    font-size: 14px;
  }
  .hud-stat .value,
  .game-hud .value {
    font-size: 34px;
  }
  .game-hud .hud-time .value {
    font-size: 48px;
  }
  .game-hud .hud-score .value {
    font-size: 30px;
  }
  .family-focus-title {
    font-size: 17px;
  }
  .family-focus-item .artifact-icon,
  .trio-badge {
    width: 68px;
    height: 68px;
  }
  .resource-button,
  .resource-display {
    min-height: 66px;
    max-width: 290px;
  }
  .resource-text .resource-value {
    font-size: 30px;
  }
  .resource-button .artifact-icon,
  .resource-display .artifact-icon {
    width: 44px;
    height: 44px;
  }
  .bag-slot {
    height: 72px;
  }
  .bag-meter b {
    font-size: 19px;
  }
}

/* System messages appear at the top, under the bar of the screen: in play the
   resources at the bottom stay in sight, in the menus the top bar stays clear. */
#toast {
  top: 100px;
  bottom: auto;
}
body[data-scene] #toast {
  top: 60px;
}
@media (max-width: 760px) {
  #toast {
    top: 76px;
  }
}

/* ---- Urgence --------------------------------------------------------------- */
.game-page.is-urgent:after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(255, 40, 72, 0.34) 100%);
}

/* ---- Appareil tenu en portrait -------------------------------------------- */
/* The overlay sits in <body>, above the dialogs, and shows only during a game. */
.rotate-overlay {
  display: none;
}
@media (orientation: portrait) and (max-width: 600px) {
  body[data-scene] .rotate-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #070a0b;
  }
  .rotate-card {
    display: grid;
    justify-items: center;
    gap: 16px;
    max-width: 300px;
    text-align: center;
  }
  .rotate-card strong {
    font: 600 22px var(--display);
    letter-spacing: 0.06em;
    color: #ccf6f0;
  }
  .rotate-card p {
    font: 17px/1.6 var(--serif);
    color: #c1dcd8;
  }
  .rotate-phone {
    position: relative;
    width: 46px;
    height: 76px;
    border: 3px solid #9ce3da;
    border-radius: 9px;
  }
  .rotate-phone:after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 5px;
    width: 10px;
    height: 3px;
    margin-left: -5px;
    border-radius: 2px;
    background: #9ce3da;
  }
  .game-page .orientation-note {
    display: none;
  }
}

/* ---- Tablette et téléphone tenus en portrait ------------------------------- */
@media (orientation: portrait) {
  .game-hud {
    height: auto;
    padding: 6px 4px 10px;
    grid-template-columns: repeat(4, 1fr);
    row-gap: 10px;
  }
  .hud-time .value,
  .game-hud .hud-time .value {
    font-size: 30px;
  }
  .family-focus {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

/* ---- Téléphone en paysage : tout tient à l'écran, sans défilement ----------- */
/* A laptop screen (501 to 700 px tall): the bag and the reserves close in,
   and the board takes what is left, so that the whole game fits. */
@media (min-height: 501px) and (max-height: 700px) and (orientation: landscape) {
  .game-table {
    width: min(clamp(1500px, 70vw, 2100px), calc((100dvh - 312px) * 20 / 7), calc(100vw - 64px));
    margin-block: 4px;
  }
  .bag-slots {
    margin-top: 8px;
  }
  .bag-slot {
    height: clamp(34px, 6.4vh, 42px);
  }
  .resource-bar {
    margin-top: 8px;
  }
  .resource-button,
  .resource-display {
    min-height: 46px;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .game-page {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  .game-topbar {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 5;
    height: 44px;
    padding: 0 6px;
    border: 0;
    background: none;
    box-shadow: none;
  }
  .game-location {
    display: none;
  }
  .game-actions {
    gap: 3px;
  }
  .game-actions .icon-button {
    width: 38px;
    height: 36px;
  }
  .game-table {
    width: calc(100vw - 12px - env(safe-area-inset-left) - env(safe-area-inset-right));
    height: calc(100dvh - 8px);
    margin: 4px calc(6px + env(safe-area-inset-right)) 4px calc(6px + env(safe-area-inset-left));
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    grid-template-rows: 40px minmax(0, 1fr) auto;
    gap: 4px 6px;
    align-content: start;
  }
  .game-hud {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 40px;
    margin: 0 134px 0 0;
    padding: 0 8px;
    border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
    border-image: none;
    background: var(--panel);
  }
  .hud-stat {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
  }
  .hud-stat .detail,
  .cup-gauge,
  .time-gauge,
  .count-gauge,
  .hud-score .label,
  .hud-time .label,
  .family-focus-title small {
    display: none;
  }
  .game-hud .value,
  .game-hud .hud-score .value,
  .hud-trios .value,
  .hud-pairs .value {
    font-size: 20px;
  }
  .game-hud .hud-time .value {
    font-size: 24px;
  }
  .hud-time-readout {
    gap: 4px;
  }
  .hud-thaw {
    width: 30px;
    height: 30px;
  }
  .hud-score .value {
    color: #b7d9d4;
  }
  .family-focus {
    flex: 1;
    order: 5;
    gap: 2px;
    padding: 0;
    border: 0;
  }
  .family-focus .icon-button {
    width: 24px;
    height: 36px;
  }
  .family-focus-content {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .family-focus-title {
    margin: 0;
    font-size: 12px;
  }
  .family-focus-icons {
    gap: 7px;
  }
  .family-focus-item .artifact-icon {
    width: 30px;
    height: 30px;
  }
  .pair-mark {
    right: -4px;
    bottom: -4px;
    width: 14px;
    height: 14px;
  }
  .pair-mark svg.glyph {
    width: 9px;
    height: 9px;
  }
  .trio-badge {
    width: 30px;
    height: 30px;
  }
  .trio-badge span {
    display: none;
  }
  .board-frame {
    grid-column: 2;
    grid-row: 2;
    justify-self: center;
    align-self: start;
    width: min(100%, calc((100dvh - 106px) * 20 / 7 + 10px));
    border-width: 5px;
    border-image-width: 5px;
  }
  .bag-slots {
    grid-column: 2;
    grid-row: 3;
    justify-self: center;
    width: min(100%, calc((100dvh - 106px) * 20 / 7 + 10px));
    margin: 0;
    gap: 3px;
  }
  .bag-slot {
    height: clamp(26px, 9dvh, 36px);
  }
  .bag-meter {
    grid-column: 1;
    grid-row: 3;
    align-self: center;
    justify-self: stretch;
    width: auto;
    margin: 0;
    padding: 0 2px;
    border-width: 4px;
    border-image-width: 4px;
    justify-content: center;
  }
  .bag-meter > span:first-child {
    display: none;
  }
  .resource-bar {
    grid-column: 1;
    grid-row: 2;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 3px;
    margin: 0;
    min-height: 0;
    overflow: hidden;
  }
  .resource-button,
  .resource-display {
    flex: 1 1 0;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    height: auto;
    max-height: 44px;
    min-height: 0;
    max-width: none;
    padding: 1px;
    border-width: 4px;
    border-image-width: 4px;
  }
  .resource-button .artifact-icon,
  .resource-display .artifact-icon {
    width: 20px;
    height: 20px;
  }
  .resource-text {
    text-align: center;
  }
  .resource-text .resource-label,
  .resource-button kbd {
    display: none;
  }
  .resource-text .resource-value {
    font-size: 15px;
  }
  .resource-button.is-active .resource-value {
    font-size: 12px;
    letter-spacing: 0.04em;
  }
  .gear-sockets {
    position: absolute;
    top: 2px;
    right: 2px;
    gap: 2px;
  }
  .gear-sockets i {
    width: 7px;
    height: 7px;
    border-width: 1px;
  }
  .mult-badge {
    top: -7px;
    right: -5px;
    padding: 0 4px;
    font-size: 12px;
  }
  .orientation-note {
    display: none;
  }
  body[data-scene] #toast {
    top: 48px;
  }
  .realm-card-emblem {
    width: 56px;
    height: 56px;
  }
  .realm-card strong {
    font-size: 26px;
  }
  .realm-card-motto {
    display: none;
  }
}

/* ---- Fenêtres : tout tient à l'écran ----------------------------------------
   Une fenêtre ne défile jamais. Un texte trop long se lit en pages, qu'on
   tourne avec ‹ › ou les flèches ; le reste se resserre (fitDialog). */
.book-page[hidden] {
  display: none !important;
}
.book-page > :first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.book-pager {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.book-pager .icon-button {
  width: 40px;
  height: 40px;
}
.book-pager .icon-button[aria-disabled="true"] {
  opacity: 0.35;
  cursor: default;
}
.book-count {
  min-width: 92px;
  text-align: center;
  font: 600 13px var(--display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.modal.paged .modal-actions:last-of-type {
  justify-content: space-between;
  align-items: center;
}
.modal.paged .modal-actions:last-of-type .button {
  flex: 0 1 260px;
}
/* The first stage explains the game: its dialog takes the width it needs. */
.modal:has(.tutorial-grid) {
  width: min(760px, 100%);
}
/* On a tall screen, « Voir le tutoriel » stands under the stage's choices. */
.modal .intro-tutorial {
  order: 3;
  flex-basis: 100%;
}
/* A laptop screen: the frame and the headings give back some room, and the
   dialogs of a stage spread across rather than down. */
@media (max-height: 820px) {
  .modal {
    padding: 26px 34px 28px;
  }
  .modal:has(.stage-objectives, .result-stats) {
    width: min(760px, 100%);
  }
  .modal .stage-objectives,
  .modal .result-stats {
    padding-block: 12px;
  }
  .tutorial-grid {
    margin: 14px 0;
  }
  .tutorial-tip {
    margin-top: 10px;
  }
  .result-emblem .artifact-icon {
    width: 80px;
    height: 80px;
  }
  .result-rays {
    width: 170px;
    height: 170px;
  }
  .result-stats {
    margin: 14px 0;
  }
  .modal-heading {
    margin-bottom: 16px;
  }
  .modal-heading h2 {
    font-size: 30px;
    margin-top: 6px;
  }
  .modal-heading p {
    margin-top: 8px;
  }
  .modal-heading:after {
    margin-top: 12px;
  }
  .modal-actions {
    margin-top: 18px;
  }
  .rule-bonus-grid {
    margin-top: 18px;
    padding-top: 18px;
  }
  .keyboard-hints {
    margin-top: 16px;
    padding-top: 14px;
  }
}
/* A small laptop: the ornament goes, the figures and the steps close in. */
@media (max-height: 700px) {
  .modal {
    padding-block: 18px 20px;
  }
  .modal-heading {
    margin-bottom: 10px;
  }
  .modal-heading h2 {
    font-size: 26px;
  }
  .modal-heading:after {
    display: none;
  }
  .modal .stage-objectives,
  .modal .result-stats {
    padding-block: 8px;
    margin-block: 8px;
  }
  .stage-objectives strong,
  .result-stats strong {
    font-size: 22px;
    margin-bottom: 2px;
  }
  .tutorial-grid {
    margin: 8px 0;
  }
  .tutorial-step .tile-plaque,
  .tutorial-step .tile-medallion {
    width: 42px;
    height: 42px;
    margin-bottom: 4px;
  }
  .tutorial-step p,
  .tutorial-tip,
  .result-note {
    font-size: 14px;
    line-height: 1.4;
  }
  .tutorial-tip {
    margin-top: 6px;
  }
  .modal-actions {
    margin-top: 10px;
  }
  .modal-actions .button {
    min-height: 42px;
  }
  /* The settings on two columns. */
  .modal:has(.settings-grid) {
    width: min(760px, 100%);
  }
  .settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 28px;
  }
  .storage-note {
    font-size: 14px;
    line-height: 1.45;
  }
  .settings-row {
    padding-block: 10px;
  }
}
/* A phone held upright: the frame thins and a book gives its room to the page. */
@media (max-width: 560px) {
  .modal {
    padding: 24px 16px 20px;
    border-width: 12px;
    border-image-width: 12px;
  }
  .modal.paged .modal-heading p {
    display: none;
  }
  .rule-row,
  .rule-bonus-grid .rule-row {
    gap: 10px;
  }
  .rule-row > .tile-plaque,
  .rule-row > .tile-medallion,
  .rule-row > .tile-copper,
  .rule-row > .tile-bare,
  .rule-row .tile-pair > * {
    width: 40px;
    height: 40px;
  }
  .rule-row .tile-pair {
    flex-direction: column;
    gap: 4px;
  }
  .book-count {
    min-width: 70px;
    letter-spacing: 0.06em;
  }
  .modal.paged .modal-actions:last-of-type .button {
    flex: 1 1 auto;
    min-width: 0;
    padding-inline: 12px;
  }
}

/* ---- Fenêtres sur écran bas (téléphone en paysage) --------------------------
   L'action principale reste visible sans faire défiler. */
@media (max-height: 500px) {
  .modal-backdrop {
    padding: 6px;
  }
  .modal {
    padding: 14px 20px 16px;
    border-width: 9px;
    border-image-width: 9px;
  }
  .modal.wide {
    width: min(760px, 100%);
  }
  .modal-heading {
    margin-bottom: 10px;
  }
  .modal-heading h2 {
    font-size: 24px;
    margin-top: 4px;
  }
  .modal-heading p {
    margin-top: 4px;
    font-size: 15px;
    line-height: 1.4;
  }
  .modal-heading:after {
    display: none;
  }
  .stage-objectives,
  .result-stats {
    padding: 8px 0;
    margin: 8px 0;
  }
  .stage-objectives strong,
  .result-stats strong {
    font-size: 22px;
    margin-bottom: 2px;
  }
  .tutorial-grid {
    margin: 10px 0;
  }
  .tutorial-step .tile-plaque,
  .tutorial-step .tile-medallion {
    width: 40px;
    height: 40px;
    margin-bottom: 4px;
  }
  .tutorial-step h3 {
    font-size: 15px;
  }
  .tutorial-tip,
  .result-note {
    margin-top: 6px;
    font-size: 14px;
    line-height: 1.45;
  }
  .modal-actions {
    margin-top: 10px;
  }
  .modal-actions.stacked {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .modal-actions.stacked .button {
    flex: 1 1 40%;
  }
  /* The pause keeps its choices; its figures are already on the HUD. */
  .modal .stage-objectives:has(+ .modal-actions.stacked) {
    display: none;
  }
  .modal-actions.stacked .text-button {
    flex: 1 1 100%;
    min-height: 32px;
  }
  .modal .tutorial-tip {
    display: none;
  }
  /* Only the decorative lines of the stage dialogs are cut short. */
  .modal:has(.stage-objectives, .result-stats) .modal-heading p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .modal-actions .button {
    min-height: 40px;
    padding-block: 8px;
  }
  .result-emblem .artifact-icon {
    width: 64px;
    height: 64px;
  }
  .result-rays {
    width: 140px;
    height: 140px;
  }
  .modal .intro-tutorial {
    order: 0;
    flex: 0 0 auto;
  }
  /* The result's second choices stand beside the first ones. */
  .modal .result-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin-top: 10px;
  }
  .result-actions > .modal-actions {
    margin-top: 0;
  }
  .result-actions > .modal-actions:first-child {
    flex: 1 1 60%;
  }
  /* A book keeps its title and gives the rest of the room to its pages. */
  .modal.paged .modal-heading p {
    display: none;
  }
  .rules-list {
    gap: 10px;
  }
  .rule-row,
  .rule-bonus-grid .rule-row {
    gap: 12px;
  }
  .rule-row h3,
  .rule-bonus-grid h3 {
    font-size: 15px;
    margin-bottom: 2px;
  }
  .rule-row p,
  .rule-bonus-grid p,
  .keyboard-hints {
    font-size: 14px;
    line-height: 1.45;
  }
  .rule-row > .tile-plaque,
  .rule-row > .tile-medallion,
  .rule-row > .tile-copper,
  .rule-row > .tile-bare,
  .rule-row .tile-pair > * {
    width: 40px;
    height: 40px;
  }
  .rule-bonus-grid {
    gap: 10px 20px;
  }
  .book-pager .icon-button {
    width: 36px;
    height: 36px;
  }
  /* The travellers side by side, on rows as low as they can be. */
  .modal:has(.profile-book) {
    width: min(760px, 100%);
  }
  .profile-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
  }
  .profile-row {
    padding: 6px 10px;
    gap: 10px;
  }
  .profile-row strong {
    font-size: 15px;
    margin-bottom: 1px;
  }
  .profile-row small {
    font-size: 13px;
    line-height: 1.3;
  }
  .form-error:empty {
    margin: 0;
    min-height: 0;
  }
}
/* A very low screen: a dialog keeps its title, its content and its actions.
   Only the decorative subtitles go; a question, a warning or the cause of a
   defeat stays. */
@media (max-height: 400px) {
  .modal:has(.settings-grid, .tutorial-chapters, .profile-book, .stage-reserves):not(:has(.result-stats)) .modal-heading p {
    display: none;
  }
  .modal-heading h2 {
    font-size: 22px;
  }
  .modal-actions {
    margin-top: 8px;
  }
  .settings-row {
    padding-block: 4px;
  }
  .storage-note {
    font-size: 13px;
    line-height: 1.3;
  }
  /* The figures of a stage on one line, each number beside its word. */
  .modal .stage-objectives,
  .modal .result-stats {
    padding-block: 5px;
    margin-block: 6px;
  }
  .stage-objectives strong,
  .result-stats strong {
    display: inline;
    margin: 0 4px 0 0;
    font-size: 19px;
  }
  .stage-reserves {
    margin-block: 6px;
    padding-block: 4px;
  }
  /* The intro's reserves speak for themselves; a result says what became of them. */
  .modal:not(:has(.result-stats)) .stage-reserves p {
    display: none;
  }
  .result-note {
    margin-top: 2px;
    font-size: 13px;
    line-height: 1.3;
  }
  .result-emblem {
    margin-bottom: 0;
  }
  .result-emblem .artifact-icon {
    width: 46px;
    height: 46px;
  }
  .result-rays {
    width: 100px;
    height: 100px;
  }
  .tutorial-grid {
    margin: 4px 0;
  }
  .tutorial-step .tile-plaque,
  .tutorial-step .tile-medallion {
    width: 34px;
    height: 34px;
    margin-bottom: 2px;
  }
  .tutorial-step h3 {
    font-size: 14px;
    margin-bottom: 2px;
  }
  .tutorial-step p {
    font-size: 13px;
    line-height: 1.3;
  }
}

/* ---- Défaite : la cause reste visible derrière la fenêtre ------------------- */
.modal-backdrop:has(.result-emblem.lost) {
  background: rgba(4, 6, 6, 0.55);
  backdrop-filter: none;
}
.modal-backdrop.peeking,
.modal-backdrop.peeking:has(.result-emblem.lost) {
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
}
.modal-backdrop.peeking .modal {
  visibility: hidden;
}
body.peek-board:after {
  content: "Touchez ou appuyez sur une touche pour revenir";
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 80;
  transform: translateX(-50%);
  padding: 8px 16px;
  font: 15px var(--serif);
  color: #def3f0;
  background: #0f181af0;
  border: 1px solid #5ea49b;
}
.game-page[data-lost="bag_blocked"] .bag-slots,
.game-page[data-lost="bag_blocked"] .bag-meter {
  outline: 3px solid var(--danger);
  outline-offset: 3px;
  animation: danger-pulse 0.9s ease-in-out infinite;
}
.game-page[data-lost="timeout"] .hud-time {
  outline: 3px solid var(--danger);
  outline-offset: 2px;
  animation: danger-pulse 0.9s ease-in-out infinite;
}

/* ---- Téléphone : le score porte une coupe, il ne reste pas un « 0 » anonyme -- */
@media (max-height: 500px) and (orientation: landscape) {
  .game-hud .hud-score .value::before {
    content: "";
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 5px;
    vertical-align: -1px;
    background: center / contain no-repeat
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 3h10v5.6a5 5 0 0 1-10 0Z' fill='%23e3b262'/%3E%3Cpath d='M7 5.6H3.6v1.9a4 4 0 0 0 4 4M17 5.6h3.4v1.9a4 4 0 0 1-4 4' fill='none' stroke='%23e3b262' stroke-width='2'/%3E%3Cpath d='M10.4 14h3.2v3.4h2.6v3.1H7.8v-3.1h2.6Z' fill='%23e3b262'/%3E%3C/svg%3E");
  }
}

/* ---- Tablette en portrait : l'invitation au paysage est une vraie action ---- */
.orientation-note .button {
  min-height: 34px;
  margin-left: 12px;
  padding: 4px 18px;
  vertical-align: middle;
}

/* Contextual tools live below the resources, in the same game table. */
.abyss-mechanics {
  display:flex; align-items:center; justify-content:center; flex-wrap:wrap;
  gap:6px 18px; margin:7px 0 0; min-height:32px;
  font:14px var(--serif); color:var(--text-soft);
}
.abyss-mechanics > div { display:flex; align-items:center; gap:6px; }
.mechanic-button, .abyss-mechanics select {
  min-height:32px; padding:3px 10px; color:var(--text);
  border:1px solid #49c9c166; border-radius:5px;
  background:#082532; font:14px var(--serif);
}
.mechanic-button:hover:not(:disabled) { background:#124654; border-color:#a3e4d9; }
.mechanic-current .mechanic-button { min-width:34px; font-size:22px; line-height:1; }
.light-preview { display:flex; align-items:center; gap:5px; }
.light-preview > span { display:flex; align-items:center; gap:1px; }
.light-preview .artifact-icon { width:26px; height:26px; }
.mechanic-breath { color:#9eece2; }
.game-table:has(.abyss-mechanics) { width:min(clamp(1500px,70vw,2100px),calc((100dvh - 365px) * 20 / 7),calc(100vw - 70px)); }
.resource-wall { flex:1.7; max-width:310px; }
.resource-wall .guardian-name { display:block; max-width:190px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; letter-spacing:.02em; }
.guardian-readout { display:flex; align-items:baseline; justify-content:space-between; gap:7px; }
.guardian-readout small { font:12px var(--numeric); white-space:nowrap; color:#bddad5; }
.guardian-gauge { display:block; height:4px; margin-top:3px; background:#03131d; border-radius:3px; overflow:hidden; }
.guardian-gauge i { display:block; height:100%; background:linear-gradient(90deg,#38858c,#a5eee0); transition:width .2s linear; }
.gear-sockets.two i { background:#9debdc; box-shadow:0 0 8px #49c9c1; }
.encounter-intro, .mechanic-intro { margin:10px 0; padding:9px 13px; border-left:2px solid #49c9c1; background:#062330; color:#d3e8e3; font:16px/1.4 var(--serif); }
.encounter-intro strong { color:#b7eee2; }
.mechanic-intro { font-size:14px; }
.route-choices { display:flex; flex-wrap:wrap; gap:9px; padding:9px 0; border:0; }
.route-choices legend { color:var(--gold); font:13px var(--display); }
.route-choice { flex:1; min-width:150px; display:grid; gap:3px; padding:9px 12px; text-align:left; border:1px solid #588c955e; border-radius:5px; background:#082735; }
.route-choice strong { font:14px var(--display); }
.route-choice small { font:14px var(--serif); color:#bed5d2; }
.route-choice[aria-pressed="true"] { border-color:#9eecde; background:#15414a; box-shadow:inset 0 0 12px #49c9c122; }
@media (max-height:720px) and (min-height:501px) {
  .game-table:has(.abyss-mechanics) { width:min(calc((100dvh - 330px) * 20 / 7),calc(100vw - 42px)); }
  .abyss-mechanics { margin-top:4px; gap:4px 10px; }
}
@media (max-height:500px) and (orientation:landscape) {
  .game-table:has(.abyss-mechanics) { width:calc(100vw - 12px - env(safe-area-inset-left) - env(safe-area-inset-right)); grid-template-rows:40px minmax(0,1fr) auto 30px; }
  .abyss-mechanics { grid-column:1 / -1; grid-row:4; margin:0; min-height:28px; flex-wrap:nowrap; gap:4px 10px; font-size:12px; }
  .mechanic-button, .abyss-mechanics select { min-height:27px; padding:1px 6px; font-size:12px; }
  .light-preview .artifact-icon { width:22px; height:22px; }
  .resource-wall .resource-text .guardian-name { display:none; }
  .guardian-readout small { font-size:10px; }
  .resource-wall .resource-text .resource-value { font-size:12px; white-space:nowrap; }
  .resource-wall .guardian-readout { display:block; }
  .resource-wall .guardian-readout small { display:none; }
  .resource-wall .guardian-gauge { width:40px; }
  .resource-wall { max-width:none; }
  .mechanic-current .mechanic-button { min-width:27px; font-size:19px; }
}

@media (max-height:500px) and (orientation:landscape) {
  .hud-time { position:relative; padding-bottom:11px; }
  .hud-time::after { content:attr(data-depth); position:absolute; bottom:-1px; left:0; right:0; color:#a9d8d5; font:12px/1 var(--numeric); text-align:center; white-space:nowrap; }
}

.modal:has(.intro-book) { width:min(800px,100%); }
.stage-story { font:16px/1.45 var(--serif); color:#c6e0dd; margin:5px 0 10px; }
.intro-book .book-page > :first-child { margin-top:0; }
@media (max-height:500px) and (orientation:landscape) {
  .modal:has(.intro-book) { width:min(900px,100%); }
  .stage-story { font-size:14px; margin-bottom:7px; }
  .intro-book .encounter-intro, .intro-book .mechanic-intro { margin:6px 0; padding:5px 10px; font-size:14px; }
  .intro-book .route-choices { padding:4px 0; }
  .intro-book .route-choice { padding:6px 9px; }
}

.mechanic-target .mechanic-button[aria-pressed="true"] { color:#ebfff8; border-color:#a9ebdd; background:#1f5660; box-shadow:0 0 8px #49c9c144; }
.mechanic-target .target-health { margin-left:3px; color:#a7cfca; font-size:12px; }
