:root {
  --felt: #1b3a2f;
  --felt-dk: #0f241c;
  --felt-lt: #2a5444;
  --cream: #f4ead3;
  --paper: #f7efdc;
  --paper-2: #fff9ec;
  --line: #dccca5;
  --ink: #2a2119;
  --muted: #6e604f;
  --brass: #d3a447;
  --brass-dk: #8a6420;
  --crimson: #a31b31;
  --ok: #2f7d4f;
  --bad: #b3262f;
  --shadow: 0 2px 0 rgba(0, 0, 0, .12), 0 10px 26px rgba(0, 0, 0, .28);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--felt-dk); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 70% at 50% -10%, var(--felt-lt) 0%, var(--felt) 50%, var(--felt-dk) 100%) fixed;
  color: var(--cream);
  font: 17px/1.45 -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  /* Game UI: no text selection or callout menu on long-press. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-appearance: none; appearance: none; }
button:disabled { cursor: default; }
h1, h2, h3 { font-family: 'Playfair Display', Georgia, serif; margin: 0; line-height: 1.15; }
p { margin: 0 0 .7em; }
p:last-child { margin-bottom: 0; }

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 28px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- basics ---------- */

.card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.screen-h { font-size: 30px; text-align: center; margin-top: 6px; }
.sub { text-align: center; color: rgba(244, 234, 211, .8); margin: -6px 0 0; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 12px 18px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(#e2b65c, #c0912f);
  color: #2b1d06;
  font-weight: 700;
  font-size: 19px;
  text-align: center;
  box-shadow: 0 3px 0 var(--brass-dk), 0 8px 18px rgba(0, 0, 0, .28);
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--brass-dk), 0 4px 10px rgba(0, 0, 0, .25); }
.btn:disabled { opacity: .4; }
.btn small { font-weight: 400; opacity: .8; }
.btn.big { min-height: 66px; font-size: 21px; flex-wrap: wrap; }
.btn.red { background: linear-gradient(#c8324a, #97182c); color: #fff; box-shadow: 0 3px 0 #5d0d1a, 0 8px 18px rgba(0, 0, 0, .3); }
.btn.ghost { background: rgba(255, 255, 255, .06); color: var(--cream); border: 2px solid rgba(244, 234, 211, .3); box-shadow: none; }
.btn.ghost-ink { background: transparent; color: var(--ink); border: 2px solid var(--line); box-shadow: none; }
.btn.small { min-height: 46px; font-size: 16px; padding: 8px 10px; }

.banner {
  background: rgba(255, 255, 255, .08);
  border: 1.5px solid rgba(244, 234, 211, .25);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: center;
  font-size: 16px;
}
.banner.red { background: rgba(163, 27, 49, .35); border-color: #e0596d; font-weight: 700; }
.banner.gold { background: rgba(211, 164, 71, .2); border-color: var(--brass); }
.banner.late { animation: fade .5s 1s both; }

#toast {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top) + 14px);
  transform: translate(-50%, -16px);
  opacity: 0;
  max-width: calc(100% - 32px);
  width: max-content;
  background: #fffaf0;
  color: var(--ink);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .35);
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  z-index: 100;
  transition: transform .25s ease, opacity .25s ease;
  pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  animation: fade .18s;
}
.sheet {
  width: 100%;
  max-width: 480px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 20px 20px 0 0;
  padding: 22px 18px calc(env(safe-area-inset-bottom) + 20px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: up .22s ease-out;
}
.sheet h3 { font-size: 24px; }
.share-box { width: 100%; min-height: 140px; font: 16px/1.4 ui-monospace, monospace; -webkit-user-select: text; user-select: text; border-radius: 10px; border: 1px solid var(--line); padding: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- tokens & icons ---------- */

.tok {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c);
  color: var(--i);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .02em;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .2), 0 1px 3px rgba(0, 0, 0, .3);
  border: 2px solid rgba(255, 255, 255, .55);
  flex: none;
}
.tok.sm { width: 28px; height: 28px; font-size: 11px; }
.tok.lg { width: 64px; height: 64px; font-size: 22px; border-width: 3px; }
.ico { font-size: 26px; line-height: 1; }
.ico.sm { font-size: 22px; }
.ico.lg { font-size: 54px; }

/* ---------- home ---------- */

.title { text-align: center; padding: 18px 0 6px; }
.title h1 {
  font-size: clamp(36px, 11vw, 48px);
  font-weight: 900;
  color: #fff6df;
  text-shadow: 0 3px 0 rgba(0, 0, 0, .35);
}
.tag { margin-top: 10px; color: var(--brass); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 14px; }
.title-icons { display: flex; justify-content: center; gap: 12px; margin-bottom: 14px; }
.title-icons > span {
  width: 46px; height: 46px; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 26px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .3);
  transform: rotate(var(--r, 0deg));
}
.die-mini { background: #fffdf7; --r: -8deg; display: grid !important; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 8px; }
.die-mini i { display: block; place-self: center; width: 7px; height: 7px; border-radius: 50%; }
.die-mini i.pip { background: var(--ink); }
.tile-mini { background: linear-gradient(#f6e2b6, #e3c27f); color: var(--ink); position: relative; --r: 5deg; }
.tile-mini sub { position: absolute; right: 4px; bottom: 2px; font-size: 10px; }
.qmark { background: var(--crimson); color: #fff; font-family: 'Playfair Display', serif; --r: -4deg; }
.arrow-mini { background: #2b4c7e; color: #fff; --r: 7deg; }
.done-card { text-align: center; }
.done-h { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 22px; }
.done-s { color: var(--muted); margin: 4px 0 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stats div { background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 10px 4px; }
.stats b { display: block; font-size: 22px; color: #fff6df; }
.stats span { font-size: 12px; color: rgba(244, 234, 211, .75); }
.foot { text-align: center; font-size: 15px; color: rgba(244, 234, 211, .7); }
.prose h3 { font-size: 21px; margin-bottom: 6px; }
.cl-rule { color: var(--brass-dk); font-weight: 700; font-size: 15px; }

/* ---------- intro ---------- */

.story { font-size: 18px; }
.time-stamp { font-weight: 700; color: var(--crimson); letter-spacing: .04em; text-transform: uppercase; font-size: 14px; }
.cast { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.cast-i { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; font-size: 13px; line-height: 1.2; }
.cast-i .tok { width: 44px; height: 44px; font-size: 15px; }

/* ---------- HUD & manor ---------- */

.hud {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr;
  background: rgba(0, 0, 0, .25);
  border: 1px solid rgba(244, 234, 211, .15);
  border-radius: 14px;
  overflow: hidden;
}
.hud div { padding: 8px 10px; text-align: center; }
.hud div + div { border-left: 1px solid rgba(244, 234, 211, .15); }
.hud span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: rgba(244, 234, 211, .65); }
.hud b { font-size: 19px; color: #fff6df; }

.map { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.room {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 104px;
  padding: 12px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(#fbf4e3, #efe2c3);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 3px 0 #b49a64, 0 8px 18px rgba(0, 0, 0, .25);
  overflow: hidden;
}
.room:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #b49a64; }
.room:disabled { opacity: .55; }
.r-ico { font-size: 30px; line-height: 1.1; }
.r-nm { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 19px; line-height: 1.15; }
.r-g { font-size: 14px; color: var(--muted); }
.room.locked {
  background: repeating-linear-gradient(-45deg, #d9cfb6 0 14px, #cfc3a6 14px 28px);
  box-shadow: 0 3px 0 #a99a78;
}
.room.locked .r-g { display: none; }
.room.locked::after {
  content: 'POLICE LINE · DO NOT CROSS';
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: 12px;
  background: #f2c230;
  color: #1b1b1b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-align: center;
  padding: 2px 0;
  transform: rotate(-6deg);
  opacity: .9;
}
.stamp {
  position: absolute;
  right: 8px;
  top: 10px;
  transform: rotate(10deg);
  border: 2px solid var(--crimson);
  color: var(--crimson);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .6);
}

/* ---------- notebook ---------- */

.nb { padding: 14px 12px; }
.nb-title { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 19px; margin-bottom: 8px; }
.nb-title small { font-family: -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif; font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 6px; }
.nb-sec + .nb-sec { margin-top: 12px; }
.nb-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-weight: 700; }
.nb-h small { font-weight: 400; color: var(--muted); font-size: 13px; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 66px;
  padding: 6px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.15;
  text-align: center;
}
.chip .cn { overflow-wrap: anywhere; }
.chip.cleared { background: #ece3cd; color: #9a8c74; }
.chip.cleared > * { opacity: .45; }
.chip.cleared::after {
  content: '';
  position: absolute;
  inset: 8px 14px;
  background:
    linear-gradient(to top right, transparent calc(50% - 1.5px), var(--crimson) calc(50% - 1.5px), var(--crimson) calc(50% + 1.5px), transparent calc(50% + 1.5px)),
    linear-gradient(to bottom right, transparent calc(50% - 1.5px), var(--crimson) calc(50% - 1.5px), var(--crimson) calc(50% + 1.5px), transparent calc(50% + 1.5px));
  opacity: .75;
  pointer-events: none;
}
.chip.only { border-color: var(--brass); background: #fff1c9; box-shadow: 0 0 0 2px var(--brass); }
.chip.sel { border-color: var(--crimson); background: #fde0e4; box-shadow: 0 0 0 3px var(--crimson); }
.chip.sel.cleared > * { opacity: .8; }
.accuse-line { text-align: center; font-size: 18px; padding: 0 6px; }
.room-intro { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.ri-ico { font-size: 44px; line-height: 1; }
.room-intro h3 { font-size: 26px; }
.room-intro p { font-size: 18px; margin: 0; }
.room-intro .cl-rule { font-size: 16px; margin-bottom: 6px; }
.peek { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.peek h3 { font-size: 26px; }
.peek p { font-size: 18px; }

/* ---------- rooms ---------- */

.room-h h2 { font-size: 27px; color: #fff6df; text-align: center; }
.how {
  background: rgba(255, 255, 255, .07);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 16px;
}
.how summary { font-weight: 700; color: var(--brass); cursor: pointer; }
.how p { margin: 8px 0 0; }
.how .cl-rule { color: var(--brass); }
.room-body { display: flex; flex-direction: column; gap: 14px; }
.hint-line { text-align: center; color: rgba(244, 234, 211, .8); font-size: 15px; min-height: 1.4em; }
.hint-line.note { color: #fff6df; font-weight: 700; font-size: 17px; }
.hint-line.note b { color: #ffd77a; }

/* dice */
.dice-tray {
  background: radial-gradient(circle at 50% 30%, #2e6650, #1a4234);
  border: 4px solid #6b4a26;
  border-radius: 18px;
  padding: 22px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: inset 0 4px 14px rgba(0, 0, 0, .45), var(--shadow);
}
.dice { display: flex; justify-content: center; gap: clamp(6px, 2.4vw, 12px); }
.die {
  --s: clamp(50px, 15vw, 62px);
  position: relative;
  width: var(--s);
  height: var(--s);
  flex: none;
  padding: calc(var(--s) * .16);
  border: 0;
  border-radius: 13px;
  background: linear-gradient(145deg, #ffffff, #ece6d8);
  box-shadow: inset 0 -4px 0 #cfc6b2, 0 5px 10px rgba(0, 0, 0, .4);
  display: grid;
  grid-template: repeat(3, minmax(0, 1fr)) / repeat(3, minmax(0, 1fr));
  transition: transform .15s;
}
.die i { display: block; place-self: center; width: calc(var(--s) * .17); height: calc(var(--s) * .17); border-radius: 50%; }
.die i.pip { background: #231a12; box-shadow: inset 0 1px 1px rgba(255, 255, 255, .2); }
.die.blank { display: grid; place-items: center; grid-template: none; padding: 0; }
.die.blank b { font-size: 28px; color: #b7ad98; font-family: 'Playfair Display', serif; }
.die:disabled { opacity: 1; }
.die.held { transform: translateY(-8px); box-shadow: inset 0 -4px 0 #cfc6b2, 0 0 0 3px var(--brass), 0 10px 14px rgba(0, 0, 0, .45); }
.die.held::after {
  content: 'HELD';
  position: absolute;
  left: 0; right: 0;
  bottom: -21px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--brass);
  text-align: center;
}
.die.rolling { animation: wobble .14s infinite alternate; }
@keyframes wobble { from { transform: rotate(-12deg) translateY(-3px); } to { transform: rotate(10deg) translateY(2px); } }

.scard { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scard .col { display: flex; flex-direction: column; gap: 6px; }
.col-h { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: rgba(244, 234, 211, .65); text-align: center; }
.sc {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 6px 9px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 15px;
  text-align: left;
  line-height: 1.1;
}
.sc .right { display: flex; flex-direction: column; align-items: flex-end; }
.sc .pts { font-weight: 700; font-size: 18px; }
.sc .pts.zero { color: #b3a68c; }
.sc .pts.muted { color: #b3a68c; }
.sc .pts.done { color: var(--muted); font-size: 16px; }
.sc .cl { font-size: 13px; line-height: 1; margin-top: 1px; }
.sc.used { background: #e1d6bb; color: #8f8169; }
.sc.used .nm { text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, .3); }
.sc:disabled { opacity: 1; }
.sticky-act { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 12px); z-index: 5; }
.sticky-act.plain { background: #fff9ec; color: var(--ink); box-shadow: 0 3px 0 #b49a64, 0 8px 18px rgba(0, 0, 0, .35); }
.sc.sel { background: #ffe9ad; border-color: var(--brass-dk); box-shadow: 0 0 0 2px var(--brass); }

/* library */
.lib-status { display: flex; justify-content: space-between; font-size: 17px; color: rgba(244, 234, 211, .85); }
.lib-status b { color: #fff6df; font-size: 19px; }
.board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 6px;
  background: #e9dfc6;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.slot {
  aspect-ratio: 1;
  border-radius: 6px;
  background: #d8ccae;
  display: grid;
  place-items: center;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  color: rgba(0, 0, 0, .5);
  letter-spacing: .02em;
}
.slot.dl { background: #b9dcee; }
.slot.tl { background: #3f7fb6; color: rgba(255, 255, 255, .85); }
.slot.dw { background: #f2b4b4; }
.slot .tile { width: 86%; height: 86%; }
.board.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.lib-preview { text-align: center; font-size: 18px; min-height: 1.5em; }
.rack {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  padding: 10px 8px 14px;
  background: linear-gradient(#8a5a2f, #5c3a1b);
  border-radius: 10px;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .25), var(--shadow);
}
.tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: linear-gradient(#f8e7c0, #e6c78a);
  box-shadow: inset 0 -3px 0 #c39d58, 0 2px 4px rgba(0, 0, 0, .35);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: clamp(20px, 6.4vw, 27px);
  color: var(--ink);
  line-height: 1;
}
.tile sub { position: absolute; right: 4px; bottom: 3px; font-size: 10px; }
.tile:active { transform: scale(.94); }
.tile-gap { aspect-ratio: 1; border-radius: 7px; background: rgba(0, 0, 0, .15); }
.played { display: flex; flex-direction: column; gap: 6px; }
.pl { display: flex; justify-content: space-between; background: rgba(255, 255, 255, .07); border-radius: 10px; padding: 8px 14px; }

/* study */
.dots { display: flex; justify-content: center; gap: 8px; }
.dots span { width: 12px; height: 12px; border-radius: 50%; background: rgba(244, 234, 211, .2); }
.dots .past { background: var(--brass); }
.dots .now { background: #fff6df; box-shadow: 0 0 0 3px rgba(255, 246, 223, .25); }
.qmeta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.chip-cat { background: var(--felt); color: var(--cream); border-radius: 99px; padding: 3px 10px; font-size: 13px; font-weight: 700; }
.q { font-size: 22px; font-weight: 700; line-height: 1.3; }
.ans { display: grid; gap: 10px; }
.ans button {
  min-height: 58px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  font-size: 19px;
  text-align: left;
  box-shadow: 0 2px 0 #c6b48a;
}
.ans button:disabled { opacity: 1; }
.ans button.right { background: #d4f0da; border-color: var(--ok); color: #13472a; font-weight: 700; }
.ans button.right::after { content: ' ✓'; }
.ans button.wrong { background: #f8d6d6; border-color: var(--bad); color: #6e1119; }
.ans button.dim { opacity: .5; }
.tv-verdict { text-align: center; font-weight: 700; font-size: 20px; }
.tv-verdict.ok { color: #9fe0b2; }
.tv-verdict.bad { color: #ffb3b3; }
.score-line { text-align: center; color: rgba(244, 234, 211, .7); font-size: 15px; }

/* gallery */
.gal-hud { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.gal-hud .btn { width: auto; }
.hearts { font-size: 24px; letter-spacing: 2px; }
.left { text-align: center; font-weight: 700; color: #fff6df; }
.canvas-wrap { display: flex; justify-content: center; }
.canvas-wrap canvas { display: block; border-radius: 14px; box-shadow: var(--shadow); touch-action: none; }

/* ---------- results & clues ---------- */

.result { text-align: center; }
.res-ico { font-size: 46px; }
.result h2 { font-size: 25px; margin: 4px 0; }
.res-pts { font-weight: 700; color: var(--ok); font-size: 19px; }
.res-list { list-style: none; padding: 0; margin: 12px 0; color: var(--muted); font-size: 15px; text-align: left; display: inline-flex; flex-direction: column; gap: 3px; }
.res-clues { margin-top: 8px; padding: 10px; border-radius: 10px; background: #fff1c9; font-weight: 700; font-size: 18px; }
.res-clues.none { background: #ece3cd; color: var(--muted); font-weight: 400; }
.dig h2 { font-size: 24px; margin-bottom: 6px; }
.dig p { color: var(--muted); }
.dig-btns { display: grid; gap: 10px; margin-top: 12px; }
.dig-btn {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 2px solid var(--brass);
  background: #fff4d6;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 3px 0 #c39d58;
}
.dig-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #c39d58; }
.dig-btn:disabled { opacity: .45; border-color: var(--line); background: #ece3cd; }
.d-ico { font-size: 28px; text-align: center; }
.d-l { font-weight: 700; font-size: 19px; }
.d-n { font-size: 14px; color: var(--muted); }

.clue-card { perspective: 900px; min-height: 300px; }
.cc-inner { position: relative; width: 100%; min-height: inherit; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .7, .3, 1.2); }
.clue-card.flip .cc-inner { animation: flipin .8s cubic-bezier(.3, .7, .3, 1.15) var(--d, .25s) both; }
.clue-card.flipped .cc-inner { transform: rotateY(180deg); }
@keyframes flipin { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }
.cc-back, .cc-front {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.cc-back {
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(45deg, #7d1526 0 10px, #8f1d30 10px 20px);
  border: 6px solid #f4ead3;
}
.cc-back span { font-family: 'Playfair Display', serif; font-size: 80px; color: #f4ead3; font-weight: 900; }
.cc-front {
  transform: rotateY(180deg);
  background: var(--paper);
  color: var(--ink);
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  border: 6px solid #e8d9b5;
}
.cc-front h2 { font-size: 26px; }
.cc-front p { font-size: 18px; }
.cc-tag {
  display: inline-block;
  border: 2px solid var(--crimson);
  color: var(--crimson);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 2px 10px;
  border-radius: 4px;
  transform: rotate(-4deg);
}

.envelope { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.clue-card.small { min-height: 196px; perspective: 600px; }
.clue-card.small .cc-back span { font-size: 44px; }
.clue-card.small .cc-back { border-width: 4px; }
.clue-card.small .cc-front { padding: 10px 6px; gap: 6px; border-width: 4px; font-size: 14px; line-height: 1.2; }
.clue-card.small .cc-front.ok { border-color: #7cc49a; background: #eefaf1; }
.clue-card.small .cc-front.bad { border-color: #e39aa2; background: #fdf0f1; }
.clue-card.small .mark { font-size: 12px; font-weight: 700; }
.cc-front.ok .mark { color: var(--ok); }
.cc-front.bad .mark { color: var(--bad); }
.after { display: flex; flex-direction: column; gap: 14px; }
.after.late { animation: fade .6s 2.6s both; }
.card.verdict { text-align: center; }
.card.verdict h2 { font-size: 28px; margin-bottom: 8px; }
.card.verdict p { font-size: 18px; }
.card.verdict.win { border: 3px solid #7cc49a; }
.card.verdict.lose { border: 3px solid #e39aa2; }
.motive { font-style: italic; color: var(--muted); }
.tally div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.tally div:last-child { border-bottom: 0; }
.tally .total { font-size: 21px; padding-top: 10px; }
.tally .total b { color: var(--crimson); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.confetti span { position: absolute; top: -40px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-delay: 0s !important; transition-duration: .01s !important; }
}

/* ---------- shared on-screen keyboard (Kitchen, Ballroom) ---------- */

.kb { display: flex; flex-direction: column; gap: 6px; user-select: none; }
.kb-row { display: flex; justify-content: center; gap: 5px; }
.key {
  flex: 1 1 0;
  max-width: 44px;
  height: clamp(40px, 7.3vh, 52px);
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: #e8dfc8;
  color: var(--ink);
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 2px 0 #b8a984;
}
.key.wide { flex: 1.6 1 0; max-width: 70px; font-size: 14px; }
.key.spacer { visibility: hidden; }
.key:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.key:disabled { opacity: .35; }
.key.correct { background: #4c9a5b; color: #fff; box-shadow: 0 2px 0 #2f6b3a; }
.key.present { background: #d9a92b; color: #fff; box-shadow: 0 2px 0 #9c7716; }
.key.absent { background: #5b5a52; color: #e6e1d3; box-shadow: 0 2px 0 #3a3934; }
.key.vowel { background: #f6e3b0; box-shadow: 0 2px 0 #c9a25e; }
.key.correct:disabled, .key.absent:disabled { opacity: .85; }

/* ---------- the Kitchen (word guess) ---------- */

/* --t (tile size) is set on the room by the game to fit the screen. */
.wd-grid { display: grid; gap: 6px; justify-content: center; }
.wd-row { display: grid; grid-template-columns: repeat(5, var(--t, 54px)); gap: 6px; }
.wd-row.shake { animation: shake .4s; }
.wd-tile {
  width: var(--t, 54px);
  height: var(--t, 54px);
  display: grid;
  place-items: center;
  border: 2px solid rgba(244, 234, 211, .28);
  border-radius: 6px;
  font-weight: 800;
  font-size: calc(var(--t, 54px) * .52);
  color: #fff6df;
  text-transform: uppercase;
}
.wd-tile.typed { border-color: rgba(244, 234, 211, .7); animation: pop .12s; }
.wd-tile.correct { background: #4c9a5b; border-color: #4c9a5b; color: #fff; }
.wd-tile.present { background: #d9a92b; border-color: #d9a92b; color: #fff; }
.wd-tile.absent { background: #5b5a52; border-color: #5b5a52; color: #f1ece0; }
.wd-tile.flip { animation: tileflip .5s ease both; animation-delay: calc(var(--i) * .18s); }
@keyframes pop { 50% { transform: scale(1.1); } }
@keyframes tileflip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }

/* ---------- the Ballroom (wheel) ---------- */

.room-body.tight { gap: 8px; }
.wh-board {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: #1f6b4f;
  border: 4px solid #c99a3e;
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px #0f3a2a, var(--shadow);
}
.wh-board > div:first-child { display: flex; flex-direction: column; gap: 4px; }
.wh-row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.wh-cat { text-align: center; color: #fff6df; font-weight: 800; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; margin-top: 2px; }
.wt {
  aspect-ratio: 5 / 6;
  display: grid;
  place-items: center;
  border-radius: 3px;
  font-weight: 800;
  font-size: clamp(15px, 4.6vw, 21px);
  color: #111;
}
.wt.off { background: #2f8a65; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.wt.blank { background: #fbfbf6; }
.wt.blank.next { box-shadow: inset 0 -4px 0 #1565c0; }
.wt.shown { background: #fbfbf6; }
.wt.shown.new { animation: lightup .9s; }
.wt.typing { background: #dbe9ff; color: #0d47a1; }
@keyframes lightup { 0%, 60% { background: #3b82f6; color: transparent; } 100% { background: #fbfbf6; color: #111; } }
.wh-mid { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.wh-wheel-wrap { position: relative; width: clamp(118px, min(40vw, 23vh), 180px); aspect-ratio: 1; }
.wh-spin { width: 100%; height: 100%; transition: transform 2.6s cubic-bezier(.12, .67, .15, 1); }
.wh-wheel { width: 100%; height: 100%; display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .35)); border-radius: 50%; }
.wh-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  z-index: 2;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 22px solid #fff6df;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5));
}
.wh-side { display: flex; flex-direction: column; gap: 10px; }
.wh-bank { display: flex; justify-content: space-between; align-items: center; gap: 6px; background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 6px 10px; }
.wh-bank .hearts { font-size: 17px; letter-spacing: 0; }
.wh-bank b { font-size: 21px; color: #fff6df; }
.btn.mid { min-height: 48px; }
.wh-btns { display: flex; flex-direction: column; gap: 8px; }
#wh-hint { min-height: 2.7em; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0 5px; }

/* ---------- deduction: traits, marks, tips, floor plan ---------- */

.nb-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.linkish {
  border: 1.5px solid var(--line);
  background: var(--paper-2);
  color: var(--ink);
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 700;
  font-family: -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif;
}
.nb-help { margin: -2px 0 8px; font-size: 14px; color: var(--muted); }
.nb-legend { font-size: 14px; color: var(--muted); margin: -2px 0 6px; line-height: 1.3; }
.chip .ct { font-size: 16px; color: var(--muted); line-height: 1.1; min-height: 1.1em; letter-spacing: 1px; }
.chip .ct.txt { font-size: 12px; letter-spacing: 0; }
.chip.mark-x { background: #ece6d6; }
.chip.mark-x > * { opacity: .5; }
.chip.mark-x::after {
  content: '';
  position: absolute;
  inset: 10px 18px;
  background:
    linear-gradient(to top right, transparent calc(50% - 1px), #6e604f calc(50% - 1px), #6e604f calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(to bottom right, transparent calc(50% - 1px), #6e604f calc(50% - 1px), #6e604f calc(50% + 1px), transparent calc(50% + 1px));
  opacity: .55;
  pointer-events: none;
}
.chip.mark-star { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass); background: #fff6dc; }
.chip.mark-star::before { content: '⭐'; position: absolute; top: 3px; right: 4px; font-size: 13px; }
.nb-tips { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.nb-tips li { background: #e6f0fb; border: 1px solid #b9d2ee; border-radius: 9px; padding: 6px 9px; font-size: 14px; line-height: 1.3; color: #1d3a57; }
.peek-traits { font-size: 15px; color: var(--muted); }
.peek-note { font-size: 13.5px; color: var(--muted); text-align: center; }
.marks { width: 100%; }
.btn.small.on { background: linear-gradient(#e2b65c, #c0912f); color: #2b1d06; }
.map-wing { text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(244, 234, 211, .7); margin-bottom: -4px; }
.map-floor {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(244, 234, 211, .7);
  margin: 2px 0 -4px;
}
.map-floor::before, .map-floor::after { content: ''; flex: 1; height: 1px; background: rgba(244, 234, 211, .25); }
.dig-cat { background: var(--paper); color: var(--ink); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.dig-h { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; font-size: 18px; margin-bottom: 8px; }
.dig-h small { font-weight: 400; font-size: 13px; color: var(--muted); }
.dig-opt {
  min-height: 52px;
  padding: 8px 6px;
  border-radius: 12px;
  border: 2px solid var(--brass);
  background: #fff4d6;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 3px 0 #c39d58;
}
.dig-opt[data-kind="tip"] { border-color: #5b8fc7; background: #e6f0fb; box-shadow: 0 3px 0 #8fb2d8; }
.dig-opt:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.dig-opt:disabled { opacity: .4; }
.cc-tag.blue { border-color: #1f5f8b; color: #1f5f8b; }
.cc-front.tip { background: #f3f8fe; border-color: #b9d2ee; }
.tip-ico { font-size: 46px; line-height: 1; }
.tip-text { font-size: 20px !important; font-weight: 700; line-height: 1.35; }
.tip-nudge { font-size: 15px !important; color: var(--muted); }
.hint-reveal { font-size: 15px; background: #fff4d6; border-radius: 10px; padding: 8px 10px; text-align: left; }
.sheet .story p { margin: 0 0 .6em; font-size: 17px; }
