@font-face{
  font-family:'Playfair';
  src:url('fonts/PlayfairDisplay.woff2') format('woff2');
  font-weight:400 900;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Special Elite';
  src:url('fonts/SpecialElite.woff2') format('woff2');
  font-weight:400;
  font-style:normal;
  font-display:swap;
}
@font-face{
  font-family:'Caveat';
  src:url('fonts/Caveat.woff2') format('woff2');
  font-weight:400 700;
  font-style:normal;
  font-display:swap;
}

:root{
  --ink:#2A211C;
  --ink-soft:#4d3e32;
  --ink-faint:rgba(42,33,28,.55);
  --paper:#EFE6D2;
  --paper-2:#D9CBAE;
  --paper-3:#C7B592;
  --manila:#D8B46A;
  --manila-dark:#B7934B;
  --stamp:#B23A2E;
  --green:#3F5A4A;
  --sky:#3FA9F5;
  --grass:#5CC44A;
  --sun:#FFD23F;
  --pink:#FF7BAC;
  --purple:#8E5CD9;
  --shadow:rgba(42,33,28,.32);
  --serif:'Playfair',Georgia,'Times New Roman',serif;
  --type:'Special Elite','Courier New',monospace;
  --hand:'Caveat','Segoe Script',cursive;
}

*{box-sizing:border-box}
html,body{height:100%;margin:0;overflow:hidden;background:var(--paper);color:var(--ink)}
body{
  font-family:var(--type);
  -webkit-tap-highlight-color:transparent;
  -webkit-user-select:none;user-select:none;
  overscroll-behavior:none;
  position:fixed;inset:0;
}
button{font-family:inherit;color:inherit}
button:focus-visible{outline:2px solid var(--stamp);outline-offset:3px}
.hidden{display:none!important}
.screen{position:absolute;inset:0}

#page{
  position:fixed;inset:0;overflow:hidden;
  background:var(--paper) url('img/paper-tile.webp') repeat;
  background-blend-mode:multiply;
}

/* ---------- the painted stage (from the reference) ---------- */
#stage{position:absolute;inset:0;overflow:hidden;z-index:1;background:var(--paper)}
.stage-bg{
  position:absolute;inset:0;
  background-size:cover;
  background-position:center top;
  opacity:0;
  transition:opacity 1.15s ease;
  transform:translateZ(0);
}
.stage-bg.on{opacity:1}
.stage-shade{
  position:absolute;inset:0;pointer-events:none;
  background:
    radial-gradient(ellipse at 50% 34%,rgba(42,33,28,0) 34%,rgba(42,33,28,.16) 100%),
    linear-gradient(to bottom,rgba(42,33,28,.08),rgba(42,33,28,0) 24%,rgba(42,33,28,0) 66%,rgba(217,203,174,.34));
  mix-blend-mode:multiply;
}
.stage-grain{
  position:absolute;inset:0;pointer-events:none;
  background:url('img/paper-tile.webp');
  opacity:.13;mix-blend-mode:multiply;
}
#game{position:absolute;inset:0;z-index:2;pointer-events:none}
#game canvas{display:block;width:100%!important;height:100%!important}

/* ---------- HUD ---------- */
#hud{
  position:absolute;inset:0;z-index:4;
  padding:calc(10px + env(safe-area-inset-top)) 12px 0;
  display:flex;align-items:flex-start;justify-content:space-between;gap:10px;
  pointer-events:none;
}
.folder{
  position:relative;
  width:min(540px,66vw);
  background-color:var(--manila);
  background-image:url('img/paper-tile.webp');
  background-blend-mode:multiply;
  border:1px solid rgba(42,33,28,.36);
  box-shadow:0 12px 22px rgba(42,33,28,.3),inset 0 1px 0 rgba(255,255,255,.34);
  padding:14px 12px 9px;
  transform:rotate(-.25deg);
  pointer-events:auto;
}
.folder::after{
  content:"EXP. 2";
  position:absolute;right:9px;top:20px;
  font-size:8px;letter-spacing:.16em;
  color:rgba(178,58,46,.5);
  border:1px solid rgba(178,58,46,.4);
  padding:1px 4px;transform:rotate(3deg);
  filter:url(#rough);
}
.folder-tabs{
  position:absolute;left:12px;top:-16px;display:flex;gap:3px;align-items:flex-end;
}
.tab{
  display:block;
  background:var(--manila);
  background-image:url('img/paper-tile.webp');
  background-blend-mode:multiply;
  border:1px solid rgba(42,33,28,.34);border-bottom:none;
  font-size:7px;letter-spacing:.1em;line-height:1;
  padding:4px 8px 5px;
  transform:skew(-5deg);
  white-space:nowrap;
  color:rgba(42,33,28,.75);
}
.tab-a{background-color:#E0C07A}
.tab-b{background-color:#C7A459;font-size:6px;opacity:.86}
.folder-body{display:flex;align-items:center;gap:10px;min-height:64px}
.folder-fold{
  position:absolute;left:7px;top:2px;bottom:2px;width:1px;
  background:linear-gradient(to bottom,transparent,rgba(42,33,28,.22) 12%,rgba(42,33,28,.1) 88%,transparent);
}
.evidence{display:flex;gap:5px;align-items:flex-end;min-height:56px}
.evidence-card{
  width:48px;position:relative;
  background:#f7f0dd;
  border:1px solid rgba(42,33,28,.2);
  box-shadow:0 1px 2px rgba(42,33,28,.22);
  padding:3px 3px 2px;
  transform:rotate(-1.6deg);
  transition:transform .3s ease,opacity .3s ease;
}
.evidence-card:nth-child(2){transform:rotate(1.2deg)}
.evidence-card:nth-child(3){transform:rotate(-.7deg)}
.evidence-card:nth-child(4){transform:rotate(1.8deg)}
.evidence-card img{display:block;width:100%;aspect-ratio:1;object-fit:cover;background:#fffdf5}
.evidence-card::before{
  content:"";position:absolute;left:50%;top:-6px;width:9px;height:17px;
  transform:translateX(-50%) rotate(2deg);
  border:1.5px solid #8d8b7f;border-radius:5px 5px 2px 2px;
  background:linear-gradient(90deg,rgba(255,255,255,.55),rgba(160,158,146,.18));
  z-index:3;opacity:.9;
}
.evidence-label{
  display:block;text-align:center;font-size:5.5px;letter-spacing:.02em;
  color:var(--ink-soft);line-height:1.25;margin-top:2px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.evidence-card.empty{
  background:rgba(255,250,236,.22);
  border:1px dashed rgba(42,33,28,.38);
  min-height:55px;
  display:grid;place-items:center;
  box-shadow:none;
}
.evidence-card.empty::before{opacity:.35}
.evidence-card.empty .evidence-label{opacity:.55;font-size:5px}
.case-stats{
  margin-left:auto;display:flex;flex-direction:column;gap:2px;
  text-align:right;white-space:nowrap;
}
.stat-line{display:flex;align-items:center;justify-content:flex-end;gap:6px;line-height:1.2}
.stat-label{font-size:6.5px;letter-spacing:.13em;opacity:.62}
.hearts{font-family:Georgia,serif;color:var(--stamp);font-size:15px;letter-spacing:1.5px;line-height:1;text-shadow:0 1px 0 rgba(255,255,255,.35)}
.hearts .off{color:rgba(42,33,28,.2);text-shadow:none}
.stat-value{font-size:10px;letter-spacing:.05em}
.stat-line.tiny{display:block;font-size:6px;letter-spacing:.12em;opacity:.45;margin-top:2px}

.paper-tag{
  position:relative;
  background:rgba(239,230,210,.92) url('img/paper-tile.webp');
  background-blend-mode:multiply;
  border:1px solid rgba(42,33,28,.38);
  box-shadow:0 6px 14px rgba(42,33,28,.22);
  padding:5px 26px 5px 9px;
  transform:rotate(1deg);
  min-width:88px;max-width:150px;
  display:flex;flex-direction:column;gap:1px;
  pointer-events:auto;
  text-align:right;
}
#zoneKicker{font-size:5.5px;letter-spacing:.18em;opacity:.55}
#zoneName{font-size:7px;letter-spacing:.08em;line-height:1.3}
#helpBtn{
  position:absolute;right:5px;top:5px;
  width:17px;height:17px;padding:0;
  border:1px solid rgba(42,33,28,.55);
  background:transparent;color:var(--ink);
  font-size:9px;line-height:1;cursor:pointer;
}
#helpBtn:hover{background:rgba(178,58,46,.12);color:var(--stamp)}

#bossBar{
  position:absolute;left:50%;bottom:22px;transform:translateX(-50%);
  display:flex;align-items:center;gap:9px;
  background:rgba(239,230,210,.92) url('img/paper-tile.webp');
  background-blend-mode:multiply;
  border:1px solid rgba(42,33,28,.4);
  box-shadow:0 6px 14px rgba(42,33,28,.22);
  padding:4px 11px;
  font-size:7px;letter-spacing:.13em;
  pointer-events:none;
}
.boss-name{color:var(--stamp);font-weight:700}
.seals{display:flex;gap:5px}
.seal{width:11px;height:11px;border:1px solid var(--stamp);border-radius:50%;opacity:.35;display:block;background:transparent}
.seal.on{opacity:1;background:var(--stamp)}
.boss-note{opacity:.6;font-size:6px;letter-spacing:.1em}
.hint{
  position:absolute;left:50%;bottom:22px;transform:translateX(-50%) rotate(-.4deg);
  background:rgba(239,230,210,.92) url('img/paper-tile.webp');
  background-blend-mode:multiply;
  border:1px solid rgba(42,33,28,.34);
  padding:4px 12px;
  font-size:7.5px;letter-spacing:.12em;text-transform:uppercase;
  max-width:88vw;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  opacity:0;transition:opacity .35s ease;
  pointer-events:none;
}
.hint.show{opacity:1}

/* ---------- touch controls ---------- */
#touch{
  position:absolute;left:0;right:0;bottom:0;z-index:6;
  display:none;justify-content:space-between;align-items:flex-end;
  padding:0 12px calc(10px + env(safe-area-inset-bottom));
  pointer-events:none;
}
body.touch #touch{display:flex}
#touch.hidden{display:none!important}
.touch-left,.touch-right{display:flex;gap:8px;align-items:flex-end;pointer-events:auto}
.tbtn{
  width:58px;height:62px;
  border:1px solid rgba(42,33,28,.55);
  background:rgba(239,230,210,.84) url('img/paper-tile.webp');
  background-blend-mode:multiply;
  color:var(--ink);
  font-family:var(--type);font-size:10px;letter-spacing:.08em;
  box-shadow:0 4px 0 rgba(42,33,28,.28);
  transform:rotate(-1deg);
  display:grid;place-items:center;
  touch-action:none;cursor:pointer;
  -webkit-user-select:none;user-select:none;
}
.tbtn:active{transform:translateY(3px) rotate(-1deg);box-shadow:0 1px 0 rgba(42,33,28,.28)}
.tbtn.move{font-size:19px;width:56px;height:62px}
.tbtn.jump{width:70px;height:74px;background-color:var(--manila);font-size:12px;transform:rotate(1.5deg);border-width:2px}
.tbtn.small{width:56px;height:46px;font-size:8px;letter-spacing:.06em}
.tbtn.evidence-btn{background-color:#e8cfa5;color:var(--stamp);border-color:var(--stamp)}
.tbtn.evidence-btn.ready{animation:pulse 1.1s ease-in-out infinite}
@keyframes pulse{0%,100%{box-shadow:0 4px 0 rgba(42,33,28,.28),0 0 0 0 rgba(178,58,46,.35)}50%{box-shadow:0 4px 0 rgba(42,33,28,.28),0 0 0 7px rgba(178,58,46,0)}}

/* ---------- transcript ---------- */
#transcript{
  position:absolute;left:0;right:0;bottom:0;z-index:7;
  display:flex;justify-content:center;
  padding:0 12px calc(10px + env(safe-area-inset-bottom));
  pointer-events:none;
}
.transcript-sheet{
  width:min(780px,94vw);
  background:var(--paper) url('img/paper-sheet.webp');
  background-size:cover;background-position:center;
  box-shadow:0 16px 34px rgba(42,33,28,.38),inset 0 0 0 1px rgba(42,33,28,.18);
  padding:13px 17px 7px;
  position:relative;
  pointer-events:auto;
  transform:rotate(-.2deg);
  clip-path:polygon(0% 3%,2% 1%,6% 2.2%,11% 0.4%,17% 2%,23% 0.8%,30% 2.1%,38% 0.6%,46% 2%,54% 0.5%,62% 2.2%,70% 0.7%,78% 2.2%,85% 0.6%,91% 2%,96% 0.8%,100% 2.6%,100% 97.6%,97% 99.4%,92% 98%,87% 99.6%,80% 98.2%,72% 99.5%,64% 98%,56% 99.4%,48% 98.1%,40% 99.6%,32% 98.2%,24% 99.4%,16% 98%,9% 99.3%,4% 98.1%,0% 99%);
}
.transcript-head{
  display:flex;justify-content:space-between;align-items:baseline;gap:10px;
  border-bottom:1px solid rgba(42,33,28,.22);
  padding-bottom:5px;margin-bottom:7px;
  font-size:8px;letter-spacing:.14em;
}
#speaker{color:var(--stamp);letter-spacing:.18em;font-size:9px}
.transcript-case{font-size:6px;letter-spacing:.13em;opacity:.45}
.transcript-body{display:flex;gap:11px;align-items:flex-start}
.portrait{
  flex:0 0 auto;width:60px;height:60px;
  background:#f6efdd;border:1px solid rgba(42,33,28,.22);
  box-shadow:0 1px 2px rgba(42,33,28,.2);
  padding:3px;transform:rotate(-1.5deg);
}
.portrait img{width:100%;height:100%;object-fit:contain;display:block;filter:sepia(.18) contrast(1.04)}
#line{
  margin:0;font-family:var(--type);
  font-size:clamp(12.5px,2.1vw,16px);
  line-height:1.5;letter-spacing:.01em;
  min-height:3.6em;
  white-space:pre-wrap;
}
.transcript-foot{
  display:flex;justify-content:flex-end;align-items:center;gap:7px;
  margin-top:3px;font-size:6px;letter-spacing:.14em;opacity:.5;
}
.caret{animation:caret 1s steps(1) infinite;font-size:9px;line-height:1}
@keyframes caret{50%{opacity:0}}

/* ---------- title ---------- */
#title{z-index:8;overflow:hidden}
.title-docket{
  position:absolute;left:4.5vw;top:4vh;
  width:min(590px,50vw);
  max-height:88vh;overflow:auto;
  background:rgba(239,230,210,.93) url('img/paper-sheet.webp');
  background-size:cover;background-position:center;
  padding:21px 26px 14px;
  border:1px solid rgba(42,33,28,.32);
  box-shadow:0 24px 52px rgba(42,33,28,.4),inset 0 0 0 1px rgba(255,255,255,.25);
  transform:rotate(-.35deg);
  clip-path:polygon(0% 1.2%,3% 0.2%,8% 1.1%,14% 0.1%,21% 1%,29% 0.2%,38% 1.1%,47% 0.1%,56% 1%,65% 0.2%,74% 1.1%,83% 0.2%,91% 1%,97% 0.2%,100% 1%,100% 99%,96% 99.9%,90% 99%,83% 99.9%,75% 99%,66% 99.9%,57% 99%,48% 99.8%,39% 99%,30% 99.9%,22% 99%,14% 99.8%,7% 99%,2% 99.8%,0% 99%);
}
.docket-head{font-size:7.5px;letter-spacing:.19em;line-height:1.7;opacity:.72;border-bottom:1px solid rgba(42,33,28,.26);padding-bottom:7px}
.docket-no{display:flex;justify-content:space-between;gap:10px;margin-top:8px;font-size:8px;letter-spacing:.16em;color:var(--stamp)}
.docket-no span{color:var(--ink-soft);opacity:.45;font-size:7px}
.title-docket h1{
  position:relative;
  font-family:var(--serif);font-weight:900;
  font-size:clamp(34px,6.6vw,78px);
  line-height:.9;letter-spacing:-.025em;
  margin:8px 0 10px;
  max-width:8.5em;
}
.docket-two{
  position:absolute;right:-2px;top:-.34em;
  font-family:var(--serif);font-weight:900;
  font-size:1.7em;line-height:1;
  color:var(--stamp);opacity:.9;
  transform:rotate(-9deg);
  filter:url(#rough);
  text-shadow:2px 2px 0 rgba(42,33,28,.1);
}
.docket-sub{
  font-family:var(--hand);
  font-size:clamp(18px,2.2vw,25px);
  line-height:1.1;color:var(--ink-soft);
  margin:0 0 13px;max-width:23em;
}
.menu{display:flex;flex-direction:column;border-top:1px solid rgba(42,33,28,.24);padding-top:8px}
.menu-item{
  display:flex;align-items:center;gap:11px;
  width:100%;text-align:left;
  background:transparent;border:0;border-bottom:1px dashed rgba(42,33,28,.26);
  padding:7px 2px;cursor:pointer;
  font-family:var(--type);font-size:clamp(12.5px,1.45vw,15.5px);letter-spacing:.05em;
  transition:background .18s ease,color .18s ease,padding .18s ease;
}
.menu-item::after{content:"\2192";margin-left:auto;opacity:.32;font-size:.95em}
.menu-item:hover:not(:disabled),.menu-item:focus-visible:not(:disabled){background:rgba(178,58,46,.08);color:var(--stamp);padding-left:7px}
.menu-item:disabled{opacity:.38;cursor:default}
.menu-no{color:var(--stamp);font-size:.78em;letter-spacing:.04em;width:1.9em;flex:0 0 auto}
.controls-note{font-size:7.5px;line-height:1.55;letter-spacing:.05em;opacity:.58;margin:11px 0 0;max-width:30em}
.docket-foot{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-top:8px;font-size:6px;letter-spacing:.1em;opacity:.42}
#titleHelp{background:none;border:0;padding:0;font-size:6px;letter-spacing:.12em;color:var(--ink);text-decoration:underline;cursor:pointer;opacity:1}
.title-lion{
  position:absolute;right:-5vw;bottom:-21vh;width:min(72vw,900px);
  margin:0;pointer-events:none;
  filter:drop-shadow(0 24px 40px rgba(42,33,28,.42));
}
.title-lion img{display:block;width:100%;height:auto;filter:contrast(1.04) sepia(.04)}
.title-wolf{
  position:absolute;left:5.5vw;bottom:3.5vh;width:min(31vw,280px);margin:0;
  pointer-events:none;filter:drop-shadow(0 16px 18px rgba(42,33,28,.4));
  animation:wolfbob 4.2s ease-in-out infinite;
}
.title-wolf img{display:block;width:100%;height:auto}
@keyframes wolfbob{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}
.title-dream{
  position:absolute;left:23vw;bottom:21vh;width:min(8.5vw,86px);margin:0;
  transform:rotate(-7deg);pointer-events:none;
  filter:drop-shadow(0 0 20px rgba(255,210,63,.65)) drop-shadow(0 10px 12px rgba(42,33,28,.3));
  animation:dreambob 5.1s ease-in-out infinite;
}
.title-dream img{display:block;width:100%;height:auto;border:1px solid rgba(42,33,28,.25);background:#fffdf5}
@keyframes dreambob{0%,100%{transform:rotate(-7deg) translateY(0)}50%{transform:rotate(-4deg) translateY(-10px)}}
.title-mark{
  position:absolute;right:12px;bottom:10px;
  font-size:6px;letter-spacing:.22em;opacity:.5;
  background:rgba(239,230,210,.85);border:1px solid rgba(42,33,28,.24);
  padding:3px 6px;transform:rotate(-.6deg);
}

/* ---------- overlay sheets ---------- */
#overlay{
  z-index:9;display:flex;align-items:center;justify-content:center;
  padding:16px;
  background:rgba(42,33,28,.3);
}
.sheet{
  width:min(660px,93vw);max-height:91vh;overflow:auto;
  background:var(--paper) url('img/paper-sheet.webp');
  background-size:cover;background-position:center;
  padding:22px 26px 18px;
  border:1px solid rgba(42,33,28,.35);
  box-shadow:0 28px 60px rgba(42,33,28,.46),inset 0 0 0 1px rgba(255,255,255,.22);
  transform:rotate(-.25deg);
  position:relative;
}
.sheet-kicker{font-size:7px;letter-spacing:.2em;opacity:.55;margin:0 0 5px}
.sheet h2{
  font-family:var(--serif);font-weight:900;
  font-size:clamp(26px,4.4vw,46px);line-height:.95;letter-spacing:-.02em;
  margin:0 0 10px;max-width:9em;
}
.sheet p{font-size:12px;line-height:1.55;margin:0 0 10px;letter-spacing:.01em}
.sheet p.small{font-size:9px;opacity:.65}
.sheet .rule{border:0;border-top:1px solid rgba(42,33,28,.24);margin:12px 0}
.sheet .stamp{
  display:inline-block;color:var(--stamp);border:3px solid var(--stamp);
  padding:2px 12px;margin:2px 0 12px;
  font-size:clamp(18px,3vw,30px);line-height:1.1;letter-spacing:.08em;
  transform:rotate(-3.4deg);opacity:.82;
  filter:url(#rough);mix-blend-mode:multiply;
}
.sheet-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
.sheet-btn{
  background:rgba(255,250,236,.35);border:1px solid rgba(42,33,28,.55);
  padding:8px 13px;font-family:var(--type);font-size:11px;letter-spacing:.06em;
  cursor:pointer;box-shadow:0 2px 0 rgba(42,33,28,.2);
  transform:rotate(-.3deg);
}
.sheet-btn:hover{background:rgba(178,58,46,.1);color:var(--stamp)}
.sheet-btn.primary{background:var(--manila);border-width:2px;font-size:12px}
.sheet-btn:active{transform:translateY(2px) rotate(-.3deg);box-shadow:0 0 0 rgba(0,0,0,0)}
.sheet-grid{display:grid;grid-template-columns:1fr 1fr;gap:6px 16px;margin:10px 0}
.sheet-grid div{font-size:10px;line-height:1.5;border-bottom:1px dotted rgba(42,33,28,.2);padding:4px 0}
.sheet-grid b{font-weight:400;color:var(--stamp);letter-spacing:.06em}
.key{display:inline-block;border:1px solid rgba(42,33,28,.5);padding:0 4px;font-size:9px;line-height:1.4;background:rgba(255,255,255,.25)}
.score-lines{display:flex;flex-wrap:wrap;gap:8px 22px;margin:10px 0}
.score-lines div{font-size:11px}
.score-lines b{font-weight:400;color:var(--stamp);font-size:16px;display:block;letter-spacing:.04em}
.board{margin-top:8px;border-top:1px solid rgba(42,33,28,.24);padding-top:8px}
.board h3{font-family:var(--serif);font-size:15px;margin:0 0 5px;font-weight:900}
.board ol{margin:0;padding-left:20px;font-size:10px;line-height:1.6}
.board li::marker{color:var(--stamp)}
.board .me{color:var(--stamp)}
.share-row{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:10px}
.share-note{font-size:8px;opacity:.6}

/* ---------- flash stamp ---------- */
#flash{
  z-index:11;display:grid;place-items:center;pointer-events:none;
  opacity:0;transition:opacity .16s ease;
}
#flash.show{opacity:1}
#flash span{
  font-family:var(--serif);font-weight:900;
  font-size:clamp(42px,12vw,150px);line-height:1;
  color:var(--stamp);border:5px solid var(--stamp);
  padding:.06em .16em;letter-spacing:.02em;
  transform:rotate(-8deg);opacity:.7;
  filter:url(#roughBig);mix-blend-mode:multiply;
  text-align:center;
}

/* ---------- loading ---------- */
#loading{
  z-index:20;display:grid;place-items:center;
  background:var(--paper) url('img/paper-tile.webp');
  background-blend-mode:multiply;
  padding:18px;
}
.loading-sheet{
  background:var(--paper) url('img/paper-sheet.webp');
  background-size:cover;background-position:center;
  width:min(430px,90vw);padding:24px 26px 23px;text-align:center;
  border:1px solid rgba(42,33,28,.34);
  box-shadow:0 24px 52px rgba(42,33,28,.4);
  transform:rotate(-.5deg);
}
.loading-kicker{font-size:7px;letter-spacing:.2em;opacity:.55;margin:0 0 6px}
.loading-title{font-family:var(--serif);font-weight:900;font-size:clamp(24px,5vw,34px);line-height:1;margin:0 0 15px}
.loading-bar{height:7px;border:1px solid rgba(42,33,28,.5);background:rgba(255,255,255,.25);overflow:hidden}
#loadingFill{display:block;height:100%;width:0;background:var(--stamp);transition:width .25s ease}
.loading-stamp{font-family:var(--serif);font-weight:900;color:var(--stamp);font-size:24px;letter-spacing:.12em;margin:14px 0 4px;transform:rotate(-5deg);opacity:.72;filter:url(#rough)}
.loading-note{font-size:8px;letter-spacing:.06em;opacity:.55;margin:0}

/* ---------- responsive ---------- */
@media (max-width:640px),(max-aspect-ratio:1/1){
  #hud{padding:calc(8px + env(safe-area-inset-top)) 8px 0;gap:6px}
  .folder{width:calc(100vw - 108px);max-width:340px;padding:12px 9px 7px}
  .folder-body{gap:7px;min-height:52px}
  .evidence{gap:4px;min-height:46px}
  .evidence-card{width:38px;padding:2px 2px 1px}
  .evidence-card::before{width:7px;height:14px;top:-5px}
  .evidence-card.empty{min-height:46px}
  .evidence-label{font-size:4.6px}
  .case-stats{gap:1px}
  .stat-label{font-size:5.5px}
  .hearts{font-size:13px}
  .stat-value{font-size:9px}
  .stat-line.tiny{font-size:5px}
  .folder-tabs{top:-14px;left:8px}
  .tab{font-size:5.6px;padding:3px 6px 4px}
  .tab-b{font-size:4.8px}
  .folder::after{font-size:6px;top:17px}
  .paper-tag{padding:4px 20px 4px 6px;min-width:88px;max-width:96px}
  #zoneName{font-size:6px;line-height:1.25}
  #zoneKicker{font-size:5px}
  #helpBtn{width:15px;height:15px;font-size:8px;right:4px;top:4px}
  #hint{bottom:calc(94px + env(safe-area-inset-bottom));font-size:6.5px;white-space:normal;text-align:center;line-height:1.4;max-width:82vw}
  #bossBar{bottom:calc(92px + env(safe-area-inset-bottom));font-size:6px;padding:3px 8px;gap:6px}
  .boss-note{display:none}
  .transcript-sheet{width:96vw;padding:10px 12px 5px}
  .portrait{width:50px;height:50px}
  #line{font-size:12.5px;line-height:1.45;min-height:4.2em}
  .transcript-head{font-size:6.5px;margin-bottom:5px;padding-bottom:4px}
  #speaker{font-size:7.5px}
  .transcript-case{font-size:5px}
  .transcript-foot{font-size:5px}
  .title-docket{left:4vw;top:2.5vh;width:92vw;max-height:76vh;padding:14px 16px 10px}
  .docket-head{font-size:6px;padding-bottom:5px}
  .docket-no{font-size:6.5px;margin-top:5px}
  .title-docket h1{font-size:clamp(32px,9.4vw,46px);margin:5px 0 6px;max-width:7.2em}
  .docket-two{top:-.28em;right:0}
  .docket-sub{font-size:17px;margin-bottom:8px}
  .menu-item{font-size:12px;padding:6px 2px}
  .controls-note{font-size:6.5px;margin-top:7px;line-height:1.45}
  .docket-foot{font-size:5px;margin-top:5px}
  #titleHelp{font-size:5px}
  .title-lion{right:-38vw;bottom:2vh;width:130vw;opacity:.56}
  .title-wolf{left:2vw;bottom:1.5vh;width:40vw}
  .title-dream{left:26vw;bottom:18vh;width:64px}
  .title-mark{font-size:5px;right:8px;bottom:8px}
  .sheet{padding:17px 17px 14px;max-height:88vh}
  .sheet h2{font-size:clamp(24px,7.4vw,34px)}
  .sheet p{font-size:11px;line-height:1.5}
  .sheet-grid{grid-template-columns:1fr;gap:3px}
  .sheet-grid div{font-size:9px}
  #flash span{border-width:3px}
  .title-docket::after{content:"";position:absolute;inset:0;pointer-events:none;background:radial-gradient(ellipse at 80% 10%,rgba(255,210,63,.12),transparent 55%)}
}
@media (max-height:560px) and (orientation:landscape){
  .title-docket{top:3vh;max-height:92vh;width:min(520px,52vw);padding:12px 18px 8px}
  .title-docket h1{font-size:clamp(26px,4.4vw,40px);margin:4px 0 5px}
  .docket-sub{font-size:16px;margin-bottom:6px}
  .menu-item{padding:4px 2px;font-size:11px}
  .controls-note{margin-top:5px;font-size:6px}
  .title-wolf{width:24vw}
  .title-dream{left:20vw;bottom:17vh;width:56px}
  .title-lion{width:62vw;right:-4vw;bottom:-26vh}
  .folder{width:min(470px,62vw);padding:10px 9px 6px}
  .evidence-card{width:38px}
  .transcript-sheet{width:min(680px,88vw);padding:8px 13px 4px}
  #line{font-size:11px;min-height:2.8em}
  .portrait{width:44px;height:44px}
  .transcript-foot{display:none}
}
@media (prefers-reduced-motion:reduce){
  .title-wolf,.title-dream,.tbtn.evidence-btn.ready{animation:none}
  .stage-bg{transition:none}
}

/* ---------- zone card ---------- */
#zoneCard{
  position:absolute;inset:0;z-index:7;
  display:flex;align-items:center;justify-content:center;
  padding:18px;background:rgba(42,33,28,.2);
  cursor:pointer;
}
#zoneCard.hidden{display:none}
.zone-card-sheet{
  width:min(580px,92vw);
  background:var(--paper) url('img/paper-sheet.webp');
  background-size:cover;background-position:center;
  border:1px solid rgba(42,33,28,.4);
  box-shadow:0 26px 60px rgba(42,33,28,.48);
  padding:24px 26px 18px;text-align:left;
  transform:rotate(-.4deg);
  animation:cardIn .5s ease both;
}
@keyframes cardIn{from{opacity:0;transform:rotate(-1.4deg) translateY(10px)}to{opacity:1;transform:rotate(-.4deg) translateY(0)}}
.zone-card-kicker{font-size:9px;letter-spacing:.26em;color:var(--stamp);margin:0 0 4px}
.zone-card-sheet h2{
  font-family:var(--serif);font-weight:900;
  font-size:clamp(28px,5vw,46px);line-height:.92;letter-spacing:-.02em;
  margin:0 0 9px;
}
.zone-card-line{font-family:var(--hand);font-size:clamp(19px,2.6vw,26px);line-height:1.15;color:var(--ink-soft);margin:0 0 14px;max-width:22em}
.zone-card-hint{display:inline-block;font-size:7px;letter-spacing:.18em;border-top:1px solid rgba(42,33,28,.25);padding-top:7px;opacity:.55}

/* ---------- dream toast ---------- */
#toast{
  position:absolute;left:50%;top:24%;z-index:5;
  transform:translate(-50%,-50%) rotate(-4deg);
  font-family:var(--hand);font-weight:700;
  font-size:clamp(26px,5vw,46px);line-height:1;
  color:var(--toast,#3FA9F5);
  text-shadow:0 2px 0 rgba(255,255,255,.7),0 0 18px rgba(255,255,255,.5);
  opacity:0;pointer-events:none;white-space:nowrap;
  transition:opacity .2s ease,transform .5s ease;
}
#toast.show{opacity:1;transform:translate(-50%,-68%) rotate(-4deg)}
#toast small{display:block;text-align:center;font-family:var(--type);font-size:7px;letter-spacing:.2em;color:var(--ink);opacity:.6;margin-top:4px;text-shadow:none}

/* ---------- boss void overlay (DOM, above the canvas) ---------- */
#bossFx{
  position:absolute;z-index:3;pointer-events:none;
  border-radius:50%;overflow:hidden;
  transform:translate(-50%,-50%);
  mix-blend-mode:normal;
  opacity:0;transition:opacity .4s ease;
}
#bossFx.on{opacity:1}
#bossFx .void-core{
  position:absolute;inset:-3%;
  background:radial-gradient(ellipse at 50% 50%,rgba(255,255,255,.32),rgba(255,255,255,0) 66%);
  mix-blend-mode:screen;
}
#bossFx .ghost{
  position:absolute;font-family:var(--type);font-size:8px;
  color:rgba(58,58,56,.4);letter-spacing:.04em;white-space:nowrap;
  text-shadow:0 0 2px rgba(255,255,255,.8);
  animation:ghostDrift 11s linear infinite;
}
@keyframes ghostDrift{
  0%{opacity:0;transform:translateX(-8px)}
  15%{opacity:1}
  70%{opacity:1}
  100%{opacity:0;transform:translateX(16px)}
}
#bossFx .void-fx{
  position:absolute;inset:0;border-radius:50%;
  opacity:0;transition:opacity .7s ease;
  pointer-events:none;
}
#bossFx .void-fx.on{opacity:1}
#voidBlue{background:url('img/void-blue.webp') center/cover;mix-blend-mode:multiply}
#voidStaves{background:url('img/void-staves.webp') center/78% no-repeat;mix-blend-mode:multiply}
#voidMeal{display:grid;place-items:center}
#voidMeal img{width:76%;height:76%;object-fit:contain;filter:sepia(.15);transition:filter 1.1s ease,opacity 1.1s ease}
#voidMeal.grey img{filter:grayscale(1) contrast(.9);opacity:.5}
#voidFill{
  background:url('img/void-color.webp') center/cover;
  clip-path:ellipse(0% 0% at 50% 50%);
  transition:clip-path 2.4s cubic-bezier(.2,.7,.2,1);
  mix-blend-mode:multiply;opacity:1;
}
#voidFill.on{clip-path:ellipse(82% 82% at 50% 50%)}
#bossFx .void-flash{
  position:absolute;inset:0;background:#fff;opacity:0;
}

/* ---------- loneliness vision ---------- */
#lonely{
  position:absolute;inset:0;z-index:9;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:18px;
  background:var(--paper) url('img/paper-tile.webp');
  background-blend-mode:multiply;
  transition:opacity .7s ease;
  padding:20px;text-align:center;
}
#lonely.hidden{display:none}
#lonely .lonely-lion{position:relative;width:min(27vw,210px);opacity:.9}
#lonely .lonely-lion img{display:block;width:100%;filter:brightness(0) contrast(1.3)}
#lonely .lonely-lion::after{
  content:"";position:absolute;left:29%;top:27%;width:42%;height:33%;
  border-radius:50%;background:var(--paper);
  box-shadow:inset 0 0 26px rgba(42,33,28,.16);
}
#lonely .lonely-lion::before{
  content:"";position:absolute;left:46.5%;top:39%;width:4px;height:4px;border-radius:50%;
  background:#5a5a56;box-shadow:13px 0 0 #5a5a56;z-index:2;
}
#lonely p{margin:0;max-width:24em;font-family:var(--hand);font-size:clamp(20px,3.2vw,30px);line-height:1.2;color:var(--ink-soft)}
#lonely .lonely-small{font-family:var(--type);font-size:7px;letter-spacing:.2em;opacity:.5}

/* =====================================================================
   Character sheet pass (Juez León sheet): the lion and the cast are
   full-colour storybook illustrations from the user's sheet.
   ===================================================================== */
.title-lion{
  right:1.2vw;bottom:-12vh;width:min(40vw,560px);
  filter:drop-shadow(0 28px 44px rgba(42,33,28,.45));
}
.title-lion img{display:block;width:100%;height:auto;filter:contrast(1.02) saturate(1.02)}
.title-wolf{width:min(28vw,250px);filter:drop-shadow(0 18px 22px rgba(42,33,28,.35))}
.title-dream{left:21vw;bottom:19vh}
.docket-two{top:-.3em}

#lonely .lonely-lion{width:min(23vw,185px);opacity:1}
#lonely .lonely-lion img{filter:drop-shadow(0 18px 24px rgba(42,33,28,.22))}
#lonely .lonely-lion::after,#lonely .lonely-lion::before{display:none;content:none}
#lonely p{max-width:22em}

#bossHead{
  width:20px;height:20px;object-fit:cover;object-position:center 22%;
  border:1px solid rgba(42,33,28,.45);border-radius:50%;
  background:var(--paper);margin-right:-3px;
}
.portrait img{object-fit:cover;object-position:center 18%}
.portrait.lion img{object-position:center 30%}

/* the four ideas that stoke the judge, around his head */
#bossFx{
  border-radius:46% 46% 40% 40%;
  -webkit-mask-image:radial-gradient(ellipse at 50% 46%,#000 58%,transparent 76%);
  mask-image:radial-gradient(ellipse at 50% 46%,#000 58%,transparent 76%);
  background:rgba(255,255,255,.02);
}
#bossFx .void-core{
  background:radial-gradient(ellipse at 50% 50%,rgba(255,252,236,.5),rgba(255,252,236,0) 66%);
}
#bossFx .ghost{
  color:rgba(42,33,28,.5);
  font-size:8px;
  text-shadow:0 0 3px rgba(255,250,236,.95),0 0 8px rgba(255,250,236,.7);
}

/* the judge's own body takes the crayon at the end */
#bossFlood{
  position:absolute;z-index:3;pointer-events:none;
  background:url('img/void-color.webp') center/cover;
  mix-blend-mode:multiply;
  opacity:0;
  -webkit-mask-image:url('img/lion-front.webp');
  mask-image:url('img/lion-front.webp');
  -webkit-mask-size:100% 100%;mask-size:100% 100%;
  -webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;
  clip-path:ellipse(0% 0% at 50% 55%);
  transition:opacity .8s ease,clip-path 2.6s cubic-bezier(.2,.7,.2,1);
}
#bossFlood.on{opacity:1;clip-path:ellipse(95% 95% at 50% 55%)}

@media (max-width:640px),(max-aspect-ratio:1/1){
  .title-lion{right:-18vw;top:-2vh;bottom:auto;width:80vw;opacity:.98}
  .title-docket{top:20vh;max-height:72vh}
  .title-wolf{left:1vw;bottom:1.2vh;width:41vw;z-index:3}
  .title-dream{left:27vw;bottom:18vh;z-index:4}
  #lonely .lonely-lion{width:34vw}
  #bossHead{width:17px;height:17px}
  #bossFx .ghost{font-size:7px}
}
@media (max-height:560px) and (orientation:landscape){
  .title-lion{right:2vw;top:-3vh;bottom:auto;width:30vw}
  .title-docket{top:3vh;max-height:92vh;width:min(520px,52vw)}
  .title-wolf{width:23vw}
  .title-dream{left:19vw;bottom:16vh}
  #lonely .lonely-lion{width:17vw}
}

/* title layering: the docket must be readable over the lion */
.title-docket{z-index:5}
.title-lion{z-index:1}
.title-wolf{z-index:6}
.title-apprentice{z-index:6}
.title-dream{z-index:7}
.title-docket h1{max-width:100%}
.title-apprentice{
  position:absolute;left:22vw;bottom:2.5vh;width:min(14vw,120px);margin:0;
  pointer-events:none;z-index:6;
  filter:drop-shadow(0 12px 16px rgba(42,33,28,.4));
  animation:apprenticeBob 4.8s ease-in-out infinite;
}
.title-apprentice img{display:block;width:100%;height:auto}
@keyframes apprenticeBob{0%,100%{transform:translateY(0) rotate(-1deg)}50%{transform:translateY(-5px) rotate(1deg)}}
@media (max-width:640px),(max-aspect-ratio:1/1){
  .title-apprentice{left:37vw;bottom:1.8vh;width:19vw}
  .title-dream{left:28vw;bottom:18vh}
}
@media (max-height:560px) and (orientation:landscape){
  .title-apprentice{left:20vw;bottom:2vh;width:11vw}
}

.foot-links{display:flex;gap:10px;align-items:center}
#titleCodex{background:none;border:0;padding:0;font-family:var(--type);font-size:6px;letter-spacing:.12em;color:var(--ink);text-decoration:underline;cursor:pointer}
.codex-sheet h2{max-width:none}
.codex-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:12px 0}
.codex-card{margin:0;background:#f8f1df;border:1px solid rgba(42,33,28,.26);padding:5px;box-shadow:0 3px 8px rgba(42,33,28,.18);transform:rotate(-.5deg)}
.codex-card:nth-child(2){transform:rotate(.6deg)}
.codex-card:nth-child(3){transform:rotate(.4deg)}
.codex-card:nth-child(4){transform:rotate(-.7deg)}
.codex-card img{width:100%;display:block;border:1px solid rgba(42,33,28,.18);background:#fffdf5}
.codex-card figcaption{display:block;margin-top:4px;font-size:5.6px;letter-spacing:.06em;line-height:1.5;color:var(--ink-soft)}
.codex-card figcaption b{display:block;font-weight:400;color:var(--stamp);font-size:6.2px;letter-spacing:.08em}
.codex-card figcaption span{display:block;opacity:.7}
@media (max-width:640px),(max-aspect-ratio:1/1){
  .codex-grid{gap:6px}
  .codex-card{padding:3px}
  .codex-card figcaption{font-size:4.6px}
  .codex-card figcaption b{font-size:5.2px}
}
