/* ═══════════════════════════════════════════════════════════════════════════
   Tempus Fractum: styles
   Materials: parchment, bronze, stone, muted Roman red.
   Sized for a classroom projector first (large type, strong contrast).
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --parchment: #efe4c8;
  --parchment-light: #f8f1de;
  --parchment-deep: #dccb9f;
  --ink: #2a1c10;
  --ink-soft: #5a4530;
  --bronze: #94703d;
  --bronze-light: #c9a466;
  --bronze-dark: #5f4524;
  --red: #8a2c22;
  --red-dark: #621d16;
  --red-hover: #9d352a;
  --stone: #3a322a;
  --stone-dark: #1c1712;
  --cream: #f6eedb;

  --font-serif: "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", P052, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: clamp(12px, 1.6vw, 28px);
  --radius: 6px;
  --shadow-panel: 0 18px 50px rgba(0, 0, 0, 0.45);

  /* Projector-friendly type scale */
  --text-latin: clamp(1.75rem, 2.1vw + 0.6rem, 3.1rem);
  --text-choice: clamp(1.2rem, 1.15vw + 0.5rem, 1.9rem);
  --text-action: clamp(1.05rem, 0.9vw + 0.5rem, 1.5rem);
  --text-narration: clamp(1.1rem, 0.85vw + 0.6rem, 1.55rem);
  --text-narration-solo: clamp(1.25rem, 1vw + 0.6rem, 1.8rem);

  --parchment-surface:
    radial-gradient(ellipse at 15% 0%, rgba(255, 255, 255, 0.45), transparent 55%),
    radial-gradient(ellipse at 100% 100%, rgba(120, 80, 30, 0.16), transparent 60%),
    linear-gradient(var(--parchment), var(--parchment));
  --parchment-edges:
    inset 0 0 0 5px var(--parchment),
    inset 0 0 0 6px rgba(148, 112, 61, 0.55),
    inset 0 0 70px rgba(120, 80, 30, 0.2);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--stone-dark);
  color: var(--ink);
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
}
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--bronze-light); outline-offset: 2px; }

.app { position: fixed; inset: 0; overflow: hidden; overflow: clip; }
.app.is-title .hud,
.app.is-title .dialogue { display: none; }

/* ── Stage ──────────────────────────────────────────────────────────────── */

.stage { position: absolute; inset: 0; }

/* Every background is 3:2. This canvas keeps that shape and covers the screen (like
   background-size: cover), so props positioned on it stay on the same spot of the painting
   on any screen shape: widescreen, 16:10, 4:3, or ultrawide. */
.stage__canvas {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100vw, 150vh);
  aspect-ratio: 3 / 2;
  transform: translate(-50%, -50%);
}

.stage__bg,
.title-screen__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

/* Painted-landscape stand-in until the real background exists */
.stage__bg.is-placeholder,
.title-screen__bg.is-placeholder {
  background:
    radial-gradient(ellipse 22% 7% at 74% 55%, rgba(150, 70, 45, 0.45), transparent 70%),
    radial-gradient(ellipse 30% 14% at 74% 50%, rgba(235, 220, 200, 0.5), transparent 70%),
    radial-gradient(ellipse 60% 30% at 70% 20%, rgba(255, 240, 200, 0.6), transparent 70%),
    linear-gradient(to bottom, #cfae80 0%, #e6cc9e 40%, #d4b886 55%, #a39b5e 56%, #82803f 72%, #5e5c2c 100%);
}
.stage__bg.is-placeholder::after {
  content: attr(data-placeholder-label);
  position: absolute;
  top: calc(var(--gutter) + 3.6rem);
  left: var(--gutter);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  background: rgba(248, 241, 222, 0.7);
  color: rgba(42, 28, 16, 0.75);
  font: 600 0.8rem/1.2 var(--font-mono);
}

.stage__vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 35%, transparent 55%, rgba(20, 14, 8, 0.45) 100%),
    linear-gradient(to bottom, rgba(20, 14, 8, 0.4), transparent 16%);
}

.stage__props,
.stage__character { position: absolute; inset: 0; pointer-events: none; }
.stage__props .placeholder__label { font-size: clamp(0.7rem, 0.9vw, 1.05rem); }

.prop { position: absolute; transition: filter 400ms ease; }
.prop img { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35)); }
.prop.is-placeholder .placeholder { aspect-ratio: 4 / 3; }
.prop.is-highlighted img { filter: drop-shadow(0 0 22px rgba(255, 214, 150, 0.95)); }
.prop.is-highlighted .placeholder {
  border-color: var(--parchment-light);
  box-shadow: 0 0 0 3px var(--bronze-light), 0 0 40px rgba(255, 214, 150, 0.85);
}

.character {
  position: absolute;
  right: 6vw;
  bottom: 0;
  height: 90vh;
  display: flex;
  align-items: flex-end;
}
.character img { height: 100%; width: auto; object-fit: contain; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.45)); }
.character.is-placeholder { width: min(34vh, 28vw); }
.character.is-arriving { animation: arrive 700ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }

@keyframes arrive {
  from { opacity: 0; transform: translateX(5vw); }
  to { opacity: 1; transform: none; }
}

/* Placeholder boxes for missing art */
.placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.8rem;
  border: 2px dashed rgba(248, 241, 222, 0.8);
  border-radius: 8px;
  background: rgba(40, 32, 24, 0.45);
  backdrop-filter: blur(2px);
  color: var(--cream);
  text-align: center;
}
.placeholder__label { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.04em; }
.placeholder__path { font: 0.72rem/1.3 var(--font-mono); opacity: 0.8; word-break: break-all; }

/* Character placeholder: a simple standing silhouette with its label */
.character .placeholder { justify-content: flex-start; padding-top: 1.4rem; }
.character .placeholder::before {
  content: "";
  width: 38%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(248, 241, 222, 0.2);
  order: -1;
}
.character .placeholder::after {
  content: "";
  flex: 1;
  width: 78%;
  margin-top: 0.4rem;
  border-radius: 45% 45% 0 0;
  background: rgba(248, 241, 222, 0.14);
}

/* ── Top bar ────────────────────────────────────────────────────────────── */

.hud {
  position: absolute;
  top: var(--gutter);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }

.hud__chapter,
.hud-button {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: rgba(28, 23, 18, 0.78);
  border: 1px solid rgba(201, 164, 102, 0.6);
  border-radius: 999px;
  color: var(--cream);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.hud__chapter { padding: 0.35rem 1.1rem 0.35rem 0.35rem; }
.hud__numeral {
  display: grid;
  place-items: center;
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--red);
  border: 1px solid var(--bronze-light);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.hud__latin { font-size: 1.15rem; font-variant: small-caps; letter-spacing: 0.12em; }
.hud__english { color: var(--bronze-light); font-style: italic; }

.hud__actions { display: flex; gap: 0.6rem; margin-left: auto; }
.hud-button { padding: 0.55rem 1.1rem; font-size: 1.05rem; transition: background 150ms, border-color 150ms; }
.hud-button:hover { background: rgba(58, 50, 42, 0.92); border-color: var(--bronze-light); }
.hud-button__en { color: var(--bronze-light); font-style: italic; font-size: 0.9em; }

.badge {
  display: grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--red);
  color: var(--cream);
  font-size: 0.85rem;
  font-weight: 700;
}

/* ── Dialogue panel ─────────────────────────────────────────────────────── */

.dialogue {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: clamp(16px, 2vw, 36px);
  /* Kept short so the scene art and the NPC stay visible above it */
  --panel-max: 42vh;
  max-height: var(--panel-max);
  padding: clamp(22px, 2vw, 36px) clamp(20px, 2.2vw, 40px) clamp(14px, 1.4vw, 24px);
  background: var(--parchment-surface);
  border: 1px solid var(--bronze-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel), var(--parchment-edges);
}
/* While the hint is open, let the panel grow so the translation and vocab fit */
.dialogue.is-hint-open { --panel-max: 62vh; }
/* Many choices (two-column grid): give the choices the wider side */
.dialogue:has(.choices.is-grid) { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
/* Each column scrolls inside the panel rather than spilling past its bottom edge */
.dialogue > .dialogue__text,
.dialogue > .choices { max-height: calc(var(--panel-max) - 64px); }

.nameplate {
  position: absolute;
  top: 0;
  left: clamp(20px, 2.4vw, 44px);
  transform: translateY(-58%);
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.3rem 1.2rem 0.4rem;
  background: linear-gradient(var(--red-hover), var(--red));
  border: 1px solid var(--bronze-light);
  border-radius: 3px;
  color: var(--cream);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.nameplate__name {
  font-size: clamp(1.15rem, 1vw + 0.6rem, 1.65rem);
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.1em;
}
.nameplate__role { font-style: italic; opacity: 0.85; font-size: clamp(0.95rem, 0.6vw + 0.6rem, 1.2rem); }

/* Patience meter: its own dark band on the nameplate, big gold seals, lost ones marked
   with a red ✕, a "−1" pop when one breaks, and a pulse on the last one. */
.patience {
  position: absolute;
  top: 0;
  right: clamp(20px, 2.4vw, 44px);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem 0.4rem 1.1rem;
  transform: translateY(-58%);
  background: linear-gradient(#3a3027, var(--stone-dark));
  border: 1px solid var(--bronze-light);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  transition: background 300ms;
}
.patience__label {
  margin-right: 0.2rem;
  font-size: clamp(1.05rem, 0.7vw + 0.7rem, 1.4rem);
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  color: #f7e3a8;
}
.seal {
  position: relative;
  width: clamp(1.65rem, 1.3vw + 0.85rem, 2.2rem);
  height: clamp(1.65rem, 1.3vw + 0.85rem, 2.2rem);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff1b8, #f0c24e 40%, #b8862b 75%, #7a5418);
  box-shadow: 0 0 0 2px #3a2610, 0 0 8px rgba(255, 205, 90, 0.75);
}
.seal.is-broken {
  background: rgba(20, 14, 8, 0.6);
  box-shadow: inset 0 0 0 2px rgba(246, 238, 219, 0.35);
}
.seal.is-broken::before,
.seal.is-broken::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: calc(50% - 2px);
  height: 4px;
  border-radius: 2px;
  background: #e0473a;
  transform: rotate(45deg);
}
.seal.is-broken::after { transform: rotate(-45deg); }
.seal.is-breaking { animation: seal-break 800ms ease-out both; }
.patience.is-low .seal:not(.is-broken) { animation: seal-pulse 1.1s ease-in-out infinite; }
.patience.is-low { background: linear-gradient(#9d352a, var(--red-dark)); }
.patience.is-shaken { animation: shake-badge 450ms ease-in-out; }
.patience__loss {
  position: absolute;
  right: 0.6rem;
  top: -1.7rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: #ff6a55;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  animation: loss-pop 1.4s ease-out both;
}

@keyframes shake-badge {
  20%, 60% { transform: translate(-5px, -58%); }
  40%, 80% { transform: translate(5px, -58%); }
}
@keyframes seal-break {
  0% { transform: scale(1.6) rotate(0deg); background: #f0c24e; box-shadow: 0 0 22px rgba(255, 90, 60, 0.95); }
  60% { transform: scale(0.85) rotate(-12deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes seal-pulse {
  50% { transform: scale(1.22); box-shadow: 0 0 0 2px #3a2610, 0 0 18px rgba(255, 150, 70, 1); }
}
@keyframes loss-pop {
  0% { opacity: 0; transform: translateY(8px) scale(0.6); }
  20% { opacity: 1; transform: translateY(0) scale(1.15); }
  70% { opacity: 1; transform: translateY(-6px) scale(1); }
  100% { opacity: 0; transform: translateY(-14px); }
}
@keyframes shake {
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.dialogue__text {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.said {
  margin: 0;
  color: var(--ink-soft);
  font-size: var(--text-action);
}
.said q { font-style: italic; font-weight: 600; color: var(--red-dark); }

.narration p {
  margin: 0 0 0.35em;
  font-size: var(--text-narration);
  font-style: italic;
  line-height: 1.45;
  color: var(--ink-soft);
}
.narration p:last-child { margin-bottom: 0; }
.dialogue.is-narration .narration p { font-size: var(--text-narration-solo); font-style: normal; color: var(--ink); }

.latin {
  margin: 0.1rem 0 0;
  font-size: var(--text-latin);
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
}
.latin--inscription {
  align-self: flex-start;
  padding: 0.45rem 1.3rem;
  border-radius: 3px;
  background: linear-gradient(#d3cab8, #b6ab95);
  box-shadow: inset 0 2px 7px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.5);
  color: #3b3229;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.hint-toggle {
  align-self: flex-start;
  margin-top: 0.2rem;
  padding: 0.3rem 0.95rem;
  background: transparent;
  border: 1px solid var(--bronze);
  border-radius: 999px;
  color: var(--bronze-dark);
  font-size: 1rem;
  font-style: italic;
  transition: background 150ms;
}
.hint-toggle:hover,
.hint-toggle.is-open { background: rgba(148, 112, 61, 0.15); }
.hint-toggle__en { font-style: normal; opacity: 0.75; font-size: 0.9em; }

.hint {
  padding: 0.6rem 0.9rem;
  border-left: 3px solid var(--bronze);
  border-radius: 0 4px 4px 0;
  background: rgba(148, 112, 61, 0.12);
  animation: rise 220ms ease-out both;
}
.hint__vocab { display: flex; flex-wrap: wrap; gap: 0.4rem 0.5rem; margin: 0; }
.hint__translation { margin: 0; font-size: var(--text-narration); animation: rise 220ms ease-out both; }
.hint__vocab:not([hidden]) + .hint__translation { margin-top: 0.6rem; }
.vocab-item {
  display: flex;
  gap: 0.4rem;
  padding: 0.15rem 0.6rem;
  background: var(--parchment-light);
  border: 1px solid rgba(148, 112, 61, 0.45);
  border-radius: 4px;
  font-size: 1.05rem;
}
.vocab-item dt { font-weight: 700; font-style: italic; }
.vocab-item dd { margin: 0; color: var(--ink-soft); }

/* ── Choices ────────────────────────────────────────────────────────────── */

.choices {
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  gap: 0.4rem;
  min-width: 0;
  margin: 0;
  padding: 0.2rem 0.3rem 0.2rem 0;
  list-style: none;
  overflow-y: auto;
}
/* Four or more choices: two columns, so the panel stays short */
.choices.is-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: safe center;
}
.choices.is-grid .choice { height: 100%; }

.choice {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  padding: 0.35rem 1rem 0.35rem 0.4rem;
  text-align: left;
  background: var(--parchment-light);
  border: 1px solid rgba(95, 69, 36, 0.45);
  border-radius: 5px;
  box-shadow: 0 2px 0 rgba(95, 69, 36, 0.25);
  transition: transform 140ms ease, background 140ms, border-color 140ms, box-shadow 140ms;
}
.choice:hover,
.choice:focus-visible {
  outline: none;
  background: #fffaee;
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(138, 44, 34, 0.25), 0 2px 0 rgba(95, 69, 36, 0.25);
  transform: translateX(4px);
}
.choice:active { transform: translateX(4px) translateY(1px); }

.choice__num {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 0.3rem;
  border-radius: 4px;
  background: var(--stone);
  color: var(--bronze-light);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.choice__text { font-size: var(--text-choice); line-height: 1.25; }

.choice--say .choice__text { font-style: italic; font-weight: 600; }
.choice--say .choice__text::before { content: "“"; }
.choice--say .choice__text::after { content: "”"; }

.choice--action .choice__text { font-size: var(--text-action); color: var(--ink-soft); }
.choice--action .choice__num { background: transparent; border: 1px solid var(--bronze); color: var(--bronze-dark); }

.choice--continue {
  background: linear-gradient(var(--red-hover), var(--red));
  border-color: var(--red-dark);
  color: var(--cream);
}
.choice--continue:hover,
.choice--continue:focus-visible { background: linear-gradient(#ab3c30, var(--red-hover)); border-color: var(--red-dark); }
.choice--continue .choice__num { background: rgba(0, 0, 0, 0.22); color: var(--cream); font-size: 1.6rem; }
.choice--continue .choice__text { font-size: var(--text-action); font-weight: 600; letter-spacing: 0.02em; }

/* Entrance motion for each new beat */
.dialogue__text.is-entering > *,
.choices.is-entering > * { animation: rise 380ms ease-out both; }
.choices.is-entering > :nth-child(2) { animation-delay: 40ms; }
.choices.is-entering > :nth-child(3) { animation-delay: 80ms; }
.choices.is-entering > :nth-child(4) { animation-delay: 120ms; }
.choices.is-entering > :nth-child(n + 5) { animation-delay: 160ms; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ── Bag drawer ─────────────────────────────────────────────────────────── */

.drawer-backdrop { position: absolute; inset: 0; z-index: 8; background: rgba(20, 14, 8, 0.45); }

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  display: flex;
  flex-direction: column;
  width: min(460px, 92vw);
  background: var(--parchment-surface);
  border-left: 1px solid var(--bronze-dark);
  box-shadow: -18px 0 50px rgba(0, 0, 0, 0.4), var(--parchment-edges);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 300ms cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s linear 300ms;
}
.drawer.is-open { transform: none; visibility: visible; transition-delay: 0s; }

.drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(148, 112, 61, 0.4);
}
.drawer__title { margin: 0; font-size: 1.7rem; font-variant: small-caps; letter-spacing: 0.1em; }
.drawer__en { font-variant: normal; letter-spacing: 0; font-style: italic; font-size: 1.1rem; color: var(--ink-soft); }

.icon-button {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--bronze);
  border-radius: 50%;
  background: transparent;
  font-size: 1.1rem;
}
.icon-button:hover { background: rgba(148, 112, 61, 0.15); }

.inventory__list { display: flex; flex-direction: column; gap: 0.9rem; margin: 0; padding: 1.2rem 1.5rem; overflow-y: auto; list-style: none; }
.inventory__empty { font-size: 1.2rem; color: var(--ink-soft); }
.inventory__empty span { font-style: italic; font-weight: 700; color: var(--ink); }

.item { display: grid; grid-template-columns: 76px 1fr; gap: 0.9rem; align-items: start; }
.item__image { width: 76px; aspect-ratio: 1; }
.item__image img { width: 100%; height: 100%; object-fit: contain; }
.item__image .placeholder { border-color: rgba(95, 69, 36, 0.5); background: rgba(148, 112, 61, 0.15); color: var(--ink-soft); padding: 0.3rem; }
.item__image .placeholder__label { font-size: 0.8rem; font-style: italic; }
.item__image .placeholder__path { display: none; }
.item__name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; margin: 0 0 0.2rem; }
.item__latin { font-size: 1.4rem; font-weight: 700; font-style: italic; }
.item__english { color: var(--ink-soft); }
.item__description { margin: 0; font-size: 1.02rem; line-height: 1.4; color: var(--ink-soft); }

/* ── Toasts ─────────────────────────────────────────────────────────────── */

.toasts {
  position: absolute;
  top: calc(var(--gutter) + 4rem);
  left: 50%;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 0.6rem 1.3rem;
  background: rgba(28, 23, 18, 0.92);
  border: 1px solid var(--bronze-light);
  border-radius: 999px;
  color: var(--cream);
  font-size: 1.2rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toast-in 320ms ease-out both, toast-out 400ms ease-in 3.1s forwards;
}
.toast strong { color: var(--bronze-light); font-style: italic; }

@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ── Overlays, cards, buttons ───────────────────────────────────────────── */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: rgba(20, 14, 8, 0.72);
  backdrop-filter: blur(3px);
  animation: fade-in 300ms ease-out both;
}
@keyframes fade-in { from { opacity: 0; } }

.card {
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 2 * var(--gutter));
  overflow-y: auto;
  padding: clamp(28px, 3.2vw, 52px);
  text-align: center;
  background: var(--parchment-surface);
  border: 1px solid var(--bronze-dark);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel), var(--parchment-edges);
  animation: rise 400ms ease-out both;
}

.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  min-width: 12rem;
  padding: 0.7rem 1.6rem;
  background: var(--parchment-light);
  border: 1px solid var(--bronze-dark);
  border-radius: 4px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  box-shadow: 0 2px 0 rgba(95, 69, 36, 0.35);
  transition: background 150ms, transform 150ms;
}
.btn small { font-size: 0.72em; font-weight: 400; font-style: italic; opacity: 0.8; letter-spacing: 0; }
.btn:hover { background: #fffaee; transform: translateY(-1px); }
.btn--primary { background: linear-gradient(var(--red-hover), var(--red)); border-color: var(--red-dark); color: var(--cream); }
.btn--primary:hover { background: linear-gradient(#ab3c30, var(--red-hover)); }

/* Ending card */
.ending__kicker { margin: 0; color: var(--bronze-dark); font-size: 1.15rem; font-style: italic; }
.ending__kicker span { font-weight: 700; font-style: normal; letter-spacing: 0.06em; }
.ending__title {
  margin: 0.3rem 0 0;
  font-size: clamp(2.4rem, 4vw, 3.8rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--red-dark);
}
.ending--chapter .ending__title,
.ending--success .ending__title { color: var(--ink); }
.ending__subtitle { margin: 0.2rem 0 1.2rem; font-size: 1.3rem; font-style: italic; color: var(--ink-soft); }
.ending__subtitle::before,
.ending__subtitle::after { content: "—"; margin: 0 0.6rem; color: var(--bronze); }
.ending__text p { margin: 0 auto 0.8rem; max-width: 36em; font-size: var(--text-narration); line-height: 1.5; }
.ending__label { margin: 1.2rem 0 0.5rem; font-variant: small-caps; letter-spacing: 0.12em; color: var(--bronze-dark); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.chip { padding: 0.2rem 0.75rem; border: 1px solid rgba(148, 112, 61, 0.5); border-radius: 999px; background: var(--parchment-light); font-size: 1.05rem; }
.chip span { font-style: italic; font-weight: 700; }
.ending__stats { margin: 1rem 0 0; color: var(--ink-soft); }
.ending__teaser { margin: 1rem 0 0; font-style: italic; color: var(--bronze-dark); }
.ending__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.8rem; margin-top: 1.6rem; }

/* Defeat card: the review list (kept compact so it fits a projector screen) */
.ending--defeat { max-width: 900px; padding-top: clamp(20px, 2.4vw, 36px); padding-bottom: clamp(18px, 2vw, 30px); }
.ending--defeat .ending__title { color: var(--red-dark); font-size: clamp(2.2rem, 3.4vw, 3.2rem); }
.ending--defeat .ending__subtitle { margin-bottom: 0.6rem; }
.ending--defeat .ending__text p { margin-bottom: 0.4rem; }
.ending--defeat .ending__actions { margin-top: 1rem; }
.review { margin-top: 0.6rem; text-align: left; }
.review .ending__label { text-align: center; }
.review__list { margin: 0 0 0.8rem; padding-left: 1.4rem; }
.review__item { margin-bottom: 0.45rem; }
.review__latin { margin: 0; font-size: 1.2rem; font-weight: 700; }
.review__english { margin: 0.1rem 0 0; color: var(--ink-soft); }
.review__said { margin: 0.1rem 0 0; font-size: 0.95rem; color: var(--ink-soft); }
.review__said q { font-style: italic; color: var(--red-dark); }
.review__words { justify-content: flex-start; }
.review__none { margin: 1rem 0 0; font-style: italic; color: var(--ink-soft); }

/* Menu */
.menu { display: flex; flex-direction: column; align-items: stretch; gap: 0.7rem; max-width: 420px; }
.menu__title { margin: 0 0 0.4rem; font-size: 2rem; font-variant: small-caps; letter-spacing: 0.14em; }

/* Title screen */
.overlay--title { background: var(--stone-dark); backdrop-filter: none; }
.title-screen__bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(20, 14, 8, 0.35), rgba(20, 14, 8, 0.82) 75%);
}
.title-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  color: var(--cream);
  animation: rise 700ms ease-out both;
}
.title-screen__kicker {
  margin: 0;
  color: var(--bronze-light);
  font-size: clamp(1rem, 1.2vw, 1.3rem);
  font-variant: small-caps;
  letter-spacing: 0.3em;
}
.title-screen__name {
  margin: 0.2em 0 0.1em;
  font-size: clamp(3rem, 8vw, 7.5rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
}
.title-screen__tagline { margin: 0; font-size: clamp(1.2rem, 1.6vw, 1.7rem); font-style: italic; color: var(--parchment-deep); }
.title-screen__tagline::before,
.title-screen__tagline::after { content: "—"; margin: 0 0.7rem; color: var(--bronze-light); }
.title-screen__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin: 2.4rem 0 2rem; }
.title-screen__help { margin: 0; font-size: 1rem; color: rgba(246, 238, 219, 0.7); }
.title-screen__difficulty { margin: -0.8rem 0 1rem; font-size: 1.05rem; color: var(--parchment-deep); }
.title-screen__difficulty span { font-style: italic; font-weight: 700; color: var(--bronze-light); }
.title-screen__settings {
  position: absolute;
  top: var(--gutter);
  right: var(--gutter);
  z-index: 1;
  display: grid;
  place-items: center;
  width: 3.2rem;
  height: 3.2rem;
  padding: 0.65rem;
  border: 1px solid rgba(201, 164, 102, 0.6);
  border-radius: 50%;
  background: rgba(20, 14, 8, 0.45);
  color: var(--bronze-light);
  transition: background 150ms, color 150ms, transform 300ms;
}
.title-screen__settings svg { width: 100%; height: 100%; }
.title-screen__settings:hover { background: rgba(20, 14, 8, 0.7); color: var(--cream); transform: rotate(45deg); }

/* Settings panel */
.settings { display: flex; flex-direction: column; align-items: stretch; gap: 0.7rem; max-width: 520px; }
.settings .menu__title small { display: block; font-size: 0.5em; font-style: italic; font-variant: normal; letter-spacing: 0; color: var(--ink-soft); }
.settings__group { display: flex; flex-direction: column; gap: 0.6rem; margin: 0 0 0.6rem; padding: 0; border: 0; }
.settings__group legend { padding: 0; margin: 0 auto 0.6rem; }
.difficulty {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  border: 1px solid rgba(148, 112, 61, 0.5);
  border-radius: 4px;
  background: var(--parchment-light);
  text-align: left;
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.difficulty:hover { background: #fffaee; }
.difficulty:has(:checked) { border-color: var(--red-dark); background: #fffaee; box-shadow: inset 0 0 0 2px var(--red); }
.difficulty:has(:focus-visible) { outline: 2px solid var(--bronze-dark); outline-offset: 2px; }
.difficulty__input { position: absolute; opacity: 0; pointer-events: none; }
.difficulty__name { display: flex; flex-direction: column; font-size: 1.35rem; font-weight: 700; }
.difficulty__name small { font-size: 0.72em; font-weight: 400; font-style: italic; color: var(--ink-soft); }
.difficulty:has(:checked) .difficulty__name > span { color: var(--red-dark); }
.difficulty__desc { font-size: 1.05rem; line-height: 1.35; color: var(--ink-soft); }
kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.05em 0.4em;
  border: 1px solid rgba(201, 164, 102, 0.6);
  border-radius: 3px;
  font: 0.85em var(--font-mono);
  text-align: center;
}

/* Debug panel (?debug) */
.debug {
  position: absolute;
  top: calc(var(--gutter) + 3.8rem);
  left: var(--gutter);
  z-index: 20;
  max-width: 380px;
  max-height: 45vh;
  margin: 0;
  padding: 0.7rem 0.9rem;
  overflow: auto;
  background: rgba(10, 10, 10, 0.85);
  border-radius: 6px;
  color: #d8f0d0;
  font: 12px/1.4 var(--font-mono);
  white-space: pre-wrap;
}

/* ── Smaller screens (desktop/projector is the priority) ───────────────── */

@media (max-width: 900px) {
  .dialogue { grid-template-columns: 1fr; gap: 0.8rem; --panel-max: 50vh; overflow-y: auto; }
  .dialogue > .dialogue__text,
  .dialogue > .choices { max-height: none; overflow: visible; }
  .character { right: 0; height: 75vh; }
  .hud__english,
  .hud-button__en { display: none; }
  .difficulty { grid-template-columns: 6.5rem 1fr; gap: 0.7rem; }
}

@media (max-height: 640px) {
  .dialogue { --panel-max: 50vh; }
  .choice__num { min-width: 2.1rem; height: 2.1rem; }
}

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