@font-face { font-family: "Elite"; src: url("./fonts/special-elite.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Hand"; src: url("./fonts/caveat.ttf") format("truetype"); font-display: swap; }

:root {
  --cork: #b4865a;
  --cork-2: #9d7148;
  --frame: #3b2a1c;
  --paper: #f6f0e1;
  --card: #fbf7ec;
  --rule: #a9c3d9;
  --margin: #d98c8c;
  --ink: #26221d;
  --red: #c1262c;
  --blue: #dbe8f2;
  --blue-ink: #2d5476;
  --focus: #1e66d0;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--frame);
  color: var(--ink);
  font: 16px/1.45 "Elite", "Courier New", monospace;
}
button, input { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.board {
  position: relative;
  max-width: 1380px;
  margin: 0 auto;
  padding: 1.6rem 1.6rem 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr) 21rem;
  grid-template-areas:
    "brief brief notes"
    "sus sus notes"
    "plan obj notes"
    "plan hh notes";
  gap: 1.4rem 1.6rem;
  align-items: start;
  background:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,.08) 0 1px, transparent 1.5px) 0 0/17px 19px,
    radial-gradient(circle at 70% 60%, rgba(255,240,210,.12) 0 1px, transparent 1.6px) 0 0/23px 13px,
    radial-gradient(circle at 40% 80%, rgba(60,30,10,.12) 0 1.2px, transparent 2px) 0 0/31px 29px,
    radial-gradient(140% 100% at 50% 0%, var(--cork), var(--cork-2));
  box-shadow: inset 0 0 0 14px #5a3e28, inset 0 0 0 16px #2b1d12, inset 0 0 60px rgba(40, 20, 5, .45);
  min-height: 100vh;
}
.strings { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; overflow: visible; }
.strings path { fill: none; stroke-linecap: round; }
.strings .yarn { stroke: var(--red); stroke-width: 2.6; opacity: .88; filter: drop-shadow(0 3px 2px rgba(40,10,0,.35)); }
.strings .yarn.dim { opacity: .18; }
.strings .truth { stroke: #fff6dd; stroke-width: 2; stroke-dasharray: 6 6; opacity: .9; }

.label { font: 600 1.35rem/1 "Hand", cursive; color: #fff7e6; margin: 0 0 .5rem; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.label span { font-size: .8em; opacity: .85; margin-left: .4rem; }

.card-paper { background: var(--paper); box-shadow: 0 10px 18px -10px rgba(30,15,0,.7), 0 1px 2px rgba(0,0,0,.25); }
.pin::before, .pinned::before {
  content: ""; position: absolute; left: 50%; top: -7px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8b8b, var(--red) 55%, #6b0f12);
  box-shadow: 0 3px 3px rgba(0,0,0,.35); z-index: 6;
}

/* brief */
.brief { grid-area: brief; position: relative; padding: 1rem 1.3rem 1rem; transform: rotate(-.4deg); }
.brief::before { content: ""; position: absolute; left: 12%; top: -9px; width: 90px; height: 22px; background: rgba(240, 225, 170, .75); transform: rotate(-4deg); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.stamp-line { margin: 0; display: flex; gap: .8rem; align-items: center; font-size: .85rem; letter-spacing: .08em; }
.tag { border: 2px solid var(--red); color: var(--red); padding: 0 .45rem; transform: rotate(-3deg); font-weight: bold; letter-spacing: .14em; text-transform: uppercase; font-size: .8rem; }
.tag.closed { border-color: #2f6b3a; color: #2f6b3a; }
.brief h1 { font: 2rem/1.1 "Elite", monospace; margin: .35rem 0 .45rem; }
.brief p { margin: .3rem 0; }
.how { font: 1.2rem/1.25 "Hand", cursive; color: #5a4a3a; }

/* suspects */
.suspects { grid-area: sus; }
.polaroids { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.2rem; }
.polaroid { position: relative; background: #fdfcf7; padding: .55rem .55rem .5rem; box-shadow: 0 12px 18px -10px rgba(30,15,0,.75), 0 1px 2px rgba(0,0,0,.2); transition: transform .2s ease; }
.polaroid:nth-child(1) { transform: rotate(-2deg); }
.polaroid:nth-child(2) { transform: rotate(1.5deg); }
.polaroid:nth-child(3) { transform: rotate(-1deg); }
.polaroid:nth-child(4) { transform: rotate(2.2deg); }
.polaroid.focus { transform: rotate(0) scale(1.03); z-index: 3; }
.polaroid .photo { display: block; width: 100%; aspect-ratio: 100 / 104; filter: sepia(.35) saturate(.85) contrast(.95); background: #ddd; }
.polaroid .who { font: 1.35rem/1.05 "Hand", cursive; margin: .35rem 0 .05rem; }
.polaroid .what { font-size: .78rem; color: #6b5d4e; margin: 0 0 .4rem; }
.polaroid .chip { position: absolute; left: .4rem; top: .4rem; width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; font: bold .8rem "Elite", monospace; color: #fff; box-shadow: 0 2px 3px rgba(0,0,0,.4); }
.polaroid .row { gap: .35rem; }
.polaroid .q { flex: 1; font-size: .82rem; padding: .25rem .4rem; }
.polaroid .focus-btn { font-size: .82rem; padding: .25rem .5rem; }
.polaroid .back { font-size: .8rem; background: #fff3cf; padding: .3rem .4rem; margin-top: .35rem; }

/* plan */
.plan { grid-area: plan; }
.blueprint {
  position: relative; padding: .8rem .9rem 1rem; color: var(--blue-ink);
  background:
    linear-gradient(rgba(45,84,118,.12) 1px, transparent 1px) 0 0/16px 16px,
    linear-gradient(90deg, rgba(45,84,118,.12) 1px, transparent 1px) 0 0/16px 16px,
    var(--blue);
  box-shadow: 0 12px 20px -10px rgba(30,15,0,.75); transform: rotate(.6deg);
}
.blueprint h2 { margin: 0 0 .5rem; font: 1rem/1.2 "Elite", monospace; letter-spacing: .12em; text-transform: uppercase; }
.floors { display: grid; gap: .6rem; }
.floor-name { font: 1.1rem "Hand", cursive; margin: 0 0 .15rem; }
.rooms { display: grid; grid-template-columns: 1fr 1fr; border: 3px solid var(--blue-ink); }
.room { position: relative; min-height: 7.2rem; padding: .45rem .5rem .5rem; display: flex; flex-direction: column; justify-content: space-between; }
.room + .room { border-left: 2px solid var(--blue-ink); }
.room .rname { font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; }
.room.crime { background: repeating-linear-gradient(-45deg, rgba(193,38,44,.07) 0 6px, transparent 6px 12px); }
.room .body { position: absolute; right: .4rem; top: .3rem; width: 46px; opacity: .8; }
.room .crime-note { font: 1.05rem/1 "Hand", cursive; color: var(--red); }

/* pins = the deduction marks */
.pins { display: flex; gap: .3rem; flex-wrap: wrap; }
.pinbtn { position: relative; width: 2rem; height: 2rem; border-radius: 50%; border: 2px dashed currentColor; background: rgba(255,255,255,.55); cursor: pointer; display: grid; place-items: center; font: bold .78rem "Elite", monospace; padding: 0; color: var(--ink); }
.pinbtn[data-state="1"] { border-style: solid; color: #fff; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c) 60%, #fff), var(--c) 60%); box-shadow: 0 3px 4px rgba(0,0,0,.35); border-color: rgba(0,0,0,.3); }
.pinbtn[data-state="2"] { opacity: .5; border-style: solid; }
.pinbtn[data-state="2"]::after { content: ""; position: absolute; inset: -3px; background: linear-gradient(45deg, transparent 46%, var(--ink) 46% 54%, transparent 54%), linear-gradient(-45deg, transparent 46%, var(--ink) 46% 54%, transparent 54%); }
.pinbtn[data-state="0"] { border-color: var(--c); color: var(--c); }
.pinbtn.dim { opacity: .25; }

/* objects */
.objects { grid-area: obj; }
.object-cards { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.obj { position: relative; background: var(--card); padding: .9rem .6rem .55rem; box-shadow: 0 10px 16px -10px rgba(30,15,0,.7); }
.obj:nth-child(odd) { transform: rotate(-1.2deg); }
.obj:nth-child(even) { transform: rotate(1deg); }
.obj svg.icon { display: block; width: 54px; height: 54px; margin: 0 auto .1rem; }
.obj .oname { text-align: center; font: 1.25rem/1 "Hand", cursive; margin: 0 0 .45rem; }
.obj .pins { justify-content: center; }

/* household */
.household { grid-area: hh; }
.witnesses { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.witness { position: relative; background: #efe6d2; padding: .8rem .7rem .6rem; box-shadow: 0 10px 16px -10px rgba(30,15,0,.7); }
.witness p { margin: 0 0 .4rem; font: 1.25rem/1.05 "Hand", cursive; }

/* testimony */
.notes { grid-area: notes; position: sticky; top: 1rem; display: flex; flex-direction: column; max-height: calc(100vh - 2rem); }
.testimony { list-style: none; margin: 0; padding: .6rem .2rem 1rem; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: .9rem; min-height: 8rem; }
.testimony li {
  position: relative; padding: .7rem .8rem .55rem 2.2rem; font-size: .92rem;
  background: linear-gradient(transparent 1.55rem, var(--rule) 1.55rem 1.62rem, transparent 1.62rem) 0 .3rem/100% 1.45rem, var(--card);
  box-shadow: 0 8px 14px -8px rgba(30,15,0,.7);
  animation: pinIn .45s cubic-bezier(.2,.9,.3,1.3);
}
.testimony li::after { content: ""; position: absolute; left: 1.6rem; top: 0; bottom: 0; width: 1px; background: var(--margin); }
.testimony li:nth-child(odd) { transform: rotate(-.8deg); }
.testimony li:nth-child(even) { transform: rotate(.7deg); }
.testimony .n { position: absolute; left: .45rem; top: .6rem; font-size: .8rem; color: #9a8b78; }
.testimony .q { margin: 0; line-height: 1.45rem; }
.testimony .by { margin: .1rem 0 0; text-align: right; font: 1.15rem "Hand", cursive; color: #5a4a3a; }
.testimony .empty { background: none; box-shadow: none; color: #fff6e3; font: 1.2rem/1.2 "Hand", cursive; padding: 0; animation: none; transform: none; }
.testimony .empty::after { display: none; }
@keyframes pinIn { from { opacity: 0; transform: translateY(-14px) rotate(-6deg) scale(1.04); } }
.desk-actions { display: flex; flex-direction: column; gap: .6rem; padding-top: .6rem; }
.check { display: flex; gap: .45rem; align-items: baseline; color: #fff6e3; font-size: .82rem; cursor: pointer; }
.check input { accent-color: var(--red); }
.colophon { margin: 0; font-size: .78rem; color: #f3e6cc; }
.colophon a { color: inherit; }

.row { display: flex; gap: .5rem; flex-wrap: wrap; }
.btn { border: 2px solid var(--ink); background: var(--card); padding: .4rem .85rem; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.35); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.red { background: var(--red); border-color: #7d1216; color: #fff; }
.btn.small { font-size: .8rem; padding: .2rem .5rem; }

dialog { border: 0; padding: 1.2rem 1.4rem; background: var(--card); max-width: min(34rem, 94vw); box-shadow: 0 30px 60px -20px #000; }
dialog::backdrop { background: rgba(20, 10, 2, .6); }
dialog h2 { margin: 0 0 .4rem; }
dialog fieldset { border: 1px solid #c9bda6; margin: .7rem 0; padding: .5rem .7rem .7rem; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .8rem; }
.choices label { display: flex; gap: .4rem; align-items: center; cursor: pointer; }
.choices input { accent-color: var(--red); }

.verdict {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-1.5deg); z-index: 20;
  width: min(30rem, 92vw); background: var(--card); padding: 1.3rem 1.4rem 1.1rem; box-shadow: 0 30px 70px -20px #000, 0 0 0 100vmax rgba(20,10,2,.45);
  animation: drop .4s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes drop { from { opacity: 0; transform: translate(-50%, -56%) rotate(-6deg); } }
.v-stamp { display: inline-block; margin: 0 0 .6rem; padding: .2rem .7rem; border: 3px solid var(--red); color: var(--red); font-size: 1.5rem; letter-spacing: .14em; text-transform: uppercase; transform: rotate(-4deg); }
.v-stamp.good { border-color: #2f6b3a; color: #2f6b3a; }

@media (max-width: 1080px) {
  .board { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "brief brief" "sus sus" "plan obj" "plan hh" "notes notes"; }
  .notes { position: static; max-height: none; }
}
@media (max-width: 680px) {
  .board { grid-template-columns: minmax(0, 1fr); grid-template-areas: "brief" "sus" "notes" "plan" "obj" "hh"; padding: 1.1rem .8rem 2rem; gap: 1.1rem; box-shadow: inset 0 0 0 8px #5a3e28, inset 0 0 40px rgba(40, 20, 5, .45); }
  .polaroids { grid-template-columns: 1fr 1fr; }
  .testimony { max-height: 24rem; }
  .brief h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; } }

.how .btn { font: .85rem "Elite", monospace; margin-left: .3rem; vertical-align: middle; }
.howto { max-width: min(42rem, 94vw); max-height: 90vh; overflow: auto; }
.howto h2:focus { outline: none; }
.howto h2 { margin: 0 0 .3rem; font-size: 1.6rem; }
.howto h3 { margin: 1.1rem 0 .3rem; font: 1.5rem/1 "Hand", cursive; color: var(--red); }
.howto p, .howto li { margin: .3rem 0; font-size: .95rem; }
.howto ul { padding-left: 1.2rem; }
.howto .lead { font: 1.35rem/1.2 "Hand", cursive; }
.howto .example { padding: .35rem .7rem; background: linear-gradient(transparent 1.4rem, var(--rule) 1.4rem 1.46rem, transparent 1.46rem) 0 .1rem/100% 1.4rem, #fff; border-left: 2px solid var(--margin); }
.howto form { text-align: right; margin-top: 1rem; }

/* the morning after */
.walk { position: relative; padding: .7rem .8rem .6rem; margin-bottom: 1.1rem; transform: rotate(.5deg); }
.walk-h { font: 600 1.3rem/1 "Hand", cursive; margin: 0; }
.hours { margin: .2rem 0 .3rem; font-size: .85rem; letter-spacing: .02em; }
.hours.low { color: var(--red); font-weight: bold; }
.walk-map { width: 100%; height: auto; display: block; }
.walk-map .path { stroke: #8a7a64; stroke-width: .9; stroke-dasharray: 2 1.6; }
.walk-map .spot circle:first-child { fill: #fbf7ec; stroke: #8a7a64; stroke-width: .8; }
.walk-map .spot.near { cursor: pointer; }
.walk-map .spot.near circle:first-child { stroke: var(--red); stroke-width: 1.2; }
.walk-map .spot.near:hover circle:first-child, .walk-map .spot.near:focus-visible circle:first-child { fill: #ffe9e9; }
.walk-map .spot.here circle:first-child { fill: #fff3c4; stroke: var(--ink); stroke-width: 1.6; }
.walk-map .spot:focus { outline: none; }
.walk-map .spot:focus-visible circle:first-child { stroke: var(--focus); stroke-width: 1.8; }
.walk-map .spot-name { font: 4.3px "Elite", monospace; text-anchor: middle; fill: var(--ink); }
.walk-map .spot.here .spot-name { font-weight: bold; }
.walk-here { margin: .1rem 0 0; font-size: .82rem; line-height: 1.3; }
.btn.away { opacity: .7; font-size: .78rem; }

/* the casebook */
.book-list { list-style: none; padding: 0; margin: .5rem 0 1rem; display: grid; gap: .4rem; }
.book-case { width: 100%; display: grid; grid-template-columns: 2rem 1fr; grid-template-rows: auto auto; text-align: left; gap: 0 .6rem; padding: .5rem .7rem; border: 1.5px solid #c9bda6; background: var(--card); cursor: pointer; }
.book-case:disabled { cursor: not-allowed; opacity: .55; }
.book-case .b-no { grid-row: span 2; font: 1.6rem/1 "Hand", cursive; color: var(--red); align-self: center; }
.book-case .b-title { font-weight: bold; }
.book-case .b-meta { font-size: .8rem; color: #5a4a3a; }
.book-list li.solved .book-case { border-color: #2f6b3a; }
.book-list li.solved .b-no { color: #2f6b3a; }

/* the archive */
.arch-title { margin: .2rem 0 0; }
.arch-desc { margin: .2rem 0; }
.arch-map { width: 100%; max-width: 26rem; height: auto; display: block; margin: .3rem auto; }
.arch-map .path { stroke: #8a7a64; stroke-width: .9; stroke-dasharray: 2 1.6; }
.arch-map .spot circle { fill: #fbf7ec; stroke: #8a7a64; stroke-width: .8; }
.arch-map .spot.near { cursor: pointer; }
.arch-map .spot.near circle { stroke: var(--red); stroke-width: 1.2; }
.arch-map .spot.near:hover circle { fill: #ffe9e9; }
.arch-map .spot.here circle { fill: #d9e8d2; stroke: #2f6b3a; }
.arch-map .spot.answer circle { fill: #fff3c4; stroke: var(--ink); stroke-width: 1.6; }
.arch-map .spot-name { font: 4.2px "Elite", monospace; text-anchor: middle; fill: var(--ink); }
.arch-map .spot:focus { outline: none; }
.arch-map .spot:focus-visible circle { stroke: var(--focus); stroke-width: 1.8; }
.arch-clues { padding-left: 1.3rem; margin: .4rem 0; }
.arch-clues li { margin: .25rem 0; }
.arch-clues .empty { list-style: none; margin-left: -1.3rem; color: #6a5a48; }
.arch-guess { border: 1.5px dashed #c9bda6; margin: .6rem 0; padding: .4rem .6rem .6rem; }
.arch-guess .choices { display: flex; flex-wrap: wrap; gap: .35rem; }

/* Double-tap zoom: touch-action is intersected across every ancestor, so
   manipulation on the root stops double-tap zoom page-wide (readouts, gaps
   between controls, sheet backdrops) while pinch zoom still works. */
html, body { touch-action: manipulation; }
