:root { --ink: #1f2430; --paper: #fffaf0; --accent: #e2674a; --gold: #f7a541; --sky: #7ec4e0;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif, "Noto Color Emoji"; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7ec4e0; color: var(--ink); font-family: var(--font); overscroll-behavior: none; }
body { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#view.dragging { cursor: grabbing; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
[hidden] { display: none !important; }

#top { position: absolute; left: 0; right: 0; top: 0; padding: max(10px, env(safe-area-inset-top)) 12px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
#top > * { pointer-events: auto; }
.case { background: rgba(255,250,240,.88); border-radius: 14px; padding: 7px 12px; display: flex; flex-direction: column; line-height: 1.15; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.case b { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.case span { font-size: 15px; font-weight: 650; }
.tools { display: flex; gap: 6px; align-items: center; }
.pill { background: rgba(255,250,240,.88); border-radius: 22px; padding: 0 12px; height: 44px; display: flex; align-items: center; gap: 6px; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.pill b { font-size: 18px; }
.pill.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.18); } }
.icon { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,250,240,.88); font-size: 19px; display: grid; place-items: center; position: relative; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.icon i { position: absolute; right: -2px; top: -2px; background: var(--accent); color: #fff; font-style: normal; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
.icon.small { width: 40px; height: 40px; font-size: 15px; }

#caption { position: absolute; left: 0; right: 0; top: calc(max(10px, env(safe-area-inset-top)) + 64px); text-align: center; pointer-events: none; transition: opacity .4s; }
#caption b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.01em; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.25), 0 0 18px rgba(0,0,0,.25); }
#caption span { display: inline-block; margin-top: 4px; font-size: 14px; background: rgba(20,22,30,.62); color: #fff; padding: 4px 10px; border-radius: 10px; }
#caption.fade { opacity: 0; }
#caption.pop b { animation: cap .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes cap { from { transform: scale(.6); opacity: 0; } }

#bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 10px max(10px, env(safe-area-inset-bottom)); pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#bottom > * { pointer-events: auto; }
#bottom .row { display: flex; gap: 8px; width: 100%; max-width: 860px; align-items: stretch; }
#chips { flex: 1; display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity; padding: 4px 2px 4px; scrollbar-width: none; touch-action: pan-x; }
#chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; width: 74px; height: 64px; border-radius: 14px; background: rgba(255,250,240,.92); padding: 5px; display: flex; flex-direction: column; justify-content: space-between; align-items: stretch; scroll-snap-align: start; box-shadow: 0 2px 8px rgba(0,0,0,.15); position: relative; transition: transform .15s; }
.chip .sw { height: 26px; border-radius: 8px; display: flex; overflow: hidden; }
.chip .sw i { flex: 1; }
.chip span { font-size: 12px; font-weight: 650; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip em { position: absolute; left: 7px; top: 3px; font-style: normal; font-size: 15px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.4)); }
.chip kbd { position: absolute; right: 6px; top: 4px; font: 600 10px var(--font); color: rgba(255,255,255,.9); text-shadow: 0 1px 2px rgba(0,0,0,.6); display: none; }
body:not(.touch) .chip kbd { display: block; }
.chip.on { background: #fff; outline: 3px solid var(--ink); transform: translateY(-3px); }
.chip.focus { outline: 3px dashed var(--accent); }
.chip.nudge { animation: nudge 1.2s infinite; }
@keyframes nudge { 50% { transform: translateY(-6px); box-shadow: 0 0 0 4px rgba(247,165,65,.7); } }
.chip .dot { position: absolute; right: -3px; top: -3px; width: 12px; height: 12px; border-radius: 6px; background: var(--accent); border: 2px solid #fff; display: none; }
.chip.seen .dot { display: block; background: #57b26a; }
#accuse { flex: 0 0 auto; border-radius: 14px; padding: 0 14px; font-weight: 750; }
.primary { background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 18px; font-weight: 700; min-height: 44px; }
.primary.big { font-size: 18px; padding: 14px 28px; }
.primary:hover { filter: brightness(1.2); }

#timeline { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 640px; background: rgba(5,8,30,.8); border-radius: 14px; padding: 6px 10px; color: #9fffaf; }
#timeline .icon { background: #1d2a55; color: #9fffaf; box-shadow: none; }
#tlBar { position: relative; flex: 1; height: 36px; touch-action: none; cursor: pointer; }
#tlBar::before { content: ''; position: absolute; left: 0; right: 0; top: 16px; height: 4px; background: #24366f; border-radius: 2px; }
#tlFill { position: absolute; left: 0; top: 16px; height: 4px; background: #3ae05a; border-radius: 2px; }
#tlKnob { position: absolute; top: 8px; width: 20px; height: 20px; margin-left: -10px; border-radius: 50%; background: #3ae05a; box-shadow: 0 0 10px #3ae05a; }
#tlMarks span { position: absolute; top: 25px; font: 10px ui-monospace, Menlo, monospace; transform: translateX(-50%); color: #6f9f7f; }
#stamp { position: absolute; left: 16px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 136px); font: 700 15px ui-monospace, Menlo, monospace; color: #e8ffe8; text-shadow: 0 0 6px #3ae05a; pointer-events: none; }
#stamp b { font-size: 22px; }
#stamp i { display: inline-block; width: 10px; height: 10px; border-radius: 5px; background: #ff3030; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

#markers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.marker { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; pointer-events: auto; background: rgba(255,255,255,.95); color: var(--ink); font-weight: 900; font-size: 22px; display: grid; place-items: center; box-shadow: 0 0 0 4px rgba(247,165,65,.85), 0 4px 14px rgba(0,0,0,.35); animation: pop .5s cubic-bezier(.2,1.7,.4,1) both, pulse 1.6s .5s infinite; }
.marker.found { background: #57b26a; color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.8); animation: none; opacity: .85; width: 34px; height: 34px; margin: -17px 0 0 -17px; font-size: 16px; }
@keyframes pop { from { transform: scale(0); } }
.marker::after { content: ''; position: absolute; left: 50%; top: 100%; width: 3px; height: 26px; margin-left: -1.5px; background: linear-gradient(rgba(255,255,255,.95), rgba(255,255,255,0)); border-radius: 2px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(247,165,65,.25), 0 4px 14px rgba(0,0,0,.35); } }
#reticle { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px var(--ink); pointer-events: none; }

#wipe { position: absolute; top: 0; bottom: 0; width: 6px; margin-left: -3px; left: -20px; pointer-events: none; background: #fff; box-shadow: 0 0 22px 8px rgba(255,255,255,.75); opacity: 0; }

.sheet { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(max(10px, env(safe-area-inset-bottom)) + 84px); width: min(94vw, 440px); max-height: 62vh; overflow-y: auto; background: var(--paper); border-radius: 18px; padding: 14px 16px 16px; box-shadow: 0 10px 40px rgba(0,0,0,.35); animation: up .25s ease-out; }
@keyframes up { from { transform: translate(-50%, 24px); opacity: 0; } }
.sheet h3 { margin: 2px 30px 6px 0; font-size: 19px; }
.sheet p { margin: 6px 0; line-height: 1.4; font-size: 15px; }
.sheet small { color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .06em; }
.sheet .close { position: absolute; right: 8px; top: 6px; width: 44px; height: 44px; background: none; font-size: 26px; color: #888; }
.sheet .hint { color: #666; font-size: 13px; }
.sus { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 12px; margin-top: 6px; background: #fff; border: 2px solid transparent; }
.sus.focus { border-color: var(--accent); }
.sus .face { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--ink); }
.sus .who { flex: 1; font-size: 14px; line-height: 1.25; }
.sus .who b { font-size: 16px; }
.sus .who em { display: block; color: #555; font-size: 12.5px; margin-top: 2px; }
.sus button.primary { padding: 10px 12px; }
.sus button { flex: 0 0 auto; }
.sus.wrong { opacity: .45; }
.sus.wrong button { pointer-events: none; background: #999; }
.note { padding: 8px 0; border-top: 1px solid #eadfcc; }
.note b { display: block; }
.note small { text-transform: none; letter-spacing: 0; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(20,24,40,.45); padding: 16px; }
.panel { background: var(--paper); border-radius: 22px; padding: 22px 22px 16px; width: min(94vw, 460px); max-height: 92vh; overflow-y: auto; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); animation: up2 .35s ease-out; }
@keyframes up2 { from { transform: translateY(20px); opacity: 0; } }
.panel small { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.panel h1 { margin: 4px 0 0; font-size: 38px; letter-spacing: -.02em; background: linear-gradient(90deg, #2f9fb7, #8cc84b, #f7a541, #e2674a, #7a4ac0, #1d4f91); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel h2 { margin: 6px 0 10px; font-size: 21px; }
.panel p { line-height: 1.45; font-size: 15px; margin: 8px 0; }
.panel .how.small { font-size: 13px; color: #555; }
.panel .foot { font-size: 12px; color: #777; margin-top: 14px; }
.panel .foot a { color: inherit; }
.panel .story { font-size: 14px; color: #444; text-align: left; background: #f3ead8; border-radius: 12px; padding: 10px 12px; }
.row-emoji { font-size: 30px; letter-spacing: 4px; margin: 8px 0; font-family: var(--font); }
.btns { display: flex; gap: 8px; justify-content: center; }
.btns button:not(.primary), .btn { background: #eadfcc; border-radius: 12px; padding: 12px 18px; font-weight: 650; color: inherit; text-decoration: none; font-size: 15px; display: inline-block; }
.btns { flex-wrap: wrap; }
.album { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; align-items: center; margin: 10px 0; }
.album i { font-style: normal; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #e6dccb; color: #a99a80; font-size: 16px; font-weight: 800; }
.album i.own { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.album i.new { outline: 3px solid var(--accent); animation: nudge 1.2s 3; }
.album small { width: 100%; text-transform: none; letter-spacing: 0; color: #777; font-weight: 600; }
#resPic { width: auto; max-width: 100%; max-height: 24vh; border-radius: 12px; margin: 10px auto 6px; display: block; }
#resPic[hidden] { display: none; }
#resKept:empty { display: none; }
.chip.loan::after { content: 'NEW'; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); background: var(--accent); color: #fff; font: 800 9px var(--font); letter-spacing: .06em; padding: 1px 5px; border-radius: 6px; }

#toast { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); background: rgba(20,22,30,.88); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 650; font-size: 16px; text-align: center; max-width: 86vw; pointer-events: none; animation: up2 .25s; }
body.crt #caption b { color: #b8ffc0; }

@media (min-width: 900px) and (pointer: fine) {
  .chip { width: 92px; height: 70px; }
  .sheet { left: auto; right: 24px; transform: none; bottom: 110px; animation: none; }
  #caption b { font-size: 34px; }
}

@media (max-width: 520px) {
  .case { padding: 6px 10px; max-width: 150px; }
  .case span { font-size: 13px; }
  .pill { flex-direction: column; gap: 0; justify-content: center; padding: 0 9px; font-size: 10px; line-height: 1; }
  .pill b { font-size: 17px; }
  #caption { top: calc(max(10px, env(safe-area-inset-top)) + 58px); }
  #caption b { font-size: 24px; }
}

/* speech bubbles (Comic) and labels (Map): a clue marker that says something, or a plain tag that isn't a clue */
.marker.tag { width: max-content; height: auto; min-height: 0; max-width: min(64vw, 260px); margin: 0; transform: translate(-50%, -100%); border-radius: 18px; padding: 7px 26px 8px 12px; display: block; text-align: left; font: 800 14px/1.2 "Comic Sans MS", "Chalkboard SE", "Comic Neue", system-ui, sans-serif; animation: tagpop .45s cubic-bezier(.2,1.7,.4,1) both; box-shadow: 0 0 0 3px var(--ink), 0 4px 14px rgba(0,0,0,.3); }
.marker.tag i { position: absolute; right: -10px; top: -10px; width: 24px; height: 24px; border-radius: 50%; background: #f7a541; color: #fff; font: 900 15px/24px system-ui, sans-serif; font-style: normal; text-align: center; box-shadow: 0 0 0 2px #fff; }
.marker.tag.found { opacity: .92; width: max-content; height: auto; margin: 0; font-size: 13px; }
.marker.tag.found i { background: #57b26a; }
.marker.tag::after { left: 22px; top: 100%; width: 0; height: 0; margin: 0; border: 9px solid transparent; border-top-color: #fff; border-left-width: 0; background: none; filter: drop-shadow(0 3px 0 var(--ink)); }
.marker.tag-map { border-radius: 4px; font: 700 13px/1.2 system-ui, -apple-system, Segoe UI, sans-serif; background: #1f2a44; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3); padding: 5px 24px 5px 9px; }
.marker.tag-map::after { border-top-color: #1f2a44; filter: none; }
.marker.tag-sketch { border-radius: 3px; background: #fbf9f1 repeating-linear-gradient(transparent 0 17px, rgba(80,140,210,.35) 17px 18px); color: #23305e; font: 600 15px/18px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; box-shadow: 0 0 0 2px #23305e, 0 4px 12px rgba(0,0,0,.25); transform: translate(-50%, -100%) rotate(-1.5deg); }
.marker.tag-sketch::after { border-top-color: #fbf9f1; filter: drop-shadow(0 2px 0 #23305e); }
.tag.plain.tag-sketch { background: #fbf9f1; color: #23305e; font: 600 13px "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive; box-shadow: 0 0 0 1.5px #23305e; transform: translate(-50%, -50%) rotate(-1.5deg); }
@keyframes tagpop { from { transform: translate(-50%, -100%) scale(0); } }
.tag.plain { position: absolute; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap; padding: 3px 8px; border-radius: 4px; font: 600 12px system-ui, -apple-system, Segoe UI, sans-serif; background: rgba(255,255,255,.88); color: #1f2a44; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.chip.bonus { box-shadow: 0 0 0 2px #f5c518; }
.chip.bonus::before { content: "★"; position: absolute; right: 5px; top: 29px; color: #f5c518; font-size: 13px; text-shadow: 0 0 2px #000; z-index: 2; }

/* Brutalist: raw facts on black, a red bar, huge type behind the island */
.marker.tag-brutalist { border-radius: 0; background: #111; color: #f2f2f2; font: 700 13px/1.25 "Courier New", ui-monospace, monospace; text-transform: uppercase; box-shadow: inset 5px 0 0 #ff2a1a, 0 3px 0 rgba(0,0,0,.25); padding: 6px 24px 6px 14px; animation-duration: .2s; }
.marker.tag-brutalist::after { border-top-color: #111; filter: none; }
.marker.tag-brutalist i { background: #ff2a1a; border-radius: 0; }
.tag.plain.tag-brutalist { border-radius: 0; background: #111; color: #f2f2f2; font: 700 12px "Courier New", ui-monospace, monospace; text-transform: uppercase; box-shadow: inset 4px 0 0 #ff2a1a; padding: 3px 8px 3px 10px; }
#brutal { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 0; }
body[data-lens="brutalist"] #brutal { display: block; }
#brutal b { position: absolute; left: 10px; top: 56px; font: 900 min(26vw, 150px)/0.9 "Arial Black", "Helvetica Neue", Helvetica, Arial, sans-serif; color: #111; opacity: .12; letter-spacing: -0.04em; }
#brutal span { position: absolute; left: 14px; top: calc(62px + min(23.4vw, 135px)); color: #111; font: 700 11px "Courier New", monospace; opacity: .45; }

/* the share picture's spoiler switch */
.spoil { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #444; margin: 2px 0 8px; cursor: pointer; }
.spoil input { width: 20px; height: 20px; accent-color: #f7a541; }
.spoil em { color: #888; font-style: normal; }
.spoil span { flex: 1; text-align: left; }
.spoil[hidden] { display: none; }

/* Brutalist on a phone: bigger facts, and the huge FACTS. type moves down out from under the caption */
body.touch .marker.tag-brutalist { font-size: 15px; padding: 8px 26px 8px 15px; }
body.touch .tag.plain.tag-brutalist { font-size: 13px; }
#brutal b { top: auto; bottom: calc(150px + min(4vw, 24px)); opacity: .1; }
#brutal span { top: auto; bottom: 150px; }

/* the end-screen question, the fake door and the wefav row (house rules §4) */
.vote { margin-top: 14px; }
.vote p { margin: 0 0 8px; font-weight: 650; font-size: 15px; }
.vote .opts { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.vote .opts button { flex: none; background: #eadfcc; border-radius: 18px; padding: 9px 13px; font-size: 14px; font-weight: 600; }
.vote-thanks { font-size: 14px; color: #555; margin: 10px 0 0; }
.door { display: block; margin: 10px auto 0; background: none; border: 2px dashed #c9b99d; border-radius: 12px; padding: 9px 14px; font-size: 14px; font-weight: 600; color: #6b5d48; }
[data-wefav-row] { margin-top: 12px; font-size: 13px; }
[data-wefav-mark] { display: block; margin-top: 10px; }
.storybox { text-align: left; margin: 4px 0 6px; font-size: 14px; }
.storybox summary { cursor: pointer; font-weight: 650; color: #6b5d48; }
.album i { width: 26px; height: 26px; font-size: 14px; }
/* on a wide screen the result is two columns (the picture on the right), so the wefav row shows without scrolling */
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  #result .panel { width: 780px; display: grid; grid-template-columns: 1fr 250px; column-gap: 20px; align-content: start; }
  #result .panel > * { grid-column: 1; }
  #result #resPic { grid-column: 2; grid-row: 1 / span 6; align-self: center; width: 100%; max-height: none; margin: 0; }
  #result #spoilRow { grid-column: 2; grid-row: 7; font-size: 12px; }
  #result #vote, #result .door, #result #voted, #result #doorNote, #result [data-wefav-row] { grid-column: 1 / -1; }
}
