:root {
  --bg: #12142a; --panel: #1c2040; --line: #323863;
  --text: #f1f2f8; --muted: #a9afd0; --accent: #f3d36b;
  --paper: #f6ecd2; --ink: #2a2118; --ink-soft: #6a5a45;
  --good: #2f8f57; --bad: #c2473d;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Every game: a way back to the others, and who's signed in. */
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.bar .home { color: var(--muted); text-decoration: none; }
.bar .home:hover { color: var(--text); }
.bar .account { color: var(--muted); text-align: right; }
.bar .account strong { color: var(--text); }

main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 20px 16px; }

/* --- Choosing a case ---------------------------------------------------- */
.hero { text-align: center; margin: 12px 0 28px; }
.hero h1 {
  font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 8vw, 58px);
  margin: 0 0 8px; letter-spacing: .5px; text-wrap: balance;
}
.hero h1 span { color: var(--accent); }
.hero p { color: var(--muted); margin: 0 auto; max-width: 34em; line-height: 1.5; text-wrap: pretty; }
.signin { text-align: center; margin: 32px 0; }
.btn {
  display: inline-block; padding: 12px 22px; border-radius: 12px; border: 0;
  background: var(--accent); color: #2a2110; font-weight: 700; text-decoration: none; font-size: 17px;
}
.btn:hover { filter: brightness(1.08); }
.btn.quiet { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.small { padding: 8px 14px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }

.case {
  background: var(--paper); color: var(--ink); border-radius: 16px; padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); position: relative;
}
.case .file { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-soft); }
.case h2 { font-family: Georgia, serif; font-size: 28px; margin: 4px 0 14px; }
.levels { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.level {
  text-align: left; border: 2px solid #d8c8a2; background: #fffaf0; color: var(--ink);
  border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 6px;
}
.level:hover { border-color: #b08a3a; }
.level strong { font-size: 18px; }
.level .blurb { color: var(--ink-soft); font-size: 14.5px; line-height: 1.4; flex: 1; }
.level .state { font-size: 14px; font-weight: 700; color: #7a4f12; }
.more { color: var(--muted); text-align: center; margin: 22px 0 0; font-size: 15px; }

/* --- Playing -------------------------------------------------------------- */
.playhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.playhead h2 { flex: 1; margin: 0; font-family: Georgia, serif; font-size: clamp(18px, 4.4vw, 24px); min-width: 0; }
.playhead h2 small { display: block; font: 600 12px/1.4 system-ui, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.tool {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  min-width: 44px; height: 44px; padding: 0 10px; font-size: 20px; flex: none;
}
.tool[aria-pressed="false"] { opacity: .6; }

.dots { display: flex; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }
.dots li { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.dots li.right { background: var(--good); }
.dots li.wrong { background: var(--bad); }
.dots li.now { background: var(--accent); }

.stage { width: 100%; aspect-ratio: 16 / 9; display: block; border-radius: 14px; background: #0c0e1c; overflow: hidden; }
.stage text { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", system-ui, sans-serif; user-select: none; }
.actor { opacity: 0; transition: transform 1.8s cubic-bezier(.2, .7, .3, 1), opacity .5s; }
.actor.on { opacity: 1; }
.actor.ghost.on { opacity: .5; }
.actor.dark .emoji { filter: brightness(.18); }
.actor.instant { transition: none; }
.actor .inner { transform-box: fill-box; transform-origin: center; transform: rotate(var(--rot, 0deg)); }
.actor .label {
  font: 700 15px system-ui, sans-serif; fill: #fff; paint-order: stroke; stroke: rgba(10, 12, 28, .8); stroke-width: 4px; stroke-linejoin: round;
}
.actor .words {
  font: 800 1em Georgia, serif; fill: #fff; paint-order: stroke; stroke: #1a1030; stroke-width: 5px; stroke-linejoin: round; letter-spacing: 1px;
}
.anim-bob { animation: bob 2.6s ease-in-out infinite; }
.anim-hop { animation: hop .9s ease-in-out infinite; }
.anim-shake { animation: shake .5s linear infinite; }
.anim-float { animation: float 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(var(--rot, 0deg)); } }
@keyframes hop { 30% { transform: translateY(-12px); } 60% { transform: translateY(0); } }
@keyframes shake { 25% { transform: translateX(-3px) rotate(-3deg); } 75% { transform: translateX(3px) rotate(3deg); } }
@keyframes float { 50% { transform: translateY(-10px); opacity: .75; } }
.spot { fill: rgba(243, 211, 107, .16); stroke: #f3d36b; stroke-width: 4; stroke-dasharray: 10 8; animation: spot 1.6s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes spot { 50% { transform: scale(1.14); stroke-opacity: .5; } }
.rain { animation: rain .7s linear infinite; }
@keyframes rain { to { transform: translate(-160px, 450px); } }
.sun { animation: sunrise 6s ease-out both; }
@keyframes sunrise { from { transform: translateY(46px); } }
@media (prefers-reduced-motion: reduce) {
  .anim-bob, .anim-hop, .anim-shake, .anim-float, .spot, .sun { animation: none; }
  .actor { transition: opacity .3s; }
}

.page {
  background: var(--paper); color: var(--ink); border-radius: 14px; padding: 18px; margin-top: 12px;
  font-family: Georgia, "Times New Roman", serif; font-size: 19px; line-height: 1.55;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.page p { margin: 0; text-wrap: pretty; }
.little .page { font-family: system-ui, sans-serif; font-size: 24px; line-height: 1.45; }
.controls { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 14px; }
.controls .count { color: var(--ink-soft); font: 600 13px system-ui, sans-serif; }

.question h3 { margin: 0 0 14px; font-size: 1.1em; text-wrap: balance; }
.question .kicker, .ending .kicker { font: 700 12px system-ui, sans-serif; letter-spacing: 2px; text-transform: uppercase; color: #8a5a12; margin-bottom: 6px; }
.options { display: grid; gap: 10px; }
.little .options { grid-template-columns: repeat(3, 1fr); }
.option {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 12px 14px; border-radius: 12px; border: 2px solid #d8c8a2; background: #fffaf0; color: var(--ink);
  font: 600 17px/1.35 system-ui, sans-serif;
}
.option .pic { font-size: 30px; flex: none; }
.little .option { flex-direction: column; text-align: center; font-size: 18px; padding: 14px 8px; }
.little .option .pic { font-size: clamp(34px, 9vw, 54px); }
.option:not(:disabled):hover { border-color: #b08a3a; }
.option:disabled { cursor: default; opacity: .7; }
.option.right { border-color: var(--good); background: #e3f4e6; opacity: 1; }
.option.wrong { border-color: var(--bad); background: #fbe5e2; opacity: 1; }
.hintbar { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.hintbar .btn { color: var(--ink); border-color: #b8a67c; }
.hinttext { flex: 1 1 14em; font: italic 16.5px/1.45 Georgia, serif; color: #5a4320; }
.little .hinttext { font: 600 20px/1.4 system-ui, sans-serif; }
.verdict { margin: 14px 0 0; font: 700 18px/1.4 system-ui, sans-serif; }
.verdict.right { color: #1f6e41; }
.verdict.wrong { color: #a3372e; }
.explain { margin-top: 6px !important; }
.clue {
  margin-top: 12px; padding: 10px 12px; border-left: 4px solid #b08a3a; background: #efe2bf; border-radius: 0 8px 8px 0;
  font: 15.5px/1.45 system-ui, sans-serif;
}
.clue b { display: block; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: #8a5a12; }

.ending { text-align: center; }
.ending .score { font-size: 54px; font-weight: 700; margin: 4px 0; }
.ending .rank { font-size: 26px; margin: 0 0 6px; }
.ending .buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.ending .btn.quiet { color: var(--ink); border-color: #b8a67c; }

/* --- Notebook --------------------------------------------------------------- */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px);
  background: var(--paper); color: var(--ink);
}
dialog::backdrop { background: rgba(6, 8, 20, .7); }
.book { padding: 18px; }
.book header { display: flex; justify-content: space-between; align-items: center; }
.book h2 { margin: 0; font-family: Georgia, serif; }
.book h3 { font: 700 12px system-ui, sans-serif; letter-spacing: 2px; text-transform: uppercase; color: #8a5a12; margin: 18px 0 8px; }
.book .close { background: none; border: 0; font-size: 26px; color: var(--ink); width: 44px; height: 44px; }
.cast { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; padding: 0; margin: 0; list-style: none; }
.cast li { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.cast .pic { font-size: 28px; }
.cast small { display: block; color: var(--ink-soft); }
.clues { margin: 0; padding-left: 22px; line-height: 1.45; }
.clues li { margin-bottom: 8px; }
.empty { color: var(--ink-soft); font-style: italic; }

/* Buy me a coffee: the same badge on every game (see ADDING_A_GAME.md). */
.bmc {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: #ffdd00; color: #0d0c22;
  font: 600 14px/1.2 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  text-decoration: none; white-space: nowrap;
}
.bmc:hover { background: #ffe74d; }
.bmc:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.bmc svg { width: 18px; height: 18px; flex: none; }
.foot { display: flex; justify-content: center; gap: 16px; align-items: center; flex-wrap: wrap; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.foot .rec { color: var(--muted); font-size: 12.5px; text-align: center; }
.foot .rec a { color: inherit; }

@media (max-width: 480px) {
  main { padding: 14px 12px; }
  .page { font-size: 17.5px; padding: 14px; }
  .little .page { font-size: 21px; }
  .little .option { font-size: 15px; }
}
