:root {
  --ink: #3b2f3f; --paper: #fff7ec; --dot: #f1dfc6; --red: #d7263d; --accent: #e07a5f; --soft: #fde9d6;
  --teal: #2e7d6b; --gold: #e9a23b; --card: #ffffff;
  --display: "Titan One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Caveat", cursive;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 600 16px/1.45 var(--body);
  background: var(--paper) radial-gradient(var(--dot) 1.4px, transparent 1.8px) 0 0 / 20px 20px;
  min-height: 100vh;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; max-width: 1180px; margin: 0 auto; padding: 14px 16px 6px; }
.logo { text-decoration: none; display: grid; grid-template-columns: auto auto; align-items: end; column-gap: 8px; line-height: .9; }
.logo .l1 { grid-column: 1 / 3; font: 400 15px var(--display); letter-spacing: .06em; text-transform: uppercase; }
.logo .l2 { font: 400 34px var(--display); color: var(--accent); text-shadow: 2.5px 2.5px 0 var(--ink); }
.logo .l3 { font: 700 26px var(--hand); color: var(--red); transform: rotate(-6deg) translateY(2px); }
nav { display: flex; gap: 8px; }
.ico { width: 42px; height: 42px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff; box-shadow: 2px 2px 0 var(--ink);
  font: 400 20px var(--display); display: grid; place-items: center; padding: 0; }
.ico svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tool, .link { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.tool svg, .link svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.ico:active, .tool:active, .btn:active { transform: translate(2px, 2px); box-shadow: none; }

main { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.case-head { text-align: center; margin: 6px 0 12px; }
.meta { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; font: 800 13px var(--body); letter-spacing: .08em; text-transform: uppercase; }
.pill { background: var(--ink); color: var(--paper); border-radius: 30px; padding: 4px 13px 3px; font: 400 14px var(--display); letter-spacing: .04em; }
.diff { border: 2px solid var(--ink); border-radius: 30px; padding: 2px 10px; background: #fff; }
.diff.liar-d { background: var(--red); color: #fff; border-color: var(--red); }
h1 { font: 400 clamp(28px, 5.4vw, 46px)/1.05 var(--display); color: var(--accent); text-shadow: 3px 3px 0 var(--ink); margin: 10px 0 6px; }
.hook { font-weight: 700; margin: 0 auto; max-width: 640px; }
.hook b { color: var(--red); }
.liar { display: inline-block; background: var(--red); color: #fff; border-radius: 22px; padding: 5px 16px; font: 900 13px var(--body); letter-spacing: .06em; margin: 10px 0 0; }

/* board */
.board { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.timer { font: 400 20px var(--display); min-width: 64px; }
.tool { border: 2.2px solid var(--ink); background: #fff; border-radius: 12px; padding: 6px 11px; font: 900 13px var(--body); box-shadow: 2px 2px 0 var(--ink); }
.tool[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.tool:disabled { opacity: .45; cursor: default; }
.plan-wrap { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 18px; box-shadow: 5px 5px 0 var(--ink); padding: 6px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.plan svg { display: block; width: 100%; height: auto; }
.overlay { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }
.rfm-coord { font: 400 30px var(--display); fill: var(--ink); }
.rfm-room { font: 900 19px var(--body); fill: var(--ink); letter-spacing: .06em; }
.cellhit { fill: transparent; cursor: pointer; }
.cellhit:hover { fill: rgba(233, 162, 59, .22); }
.cellhit.blocked { cursor: not-allowed; }
.cellhit.blocked:hover { fill: rgba(59, 47, 63, .08); }
.shade { fill: rgba(59, 47, 63, .11); pointer-events: none; }
.xmark { stroke: var(--ink); stroke-width: 7; stroke-linecap: round; opacity: .7; pointer-events: none; }
.tok { pointer-events: none; transition: transform .12s; }
.tok .ring { stroke: var(--ink); stroke-width: 5; }
.tok.bad .ring { stroke: var(--red); stroke-width: 9; }
.tok.locked .ring { stroke-dasharray: 9 6; }
.tok.killer .ring { stroke: var(--red); stroke-width: 10; }
.tok.wrong .ring { stroke: var(--red); stroke-width: 10; stroke-dasharray: 6 5; }
.tok.sel .ring { stroke: var(--gold); stroke-width: 10; }
.tok text { font: 400 26px var(--display); fill: #fff; stroke: var(--ink); stroke-width: 5; paint-order: stroke; }

/* suspect tray (always next to the plan) */
.tray { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 6px; scrollbar-width: thin; }
.chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 0; padding: 0; width: 64px; }
.chip .av { width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--ink); background: var(--c); overflow: hidden; box-shadow: 2px 2px 0 var(--ink); position: relative; }
.chip .av svg { width: 100%; height: 100%; display: block; }
.chip .nm { font: 900 12px var(--body); white-space: nowrap; }
.chip.placed .av { opacity: .45; }
.chip.placed .av::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font: 400 26px var(--display); color: #fff; text-shadow: 0 0 3px var(--ink), 2px 2px 0 var(--ink); }
.chip.sel .av { border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold), 2px 2px 0 var(--ink); }
.chip.victim { cursor: pointer; }
.chip.victim .av { filter: grayscale(.85); }
.say { min-height: 50px; background: #fff; border: 2.2px solid var(--ink); border-radius: 14px; padding: 8px 12px; font-weight: 800; position: relative; }
.say::before { content: ""; position: absolute; top: -9px; left: 26px; width: 14px; height: 14px; background: #fff; border-left: 2.2px solid var(--ink); border-top: 2.2px solid var(--ink); transform: rotate(45deg); }
.say b { color: var(--accent); font-family: var(--display); font-weight: 400; }
.say .tip { color: #8a7a85; font-weight: 700; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.legend .g { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 4px 9px; font: 900 11px var(--body); text-transform: uppercase; letter-spacing: .05em; }
.legend .it { display: inline-flex; flex-direction: column; align-items: center; font-size: 9px; letter-spacing: 0; }
.legend .it svg { width: 26px; height: 26px; }

.sub { font: 400 22px var(--display); margin: 0 0 10px; }
.cards { display: grid; gap: 10px; }
.card { display: flex; gap: 10px; align-items: center; background: #fff; border: 2.4px solid var(--ink); border-radius: 14px; box-shadow: 3px 3px 0 var(--ink); padding: 8px 10px; text-align: left; width: 100%; }
.card .av { flex: 0 0 52px; height: 52px; border-radius: 50%; border: 2.5px solid var(--ink); overflow: hidden; background: var(--c); }
.card .av svg { width: 100%; height: 100%; display: block; }
.card .who { font: 400 17px var(--display); line-height: 1.1; }
.card .who small { font: 800 12px var(--body); color: #8a7a85; margin-left: 4px; }
.card .cl { font-weight: 700; font-size: 15px; line-height: 1.35; }
.card.sel { outline: 4px solid var(--gold); }
.card.done { background: #f3fbf7; }
.card.done .cl { color: #6d8f80; }
.card.victim { background: #fbeff0; border-style: dashed; }
.card.victim .who { color: var(--red); }
.link { background: none; border: 0; text-decoration: underline; font-weight: 800; margin-top: 12px; padding: 4px 0; color: #8a7a85; }

/* promo */
.promo { margin: 36px 0 10px; }
.promo-in { display: grid; grid-template-columns: 1fr 220px; gap: 24px; align-items: center; background: var(--soft); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 6px 6px 0 var(--ink); padding: 22px 26px; }
.promo h2 { font: 400 26px/1.1 var(--display); margin: 0 0 8px; }
.buy { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn { display: inline-block; border: 2.5px solid var(--ink); background: var(--accent); color: #fff; border-radius: 14px; padding: 9px 18px; font: 400 17px var(--display); letter-spacing: .02em; text-decoration: none; box-shadow: 3px 3px 0 var(--ink); text-shadow: 1px 1px 0 var(--ink); }
.btn.alt { background: #fff; color: var(--ink); text-shadow: none; }
.book { aspect-ratio: 8.5 / 11; background: var(--accent); border: 3px solid var(--ink); border-radius: 6px 14px 14px 6px; box-shadow: 6px 6px 0 var(--ink); display: flex; flex-direction: column; justify-content: center; align-items: center; color: #fff; transform: rotate(3deg); padding: 10px; text-align: center;
  background-image: radial-gradient(rgba(255, 255, 255, .25) 1.5px, transparent 2px); background-size: 14px 14px; }
.book span { font: 400 18px var(--display); text-shadow: 2px 2px 0 var(--ink); }
.book b { font: 400 38px var(--display); text-shadow: 3px 3px 0 var(--ink); font-weight: 400; }
.book i { font: 900 11px var(--body); font-style: normal; text-transform: uppercase; letter-spacing: .1em; margin-top: 8px; background: var(--ink); padding: 3px 8px; border-radius: 10px; }

.foot { max-width: 1180px; margin: 0 auto; padding: 10px 16px 40px; text-align: center; }
.small { font-size: 13px; color: #8a7a85; }

/* header strip: a shelf of our own furniture */
.strip { height: 64px; margin: 2px 0 4px; background: url(img/strip.svg) repeat-x center / auto 64px; border-bottom: 3px solid var(--ink); opacity: .95; }
.solvers { font: 800 13px var(--body); color: var(--teal); margin: 8px 0 0; }
.kicker { display: inline-block; font: 900 12px var(--body); letter-spacing: .14em; text-transform: uppercase; background: var(--ink); color: var(--paper); border-radius: 20px; padding: 3px 10px; margin-bottom: 8px; }
.promo-art { border: 0; padding: 0; background: none; cursor: zoom-in; }
.promo-art img { display: block; width: 100%; height: auto; border: 3px solid var(--ink); border-radius: 6px 14px 14px 6px; box-shadow: 7px 7px 0 var(--ink); transform: rotate(2.5deg); transition: transform .2s; }
.promo-art:hover img { transform: rotate(0deg) scale(1.02); }
.row-links { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.about { display: grid; grid-template-columns: 180px 1fr; gap: 24px; align-items: center; margin: 34px 0 6px; }
.about h2 { font: 400 26px var(--display); margin: 0 0 8px; }
.about p { margin: 0 0 10px; }
.about-art { aspect-ratio: 1; background: url(img/cast.svg) center / contain no-repeat; }
.board-list { list-style: none; padding: 0; margin: 10px 0; counter-reset: r; }
.board-list li { counter-increment: r; display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 6px 10px; margin-bottom: 6px; font-weight: 800; }
.board-list li::before { content: counter(r); font: 400 18px var(--display); color: var(--accent); }
.board-list li.me { background: #fff3d6; outline: 3px solid var(--gold); }
.board-list .h { font-size: 12px; color: #8a7a85; }
.board-list .t { font: 400 17px var(--display); }
.rank-line { font: 800 15px var(--body); color: var(--teal); margin: 0 0 6px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.medal { background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 6px; text-align: center; font: 800 11.5px/1.25 var(--body); }
.medal svg { width: 46px; height: 46px; display: block; margin: 0 auto 4px; }
.medal b { display: block; font: 400 14px var(--display); margin-bottom: 2px; }
.medal.locked { opacity: .45; filter: grayscale(1); background: transparent; border-style: dashed; }
.new-badges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; }
.new-badges .medal { width: 130px; background: #fff3d6; }
.look .look-view { position: relative; display: grid; place-items: center; }
.look img { max-width: 100%; max-height: 64vh; border: 2.5px solid var(--ink); border-radius: 8px; box-shadow: 4px 4px 0 var(--ink); background: #fff; }
.look .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff; font: 400 26px/1 var(--display); box-shadow: 2px 2px 0 var(--ink); }
.look .prev { left: 4px; } .look .next { right: 4px; }
.look-cap { text-align: center; font-weight: 800; margin: 10px 0; }
.buy.center { justify-content: center; }
.modal.wide { max-width: min(760px, calc(100vw - 24px)); }
.print-only { display: none; }

.faq { margin: 28px 0 0; }
.faq h2 { font: 400 26px var(--display); margin: 0 0 10px; }
.faq details { background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px 14px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font: 400 17px var(--display); }
.faq p { margin: 8px 0 2px; }
.textnav { display: flex; gap: 8px; }
.textnav .btn { font-size: 14px; padding: 6px 12px; }
.rules-box { margin-top: 14px; }
/* newsletter */
.news { margin-top: 18px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; box-shadow: 4px 4px 0 var(--ink); padding: 14px 18px; text-align: left; display: flex; gap: 18px; align-items: center; }
.news-body { flex: 1; min-width: 0; }
.news-gift { flex: 0 0 96px; height: 96px; border-radius: 50%; background: var(--gold); border: 3px solid var(--ink); display: grid; place-items: center; align-content: center; transform: rotate(-8deg); box-shadow: 3px 3px 0 var(--ink); }
.news-gift span { font: 400 40px/0.9 var(--display); color: #fff; text-shadow: 2px 2px 0 var(--ink); }
.news-gift small { font: 900 11px/1 var(--body); text-transform: uppercase; letter-spacing: .06em; text-align: center; }
.news-t b { display: block; font: 400 21px var(--display); color: var(--accent); text-shadow: 1.5px 1.5px 0 var(--ink); }
.news-t span { font-weight: 700; font-size: 14.5px; }
.news-f { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.news-f input { flex: 1 1 200px; min-width: 0; border: 2.5px solid var(--ink); border-radius: 12px; padding: 9px 12px; font: 700 16px var(--body); background: var(--paper); color: var(--ink); }
.news-msg { min-height: 0; margin: 6px 0 0; font-weight: 800; color: var(--teal); }
.news .small { margin: 6px 0 0; }
.news.in-modal { margin-top: 14px; box-shadow: none; }

/* modals */
.modal { border: 3px solid var(--ink); border-radius: 22px; box-shadow: 6px 6px 0 var(--ink); background: var(--paper); color: var(--ink); max-width: min(560px, calc(100vw - 24px)); width: 100%; padding: 22px 22px 18px; }
.modal::backdrop { background: rgba(59, 47, 63, .55); }
.modal h2 { font: 400 28px var(--display); margin: 0 0 10px; color: var(--accent); text-shadow: 2px 2px 0 var(--ink); }
.modal h3 { font: 400 18px var(--display); margin: 14px 0 4px; }
.modal .x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font: 400 30px var(--display); line-height: 1; }
.rules { padding-left: 22px; margin: 0; }
.rules li { margin-bottom: 7px; }
.arch { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; max-height: 60vh; overflow: auto; padding: 4px; }
.arch a { display: block; text-decoration: none; text-align: center; background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 6px 4px; font: 800 12px var(--body); }
.arch a b { display: block; font: 400 18px var(--display); }
.arch a.solved { background: #e6f5ee; }
.arch a.solved::after { content: "✓ solved"; display: block; color: var(--teal); }
.arch a.today { outline: 3px solid var(--gold); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.stat-grid div { background: #fff; border: 2px solid var(--ink); border-radius: 14px; padding: 8px 4px; font: 800 11px var(--body); text-transform: uppercase; letter-spacing: .04em; }
.stat-grid b { display: block; font: 400 28px var(--display); letter-spacing: 0; }
.best { margin-top: 12px; }
.best table { width: 100%; border-collapse: collapse; }
.best td { padding: 4px 6px; border-bottom: 1.5px dashed var(--dot); }
.acc { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.acc button { background: #fff; border: 2.4px solid var(--ink); border-radius: 14px; box-shadow: 2px 2px 0 var(--ink); padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font: 400 15px var(--display); }
.acc .av { width: 58px; height: 58px; border-radius: 50%; overflow: hidden; border: 2.5px solid var(--ink); background: var(--c); }
.acc .av svg { width: 100%; height: 100%; display: block; }
.acc button.no { opacity: .4; text-decoration: line-through; }
.acc-msg { font-weight: 800; color: var(--red); min-height: 1.4em; }
.solved { text-align: center; }
.stamp { display: inline-block; font: 400 36px var(--display); color: var(--red); border: 5px solid var(--red); border-radius: 12px; padding: 2px 16px; transform: rotate(-4deg); margin: 4px 0 10px; letter-spacing: .03em; }
.solved-line { font-weight: 800; }
#badge { width: min(300px, 70vw); height: auto; border: 2.5px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--ink); margin: 6px 0 12px; }
.share { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.next { font-weight: 800; margin: 10px 0 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; visibility: hidden; pointer-events: none; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 14px; font-weight: 800; transition: transform .25s, opacity .25s, visibility .25s; max-width: calc(100vw - 32px); text-align: center; z-index: 50; }
.toast.on { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

@media (max-width: 860px) {
  .board { grid-template-columns: 1fr; }
  .promo-in { grid-template-columns: 1fr; }
  .promo-art { width: 60%; margin: 0 auto; order: -1; }
  .logo .l2 { font-size: 28px; }
  .toolbar { flex-wrap: nowrap; gap: 5px; }
  .timer { min-width: 0; font-size: 17px; margin-right: 2px; }
  .tool { flex: 1 1 0; padding: 6px 3px; font-size: 12px; white-space: nowrap; }
}
@media (max-width: 640px) {
  .about { grid-template-columns: 1fr; }
  .about-art { width: 150px; margin: 0 auto; }
  .news { flex-direction: column; align-items: stretch; }
  .news-gift { display: none; }
  .strip { height: 48px; background-size: auto 48px; }
}
@media (max-width: 480px) {
  .top { padding-top: 10px; }
  nav { gap: 5px; }
  .ico { width: 34px; height: 34px; font-size: 16px; border-width: 2px; }
  .ico svg { width: 18px; height: 18px; }
  .logo .l1 { font-size: 12px; } .logo .l2 { font-size: 24px; } .logo .l3 { font-size: 20px; }
  .tool span { font-size: 11px; }
  .tool svg { width: 15px; height: 15px; }
  .toolbar { display: grid; grid-template-columns: auto repeat(4, minmax(0, 1fr)); gap: 4px; }
  .tool { min-width: 0; overflow: hidden; padding: 6px 1px; font-size: 11.5px; }
  .tray { gap: 3px; }
  .chip { width: 49px; }
  .chip .av { width: 44px; height: 44px; border-width: 2.5px; }
  .chip .nm { font-size: 11px; }
}
@media (max-width: 400px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* print: just the case — plan, key and statements on one page */
@media print {
  @page { size: auto; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .top nav, .strip, .toolbar, .tray, .say, .promo, .about, .foot, .row-links, .solvers, dialog, .toast, .overlay { display: none !important; }
  .top { padding: 0; } .logo .l2 { font-size: 24px; } .logo .l1 { font-size: 11px; } .logo .l3 { font-size: 18px; }
  .case-head { margin: 0 0 6px; } h1 { font-size: 26px; margin: 4px 0; text-shadow: 2px 2px 0 var(--ink); }
  .board { grid-template-columns: 1fr 1fr; gap: 12px; }
  .plan-wrap { box-shadow: none; border-width: 2px; break-inside: avoid; }
  .card { box-shadow: none; padding: 4px 8px; break-inside: avoid; } .card .av { flex-basis: 36px; height: 36px; } .card .cl { font-size: 12.5px; } .card .who { font-size: 14px; }
  .cards { gap: 5px; } .sub { font-size: 16px; margin-bottom: 6px; }
  .legend { margin-top: 6px; } .legend .g { padding: 2px 6px; }
  .print-only { display: block; }
  .killer-line { font: 400 18px var(--display); margin-top: 16px; }
  .print-foot { position: fixed; bottom: 0; left: 0; right: 0; text-align: center; font: 800 10px var(--body); color: #8a7a85; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
