:root {
  --ink: #2b2420; --paper: #f6efe1; --paper-2: #efe4cf; --line: #d8c9ac; --muted: #7a6c5a;
  --cork: #b98a5a; --cork-2: #a87a4c; --red: #b3372f; --red-soft: #f6dcd6; --green: #2f7d4f; --green-soft: #dcefe1;
  --gold: #d9a72b; --bg: #2a2522; --bg-2: #3a332e; --type: "Special Elite", "Courier New", monospace;
  --ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 30% 0%, #3d3530, var(--bg) 60%); color: var(--paper); font: 16px/1.55 var(--ui); }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 12px 20px; background: rgba(30, 26, 23, .92);
  backdrop-filter: blur(6px); border-bottom: 1px solid #4a413a; flex-wrap: wrap; }
.brand { font-family: var(--type); font-size: 1.35rem; text-decoration: none; letter-spacing: .02em; }
.top nav { display: flex; gap: 6px; }
.top nav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; color: #e7dcc7; }
.top nav a.on, .top nav a:hover { background: #4a413a; color: #fff; }
.rank { margin-left: auto; font-size: .92rem; color: #e7dcc7; }
.rank b { color: var(--gold); }
main { max-width: 980px; margin: 0 auto; padding: 22px 16px 40px; }
.foot { text-align: center; color: #a89a86; font-size: .85rem; padding: 0 16px 28px; }
.linkish { background: none; border: 0; color: #e7c98a; text-decoration: underline; padding: 0; }

/* the case board */
.board { background: var(--cork); background-image: radial-gradient(rgba(0, 0, 0, .08) 1px, transparent 1px); background-size: 7px 7px;
  border-radius: 16px; padding: 26px 20px; box-shadow: inset 0 0 0 10px #7b5532, inset 0 0 0 12px #5e3f24, 0 12px 30px rgba(0, 0, 0, .4); }
.board h1 { font-family: var(--type); color: #2b1d10; margin: 0 0 4px; font-size: 1.7rem; text-align: center; }
.board .sub { text-align: center; color: #3b2a1a; margin: 0 0 20px; }
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 22px; }
.folder { position: relative; background: #e9c98b; color: var(--ink); border-radius: 4px 10px 6px 6px; padding: 16px 14px 14px; text-align: left; border: 0;
  box-shadow: 0 6px 12px rgba(0, 0, 0, .3); transform: rotate(var(--r, -1deg)); transition: transform .15s; min-height: 150px; }
.folder::before { content: ''; position: absolute; left: 12px; top: -12px; width: 70px; height: 16px; background: #e9c98b; border-radius: 6px 6px 0 0; }
.folder:hover:not(:disabled) { transform: rotate(0) translateY(-3px); }
.folder .pin { position: absolute; right: 14px; top: -8px; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff6b5e, #a8231b); box-shadow: 0 2px 3px rgba(0, 0, 0, .4); }
.folder .num { font-family: var(--type); font-size: .85rem; color: #6b4d24; }
.folder .ico { font-size: 2.2rem; margin: 6px 0 2px; }
.folder h2 { font-family: var(--type); font-size: 1.15rem; margin: 0; }
.folder .lvl { font-size: .82rem; color: #6b4d24; }
.folder .stars { position: absolute; right: 12px; bottom: 10px; font-size: 1rem; }
.folder.locked { filter: grayscale(.8) brightness(.8); cursor: not-allowed; }
.folder.locked .ico::after { content: ' 🔒'; font-size: 1.2rem; }
.folder .stamp { position: absolute; right: 8px; top: 36px; transform: rotate(-14deg); border: 3px solid var(--red); color: var(--red); font-family: var(--type);
  padding: 0 6px; border-radius: 4px; font-size: 1rem; opacity: .85; }

/* a case: a dossier on paper */
.dossier { background: var(--paper); color: var(--ink); border-radius: 6px; padding: 26px clamp(16px, 4vw, 40px) 30px; box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
  background-image: linear-gradient(transparent 31px, rgba(160, 130, 90, .14) 32px); background-size: 100% 32px; position: relative; }
.dossier .back { font-size: .9rem; color: var(--muted); text-decoration: none; }
.dossier h1 { font-family: var(--type); margin: 6px 0 2px; font-size: clamp(1.5rem, 4vw, 2.1rem); }
.dossier .meta { color: var(--muted); font-size: .9rem; margin-bottom: 14px; }
.story p { font-family: var(--type); font-size: 1.08rem; margin: 0 0 10px; opacity: 0; animation: type .5s ease-out forwards; }
@keyframes type { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.section-title { font-family: var(--type); font-size: 1.05rem; margin: 22px 0 8px; border-bottom: 2px dashed var(--line); padding-bottom: 4px; }
.clues { display: flex; flex-wrap: wrap; gap: 10px; }
.clue { background: #fffaf0; border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; align-items: center; gap: 8px; color: var(--ink);
  cursor: zoom-in; transition: transform .12s, border-color .12s; }
.clue:hover { transform: translateY(-2px); border-color: #b8a07a; }
.clue .e { font-size: 1.6rem; }
.clue.seen { border-color: var(--green); background: var(--green-soft); }
.clue.seen::after { content: '✓'; color: var(--green); font-weight: 700; }
.suspects { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.suspect { background: #fffaf0; border: 2px solid var(--line); border-radius: 14px; padding: 12px; display: flex; gap: 10px; align-items: flex-start; }
.suspect .e { font-size: 2rem; line-height: 1; }
.suspect b { display: block; }
.suspect q { font-family: var(--type); }

/* the notebook: clues you have inspected */
.notebook { margin-top: 18px; background: #fffdf6; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background-image: linear-gradient(90deg, transparent 28px, #f0b7b0 28px 30px, transparent 30px); }
.notebook h3 { margin: 0 0 6px 36px; font-family: var(--type); font-size: 1rem; }
.notebook ol { margin: 0; padding-left: 52px; }
.notebook li { font-family: var(--type); margin: 4px 0; animation: type .4s ease-out; }
.notebook .empty { margin: 0 0 0 36px; color: var(--muted); font-size: .9rem; }

/* decoder wheel */
.decoder { margin-top: 14px; background: #fffaf0; border: 2px solid var(--line); border-radius: 14px; padding: 14px; }
.decoder .row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.decoder input[type=range] { flex: 1; min-width: 160px; accent-color: var(--red); }
.decoder .out { font-family: var(--type); font-size: 1.25rem; letter-spacing: .08em; margin-top: 8px; word-break: break-word; }
.decoder .out.good { color: var(--green); }
.decoder .alpha { font-family: var(--type); font-size: .85rem; color: var(--muted); overflow-x: auto; white-space: nowrap; }

/* answering */
.answer { margin-top: 22px; background: var(--paper-2); border-radius: 14px; padding: 16px; }
.answer h3 { margin: 0 0 10px; font-family: var(--type); }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.opt { background: #fffaf0; border: 2px solid var(--line); border-radius: 12px; padding: 12px; color: var(--ink); font-weight: 600; text-align: left; }
.opt:hover:not(:disabled) { border-color: #9a8158; }
.opt.wrong { border-color: var(--red); background: var(--red-soft); animation: shake .3s; }
.opt.right { border-color: var(--green); background: var(--green-soft); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.riddle { margin: 8px 0 12px; }
.riddle p { margin: 0 0 6px; font-family: var(--type); }
.riddle input { width: 100%; max-width: 320px; padding: 10px 12px; border-radius: 10px; border: 2px solid var(--line); background: #fffaf0; font: inherit; color: var(--ink); }
.riddle input.ok { border-color: var(--green); background: var(--green-soft); }
.riddle input.no { border-color: var(--red); background: var(--red-soft); }
.btn { background: var(--ink); color: var(--paper); border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.hint { margin-top: 10px; background: #fff3cf; border-left: 4px solid var(--gold); padding: 8px 12px; border-radius: 6px; }
.feedback { margin-top: 10px; font-weight: 600; }
.feedback.no { color: var(--red); }
.handbook-link { font-size: .9rem; color: var(--muted); }
.handbook-link a { color: #6b4d24; }

/* solved */
.solved { margin-top: 20px; text-align: center; position: relative; }
.solved .big-stamp { display: inline-block; font-family: var(--type); font-size: 2.6rem; color: var(--red); border: 5px solid var(--red); border-radius: 8px;
  padding: 2px 18px; transform: rotate(-8deg); animation: stamp .45s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes stamp { from { transform: rotate(-8deg) scale(2.6); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 1; } }
.solved .got { font-size: 1.8rem; margin: 10px 0 4px; letter-spacing: 4px; }
.solved .why { font-family: var(--type); text-align: left; background: #fffaf0; border-radius: 12px; padding: 12px 16px; border: 2px solid var(--line); }

/* the handbook (wiki) */
.wiki { display: grid; grid-template-columns: 230px 1fr; gap: 18px; }
@media (max-width: 720px) { .wiki { grid-template-columns: 1fr; } }
.wiki aside { background: var(--bg-2); border-radius: 14px; padding: 12px; align-self: start; position: sticky; top: 70px; }
@media (max-width: 720px) { .wiki aside { position: static; } }
.wiki aside input { width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid #5a5048; background: #241f1c; color: var(--paper); font: inherit; margin-bottom: 8px; }
.wiki aside a { display: block; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: #e7dcc7; }
.wiki aside a.on, .wiki aside a:hover { background: #4a413a; color: #fff; }
.article { background: var(--paper); color: var(--ink); border-radius: 8px; padding: 22px clamp(16px, 4vw, 36px); box-shadow: 0 12px 30px rgba(0, 0, 0, .35); }
.article h1 { font-family: var(--type); margin: 0 0 12px; }
.article p { margin: 0 0 12px; }
.article ul { margin: 0 0 12px; padding-left: 1.2em; }
.article li { margin: 4px 0; }
.article .tip { background: #fff3cf; border-left: 4px solid var(--gold); padding: 10px 14px; border-radius: 6px; margin: 0 0 12px; }
.article .tip::before { content: '🔎 Tip: '; font-weight: 700; }
.article details { background: #fffaf0; border: 2px dashed var(--line); border-radius: 12px; padding: 10px 14px; margin: 0 0 12px; }
.article summary { cursor: pointer; font-weight: 600; }
.article .used-in { margin-top: 16px; font-size: .92rem; color: var(--muted); }
.wiki-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.wiki-card { background: var(--paper); color: var(--ink); border-radius: 12px; padding: 14px; text-decoration: none; box-shadow: 0 6px 14px rgba(0, 0, 0, .3); }
.wiki-card .e { font-size: 1.8rem; }
.wiki-card b { display: block; font-family: var(--type); font-size: 1.1rem; }
.wiki-card span { color: var(--muted); font-size: .88rem; }
.wiki-title { font-family: var(--type); color: var(--paper); }
mark { background: #ffe08a; padding: 0 2px; border-radius: 3px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .story p { opacity: 1; } }
