:root {
  --indigo: #1B1F3B;
  --sage: #DDE8D0;
  --ink: #23262E;
  --gold: #E8B84A;
  --leaf: #5E8C61;
  --tablet: #EEF1EE;
  --ember: #E8793A;
  --muted: #5B6170;
  --line: #C9D4C2;
  --sky-top: #A9C4D9;
  --sky-bottom: #DDE8D0;
  --sky-ink: var(--ink);
  --serif: "Alegreya", Georgia, "Times New Roman", serif;
  --sans: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --gap: 1.25rem;
}

* { box-sizing: border-box; }

html {
  background: var(--sage);
  overflow-x: clip;
}

body {
  margin: 0;
  max-width: 100%;
  overflow-x: clip;
  color: var(--ink);
  font: 400 var(--step-0)/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0; }
h2 { font-size: var(--step-2); margin-bottom: 0.75rem; }
h3 { font-size: var(--step-1); font-weight: 600; }
p { margin: 0; }
ul, ol { list-style: none; margin: 0; padding: 0; }
a { color: inherit; text-underline-offset: 3px; }

button {
  font: 500 var(--step-0)/1 var(--sans);
  color: var(--ink);
  background: var(--tablet);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #fff; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--gold); border-color: var(--ink); font-weight: 700; }
button.primary:hover:not(:disabled) { background: #F0C868; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* --- The sky: the one loud thing ------------------------------------------ */

.sky {
  position: relative;
  min-height: 15rem;
  padding: 1.5rem var(--gap) 4.5rem;
  color: var(--sky-ink);
  background: linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
  overflow: hidden;
  transition: color 1.2s ease;
}

.stars {
  position: absolute;
  inset: 0;
  opacity: var(--stars, 0);
  transition: opacity 2s ease;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 12%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 16%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 26%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 10%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 44%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 92% 40%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 48%, #fff 50%, transparent 51%);
}

.orb {
  position: absolute;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  left: var(--orb-x, 50%);
  top: var(--orb-y, 30%);
  transform: translate(-50%, -50%);
  background: var(--orb, #F6D77A);
  box-shadow: 0 0 2.5rem 0.5rem var(--orb-glow, rgba(246, 215, 122, 0.55));
  transition: left 1.2s linear, top 1.2s linear, background 1.2s ease;
}

.sky-text { position: relative; max-width: 72rem; margin: 0 auto; }

.era { font: italic 400 var(--step-1)/1.2 var(--serif); opacity: 0.85; }

.clock {
  font-size: clamp(var(--step-3), 8vw, 3.8rem);
  letter-spacing: -0.01em;
  margin: 0.15rem 0 0.6rem;
}

.veille {
  font: italic 0.95rem/1.3 var(--serif);
  margin: -0.35rem 0 0.55rem;
}
.veille[hidden] { display: none; }

.faith { display: inline-flex; align-items: center; gap: 0.5rem; font: 500 var(--step-1)/1 var(--sans); }
.faith #faith-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.halo {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 3px solid var(--gold);
  box-shadow: 0 0 0.6rem var(--gold);
}

.scenario[hidden] { display: none; }
.scenario {
  width: min(100%, 72rem);
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.45rem var(--gap) 0;
}
.scenario article {
  background: var(--indigo);
  color: var(--sage);
  border-radius: 0.7rem;
  padding: 0.75rem 1rem 0.9rem;
}
.scenario h3 { color: var(--gold); font-size: var(--step-1); }
.scenario p { font: italic 1.05rem/1.35 var(--serif); margin-top: 0.15rem; }
.scenario ul { display: grid; gap: 0.15rem; margin-top: 0.4rem; }
.scenario li { padding-left: 0.85rem; position: relative; }
.scenario li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55rem;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--gold);
}
.scenario-tip {
  margin-top: 0.55rem;
  padding: 0.45rem 0.55rem;
  border-radius: 0.45rem;
  background: color-mix(in srgb, var(--gold) 22%, transparent);
  font: 400 0.88rem/1.35 var(--sans);
  color: var(--sage);
}
.scenario article.malus {
  box-shadow: inset 0 -3px 0 var(--ember);
}
.scenario article.malus h3 { color: var(--ember); }
.scenario article.malus .scenario-tip {
  background: color-mix(in srgb, var(--ember) 28%, transparent);
}
.scenario article.errant {
  box-shadow: inset 0 -3px 0 var(--sage);
}
.scenario article.errant h3 { color: var(--sage); }
.scenario article.errant .scenario-tip {
  background: color-mix(in srgb, var(--sage) 22%, transparent);
}

.phenomenes[hidden] { display: none; }
.phenomenes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  position: sticky;
  top: 0;
  z-index: 6;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.55rem max(var(--gap), calc((100% - 72rem) / 2 + var(--gap))) 0.35rem;
  background: var(--sage);
  box-shadow: 0 0.35rem 0.75rem color-mix(in srgb, var(--sage) 55%, transparent);
}
.phenomene { position: relative; }
.phenomene-mark {
  display: grid;
  gap: 0.05rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--tablet) 90%, transparent);
  border-radius: 0.7rem;
  padding: 0.35rem 0.75rem 0.4rem;
  text-align: left;
}
.phenomene.mal .phenomene-mark { box-shadow: inset 0 -3px 0 var(--ember); }
.phenomene.bien .phenomene-mark { box-shadow: inset 0 -3px 0 var(--leaf); }
.phenomene.mixte .phenomene-mark { box-shadow: inset 0 -3px 0 var(--gold); }
.phenomene-nom { font: 600 1rem/1.2 var(--serif); }
.phenomene-meta { color: var(--muted); font-size: 0.82rem; }
.phenomene .impacts {
  display: none;
  position: absolute;
  z-index: 4;
  top: calc(100% + 0.35rem);
  left: 0;
  width: min(18rem, 72vw);
  padding: 0.75rem 0.85rem;
  background: var(--tablet);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 0.45rem;
}
.phenomene:hover .impacts,
.phenomene:focus-within .impacts,
.phenomene.open .impacts { display: grid; gap: 0.35rem; }
.phenomene .impacts p { font: italic 1rem/1.35 var(--serif); }
.phenomene .impacts ul { display: grid; gap: 0.2rem; }
.phenomene .impacts li { padding-left: 0.7rem; position: relative; }
.phenomene .impacts li::before { content: ""; position: absolute; left: 0; top: 0.55rem; width: 0.35rem; height: 0.35rem; border-radius: 50%; background: var(--ink); }
.phenomene.mal .impacts li::before { background: var(--ember); }
.phenomene.bien .impacts li::before { background: var(--leaf); }
.phenomene.mixte .impacts li::before { background: var(--gold); }

.land { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 4rem; }
.land .hill-back { fill: var(--hill-back, #7FA37A); transition: fill 1.2s ease; }
.land .hill-front { fill: var(--hill-front, var(--leaf)); transition: fill 1.2s ease; }

.camp {
  position: absolute;
  left: 50%;
  bottom: 0.55rem;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 0.3rem;
  color: var(--camp-ink, var(--ink));
  transition: color 1.2s ease;
}
.camp svg { display: block; fill: currentColor; }
.camp .fire { fill: var(--ember); filter: drop-shadow(0 0 0.35rem var(--gold)); }
.camp .more { font: 700 0.85rem/1 var(--sans); color: var(--tablet); margin-left: 0.2rem; }

/* --- Layout --------------------------------------------------------------- */

.balance {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 1.35rem;
  width: min(100%, 72rem);
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.7rem var(--gap) 0;
}
button.seal {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.15rem 0.15rem;
  border: 0;
  background: transparent;
  border-radius: 999px;
  color: var(--ink);
  font: 700 1.2rem/1 var(--sans);
  font-variant-numeric: tabular-nums;
  cursor: help;
}
button.seal:hover:not(:disabled),
button.seal.open {
  background: transparent;
}
.seal .ring { width: 2.75rem; height: 2.75rem; display: block; flex: none; }
.seal .ring circle { fill: none; stroke-width: 3; }
.seal .ring .track { stroke: color-mix(in srgb, var(--ink) 18%, var(--sage)); }
.seal .ring .arc { stroke: var(--leaf); stroke-linecap: round; }
.seal.short .ring .track { stroke: color-mix(in srgb, var(--ember) 42%, var(--line)); }
.seal.short .ring .arc { stroke: var(--ember); }
.seal .ring .glyph,
.seal .ring .glyph circle { fill: currentColor; stroke: none; }
.seal.water.short .glyph { fill: none; stroke: currentColor; stroke-width: 1.35; }
.seal-num small { font-weight: 500; font-size: 0.72em; opacity: 0.72; margin-left: 0.06em; }
.seal .tip {
  position: absolute;
  left: 0;
  top: calc(100% + 0.4rem);
  z-index: 8;
  width: max-content;
  max-width: min(18rem, 70vw);
  padding: 0.35rem 0.65rem;
  border-radius: 0.45rem;
  background: var(--indigo);
  color: var(--sage);
  font: italic 400 0.95rem/1.3 var(--serif);
  text-align: left;
  opacity: 0;
  pointer-events: none;
}
.seal:hover .tip,
.seal:focus-visible .tip,
.seal.open .tip { opacity: 1; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.25rem;
  width: min(100%, 72rem);
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.15rem var(--gap) max(6.25rem, calc(5rem + env(safe-area-inset-bottom)));
}

.column { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.25rem; align-content: start; min-width: 0; }
.column > section { min-width: 0; }

@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(1.5rem, 3vw, 3rem); }
}

@media (min-width: 1200px) {
  .heaven { position: sticky; top: 0.75rem; align-self: start; z-index: 1; }
}

/* --- Dessein ---------------------------------------------------------------- */

.dessein .etape {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}
.dessein .etape + .etape { margin-top: 0.85rem; }
.dessein .etape-texte {
  font: italic 600 1.45rem/1.25 var(--serif);
  min-width: 0;
}
.dessein .etape.suivante .etape-texte {
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--muted);
}
.dessein .etape-delai {
  flex: none;
  font: 500 0.95rem/1 var(--sans);
  font-style: normal;
  color: var(--ink);
}
.dessein .voie {
  display: grid;
  gap: 0.2rem;
  margin: 0.4rem 0 0.15rem;
}
.dessein .voie li {
  position: relative;
  padding-left: 0.95rem;
  color: var(--muted);
  font-size: 0.98rem;
}
.dessein .voie li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62rem;
  width: 0.5rem;
  height: 1px;
  background: var(--leaf);
}
.dessein .dessein-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-top: 0.9rem;
}
button.quiet {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0.35rem 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}
button.quiet:hover:not(:disabled) { background: transparent; color: var(--leaf); }

.trame-dialog {
  width: min(28rem, calc(100% - 2rem));
  max-width: calc(100dvw - 2rem);
  border: 1.5px solid var(--ink);
  border-radius: 1.6rem 1.6rem 0.45rem 0.45rem;
  background: var(--tablet);
  color: var(--ink);
  padding: 1.35rem 1.25rem 1.1rem;
}
.trame-dialog::backdrop { background: rgba(27, 31, 59, 0.55); }
.trame-dialog h2 { margin-bottom: 0.75rem; }
.trame-line {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}
.trame-line input {
  flex: 1;
  min-width: 0;
  font: italic 400 1.15rem/1.4 var(--serif);
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0.4rem 0;
}
.trame-line.franchie input { color: var(--muted); }
.trame-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
}
.trame-actions .primary { margin-left: auto; }

/* --- Prayers: stone tablets ----------------------------------------------- */

.prayers { display: grid; gap: 1.1rem; }

.tablet {
  position: relative;
  background: var(--tablet);
  border: 1.5px solid var(--ink);
  border-radius: 46% 46% 0.5rem 0.5rem / 2.6rem 2.6rem 0.5rem 0.5rem;
  padding: 1.9rem 1.25rem 1.1rem;
  box-shadow: 0 0 1.6rem rgba(232, 184, 74, var(--glow, 0.25));
}
.tablet.new { animation: rise 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.tablet.supplication {
  background: var(--indigo);
  color: var(--sage);
  border-color: var(--gold);
}
.tablet.supplication .voice,
.tablet.supplication .offer-desc,
.tablet.supplication .mercy-left { color: var(--sage); }
.tablet.supplication h3 { color: var(--gold); font-size: var(--step-2); }
.tablet.supplication .mercy-left { font: italic 1.05rem/1.35 var(--serif); margin-top: 0.35rem; }
.tablet .voice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.95rem;
}
.tablet .voice .place { flex: 0 0 auto; }
.tablet .voice-text { flex: 1 1 12rem; min-width: 0; }
.tablet .choir-faces {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.tablet .choir-face {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  margin-left: -0.45rem;
  background: var(--tablet);
  object-fit: cover;
}
.tablet .choir-faces .choir-face:first-child { margin-left: 0; }
.tablet.kept .choir-face { opacity: 0.72; }
.tablet .choir-more {
  margin-left: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ember);
}
.tablet .place {
  display: inline-block;
  min-width: 1.1rem;
  margin-right: 0.35rem;
  color: var(--ember);
  font-weight: 600;
}
.tablet.kept { box-shadow: none; }
.tablet .bonus { color: var(--muted); font-size: 0.92rem; margin: 0.35rem 0 0; }
.tablet h3 { font-size: var(--step-2); margin: 0.1rem 0 0.35rem; }
.tablet .reason { font: italic 400 1.05rem/1.45 var(--serif); }
.tablet .fervor { color: var(--ember); margin-left: 0.35rem; font-weight: 600; letter-spacing: 0.04em; }
.tablet .devotion { color: var(--ember); font-size: 0.95rem; margin: 0.35rem 0 0; }
.tablet .offer { margin-top: 0.9rem; padding-top: 0.8rem; border-top: 1px dashed var(--line); }
.tablet .offer-title { font: 600 var(--step-1)/1.25 var(--serif); }
.tablet .offer-desc { color: var(--muted); margin: 0.2rem 0 0.8rem; }
.tablet .waiting { margin-top: 0.8rem; color: var(--muted); font-style: italic; }
.tablet .lack { margin-left: 0.6rem; color: var(--muted); font-size: 0.95rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(1.5rem); }
  to { opacity: 1; transform: none; }
}

.empty { color: var(--muted); font-style: italic; }

/* --- Chronicle ------------------------------------------------------------ */

.chronicle { display: grid; gap: 0.9rem; }
.chronicle p { font: 400 1.12rem/1.6 var(--serif); max-width: 36em; }
.chronicle .day { font: 500 0.9rem/1 var(--sans); color: var(--muted); margin-bottom: 0.25rem; }
.column .column .chronicle article:first-child p { font-size: var(--step-1); }
.chronicle-more { margin-top: 0.85rem; }
.chronicle-more { margin-top: 0.85rem; }

/* --- Quests --------------------------------------------------------------- */

.quest h3 { margin-bottom: 0.2rem; }
.quest > p { color: var(--muted); margin-bottom: 0.6rem; }
.quest ol { display: grid; gap: 0.45rem; }
.quest li { display: grid; grid-template-columns: 1.4rem 1fr; gap: 0.4rem; align-items: start; }
.quest li::before { content: "○"; color: var(--muted); }
.quest li.done::before { content: "●"; color: var(--leaf); }
.quest li.current::before { content: "◐"; color: var(--gold); }
.quest li.done span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

.bar { height: 0.35rem; background: var(--line); border-radius: 1rem; overflow: hidden; margin-top: 0.3rem; }
.bar > i { display: block; height: 100%; background: var(--leaf); border-radius: inherit; }

/* --- Mis ------------------------------------------------------------------ */

.census { margin-bottom: 0.9rem; color: var(--muted); }
.census strong { color: var(--ink); }

.mis-frame { position: relative; }
.mis { display: grid; gap: 0.2rem; min-width: 0; }
.mis-frame.bounded {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border: 1.5px solid transparent;
  border-radius: 1.15rem;
  padding: 0.2rem 0.7rem 0.15rem;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--tablet) 82%, var(--sage)), var(--sage)) padding-box,
    linear-gradient(155deg, var(--indigo), var(--gold) 46%, var(--leaf)) border-box;
}
.mis-frame.bounded .mis {
  max-height: var(--mi-clip, 16rem);
  overflow: hidden;
  overscroll-behavior-y: auto;
  scroll-padding-bottom: 2.6rem;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.mis-frame.bounded .mis::-webkit-scrollbar {
  width: 0;
  height: 0;
  background: transparent;
}
.mis-frame.bounded .mis::-webkit-scrollbar-button,
.mis-frame.bounded .mis::-webkit-scrollbar-track,
.mis-frame.bounded .mis::-webkit-scrollbar-thumb,
.mis-frame.bounded .mis::-webkit-scrollbar-corner {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}
.mis-frame.bounded.open .mis {
  max-height: none;
  overflow-x: clip;
  overflow-y: visible;
  padding-bottom: 2.6rem;
}
@media (hover: hover) and (pointer: fine) {
  .mis-frame.bounded:hover .mis,
  .mis-frame.bounded:focus-within .mis,
  .mis-frame.bounded.open .mis {
    max-height: min(64vh, 38rem);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding-bottom: 0.35rem;
  }
}
@media (hover: none), (pointer: coarse) {
  .mis-frame.bounded.open .mis-more {
    position: fixed;
    left: 50%;
    bottom: calc(4.7rem + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    margin: 0;
    z-index: 7;
  }
  .mis-frame.bounded.open::after { opacity: 0; }
}
.mis-frame.bounded::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 1.5px;
  right: 1.5px;
  bottom: 2.65rem;
  height: 2.6rem;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--sage) 92%, var(--tablet)) 88%);
  pointer-events: none;
}
.mis-frame.bounded.scrolled::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 1.5px;
  right: 1.5px;
  top: 1.5px;
  height: 1.4rem;
  border-radius: 1rem 1rem 0 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tablet) 88%, var(--line) 12%), transparent);
  pointer-events: none;
}
.mis-frame.bounded.at-end::after { opacity: 0; }
.mis-more {
  position: relative;
  z-index: 2;
  align-self: center;
  margin: 0.15rem 0 0.4rem;
  padding: 0.32rem 0.85rem;
  font-size: 0.9rem;
  background: var(--tablet);
  scroll-margin-bottom: 5.5rem;
}
.mis-more[hidden] { display: none; }
.mi {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 0.2rem 0.85rem;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.mi.child { padding-top: 0.45rem; padding-bottom: 0.45rem; }
.bubble { position: relative; grid-row: 1 / 4; width: 3.25rem; align-self: center; }
.mi .portrait { width: 3.25rem; height: 3.25rem; border-radius: 50%; display: block; }
.mi.child .portrait { width: 2.7rem; height: 2.7rem; }
.mi.child .bubble { width: 2.7rem; }
.mi.errant .portrait { box-shadow: 0 0 0 2px var(--indigo); }
.errant-mark { margin-left: 0.45rem; font: italic 400 0.92rem/1.2 var(--serif); color: var(--indigo); }
.mi.exploring .portrait { box-shadow: 0 0 0 2px var(--leaf); }
.explore-mark {
  display: inline-flex;
  margin-left: 0.35rem;
  color: var(--leaf);
  cursor: help;
  vertical-align: -0.15em;
}
.explore-mark svg { width: 1.35rem; height: 1.35rem; fill: currentColor; stroke: none; }
.bond-badge {
  position: absolute;
  right: -0.28rem;
  bottom: -0.05rem;
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--tablet);
  z-index: 1;
}
.bond-badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bond-badge[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--gold); }
.mi .who { font: 600 1.1rem/1.2 var(--serif); min-width: 0; overflow-wrap: anywhere; }
.mi.child .who { font-size: 1.02rem; }
.mi .who small { font: 400 0.9rem var(--sans); color: var(--muted); margin-left: 0.35rem; }
.bond-chip { margin-left: 0.45rem; font: italic 400 0.92rem/1.2 var(--serif); color: var(--leaf); }
.bond-chip.warm { color: #8A5A12; }
.bond-chip.cold { color: var(--ember); }
.mi .doing { color: var(--muted); font-size: 0.95rem; }
.bond-panel { grid-column: 1 / -1; display: grid; gap: 0.55rem; padding-top: 0.35rem; }
.bond-row { display: flex; flex-wrap: wrap; gap: 0.35rem 0.7rem; align-items: center; }
.bond-row img { width: 1.6rem; height: 1.6rem; border-radius: 50%; }
.bond-row p { font: italic 0.95rem/1.2 var(--serif); }
.gauges {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.35rem;
  margin-top: 0.3rem;
  min-width: 0;
}
.gauge { font-size: 0.72rem; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.gauge .bar { margin-top: 0.15rem; }
.gauge.low .bar > i { background: var(--ember); }

.peuple { margin-top: 1rem; display: grid; gap: 0.3rem; }
.peuple p { color: var(--muted); }
.brigade { display: flex; gap: 0.6rem; align-items: baseline; }
.brigade b { font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }

.betes { display: grid; gap: 0.35rem; }
.bete { display: flex; justify-content: space-between; gap: 0.8rem; align-items: baseline; min-width: 0; }
.bete > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.bete .where, .betes > .where { color: var(--muted); }
.bete .where { font-size: 0.92rem; }
.bete b { font-variant-numeric: tabular-nums; flex-shrink: 0; }

.stir { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.stir button { padding: 0.28rem 0.7rem; font-size: 0.88rem; }
.path { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin-top: 0.15rem; }
.path input { flex: 1 1 12rem; min-width: 0; font: 400 0.95rem/1.3 var(--sans); padding: 0.28rem 0.5rem; }
.path button { padding: 0.28rem 0.7rem; font-size: 0.88rem; }
.stir button.hate { border-color: var(--ember); color: var(--ember); }

/* --- Stock ---------------------------------------------------------------- */

.stock { display: grid; gap: 1rem; }
.stock h3 { font-size: 1.05rem; color: var(--muted); font-weight: 600; margin-bottom: 0.4rem; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 0.5rem; }
.item { display: grid; justify-items: center; text-align: center; gap: 0.15rem; padding: 0.35rem 0.2rem; }
.item img { width: 2.75rem; height: 2.75rem; }
.item .qty { font-weight: 700; font-variant-numeric: tabular-nums; }
.item .name { font-size: 0.82rem; line-height: 1.2; color: var(--muted); }

/* --- Buildings and plans -------------------------------------------------- */

.site { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 1rem; padding: 0.45rem 0; }
.site .where { color: var(--muted); font-size: 0.9rem; }
.site .bar { grid-column: 1 / -1; }
.plans { display: grid; gap: 0.9rem; margin-top: 1rem; }
.plan {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0.2rem 0.9rem;
  padding: 0.9rem;
  border: 1.5px dashed var(--muted);
  border-radius: 0.6rem;
}
.plan img { width: 3rem; height: 3rem; grid-row: span 3; }
.plan .desc { color: var(--muted); font-size: 0.95rem; }
.cost { display: flex; flex-wrap: wrap; gap: 0.35rem 0.8rem; font-size: 0.92rem; }
.cost .short { color: var(--ember); font-weight: 700; }
.plan button { justify-self: start; margin-top: 0.5rem; }

/* --- Discoveries ---------------------------------------------------------- */

.leads { color: var(--muted); margin-bottom: 0.9rem; display: grid; gap: 0.2rem; }
.discoveries { display: grid; gap: 0.6rem; }
.discovery { display: grid; grid-template-columns: 2.5rem 1fr; gap: 0 0.8rem; align-items: center; }
.discovery img { width: 2.5rem; height: 2.5rem; grid-row: span 2; }
.discovery .name { font: 600 1.05rem/1.2 var(--serif); }
.discovery .meta { color: var(--muted); font-size: 0.88rem; }

/* --- Journal -------------------------------------------------------------- */

.events { display: grid; gap: 0.35rem; font-size: 0.95rem; }
.events li { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr); gap: 0.6rem; }
.events li span { min-width: 0; overflow-wrap: anywhere; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; }
.events .ev-bienfait, .events .ev-decouverte, .events .ev-quete, .events .ev-couple, .events .ev-naissance, .events .ev-majorite { font-weight: 500; }
.events .ev-attirance, .events .ev-couple { color: #8A5A12; }
.events .ev-haine, .events .ev-tension, .events .ev-refus { color: var(--ember); }
.events .ev-amitie, .events .ev-apaisement { color: var(--leaf); }
.events li.empty { display: block; }
.events .ev-attente { color: var(--muted); }
.events .ev-souffle { font-style: italic; }
.events .ev-phenomene, .events .ev-exploration { font-style: italic; }
.events .ev-exploration { color: var(--leaf); }
.events li.empty { display: block; }

/* --- Controls ------------------------------------------------------------- */

.controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  align-items: center;
  padding: 0.65rem 0.9rem calc(0.65rem + env(safe-area-inset-bottom));
  background: var(--indigo);
  color: var(--tablet);
}
.speed { display: inline-flex; border: 1.5px solid var(--tablet); border-radius: 999px; overflow: hidden; }
.speed button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--tablet);
  padding: 0.5rem 0.7rem;
  font-variant-numeric: tabular-nums;
}
.speed button[aria-checked="true"] { background: var(--gold); color: var(--ink); font-weight: 700; }
.policy { display: inline-flex; gap: 0.5rem; align-items: center; font-size: 0.95rem; cursor: pointer; }
.policy input { width: 1.1rem; height: 1.1rem; accent-color: var(--gold); }
.supervisor { display: grid; gap: 0.5rem; }
.supervisor #status { display: grid; gap: 0.25rem; font-size: 0.95rem; }
.supervisor .note { color: var(--muted); }

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 5.5rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--tablet);
  padding: 0.6rem 1rem;
  border-radius: 0.5rem;
  max-width: min(36rem, calc(100% - 2rem));
}

/* --- Stone tablets: Dessein, Journal, Chronique --------------------------- */

.tablettes {
  position: fixed;
  z-index: 17;
  top: 0.85rem;
  right: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.tablette {
  display: grid;
  justify-items: center;
  gap: 0.2rem;
  width: 4.85rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.15rem 0.1rem 0.1rem;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: var(--ink);
}

.tablette:hover:not(:disabled),
.tablette.open {
  background: transparent;
}

.tablette-pierre {
  display: grid;
  place-items: center;
  width: 2.85rem;
  height: 3.4rem;
  background: var(--tablet);
  color: var(--indigo);
  border: 1.5px solid var(--ink);
  border-radius: 46% 46% 0.35rem 0.35rem / 1.15rem 1.15rem 0.35rem 0.35rem;
  box-shadow: 0 0.12rem 0 color-mix(in srgb, var(--ink) 22%, transparent);
}

.tablette-pierre svg { width: 1.45rem; height: 1.45rem; display: block; }
.tablette-pierre .traits { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.tablette-pierre .jour { fill: none; stroke: var(--gold); stroke-width: 1.7; }

.tablette.loi .tablette-pierre {
  width: 2.95rem;
  height: 3.35rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.tablette.loi .tablette-pierre svg { width: 2.95rem; height: 3.35rem; }
.tablette.loi .tablette-pierre svg path { fill: var(--tablet); stroke: var(--ink); stroke-width: 2; }
.tablette.loi .tablette-pierre svg .traits { fill: none; stroke: var(--indigo); stroke-width: 1.7; }

.tablette.open .tablette-pierre {
  box-shadow: 0 0 0.95rem rgba(232, 184, 74, 0.9);
}

.tablette.loi.open .tablette-pierre { box-shadow: none; }
.tablette.loi.open .tablette-pierre svg { filter: drop-shadow(0 0 0.45rem rgba(232, 184, 74, 0.95)); }

.tablette-nom { font: 600 0.8rem/1.1 var(--sans); }

.pane {
  position: fixed;
  z-index: 16;
  top: 0.7rem;
  right: 6.15rem;
  bottom: calc(4.8rem + env(safe-area-inset-bottom));
  width: min(26rem, calc(100vw - 8rem));
  display: flex;
  flex-direction: column;
  padding: 1.35rem 1.2rem 1rem;
  background: var(--tablet);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 1.7rem 1.7rem 0.45rem 0.45rem;
  box-shadow: 0 0 1.8rem rgba(232, 184, 74, 0.32);
  visibility: hidden;
  pointer-events: none;
}

.pane.open {
  visibility: visible;
  pointer-events: auto;
}

.pane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex: none;
}

.pane-head h2 { margin-bottom: 0; }

.pane-body {
  flex: 1;
  min-height: 0;
  margin-top: 0.85rem;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.pane .chronicle { gap: 0; }
.pane .chronicle article {
  padding: 0.8rem 0.05rem 0.85rem;
  border-bottom: 1px solid var(--line);
}
.pane .chronicle article:last-child { border-bottom: 0; }
.pane .events li { grid-template-columns: 6.4rem minmax(0, 1fr); }
.pane .events time { white-space: nowrap; }

@media (min-width: 900px) {
  body { padding-right: 6rem; }
  .controls {
    margin-right: -6rem;
    padding-right: calc(0.9rem + 6rem);
  }
}

@media (max-width: 899px) {
  .tablettes {
    top: auto;
    bottom: calc(4.55rem + env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    justify-content: center;
    flex-direction: row;
    gap: 0.55rem;
  }
  .tablette { width: 3.15rem; padding: 0; }
  .tablette-nom {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .tablette-pierre { width: 2.5rem; height: 2.95rem; }
  .tablette.loi .tablette-pierre,
  .tablette.loi .tablette-pierre svg { width: 2.45rem; height: 2.8rem; }
  .pane {
    top: 0.45rem;
    right: 0.45rem;
    left: 0.45rem;
    bottom: calc(8.5rem + env(safe-area-inset-bottom));
    width: auto;
  }
  .layout { padding-bottom: calc(9.4rem + env(safe-area-inset-bottom)); }
}

@media (max-width: 899px) and ((hover: none) or (pointer: coarse)) {
  .mis-frame.bounded.open .mis-more {
    bottom: calc(8.5rem + env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
