/* ==========================================================================
   KNOCK, KNOCK!  —  styles
   Layout: illustration on the left, story + buttons on the right.
           On phones / tall windows they stack (picture on top).
   ========================================================================== */

:root {
  --bg: #0b1420;
  --panel: #0e1a2a;
  --panel-2: #132339;
  --ink: #f6f1e4;
  --ink-dim: #c3cbd6;
  --line: rgba(255, 255, 255, 0.14);
  --gold: #f3c969;
  --gold-deep: #c8962c;
  --green: #a9da62;
  --blue: #8fc3ff;
  --rose: #ff9aa8;
  --parch: #f6ead0;
  --parch-2: #ead8a8;
  --parch-ink: #3a2a14;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.38);
  --font-ui: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-story: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: clamp(16px, 0.5vw + 12px, 22px);
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

button { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- layout */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(380px, 1fr);
}

.stage {
  position: relative;
  overflow: hidden;
  background: #060c14;
  isolation: isolate;
}

.panel {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(243, 201, 105, 0.07), transparent 55%),
    linear-gradient(180deg, var(--panel-2), var(--panel));
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.35);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.panel-inner {
  width: 100%;
  max-width: 44rem;
  margin: auto;
  padding: clamp(1.1rem, 2.6vw, 2.6rem);
  padding-top: clamp(1.4rem, 3vw, 3rem);
  outline: none;
}

@media (max-width: 860px), (max-aspect-ratio: 5/6) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(190px, 38dvh) minmax(0, 1fr);
  }
  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    box-shadow: 0 -14px 34px rgba(0, 0, 0, 0.4);
  }
  .panel-inner { padding-top: 1.2rem; }
  .stage-bar { gap: 0.4rem; padding-inline: 0.6rem; }
  .pill { padding: 0.4rem 0.7rem 0.4rem 0.6rem; font-size: 0.74rem; gap: 0.35rem; }
}

/* ---------------------------------------------------------- scene layers */
.layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.045);
  transition: opacity 0.55s ease, transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: opacity, transform;
}
.layer.is-in { opacity: 1; transform: scale(1); z-index: 1; }
.layer svg { width: 100%; height: 100%; display: block; pointer-events: none; }

.layer.shake { animation: shake 0.62s ease-out; }

/* stage buttons */
.stage-bar {
  position: absolute;
  z-index: 5;
  inset: 0 0 auto 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.85rem 0.75rem;
  pointer-events: none;
}
.stage-bar > * { pointer-events: auto; }
.spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.9rem 0.5rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(8, 14, 24, 0.58);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, border-color 0.15s;
}
.pill svg { width: 1.05em; height: 1.05em; flex: none; }
.pill:hover { background: rgba(8, 14, 24, 0.85); border-color: rgba(255, 255, 255, 0.55); transform: translateY(-1px); }
.pill:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.pill--gold { border-color: rgba(243, 201, 105, 0.55); color: var(--gold); }
.pill--gold b { color: #fff; font-weight: 800; }
.pill[hidden] { display: none; }

/* "your choices are below" hint, pinned to the bottom of the story panel */
.more-wrap { position: sticky; bottom: 0; height: 0; overflow: visible; z-index: 6; flex: none; }
.more {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.05rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 233, 168, 0.8);
  color: #2a1c05;
  background: linear-gradient(180deg, #ffe08a, #f1b53f);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  animation: nudge 1.8s ease-in-out infinite;
}
.more[hidden] { display: none; }
.more:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* ------------------------------------------------------------- the lines */
.line {
  margin: 0 0 0.95rem;
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: calc(var(--i, 0) * 0.26s);
}
@keyframes rise { to { opacity: 1; transform: none; } }

.line--narrator {
  font-family: var(--font-story);
  font-style: italic;
  font-size: 1.1em;
  line-height: 1.55;
  color: var(--ink);
  padding-left: 0.95rem;
  border-left: 3px solid var(--gold);
}
.line--narrator.dim { color: var(--ink-dim); border-left-color: var(--line); }

.line--ogre, .line--you {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr);
  gap: 0.2rem 0.7rem;
  align-items: start;
}
.line--you { grid-template-columns: minmax(0, 1fr) 2.6rem; }
.line--you .avatar { grid-column: 2; grid-row: 1 / span 2; }
.line--you .who, .line--you .bubble { grid-column: 1; }
.line--you .who { text-align: right; }

.avatar {
  grid-row: 1 / span 2;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
}
.avatar svg { width: 100%; height: 100%; display: block; }
.line--ogre .avatar { background: #25401f; border-color: rgba(169, 218, 98, 0.6); }
.line--you .avatar { background: #1d3354; border-color: rgba(143, 195, 255, 0.6); }

.who {
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;
  padding-top: 0.2rem;
}
.line--ogre .who { color: var(--green); }
.line--you .who { color: var(--blue); }

.bubble {
  font-family: var(--font-story);
  font-size: 1.12em;
  line-height: 1.52;
  padding: 0.7rem 1rem 0.75rem;
  border-radius: 16px;
  margin: 0;
  overflow-wrap: anywhere;
}
.line--ogre .bubble {
  background: rgba(169, 218, 98, 0.12);
  border: 1px solid rgba(169, 218, 98, 0.38);
  border-top-left-radius: 4px;
}
.line--you .bubble {
  background: rgba(143, 195, 255, 0.12);
  border: 1px solid rgba(143, 195, 255, 0.4);
  border-top-right-radius: 4px;
}

/* scripture card ---------------------------------------------------------- */
.verse {
  display: block;
  position: relative;
  margin: 0 0 1rem;
  padding: 0.85rem 1.1rem 1rem 1.2rem;
  border-radius: 12px;
  color: var(--parch-ink);
  background:
    radial-gradient(120% 90% at 0% 0%, rgba(255, 255, 255, 0.55), transparent 60%),
    linear-gradient(180deg, var(--parch), var(--parch-2));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(120, 80, 20, 0.25);
  font-family: var(--font-story);
}
.verse::before { /* bookmark ribbon */
  content: "";
  position: absolute;
  top: -4px;
  right: 1.1rem;
  width: 0.9rem;
  height: 2.1rem;
  background: linear-gradient(180deg, #b3342e, #8c2420);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}
.verse-ref {
  display: block;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #8a5a14;
  margin-bottom: 0.3rem;
}
.verse-ref::before { content: "📖 "; letter-spacing: 0; }
.verse-text { display: block; font-size: 1.04em; line-height: 1.55; }
.verse-text strong, .verse-text b {
  font-weight: 700;
  background: linear-gradient(transparent 52%, rgba(243, 190, 70, 0.7) 52%);
  padding: 0 0.08em;
}
.lord { font-variant: small-caps; letter-spacing: 0.02em; }

/* ---------------------------------------------------------------- choices */
.choices { display: grid; gap: 0.8rem; margin-top: 1.25rem; }
.choices-label {
  margin: 1.2rem 0 -0.35rem;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0;
  animation: rise 0.5s ease forwards;
  animation-delay: var(--cd, 0.4s);
}

.choice {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 1rem 0.9rem 0.85rem;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.045));
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  opacity: 0;
  transform: translateY(10px);
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
  animation-delay: calc(var(--cd, 0.4s) + var(--i, 0) * 0.1s);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, translate 0.15s;
}
.choice:hover, .choice.is-hot {
  translate: 0 -2px;
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(243, 201, 105, 0.2), rgba(243, 201, 105, 0.08));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
}
.choice:active { translate: 0 0; }
.choice:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.choice[disabled] { pointer-events: none; }

.choice-num {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  margin-top: 0.05rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--gold);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.choice-body { display: block; min-width: 0; flex: 1; }
.choice-tag {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
}
.choice-text { display: block; font-family: var(--font-story); font-size: 1.08em; line-height: 1.45; }
.choice--do .choice-text { font-family: var(--font-ui); font-weight: 700; font-size: 1.02em; }
.choice-then {
  display: block;
  margin-top: 0.6rem;
  padding-top: 0.55rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.22);
  font-family: var(--font-story);
  font-size: 0.98em;
  line-height: 1.45;
  color: var(--ink-dim);
}
.choice-then::before {
  content: "Then you say";
  display: block;
  margin-bottom: 0.15rem;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.64rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--blue);
}
.choice .verse { margin: 0.1rem 0 0; box-shadow: inset 0 0 0 1px rgba(120, 80, 20, 0.25); padding: 0.65rem 0.9rem 0.75rem; }
.choice .verse::before { display: none; }
.choice .verse-text { font-size: 0.98em; }

.continue-wrap { margin-top: 1.3rem; opacity: 0; animation: rise 0.5s ease forwards; animation-delay: var(--cd, 0.4s); }

/* ----------------------------------------------------------------- buttons */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  cursor: pointer;
  padding: 0.7rem 1.15rem;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-weight: 800;
  font-size: 0.95rem;
  transition: transform 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.14); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn svg { width: 1.15em; height: 1.15em; }
.btn--primary {
  color: #2a1c05;
  border-color: #ffe9a8;
  background: linear-gradient(180deg, #ffe08a, #f1b53f);
  box-shadow: 0 8px 22px rgba(243, 169, 59, 0.35);
}
.btn--primary:hover { background: linear-gradient(180deg, #ffe9a8, #f5be50); border-color: #fff3cf; box-shadow: 0 12px 28px rgba(243, 169, 59, 0.5); }
.btn--ghost { background: transparent; }
.btn--big { font-size: 1.15rem; padding: 0.95rem 1.8rem; border-radius: 14px; }
.btn--wide { width: 100%; }

/* ------------------------------------------------------------ title screen */
.title { text-align: left; }
.title .eyebrow {
  margin: 0 0 0.6rem;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}
.title h1 {
  margin: 0 0 0.8rem;
  font-weight: 900;
  font-size: clamp(2.8rem, 6.4vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff6d6 10%, #f3c969 70%, #d99a2b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 18px rgba(243, 169, 59, 0.25));
}
.title .lede {
  margin: 0 0 1.3rem;
  font-family: var(--font-story);
  font-size: 1.22em;
  line-height: 1.5;
  color: var(--ink);
}
.howto { list-style: none; margin: 0 0 1.7rem; padding: 0; display: grid; gap: 0.6rem; }
.howto li { display: flex; gap: 0.7rem; align-items: flex-start; color: var(--ink-dim); font-size: 0.95em; }
.howto .ico {
  flex: none;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.title .fine { margin: 1.1rem 0 0; font-size: 0.8rem; color: var(--ink-dim); }

/* ------------------------------------------------------------------ endings */
.ending-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0;
  animation: rise 0.5s ease forwards;
}
.ending-badge .new { color: var(--gold); }
.ending-title {
  margin: 0.7rem 0 1.1rem;
  font-weight: 900;
  font-size: clamp(2.1rem, 4.6vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  opacity: 0;
  animation: rise 0.6s ease forwards;
  animation-delay: 0.1s;
}
.ending--win .ending-title {
  background: linear-gradient(90deg, #fff1b8, #f3b43f 60%, #f08a2a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ending--win .ending-badge { border-color: rgba(243, 201, 105, 0.7); color: var(--gold); }
.ending--funny .ending-badge { color: #ffc2a6; }
.ending--seed .ending-badge { color: var(--green); }
.ending--miss .ending-badge { color: #bcd0ea; }

.ending-progress {
  margin: 1.4rem 0 1.2rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  opacity: 0;
  animation: rise 0.5s ease forwards;
  animation-delay: var(--cd, 0.5s);
}
.ending-progress p { margin: 0 0 0.55rem; font-size: 0.92em; color: var(--ink-dim); }
.ending-progress p b { color: var(--ink); }
.dots { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.dots i {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.dots i.on { background: var(--gold); border-color: #ffe9a8; box-shadow: 0 0 8px rgba(243, 201, 105, 0.55); }
.dots i.now { outline: 2px solid #fff; outline-offset: 2px; }

.ending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  opacity: 0;
  animation: rise 0.5s ease forwards;
  animation-delay: calc(var(--cd, 0.5s) + 0.1s);
}
.ending-actions .btn--primary { flex: 1 1 12rem; }

.path {
  margin-top: 1.3rem;
  font-size: 0.9em;
  color: var(--ink-dim);
  opacity: 0;
  animation: rise 0.5s ease forwards;
  animation-delay: calc(var(--cd, 0.5s) + 0.2s);
}
.path summary { cursor: pointer; font-weight: 800; letter-spacing: 0.04em; padding: 0.3rem 0; }
.path summary:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 6px; }
.path ol { margin: 0.5rem 0 0; padding-left: 1.35rem; display: grid; gap: 0.35rem; }
.path li::marker { color: var(--gold); font-weight: 800; }

/* ----------------------------------------------------------- endings dialog */
dialog {
  width: min(34rem, calc(100vw - 1.5rem));
  max-height: min(42rem, calc(100dvh - 2rem));
  padding: 0;
  color: var(--ink);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; animation: dlgin 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
dialog::backdrop { background: rgba(4, 8, 14, 0.72); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
@keyframes dlgin { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.3rem 0.2rem; }
.dlg-head h2 { margin: 0; font-weight: 900; font-size: 1.5rem; }
.dlg-x {
  appearance: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
  font-size: 1rem;
}
.dlg-x:hover { background: rgba(255, 255, 255, 0.18); }
.dlg-x:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.dlg-sub { margin: 0.2rem 1.3rem 0.8rem; color: var(--ink-dim); font-size: 0.92em; }
.endings-list { list-style: none; margin: 0; padding: 0 1.3rem 0.6rem; overflow-y: auto; display: grid; gap: 0.5rem; }
.endings-list li {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.1rem 0.7rem;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
}
.endings-list .em { grid-row: 1 / span 2; font-size: 1.5rem; text-align: center; }
.endings-list .et { font-weight: 800; }
.endings-list .eb { font-size: 0.85em; color: var(--ink-dim); }
.endings-list li.locked { opacity: 0.55; }
.endings-list li.locked .et { letter-spacing: 0.2em; }
.endings-list li.win { border-color: rgba(243, 201, 105, 0.6); background: rgba(243, 201, 105, 0.1); }
.dlg-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.8rem 1.3rem 1.1rem; border-top: 1px solid var(--line); }

/* ----------------------------------------------------- SVG scene animations */
@keyframes twinkle { 0%, 100% { opacity: var(--o1, 0.3); } 50% { opacity: var(--o2, 1); } }
.twinkle { animation: twinkle var(--d, 3.2s) ease-in-out infinite; animation-delay: var(--dl, 0s); }

@keyframes ffmove {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(var(--dx), calc(var(--dy) * 0.4)); }
  50% { transform: translate(calc(var(--dx) * 0.3), var(--dy)); }
  75% { transform: translate(calc(var(--dx) * -0.6), calc(var(--dy) * 0.5)); }
}
@keyframes ffglow { 0%, 100% { opacity: 0.12; } 50% { opacity: 1; } }
.ff { animation: ffmove var(--d, 9s) ease-in-out infinite, ffglow var(--g, 3s) ease-in-out infinite; animation-delay: var(--dl, 0s), var(--dl2, 0s); }

@keyframes fall { from { transform: translate(0, -30px); } to { transform: translate(var(--sway, 30px), 1060px); } }
.flake { animation: fall var(--d, 10s) linear infinite; animation-delay: var(--dl, 0s); }

@keyframes drift { 0%, 100% { transform: translateX(-50px); } 50% { transform: translateX(50px); } }
.drift { animation: drift var(--d, 24s) ease-in-out infinite; animation-delay: var(--dl, 0s); }

@keyframes breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.01, 1.018); } }
.breathe { transform-box: fill-box; transform-origin: 50% 100%; animation: breathe 4.6s ease-in-out infinite; }

@keyframes blink { 0%, 92%, 100% { transform: scaleY(0); } 95% { transform: scaleY(1); } }
.blink { transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); animation: blink 5.8s infinite; } /* eyes are open unless the blink animation is running */

@keyframes sway { 0%, 100% { transform: rotate(-2.4deg); } 50% { transform: rotate(2.4deg); } }
.sway { transform-box: fill-box; transform-origin: 50% 100%; animation: sway var(--d, 5s) ease-in-out infinite; animation-delay: var(--dl, 0s); }

@keyframes flicker { 0%, 100% { opacity: 0.92; } 20% { opacity: 0.74; } 40% { opacity: 1; } 60% { opacity: 0.8; } 80% { opacity: 0.96; } }
.flicker { animation: flicker 3.4s ease-in-out infinite; }

@keyframes smoke {
  0% { transform: translate(0, 0) scale(0.6); opacity: 0; }
  15% { opacity: 0.55; }
  100% { transform: translate(36px, -160px) scale(1.8); opacity: 0; }
}
.smoke { transform-box: fill-box; transform-origin: center; animation: smoke 6.5s ease-out infinite; animation-delay: var(--dl, 0s); }

@keyframes popin {
  0% { transform: scale(0.2) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.pop { transform-box: fill-box; transform-origin: center; animation: popin 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.3) both; animation-delay: var(--dl, 0.2s); }

@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-14px); } }
.floaty { animation: floaty var(--d, 3s) ease-in-out infinite; animation-delay: var(--dl, 0s); }

@keyframes wobble { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.wobble { transform-box: fill-box; transform-origin: 50% 90%; animation: wobble var(--d, 2.4s) ease-in-out infinite; }

@keyframes drip { 0% { transform: translateY(0); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(28px); opacity: 0; } }
.drip { animation: drip 1.8s ease-in infinite; animation-delay: var(--dl, 0s); }

@keyframes confetti { from { transform: translate(0, -40px) rotate(0); } to { transform: translate(var(--sway, 40px), 1080px) rotate(var(--rot, 720deg)); } }
.confetti { animation: confetti var(--d, 6s) linear infinite; animation-delay: var(--dl, 0s); }

@keyframes rays { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.95; } }
.rays { animation: rays 5s ease-in-out infinite; }

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.bob { animation: bob var(--d, 0.7s) ease-in-out infinite; animation-delay: var(--dl, 0s); }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { transform-box: fill-box; transform-origin: center; animation: spin var(--d, 30s) linear infinite; }

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-14px, 6px); }
  20% { transform: translate(12px, -8px); }
  30% { transform: translate(-10px, -6px); }
  40% { transform: translate(9px, 7px); }
  50% { transform: translate(-6px, 3px); }
  60% { transform: translate(5px, -3px); }
  80% { transform: translate(-2px, 1px); }
}

@keyframes chomp { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.78); } }
.chomp { transform-box: fill-box; transform-origin: 50% 0; animation: chomp 0.5s ease-in-out infinite; }

@keyframes zoomin { from { transform: scale(0.4); } to { transform: scale(1); } }
.charge { transform-box: fill-box; transform-origin: 50% 100%; animation: zoomin 0.7s cubic-bezier(0.2, 0.9, 0.3, 1.1) both; }

/* clickable doors on the first screen */
.door-hit { cursor: pointer; pointer-events: all; transition: filter 0.2s; }
.door-hit * { pointer-events: all; }
.layer.hot-0 [data-door="0"], .layer.hot-1 [data-door="1"] { filter: brightness(1.22) saturate(1.1); }
.layer.hot-0 [data-door="1"], .layer.hot-1 [data-door="0"] { filter: brightness(0.82); }
.door-hit .hint { opacity: 0; transition: opacity 0.2s; }
.layer.hot-0 [data-door="0"] .hint, .layer.hot-1 [data-door="1"] .hint { opacity: 1; }

/* "calm" = no animation inside the pictures (automatic on slow computers, or the switch in the Endings window) */
.app.calm .layer svg *, .app.calm .layer { animation: none !important; }
.app.calm .layer svg .flake, .app.calm .layer svg .confetti, .app.calm .layer svg .smoke { display: none; }
.app.calm .layer svg .twinkle { opacity: var(--o2, 0.8); }
.app.calm .layer svg .ff { opacity: 0.7; }

.switch { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; font-weight: 700; font-size: 0.9rem; color: var(--ink-dim); }
.switch input { width: 1.15rem; height: 1.15rem; accent-color: var(--gold); cursor: pointer; }
.switch:hover { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .line, .choice, .choices-label, .continue-wrap, .ending-badge, .ending-title, .ending-progress, .ending-actions, .path { opacity: 1 !important; transform: none !important; }
  .layer { transform: none !important; }
  .twinkle, .ff { opacity: 0.8; }
}
