:root {
  --paper: #f4e7c9;
  --paper-2: #efdfbb;
  --ink: #2a1c12;
  --red: #c41230;
  --gold: #e7b641;
  --green: #2f8a3c;
  --night: #070d1c;
  --todo: #fff3a8;
  --kraft: #c8a272;
  --fn-yellow: #ffe14d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: #fff; font-family: Nunito, system-ui, sans-serif; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Fortnite-ish buttons ---------- */
.fn-btn {
  border: 0; background: var(--fn-yellow); color: #1a1405;
  font-family: 'Luckiest Guy', sans-serif; font-size: 20px; letter-spacing: 0.04em;
  padding: 12px 22px 9px; transform: skewX(-8deg);
  box-shadow: 0 4px 0 #b08d12, 0 8px 20px rgba(0,0,0,0.35);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s;
}
.fn-btn:hover:not(:disabled) { transform: skewX(-8deg) translateY(-2px); filter: brightness(1.06); }
.fn-btn:active:not(:disabled) { transform: skewX(-8deg) translateY(2px); box-shadow: 0 1px 0 #b08d12; }
.fn-btn:disabled { filter: grayscale(.8) brightness(.8); cursor: not-allowed; }
.fn-btn.big { font-size: 28px; padding: 16px 34px 12px; }
.fn-btn.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 3px rgba(255,255,255,.75); }

.chip {
  position: fixed; z-index: 30; border: 0; border-radius: 999px;
  background: rgba(10,14,28,.55); color: #fff; backdrop-filter: blur(6px);
  padding: 8px 14px; font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .4s;
}
#skip { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
#skip.on { opacity: 1; pointer-events: auto; }
#mute { right: 16px; top: calc(16px + env(safe-area-inset-top)); opacity: .9; pointer-events: auto; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; }
#mute .off { display: none; } #mute.muted .on { display: none; } #mute.muted .off { display: block; }

/* ---------- letterbox, captions, fades ---------- */
.bar { position: fixed; left: 0; right: 0; height: 0; background: #000; z-index: 10; transition: height 1.2s ease; }
.bar.top { top: 0; } .bar.bot { bottom: 0; }
body.cinema .bar { height: 9vh; }
#caption {
  position: fixed; left: 50%; bottom: 12vh; transform: translate(-50%, 10px); z-index: 12;
  width: min(92vw, 900px); text-align: center;
  font-family: 'IM Fell English', serif; font-style: italic; font-size: clamp(20px, 3.2vw, 38px);
  color: #fff6e2; text-shadow: 0 2px 14px rgba(0,0,0,.9), 0 0 2px rgba(0,0,0,.9);
  opacity: 0; transition: opacity .9s ease, transform .9s ease; pointer-events: none;
}
#caption.on { opacity: 1; transform: translate(-50%, 0); }
#fade { position: fixed; inset: 0; z-index: 20; opacity: 0; pointer-events: none; background: #000; }
#hint {
  position: fixed; left: 50%; top: calc(18px + env(safe-area-inset-top)); transform: translate(-50%, -8px); z-index: 12;
  font-family: 'Luckiest Guy', sans-serif; font-size: clamp(18px, 2.4vw, 26px); letter-spacing: .04em;
  color: #fff; text-shadow: 0 3px 0 #000, 0 0 14px rgba(0,0,0,.7); -webkit-text-stroke: 1px #000;
  opacity: 0; transition: opacity .4s, transform .4s; pointer-events: none; white-space: nowrap;
}
#hint.on { opacity: 1; transform: translate(-50%, 0); animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, 4px); } }
#credit { position: fixed; left: 12px; bottom: 6px; margin: 0; z-index: 5; font-size: 11px; color: rgba(255,255,255,.4); max-width: 60vw; }
body.cinema #credit { opacity: 0; }

/* ---------- start ---------- */
#start {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; text-align: center;
  background: radial-gradient(ellipse at 50% 120%, rgba(255,160,80,.18), transparent 60%), linear-gradient(rgba(5,9,20,.35), rgba(5,9,20,.7));
  transition: opacity 1s ease;
}
#start.gone { opacity: 0; pointer-events: none; }
.start-inner { padding: 24px 16px; }
#start .kicker { font-family: 'IM Fell English', serif; font-style: italic; font-size: clamp(16px, 2.2vw, 22px); margin: 0 0 6px; color: #ffe9c8; }
#start h1 {
  font-family: 'Luckiest Guy', sans-serif; font-weight: 400; margin: 0; line-height: .95;
  font-size: clamp(56px, 11vw, 148px); color: #fff; letter-spacing: .02em;
  text-shadow: 0 6px 0 var(--red), 0 10px 0 #5a0715, 0 18px 40px rgba(0,0,0,.6);
  transform: rotate(-3deg);
}
#start .by { font-family: Caveat, cursive; font-size: clamp(26px, 3.6vw, 40px); margin: 18px 0 28px; color: var(--gold); }
#start .tip { font-size: 14px; opacity: .75; margin: 18px 0 0; }
#loading { font-size: 13px; opacity: .6; margin-top: 8px; }
#loading.gone { display: none; }

/* ---------- the book ---------- */
#book {
  position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3vh 16px; background: radial-gradient(ellipse at center, rgba(0,0,0,.15), rgba(0,0,0,.55));
  opacity: 0; transition: opacity .6s ease;
}
#book.on { opacity: 1; }
.spread {
  display: grid; grid-template-columns: 1fr 1fr; width: min(1080px, 94vw); aspect-ratio: 1.42 / 1; max-height: 78vh;
  background: #6d1220; padding: 12px; border-radius: 10px; box-shadow: 0 30px 80px rgba(0,0,0,.6);
  transform: perspective(1600px) rotateX(4deg); animation: bookIn .7s ease both;
}
@keyframes bookIn { from { transform: perspective(1600px) rotateX(14deg) translateY(30px) scale(.94); opacity: 0; } }
.page {
  position: relative; background: var(--paper); color: var(--ink); overflow: auto; padding: clamp(18px, 3.4vw, 44px);
  font-family: 'IM Fell English', serif; font-size: clamp(15px, 1.5vw, 19px); line-height: 1.45;
  background-image: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(120,80,30,.16));
}
.page.left { border-radius: 6px 0 0 6px; box-shadow: inset -30px 0 40px -20px rgba(90,60,30,.45); }
.page.right { border-radius: 0 6px 6px 0; box-shadow: inset 30px 0 40px -20px rgba(90,60,30,.45); }
.folio { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 13px; opacity: .55; }
.pg-title { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 2px solid rgba(42,28,18,.5); outline: 1px solid rgba(42,28,18,.3); outline-offset: -10px; padding: 20px; }
.pg-title .kicker { font-style: italic; margin: 0; }
.pg-title h1 { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; color: var(--red); font-size: clamp(40px, 6vw, 84px); line-height: .95; margin: 14px 0 8px; }
.pg-title .by { font-style: italic; font-size: 1.4em; margin: 10px 0 0; }
.pg-title .meta { font-size: .9em; opacity: .8; }
.orn { width: 60%; height: 12px; margin: 8px auto; background: linear-gradient(var(--ink), var(--ink)) left center / 42% 2px no-repeat, linear-gradient(var(--ink), var(--ink)) right center / 42% 2px no-repeat; position: relative; opacity: .8; }
.orn::after { content: ''; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; background: var(--red); transform: translate(-50%, -50%) rotate(45deg); }
.chap { text-transform: uppercase; letter-spacing: .14em; font-size: .8em; opacity: .7; margin: 0 0 14px; text-align: center; }
.pg-open { display: flex; flex-direction: column; justify-content: center; height: 100%; }
.dropcap { font-style: italic; font-size: clamp(24px, 2.8vw, 38px); line-height: 1.25; margin: 0 0 24px; }
.dropcap::first-letter { font-family: 'Luckiest Guy', sans-serif; font-style: normal; color: var(--red); float: left; font-size: 3em; line-height: .8; margin: 6px 10px 0 0; }
.pg-how .lead { font-family: 'Luckiest Guy', sans-serif; color: var(--red); font-size: 1.5em; margin: 0 0 8px; }
.pg-how p { margin: 0 0 4px; }
.envlist { list-style: none; padding: 0; margin: 16px 0 0; border-top: 1px solid rgba(42,28,18,.25); }
.envlist li { display: grid; grid-template-columns: 54px 1fr; gap: 0 10px; padding: 7px 0; border-bottom: 1px solid rgba(42,28,18,.18); }
.envlist .num { font-family: 'Special Elite', monospace; font-size: .85em; grid-row: span 2; padding-top: 3px; }
.envlist .unit { font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .78em; }
.envlist .front { font-family: Caveat, cursive; font-size: 1.35em; line-height: 1.05; }
.seal { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; color: var(--red); font-size: .8em; letter-spacing: .05em; }
.pg-guess { display: flex; flex-direction: column; height: 100%; }
.pg-guess .prompt { font-style: italic; font-size: 1.25em; margin: 0 0 14px; text-align: center; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.opt {
  border: 2px solid rgba(42,28,18,.35); background: #fff8e6; color: var(--ink); border-radius: 8px;
  padding: 10px 10px; font-family: Nunito, sans-serif; font-weight: 700; font-size: .78em; text-align: left; line-height: 1.2;
  transition: transform .12s, background .12s, border-color .12s;
}
.opt:hover { transform: translateY(-2px); border-color: var(--ink); }
.opt.picked { background: var(--fn-yellow); border-color: #1a1405; box-shadow: 0 3px 0 #b08d12; }
.pg-guess .go { align-self: center; margin-top: auto; }
.booknav { display: flex; align-items: center; gap: 18px; margin-top: 18px; }
.booknav .nav { background: none; border: 0; color: #fff; font-weight: 800; font-size: 15px; padding: 8px 6px; opacity: .9; text-shadow: 0 2px 8px #000; }
.booknav .nav:disabled { opacity: .25; cursor: default; }
.dots { display: flex; gap: 8px; } .dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.35); } .dots i.on { background: var(--fn-yellow); }

/* ---------- todo brackets ---------- */
.todo {
  background: var(--todo); color: #4a3a00; border-radius: 4px; padding: 1px 6px;
  font-family: Caveat, cursive; font-size: 1.12em; font-style: normal; line-height: 1.35;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; box-shadow: 0 0 0 1px rgba(160,130,0,.35);
}
#caption .todo { font-size: .9em; }

/* ---------- envelope card ---------- */
#card {
  position: fixed; inset: 0; z-index: 26; overflow-y: auto; padding: 5vh 16px 8vh;
  background: rgba(8,5,3,.55); backdrop-filter: blur(3px); opacity: 0; transition: opacity .4s ease;
}
#card.on { opacity: 1; }
#book:not(.on), #card:not(.on), #finale:not(.on) { pointer-events: none; }
.card-inner {
  position: relative; max-width: 720px; margin: 0 auto; color: var(--ink);
  background: #fbf3df; border-radius: 6px; padding: clamp(20px, 4vw, 44px);
  background-image: repeating-linear-gradient(transparent 0 31px, rgba(42,28,18,.07) 31px 32px);
  box-shadow: 0 30px 90px rgba(0,0,0,.6), 0 0 0 10px var(--kraft);
  font-family: 'IM Fell English', serif; font-size: 18px; line-height: 1.5;
  transform: translateY(30px) rotate(-1deg); transition: transform .5s cubic-bezier(.2,1.3,.4,1);
}
#card.on .card-inner { transform: none; }
.card-inner header { display: flex; align-items: baseline; gap: 14px; border-bottom: 2px solid var(--ink); padding-bottom: 8px; margin-bottom: 18px; }
.card-inner .no { font-family: 'Special Elite', monospace; font-size: 16px; }
.card-inner h2 { margin: 0; font-family: 'Luckiest Guy', sans-serif; font-weight: 400; font-size: clamp(30px, 5vw, 46px); color: var(--red); letter-spacing: .02em; flex: 1; }
.card-inner .x { background: none; border: 0; font-size: 34px; line-height: 1; color: var(--ink); padding: 0 4px; }
.excuse { background: var(--kraft); color: #1d1209; padding: 12px 16px; border-radius: 4px; transform: rotate(-.6deg); }
.excuse .lbl { font-family: 'Special Elite', monospace; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; opacity: .75; }
.excuse p { margin: 2px 0 0; font-family: Caveat, cursive; font-size: 32px; line-height: 1.1; text-decoration: line-through; text-decoration-color: rgba(196,18,48,.75); text-decoration-thickness: 3px; }
.divider { text-align: center; font-style: italic; margin: 22px 0 6px; opacity: .8; }
.divider::before, .divider::after { content: ''; display: inline-block; width: 50px; height: 1px; background: var(--ink); vertical-align: middle; margin: 0 10px; opacity: .5; }
.card-inner section { margin: 18px 0; }
.card-inner h3 { font-family: Nunito, sans-serif; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; margin: 0 0 6px; color: #6a4a2a; }
.card-inner ul { margin: 0; padding-left: 20px; }
.card-inner li { margin: 3px 0; }
blockquote { margin: 18px 0; padding: 8px 0 8px 18px; border-left: 4px solid var(--red); }
blockquote p { margin: 0; font-style: italic; font-size: 1.2em; }
blockquote.small p { font-size: 1.05em; }
blockquote cite { display: block; margin-top: 4px; font-style: normal; font-family: Nunito, sans-serif; font-size: 13px; font-weight: 700; color: #6a4a2a; }
blockquote cite::before { content: '- '; }
.stamp-row { display: flex; align-items: center; gap: 16px; margin: 20px 0; flex-wrap: wrap; }
.stamp {
  display: inline-flex; flex-direction: column; align-items: center; padding: 8px 18px; border: 4px solid var(--red); border-radius: 6px;
  color: var(--red); transform: rotate(-6deg); mix-blend-mode: multiply; opacity: .9;
}
.stamp .g { font-family: 'Luckiest Guy', sans-serif; font-size: 34px; line-height: 1; }
.stamp .n { font-family: 'Special Elite', monospace; font-size: 14px; }
.stamp-by { margin: 0; font-size: 14px; opacity: .75; font-family: Nunito, sans-serif; }
.link-btn {
  display: inline-block; margin: 6px 0 4px; padding: 9px 16px; border-radius: 999px; background: var(--ink); color: #fff3d6;
  font-family: Nunito, sans-serif; font-weight: 800; font-size: 14px; text-decoration: none;
}
.link-btn:hover { background: var(--red); }
.sticky { background: var(--todo); padding: 14px 16px 16px; margin: 22px 0; transform: rotate(.6deg); box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.sticky h4 { margin: 0 0 4px; font-family: Nunito, sans-serif; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: #6a5200; }
.sticky p { margin: 0; }
.sticky .todo { background: none; box-shadow: none; padding: 0; font-size: 1.35em; }
.media-slot { border: 2px dashed rgba(42,28,18,.4); border-radius: 8px; padding: 26px 16px; text-align: center; margin: 18px 0; background: rgba(255,255,255,.4); }
.imgs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.imgs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; background: #111; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.bars { display: grid; gap: 6px; font-family: Nunito, sans-serif; font-size: 14px; }
.brow { display: grid; grid-template-columns: 150px 1fr 28px; align-items: center; gap: 10px; }
.brow .k { font-weight: 700; } .brow .k em { font-style: normal; font-family: Caveat, cursive; font-size: 17px; color: var(--red); }
.brow .track { height: 16px; background: rgba(42,28,18,.1); border-radius: 3px; overflow: hidden; }
.brow .fill { display: block; height: 100%; width: 0; background: var(--ink); transition: width .8s cubic-bezier(.2,.9,.3,1); }
.brow .fill.go { width: var(--w); }
.brow.mine .fill { background: var(--red); }
.brow .v { font-weight: 800; text-align: right; }
.log { display: grid; gap: 0; font-size: 16px; border-top: 1px solid rgba(42,28,18,.25); }
.log .row { display: grid; grid-template-columns: 78px 1fr 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(42,28,18,.18); }
.log .d { font-family: 'Special Elite', monospace; font-size: 13px; padding-top: 3px; }
.log .n { font-family: Caveat, cursive; font-size: 20px; line-height: 1.15; color: #5a1a10; }
.reveal { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 0 18px; }
.reveal .cell { background: var(--ink); color: #fff3d6; border-radius: 8px; padding: 14px; }
.reveal .cell span { display: block; font-family: Nunito, sans-serif; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; opacity: .7; }
.reveal .cell b { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; font-size: 22px; letter-spacing: .02em; }
.reveal .cell .todo { display: inline; font-size: 18px; text-transform: none; letter-spacing: 0; opacity: 1; }
.reveal .verdict { grid-column: span 2; margin: 0; text-align: center; font-family: 'Luckiest Guy', sans-serif; font-size: 24px; color: var(--red); }
.reveal .verdict.hit { color: var(--green); }
.card-inner footer { text-align: center; margin-top: 26px; }

/* ---------- finale ---------- */
#finale {
  position: fixed; inset: 0; z-index: 25; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 24px 16px; background: radial-gradient(ellipse at center, rgba(0,0,0,.2), rgba(0,0,0,.65)); opacity: 0; transition: opacity 1s ease;
}
#finale.on { opacity: 1; }
#finale h1 { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; margin: 0; font-size: clamp(56px, 10vw, 128px); text-shadow: 0 6px 0 var(--red), 0 10px 0 #5a0715, 0 18px 40px rgba(0,0,0,.6); }
#finale .closing { font-family: 'IM Fell English', serif; font-style: italic; font-size: clamp(20px, 2.6vw, 30px); max-width: 760px; margin: 22px 0 6px; }
#finale .sig { font-family: Caveat, cursive; font-size: 28px; color: var(--gold); margin: 0 0 28px; }
#finale .row { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

/* ---------- snow on the start screen ---------- */
.snowfx { position: absolute; inset: 0; pointer-events: none; opacity: .0; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  #book { justify-content: flex-start; overflow-y: auto; padding-top: 7vh; }
  .spread { grid-template-columns: 1fr; aspect-ratio: auto; max-height: none; transform: none; }
  .page.left { border-radius: 6px 6px 0 0; box-shadow: inset 0 -20px 30px -20px rgba(90,60,30,.45); }
  .page.right { border-radius: 0 0 6px 6px; box-shadow: inset 0 20px 30px -20px rgba(90,60,30,.45); }
  .page { overflow: visible; padding-bottom: 36px; }
  .pg-title { min-height: 300px; }
  .opts { grid-template-columns: 1fr; }
  .brow { grid-template-columns: 100px 1fr 24px; }
  .log .row { grid-template-columns: 1fr; gap: 2px; }
  .reveal, .imgs { grid-template-columns: 1fr; }
  .reveal .verdict { grid-column: auto; }
  #hint { white-space: normal; width: 90vw; text-align: center; }
  #credit { max-width: 80vw; }
}
