/* =====================================================================
   Cửa Hàng Tiện Lợi Âm Dương — interactive horror reader
   Offline, system fonts only, mobile-first.
   ===================================================================== */
:root {
  --bg: #07060c;
  --bg2: #0f0d19;
  --ink: #dcd8e6;
  --ink-dim: #9a95ad;
  --ink-strong: #f4f1fb;
  --cyan: #3ff0ff;
  --mag: #ff3fa6;
  --red: #ff2b3a;
  --gold: #ffcf7a;
  --line: rgba(255, 255, 255, .12);
  --hud-bg: rgba(7, 6, 12, .74);
  --sound: #9ff8ff;
  --sound-glow: rgba(63, 240, 255, .55);
  --paper: #eadcb4;
  --paper2: #d9c48f;
  --paper-ink: #2b2114;
  --serif: "Noto Serif", "Cambria", "Georgia", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Roboto Mono", "Courier New", monospace;
  --type: "Courier New", Courier, ui-monospace, monospace;
  --hud-h: 52px;
  --col: 40rem;
  --gutter: 1.25rem;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: #000; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.8;
  overflow-x: hidden;
  transition: background-color 1.6s ease, color 1.6s ease;
  -webkit-tap-highlight-color: transparent;
}
body.pre { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

/* ---------- environments (story lighting) ---------- */
body::before {               /* ambient neon spill on the edges */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 40% at -10% 30%, rgba(63, 240, 255, .10), transparent 70%),
    radial-gradient(60% 40% at 110% 70%, rgba(255, 63, 166, .10), transparent 70%);
  transition: opacity 1.6s ease;
}
body::after {                /* the red -18°C glow during the blackout */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0;
  background: radial-gradient(70% 35% at 50% 108%, rgba(255, 30, 40, .22), transparent 70%);
  transition: opacity 2s ease;
}
body.env-dark {
  --bg: #000;
  --ink: #8f878f;
  --ink-dim: #5e565d;
  --ink-strong: #c9bfc5;
  --hud-bg: rgba(0, 0, 0, .78);
  --sound: #ff6b72;
  --sound-glow: rgba(255, 30, 45, .6);
}
body.env-dark::before { opacity: 0; }
body.env-dark::after { opacity: 1; }
body.env-day {
  --bg: #efe4cf;
  --bg2: #e6d8bd;
  --ink: #2d251d;
  --ink-dim: #6e604f;
  --ink-strong: #1a140e;
  --line: rgba(40, 25, 10, .15);
  --hud-bg: rgba(239, 228, 207, .82);
  --sound: #7c2414;
  --sound-glow: rgba(255, 170, 80, .45);
  color-scheme: light;
}
body.env-day::before {
  opacity: 1;
  background: radial-gradient(80% 50% at 50% -10%, rgba(255, 196, 110, .35), transparent 70%);
}

/* ---------- start screen ---------- */
.start {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  overflow-y: auto;
  background: #05040a;
  padding: max(1.5rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
  transition: opacity .7s ease, visibility .7s;
}
.start.leaving { opacity: 0; visibility: hidden; }
.start-bg {
  position: fixed; inset: 0;
  background-size: cover; background-position: 50% 45%;
  opacity: .42; filter: saturate(1.1);
  animation: kb-start 30s ease-in-out infinite alternate;
}
.start-bg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(5, 4, 10, .55), rgba(5, 4, 10, .82) 45%, #05040a 100%);
}
@keyframes kb-start { from { transform: scale(1.04); } to { transform: scale(1.14) translate(-1.5%, 1%); } }
.start-inner {
  position: relative; width: 100%; max-width: 34rem;
  font-family: var(--sans); line-height: 1.55;
}
.kicker {
  margin: 0 0 .5rem; font-size: .78rem; letter-spacing: .22em; text-transform: uppercase; color: var(--cyan);
}
.start h1 { margin: 0 0 1rem; font-family: var(--serif); font-weight: 700; line-height: 1.15; }
.start h1 .t1 {
  display: block; font-size: clamp(1.85rem, 7.5vw, 2.8rem); color: #fff;
  text-shadow: 0 0 18px rgba(255, 63, 166, .55), 0 0 42px rgba(63, 240, 255, .25);
}
.start h1 .t2 { display: block; margin-top: .3rem; font-size: clamp(1.2rem, 4.5vw, 1.6rem); color: var(--mag); }
.disclaimer { margin: 0 0 1.1rem; font-size: .86rem; color: #b9b3c9; font-style: italic; }
.notes { list-style: none; margin: 0 0 1.1rem; padding: 0; display: grid; gap: .6rem; }
.notes li {
  display: grid; grid-template-columns: 1.5rem 1fr; gap: .6rem; align-items: start;
  padding: .7rem .8rem; border-radius: 12px; font-size: .88rem;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08); color: #d5d0e2;
}
.notes svg { width: 1.4rem; height: 1.4rem; color: var(--cyan); }
.notes li.warn { border-color: rgba(255, 190, 60, .35); background: rgba(255, 170, 40, .07); }
.notes li.warn svg { color: #ffc23d; }
.resume {
  display: flex; align-items: center; gap: .6rem; margin: 0 0 .9rem;
  font-size: .92rem; color: #e8e3f3; cursor: pointer;
}
.resume input { width: 1.15rem; height: 1.15rem; accent-color: var(--mag); }
.resume b { color: var(--cyan); }
.modes { display: grid; gap: .7rem; }
.mode-btn {
  display: grid; gap: .2rem; text-align: left; width: 100%;
  padding: 1rem 1.1rem; border-radius: 14px; border: 1px solid; background: rgba(10, 8, 18, .8);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.mode-btn b { font-size: 1.08rem; }
.mode-btn small { font-size: .82rem; opacity: .8; }
.mode-btn.full { border-color: rgba(255, 43, 58, .7); box-shadow: 0 0 0 1px rgba(255, 43, 58, .15), 0 0 26px rgba(255, 43, 58, .18); }
.mode-btn.full b { color: #ff6d76; }
.mode-btn.gentle { border-color: rgba(63, 240, 255, .45); }
.mode-btn.gentle b { color: var(--cyan); }
.mode-btn:hover { transform: translateY(-1px); background: rgba(22, 18, 36, .9); }
.mode-btn:active { transform: translateY(1px); }
.hint { margin: .9rem 0 0; font-size: .78rem; color: #8e88a2; text-align: center; }
@media (min-width: 560px) {
  .modes { grid-template-columns: 1fr 1fr; }
}

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--hud-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(.4rem, env(safe-area-inset-right)) 0 max(.4rem, env(safe-area-inset-left));
  display: flex; align-items: center; gap: .25rem;
  background: var(--hud-bg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font-family: var(--sans);
  transition: background-color 1.6s ease, transform .2s ease, filter .2s ease;
}
.ic {
  width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink);
}
.ic svg { width: 22px; height: 22px; }
.ic:hover { background: rgba(127, 127, 127, .12); }
#btn-sound .off { display: none; }
#btn-sound[aria-pressed="false"] .on { display: none; }
#btn-sound[aria-pressed="false"] .off { display: block; }
#btn-sound[aria-pressed="false"] { color: var(--ink-dim); }
.hud-mid { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: .7rem; padding-left: .2rem; }
.chap {
  font-size: .74rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.clock {
  margin-left: auto; padding-right: .3rem;
  font-family: var(--mono); font-size: 1.2rem; font-weight: 600; letter-spacing: .06em;
  color: var(--cyan); text-shadow: 0 0 10px rgba(63, 240, 255, .55);
  font-variant-numeric: tabular-nums;
}
.clock .colon { animation: blink 2s steps(1) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.clock.tick { animation: tick .6s ease; }
@keyframes tick { 0% { opacity: .2; } 100% { opacity: 1; } }
body.env-dark .clock { color: #ff3b46; text-shadow: 0 0 10px rgba(255, 30, 45, .8); }
body.env-day .clock { color: #9a4a12; text-shadow: none; }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: rgba(127, 127, 127, .15); }
.progress i {
  display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--cyan), var(--mag));
  transition: transform .3s ease;
}
body.env-dark .progress i { background: linear-gradient(90deg, #7a0b12, #ff2b3a); }
body.env-day .progress i { background: linear-gradient(90deg, #e9a24b, #c2501e); }

/* ---------- drawers ---------- */
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .55); }
.drawer {
  position: fixed; top: 0; bottom: 0; z-index: 50; width: min(22rem, 88vw);
  padding: max(.8rem, env(safe-area-inset-top)) 1rem 1.2rem;
  background: #0d0b16; color: #e4e0ee; border: 1px solid rgba(255, 255, 255, .08);
  overflow-y: auto; font-family: var(--sans); line-height: 1.45;
  box-shadow: 0 0 40px rgba(0, 0, 0, .6);
}
.drawer.left { left: 0; }
.drawer.right { right: 0; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.drawer-head h2 { margin: 0; font-size: 1rem; letter-spacing: .14em; text-transform: uppercase; color: var(--cyan); }
.drawer .ic { color: #e4e0ee; }
.chap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.chap-list button {
  width: 100%; display: grid; grid-template-columns: 84px 1fr; gap: .75rem; align-items: center; text-align: left;
  padding: .45rem; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .03);
}
.chap-list button:hover, .chap-list button[aria-current="true"] { border-color: rgba(63, 240, 255, .5); background: rgba(63, 240, 255, .06); }
.chap-list img { width: 84px; height: 54px; object-fit: cover; border-radius: 8px; display: block; background: #222; }
.chap-list .cl-label { display: block; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--mag); }
.chap-list .cl-title { display: block; font-size: .86rem; margin-top: .1rem; }
.chap-list .cl-time { display: block; font-family: var(--mono); font-size: .74rem; color: #8f8aa3; margin-top: .15rem; }
.chap-list .locked { opacity: .55; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 1.1rem; border: 0; padding: 0; }
.set-row.col { flex-direction: column; align-items: stretch; gap: .5rem; }
.set-row legend { padding: 0; margin-bottom: .45rem; }
.set-row output { font-family: var(--mono); color: var(--cyan); margin-left: .3rem; }
.set-row input[type="range"] { width: 100%; accent-color: var(--mag); }
.radio { display: flex; align-items: center; gap: .55rem; padding: .35rem 0; }
.radio input { accent-color: var(--mag); width: 1.05rem; height: 1.05rem; }
.switch { width: 2.6rem; height: 1.4rem; accent-color: var(--mag); }
.set-note { font-size: .78rem; color: #8f8aa3; margin-top: 1rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .6rem 1.2rem; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .06); font-family: var(--sans); font-weight: 600;
}
.btn:hover { background: rgba(255, 255, 255, .12); }
.btn.ghost { width: 100%; }

/* ---------- story column ---------- */
.story {
  position: relative; z-index: 1;
  padding: calc(var(--hud-h) + env(safe-area-inset-top)) 0 0;
  outline: none;
}
.para {
  max-width: var(--col);
  margin: 0 auto 1.15em;
  padding: 0 var(--gutter);
  font-size: 1.125rem;
  line-height: 1.82;
  text-wrap: pretty;
  hyphens: manual;
}
.para strong { color: var(--ink-strong); font-weight: 700; }
.para em { font-style: italic; }
.k-dlg { color: var(--ink-strong); }
.k-thought { font-style: italic; }
.cue {
  display: inline-block; width: 1px; height: 1em; margin-right: -1px;
  vertical-align: text-top; pointer-events: none;
}
.beat { display: block; height: .7em; }
.beat-blk { min-height: 1px; }
.k-sound {
  margin: 1.4em auto 1.5em;
  text-align: center;
  font-family: var(--sans); font-style: normal; font-weight: 800;
  font-size: clamp(1.3rem, 5.2vw, 1.65rem); letter-spacing: .08em; line-height: 1.4;
  color: var(--sound); text-shadow: 0 0 14px var(--sound-glow), 0 0 32px var(--sound-glow);
}
.k-sound em { font-style: normal; }
.k-display {
  width: fit-content; max-width: calc(100% - 2 * var(--gutter));
  margin: 1.4em auto 1.6em; padding: .55rem 1.4rem;
  font-family: var(--mono); font-size: clamp(1.5rem, 7vw, 2rem); letter-spacing: .12em;
  color: #ff3341; background: #120206; border: 1px solid rgba(255, 51, 65, .5); border-radius: 6px;
  text-shadow: 0 0 10px rgba(255, 30, 45, .9);
  box-shadow: inset 0 0 22px rgba(255, 0, 20, .18), 0 0 24px rgba(255, 0, 20, .15);
}
.k-display strong { color: inherit; }
.k-outro {
  margin-top: 3rem; padding-top: 2rem; font-size: 1rem; font-style: italic; color: var(--ink-dim);
  border-top: 1px solid var(--line); position: relative;
}
.para.chroma { text-shadow: -2px 0 rgba(255, 30, 80, .75), 2px 0 rgba(30, 240, 255, .75); }

/* intro + chapter headings */
.intro {
  min-height: 78vh; display: grid; place-content: center; text-align: center;
  padding: 2rem var(--gutter); font-family: var(--sans);
}
.intro-kick { margin: 0; font-size: .75rem; letter-spacing: .24em; text-transform: uppercase; color: var(--cyan); }
.intro h1 {
  margin: .6rem 0 .2rem; font-family: var(--serif); font-size: clamp(2rem, 9vw, 3.4rem); line-height: 1.12;
  color: var(--ink-strong); text-shadow: 0 0 22px rgba(255, 63, 166, .45);
}
.intro-ep { margin: 0; font-size: 1.15rem; color: var(--mag); letter-spacing: .1em; }
.intro-hint { margin: 2.2rem 0 0; font-size: .85rem; color: var(--ink-dim); }
.scroll-cue {
  display: block; width: 1px; height: 46px; margin: .8rem auto 0;
  background: linear-gradient(var(--cyan), transparent); animation: drip 2.2s ease-in-out infinite;
}
@keyframes drip { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

.chapter {
  position: relative; overflow: hidden;
  min-height: min(78vh, 46rem);
  margin: 4.5rem 0 2.6rem;
  display: grid; align-items: end; justify-items: center; text-align: center;
  font-family: var(--sans);
}
.chapter:first-of-type { margin-top: 0; }
.chapter .cover { position: absolute; inset: 0; }
.chapter .cover img {
  width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.06);
  transition: opacity 1.6s ease;
}
.chapter.in .cover img { opacity: .62; animation: kb 26s ease-out forwards; }
.chapter::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, var(--bg) 0%, transparent 22%, transparent 45%, var(--bg) 96%);
  transition: background 1.6s ease;
}
.ch-inner { position: relative; z-index: 1; padding: 0 var(--gutter) 1rem; max-width: 44rem; }
.ch-label { margin: 0; font-size: .8rem; letter-spacing: .3em; color: var(--cyan); text-transform: uppercase; font-weight: 700; }
.ch-title {
  margin: .45rem 0 .5rem; font-family: var(--serif); font-size: clamp(1.45rem, 6vw, 2.3rem); line-height: 1.25;
  color: var(--ink-strong); letter-spacing: .02em;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .7);
}
.ch-title.big { font-size: clamp(2.2rem, 10vw, 3.4rem); letter-spacing: .12em; }
.ch-range { margin: 0; font-family: var(--mono); font-size: .95rem; color: var(--mag); letter-spacing: .1em; }
body.env-day .ch-title { text-shadow: none; }

/* hero images: Ken-Burns + parallax */
.hero {
  position: relative; overflow: hidden;
  width: 100%; max-width: 64rem; aspect-ratio: 16 / 9;
  margin: 2.2rem auto 2.4rem;
  background: #0b0a12;
}
@supports not (aspect-ratio: 1 / 1) { .hero { height: 0; padding-top: 56.25%; } }
@media (min-width: 64rem) { .hero { border-radius: 6px; } }
.hero .pz { position: absolute; inset: 0; transform: scale(1.12); will-change: transform; }
.hero img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transform: scale(1.02);
  transition: opacity 1.5s ease, filter 1.6s ease;
}
.hero.in img { opacity: 1; animation: kb 22s ease-out forwards; }
@keyframes kb {
  from { transform: scale(1.02) translate3d(0, 0, 0); }
  to { transform: scale(1.15) translate3d(var(--kx, -1.5%), var(--ky, -1%), 0); }
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 60px 10px var(--bg);
  transition: box-shadow 1.6s ease;
}
body.env-dark .hero img { filter: brightness(.62) saturate(.8); }
body.env-day .hero img { filter: saturate(1.05); }

/* ---------- the rule sheet (yellowed paper that types in) ---------- */
.paper {
  position: relative;
  width: calc(100% - 2 * var(--gutter)); max-width: 36rem;
  margin: 0 auto;
  padding: .55rem 1.2rem;
  color: var(--paper-ink);
  font-family: var(--type); font-size: .98rem; line-height: 1.62;
  background-color: var(--paper);          /* uniform, so stacked rule blocks read as one sheet */
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
}
.paper.p-start {
  background-image:
    radial-gradient(130px 90px at 88% 18%, rgba(120, 70, 20, .16), transparent 70%),
    linear-gradient(180deg, rgba(255, 250, 230, .35), transparent 60px);
}
.paper.p-end, .paper.p-solo {
  background-image:
    radial-gradient(160px 110px at 10% 78%, rgba(120, 70, 20, .16), transparent 70%),
    linear-gradient(0deg, rgba(150, 110, 50, .18), transparent 50px);
}
.paper.p-start, .paper.p-solo { margin-top: 1.8rem; padding-top: 1.2rem; border-radius: 3px 3px 0 0; }
.paper.p-end, .paper.p-solo { margin-bottom: 1.9rem; padding-bottom: 1.2rem; border-radius: 0 0 3px 3px; }
.paper.p-solo { border-radius: 3px; }
.paper.p-start::before, .paper.p-solo::before {      /* tape */
  content: ""; position: absolute; top: -12px; left: 14%; width: 86px; height: 24px;
  background: rgba(240, 235, 210, .55); transform: rotate(-4deg); box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.paper.p-start::after {
  content: ""; position: absolute; top: -10px; right: 12%; width: 72px; height: 22px;
  background: rgba(240, 235, 210, .5); transform: rotate(5deg); box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.sheet-title {
  margin: .2rem 0 .8rem; text-align: center; font-size: 1.02rem; font-weight: 700; letter-spacing: .04em;
  text-decoration: underline; text-decoration-color: rgba(170, 20, 20, .8); text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.rl { margin: .3rem 0; }
.rl .lbl { font-weight: 700; }
.rl.ring {
  margin: .55rem -.4rem; padding: .35rem .5rem;
  border: 2px solid rgba(178, 22, 22, .78); border-radius: 14px 8px 16px 9px / 9px 15px 8px 14px;
  transform: rotate(-.4deg);
}
.paper .ty { color: inherit; }
.paper .rest { color: transparent; }
.paper.pre-type .rl, .paper.pre-type .sheet-title, .paper.pre-type .miss { opacity: 0; }
.paper .rl, .paper .sheet-title, .paper .miss { transition: opacity .4s ease; }
.paper.typing .ty::after {
  content: "▌"; color: rgba(150, 20, 20, .8); animation: blink .8s steps(1) infinite;
}
.miss { margin: .35rem 0; }
.ill { margin: .25rem 0; display: flex; gap: .5rem; align-items: center; filter: blur(.6px); opacity: .75; }
.ill .lbl { font-weight: 700; flex: none; }
.ill .bars { flex: 1; display: grid; gap: 5px; }
.ill .bars i { display: block; height: 7px; border-radius: 3px; background: rgba(43, 33, 20, .45); }
.ill .bars i + i { width: 62%; }
.miss.stain { position: relative; }
.miss.stain::after {
  content: ""; position: absolute; inset: -8px -10px; pointer-events: none;
  background:
    radial-gradient(45% 60% at 30% 55%, rgba(96, 52, 18, .55), transparent 72%),
    radial-gradient(35% 50% at 70% 40%, rgba(110, 60, 20, .45), transparent 70%);
  filter: blur(3px);
}
.miss.stain .ill { filter: blur(1.8px); }
.miss.cross { position: relative; }
.miss.cross::after {
  content: ""; position: absolute; inset: -4px 0; pointer-events: none;
  background:
    linear-gradient(8deg, transparent 46%, rgba(185, 20, 20, .85) 47%, rgba(185, 20, 20, .85) 50%, transparent 51%),
    linear-gradient(-6deg, transparent 47%, rgba(185, 20, 20, .8) 48%, rgba(185, 20, 20, .8) 51%, transparent 52%),
    repeating-linear-gradient(-30deg, transparent 0 9px, rgba(185, 20, 20, .5) 9px 11px);
}
.paper.torn {
  width: calc(78% - var(--gutter)); max-width: 28rem;
  margin-left: max(var(--gutter), calc(50% - 18rem));
  transform: rotate(1.2deg);
  clip-path: polygon(0 0, 92% 0, 97% 8%, 91% 17%, 99% 27%, 93% 38%, 100% 49%, 92% 60%, 98% 71%, 90% 82%, 96% 92%, 89% 100%, 0 100%);
  padding-right: 2.4rem;
}
.paper.torn .rl .txt {
  color: #8d0f12; font-weight: 700;
  text-shadow: .5px .5px 0 rgba(150, 10, 10, .6), -.6px .3px 0 rgba(150, 10, 10, .5), .3px -.6px 0 rgba(120, 0, 0, .45);
}
.paper.torn .rest { color: transparent; text-shadow: none; }
.paper.recall {
  width: fit-content; max-width: calc(100% - 2 * var(--gutter));
  margin: 1.6rem auto 1.8rem; padding: .55rem 1rem; transform: rotate(-1deg); border-radius: 2px;
  font-size: 1rem;
}
.paper.recall .rl { margin: 0; text-decoration: underline wavy rgba(180, 20, 20, .7); text-underline-offset: 5px; }
body.env-dark .paper { filter: brightness(.7); }

/* ---------- SMS / notification ---------- */
.sms {
  width: calc(100% - 2 * var(--gutter)); max-width: 26rem;
  margin: 1.8rem auto 2rem; padding: .85rem 1rem .75rem;
  border-radius: 20px; background: rgba(18, 18, 22, .95); color: #ececf2;
  font-family: var(--sans); line-height: 1.5;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .35), 0 0 0 1px rgba(255, 255, 255, .06);
}
.sms-head { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: #a7a7b4; margin-bottom: .45rem; }
.sms-head b { color: #fff; font-size: .88rem; }
.sms-head time { margin-left: auto; }
.sms-ic { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, #3a3a46, #15151b); display: grid; place-items: center; }
.sms-ic::before { content: "?"; font-weight: 800; font-size: .8rem; color: #ff5260; }
.sms-body { margin: 0; font-size: 1rem; }
.sms-foot { margin-top: .6rem; padding-top: .5rem; border-top: 1px solid rgba(255, 255, 255, .1); font-size: .76rem; color: #8a8a96; text-align: center; }

/* ---------- support line (subtle) ---------- */
.support-mid {
  max-width: var(--col); margin: 2.6rem auto; padding: 0 var(--gutter);
  text-align: center; font-family: var(--sans); font-size: .78rem; letter-spacing: .04em;
  color: var(--ink-dim); opacity: .6;
}
.support-mid::before, .support-mid::after { content: " · · · "; opacity: .6; }

/* ---------- choices ---------- */
.choice {
  width: calc(100% - 2 * var(--gutter)); max-width: 34rem;
  margin: 2.4rem auto 2.6rem; padding: 1.15rem 1.1rem 1rem;
  border-radius: 16px; border: 1px solid rgba(255, 43, 58, .45);
  background: linear-gradient(180deg, rgba(40, 4, 12, .82), rgba(16, 4, 10, .9));
  box-shadow: 0 0 34px rgba(255, 20, 40, .12);
  font-family: var(--sans); line-height: 1.5; color: #eee6ea;
}
.ch-kick { margin: 0 0 .35rem; font-size: .72rem; letter-spacing: .22em; text-transform: uppercase; color: #ff6d76; }
.ch-prompt { margin: 0 0 .9rem; font-family: var(--serif); font-size: 1.05rem; }
.ch-opts { display: grid; gap: .6rem; }
.opt {
  min-height: 48px; padding: .7rem 1rem; text-align: left; border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .05); font-weight: 650;
  transition: background .2s ease, border-color .2s ease, transform .12s ease;
}
.opt:hover:not(:disabled) { background: rgba(255, 43, 58, .16); border-color: rgba(255, 43, 58, .7); }
.opt:active:not(:disabled) { transform: translateY(1px); }
.opt:disabled { cursor: default; opacity: .45; }
.opt.chosen { opacity: 1; border-color: rgba(63, 240, 255, .7); background: rgba(63, 240, 255, .1); }
.opt.chosen::before { content: "✓ "; color: var(--cyan); }
.ch-note { margin: .8rem 0 0; font-size: .85rem; color: #9ff4ff; font-style: italic; }
.ch-wait { margin: .8rem 0 0; font-size: .78rem; color: #b6a3aa; text-align: center; }
.choice.done .ch-wait { display: none; }
.choice.done { border-color: rgba(63, 240, 255, .25); box-shadow: none; }
@media (min-width: 560px) { .ch-opts { grid-template-columns: 1fr 1fr; } }
/* story stays canon: nothing after an unanswered choice is shown */
.choice.pending ~ * { display: none !important; }
body.env-day .choice { background: linear-gradient(180deg, rgba(60, 10, 14, .92), rgba(30, 6, 10, .95)); }

/* ---------- bad ending ---------- */
.bad {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 1.5rem 1.1rem;
  background: radial-gradient(120% 90% at 50% 50%, #2a0306 0%, #120002 60%, #000 100%);
  opacity: 0; transition: opacity .8s ease;
  overflow-y: auto;
}
.bad.full { background: radial-gradient(120% 90% at 50% 50%, #7a0710 0%, #2a0105 55%, #000 100%); }
.bad.show { opacity: 1; }
.bad.full.show .bad-inner { animation: bad-hit .5s ease-out; }
@keyframes bad-hit { 0% { transform: scale(1.06); filter: blur(4px); } 100% { transform: none; filter: none; } }
.bad-inner { max-width: 32rem; text-align: center; font-family: var(--sans); color: #f3dcdc; }
.bad-kicker { margin: 0; font-size: .75rem; letter-spacing: .3em; text-transform: uppercase; color: #ff7b83; }
.bad h2 { margin: .4rem 0 1.1rem; font-family: var(--serif); font-size: clamp(1.6rem, 7vw, 2.3rem); color: #fff; text-shadow: 0 0 22px rgba(255, 20, 40, .8); }
.bad-text p {
  margin: 0 0 .9rem; font-family: var(--serif); font-size: 1.08rem; line-height: 1.75; text-align: left;
  opacity: 0; animation: bad-in 1s ease forwards; animation-delay: calc(var(--k, 0) * 1.1s + .5s);
}
@keyframes bad-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.bad .btn { margin-top: .8rem; border-color: rgba(255, 255, 255, .45); min-width: 10rem; }
body.bad-open { overflow: hidden; }

/* ---------- end screen ---------- */
.end {
  position: relative; min-height: 100vh; overflow: hidden;
  display: grid; place-items: center; text-align: center;
  padding: 4rem var(--gutter) max(2.5rem, env(safe-area-inset-bottom));
  margin-top: 3rem; font-family: var(--sans); color: #ece6f2;
}
.end-bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .5; }
.end::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, var(--bg) 0%, rgba(5, 4, 10, .55) 30%, rgba(5, 4, 10, .85) 100%);
}
.end-inner { position: relative; z-index: 2; max-width: 30rem; }
.end-kick { margin: 0; font-size: .78rem; letter-spacing: .24em; text-transform: uppercase; color: var(--cyan); }
.end-title {
  margin: .5rem 0 1.6rem; font-family: var(--serif); font-size: clamp(2.4rem, 11vw, 3.8rem); line-height: 1.1;
  color: #fff; text-shadow: 0 0 24px rgba(255, 63, 166, .6);
}
.end-actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; }
.end .btn { color: #fff; }
.end .btn.primary { background: rgba(255, 63, 166, .18); border-color: rgba(255, 63, 166, .6); }
.end-support { margin: 2.6rem 0 0; font-size: .78rem; color: rgba(236, 230, 242, .55); letter-spacing: .03em; }

/* ---------- FX layers ---------- */
.fx-root { position: fixed; inset: 0; z-index: 70; pointer-events: none; }
.fx { position: fixed; inset: 0; pointer-events: none; opacity: 0; }

#fx-black { background: #000; z-index: 6; }
#fx-black.on { opacity: 1; }
#fx-black.fade { opacity: 0; transition: opacity 1.6s ease; }
#fx-black::before, #fx-black::after {
  content: ""; position: absolute; left: 6%; right: 6%; height: 4px; border-radius: 4px; opacity: 0;
}
#fx-black::before { top: 16%; background: #c9feff; box-shadow: 0 0 16px 5px rgba(63, 240, 255, .8), 0 0 90px 26px rgba(63, 240, 255, .35); }
#fx-black::after { top: 24%; background: #ffd0ea; box-shadow: 0 0 16px 5px rgba(255, 63, 166, .8), 0 0 90px 26px rgba(255, 63, 166, .35); }
#fx-black.flicker::before { animation: tube 1.8s steps(1, end) forwards; }
#fx-black.flicker::after { animation: tube 1.8s steps(1, end) .12s forwards; }
@keyframes tube {             /* < 3 flashes per second */
  0% { opacity: 0; } 8% { opacity: .95; } 18% { opacity: 0; } 42% { opacity: .55; } 50% { opacity: 0; }
  76% { opacity: .3; } 82% { opacity: 0; } 100% { opacity: 0; }
}

#fx-vig {
  z-index: 2;
  background: radial-gradient(ellipse 80% 70% at 50% 50%, transparent 42%, rgba(150, 0, 14, .55) 82%, rgba(90, 0, 8, .9) 100%);
  transition: opacity 1.2s ease;
}
#fx-vig.on { opacity: .55; }
#fx-vig.beat { animation: hb var(--period, 465ms) ease-out infinite; }
@keyframes hb { 0% { opacity: .95; } 22% { opacity: .4; } 34% { opacity: .78; } 100% { opacity: .35; } }

#fx-frost {
  z-index: 3;
  background:
    radial-gradient(ellipse 72% 62% at 50% 50%, transparent 52%, rgba(150, 0, 20, .4) 78%, rgba(205, 12, 32, .75) 100%),
    radial-gradient(ellipse 110% 95% at 50% 50%, transparent 62%, rgba(225, 238, 255, .22) 86%, rgba(245, 250, 255, .4) 100%);
  transition: opacity 1.4s ease;
}
#fx-frost::after {
  content: ""; position: absolute; inset: 0; opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.6 -.55'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, transparent 55%, #000 92%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, transparent 55%, #000 92%);
}
#fx-frost.on { opacity: 1; }
#fx-frost.off { opacity: 0; transition: opacity 2.2s ease; }

#fx-whisper { z-index: 4; opacity: 1; }
.whisper {
  position: absolute; white-space: nowrap;
  font-family: var(--serif); font-style: italic; font-size: clamp(1rem, 4.4vw, 1.35rem); letter-spacing: .18em;
  color: rgba(255, 214, 218, .85); text-shadow: 0 0 12px rgba(255, 30, 50, .9), 0 0 2px rgba(255, 255, 255, .5);
  opacity: 0; animation: whisper 4s ease forwards;
}
@keyframes whisper {
  0% { opacity: 0; transform: translateY(8px); filter: blur(5px); }
  30% { opacity: .85; filter: blur(0); }
  100% { opacity: 0; transform: translateY(-16px); filter: blur(4px); }
}

#fx-scan {
  z-index: 5;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .06) 0 1px, transparent 1px 3px),
    linear-gradient(90deg, rgba(255, 0, 60, .08), rgba(0, 255, 255, .08));
  transition: opacity .3s ease;
}
#fx-scan.on { opacity: 1; }
#fx-scan::before, #fx-scan::after {       /* displaced slices, positioned per pulse from JS */
  content: ""; position: absolute; left: 0; right: 0; opacity: 0;
  -webkit-backdrop-filter: hue-rotate(150deg) saturate(2.2) contrast(1.3);
  backdrop-filter: hue-rotate(150deg) saturate(2.2) contrast(1.3);
  background: rgba(63, 240, 255, .08);
}
#fx-scan::before { top: var(--b1, 30%); height: 6%; transform: translateX(var(--bx, 10px)); }
#fx-scan::after { top: var(--b2, 64%); height: 3.5%; transform: translateX(calc(var(--bx, 10px) * -1.6)); background: rgba(255, 63, 166, .1); }
body.glitch #fx-scan::before, body.glitch #fx-scan::after { opacity: 1; }
body.glitch #story { animation: glitch .26s steps(3) both; }
body.glitch .para, body.glitch .chapter, body.glitch .hero {
  text-shadow: -2px 0 rgba(255, 30, 80, .85), 2px 0 rgba(30, 240, 255, .85);
}
body.glitch .hud { transform: translateX(3px); filter: hue-rotate(90deg) saturate(2); }
@keyframes glitch {             /* translate only: #story is very tall, skew/clip % would explode */
  0% { transform: translate(0); }
  25% { transform: translate(-6px, 1px); }
  50% { transform: translate(5px, -1px); }
  75% { transform: translate(-3px, 0); }
  100% { transform: translate(0); }
}

#fx-dawn {
  z-index: 1;
  background:
    radial-gradient(120% 85% at 50% 115%, rgba(255, 214, 140, .95), rgba(255, 176, 92, .55) 42%, rgba(255, 238, 205, 0) 78%),
    linear-gradient(0deg, rgba(255, 232, 186, .85), rgba(255, 250, 236, .45));
}
#fx-dawn.on { opacity: .94; transition: opacity 1.8s ease-in; }
#fx-dawn.soft.on { opacity: .55; }
#fx-dawn.off { opacity: 0; transition: opacity 4.5s ease; }

#fx-img { z-index: 5; background: #000; overflow: hidden; }
#fx-img img { width: 100%; height: 100%; object-fit: cover; display: block; transform-origin: 50% 50%; }
#fx-img.ghost img { filter: grayscale(1) contrast(1.9) brightness(1.15); }
#fx-img.ghost.soft { opacity: .45; transition: opacity .7s ease; }
#fx-img.eye img { filter: url(#f-rgb) saturate(1.4) contrast(1.15); }
#fx-img.eye.show { opacity: 1; transition: opacity .15s ease; }
#fx-img.eye { transition: opacity .7s ease; }

#story.shake { animation: shake .38s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake {
  10%, 90% { transform: translate3d(calc(var(--amp, 6px) * -.3), 0, 0); }
  20%, 80% { transform: translate3d(calc(var(--amp, 6px) * .6), 1px, 0); }
  30%, 50%, 70% { transform: translate3d(calc(var(--amp, 6px) * -1), -1px, 0); }
  40%, 60% { transform: translate3d(var(--amp, 6px), 1px, 0); }
}

.noscript { padding: 2rem; text-align: center; font-family: var(--sans); }

/* ---------- larger screens ---------- */
@media (min-width: 720px) {
  :root { --gutter: 1.5rem; --hud-h: 56px; }
  .para { font-size: 1.2rem; }
  .hud { padding-left: 1rem; padding-right: 1rem; }
  .chap { font-size: .8rem; }
  .clock { font-size: 1.3rem; }
}

/* ---------- reduced motion: keep the mood, drop the movement ---------- */
@media (prefers-reduced-motion: reduce) {
  .start-bg, .scroll-cue, .clock .colon { animation: none !important; }
  .hero .pz { transform: none !important; }
  .hero.in img, .chapter.in .cover img { animation: none !important; transform: none !important; }
  #story.shake, body.glitch #story { animation: none !important; }
  body.glitch .hud { transform: none; }
  #fx-black.flicker::before, #fx-black.flicker::after { animation: none !important; }
  #fx-vig.beat { animation: none !important; opacity: .6; }
  .whisper { animation-name: whisper-still; }
  @keyframes whisper-still { 0% { opacity: 0; } 30% { opacity: .85; } 100% { opacity: 0; } }
  .bad.full.show .bad-inner { animation: none; }
  .bad-text p { animation: none; opacity: 1; }
}
