/* SpyLeman - There is a Spy Among Us
   Palette and layout. Animations prefer transform/opacity. */

:root {
  --mint: #d3c2dc;
  --peach: #e8c4d2;
  --lilac: #ddd2e0;
  --butter: #ebddbc;
  --sky: #d2cbe0;
  --rose: #e6c6d3;
  --ink: #2c2623;
  --ink-soft: #6e625a;
  --paper: #efe7dc;
  --card: #fcfaf6;
  --coral: #8a4f7a;
  --gold: #b8924f;
  --shadow: 0 6px 18px rgba(44, 38, 35, 0.12);
  --shadow-lift: 0 14px 30px rgba(44, 38, 35, 0.18);
  --radius: 18px;
  --font-head: "DM Serif Display", Georgia, "Times New Roman", serif;
  --font-brand: "Jost", "Futura", "Century Gothic", "Avenir Next", sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, Arial, sans-serif;
  --dur: 220ms;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 10% 6%, #f3dde6 0, transparent 38%),
    radial-gradient(circle at 92% 14%, #e1d5ec 0, transparent 38%),
    radial-gradient(circle at 50% 108%, #dcc6cf 0, transparent 46%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.45;
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after {
  animation-duration: 1ms !important;
  transition-duration: 1ms !important;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 400; letter-spacing: .01em; }
.btn, .tool, .chip, .tier-tab { font-family: var(--font-body); font-weight: 600; letter-spacing: .01em; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
code { background: var(--lilac); padding: 1px 6px; border-radius: 6px; }

.screen { max-width: 1560px; margin: 0 auto; padding: 16px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
button, .cell { touch-action: manipulation; }

/* ---------- buttons ---------- */
.btn {
  border: 0; cursor: pointer;
  background: var(--lilac); color: var(--ink);
  font-size: 1rem; font-weight: 600;
  padding: 10px 18px; border-radius: 999px;
  box-shadow: var(--shadow);
  transition: transform var(--dur) cubic-bezier(.34,1.56,.64,1), box-shadow var(--dur);
}
.btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: var(--shadow-lift); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn-mint { background: var(--mint); }
.btn-peach { background: var(--peach); }
.btn-rose { background: var(--rose); }
.btn-icon { width: 42px; height: 42px; padding: 0; font-size: 1.2rem; display: inline-grid; place-items: center; }

/* ---------- home ---------- */
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 0 8px; }
.title-wrap { display: flex; align-items: center; gap: 14px; }
.magnifier { width: 64px; height: 64px; border-radius: 16px; box-shadow: 0 4px 12px rgba(44, 38, 35, .22); }   /* static: no animation */
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-6px) rotate(6deg); } }
.game-title {
  margin: 0; font-family: var(--font-brand); font-size: clamp(1.7rem, 4.4vw, 2.6rem); font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink);
}
.subtitle { margin: 2px 0 0; color: var(--ink-soft); font-family: var(--font-brand); font-weight: 400; font-size: .74rem; letter-spacing: .32em; text-transform: uppercase; }
.head-actions { display: flex; gap: 10px; align-items: center; }

.tier-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 8px; }
.tier-tab {
  position: relative; flex: 0 1 auto; min-width: 118px; text-align: left; cursor: pointer;
  border: 2px solid transparent; background: var(--card); color: var(--ink); border-radius: 14px;
  padding: 6px 10px 8px; box-shadow: var(--shadow);
  transition: transform var(--dur) cubic-bezier(.34,1.56,.64,1), border-color var(--dur);
}
.tier-tab:hover { transform: translateY(-2px); }
.tier-tab.active { border-color: var(--ink); }
.tier-tab.locked { opacity: .55; filter: saturate(.4); }
.tier-tab .tt-name { font-weight: 600; font-size: .92rem; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tier-tab .tt-count { font-size: .72rem; color: var(--ink-soft); font-family: var(--font-body); font-weight: 600; white-space: nowrap; }
.tier-tab .tt-stars { display: none; }     /* total stars live in Records; keeps the tabs small */
.progress { height: 4px; border-radius: 999px; background: var(--lilac); overflow: hidden; margin-top: 5px; }
.progress > i { display: block; height: 100%; background: var(--tier-color, var(--mint)); border-radius: 999px; transform-origin: left; transition: transform 600ms cubic-bezier(.34,1.3,.64,1); }
.tier-badge {
  width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center;
  background: #e9e1d6; color: #bfb3a6; font-size: .9rem; transition: transform var(--dur), background var(--dur), color var(--dur);
}
.tier-badge { overflow: hidden; }
.tier-badge img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.45); transform-origin: 50% 30%; filter: grayscale(1); opacity: .38; transition: opacity var(--dur), filter var(--dur); }
.tier-badge.lit img { filter: none; opacity: 1; }
.tier-badge.lit { background: var(--gold); color: #5d4513; box-shadow: 0 0 0 4px rgba(184,146,79,.3); animation: badgepop 700ms cubic-bezier(.34,1.56,.64,1); }
@keyframes badgepop { 0% { transform: scale(0.3) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }

.tier-summary { color: var(--ink-soft); font-weight: 700; margin: 4px 2px 10px; }

/* daily case */
.daily {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; cursor: pointer; margin: 10px 0 4px;
  border: 2px solid transparent; border-radius: var(--radius); padding: 12px 16px; color: var(--ink);
  background: linear-gradient(120deg, var(--butter), var(--peach) 60%, var(--rose)); box-shadow: var(--shadow);
  transition: transform var(--dur) cubic-bezier(.34,1.56,.64,1), box-shadow var(--dur);
}
.daily:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.daily.done { background: linear-gradient(120deg, var(--mint), var(--sky)); }
.daily .d-icon { width: 40px; height: 40px; flex: 0 0 40px; }
.daily .d-text { flex: 1; min-width: 0; }
.daily .d-kicker { font-family: var(--font-body); font-weight: 800; font-size: .78rem; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); }
.daily .d-title { font-family: var(--font-head); font-weight: 600; font-size: 1.15rem; }
.daily .d-sub { font-family: var(--font-body); font-weight: 700; font-size: .85rem; color: var(--ink-soft); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.daily .d-streak { font-family: var(--font-head); font-weight: 700; font-size: 1rem; background: rgba(255,255,255,.7); border-radius: 999px; padding: 6px 12px; white-space: nowrap; }

/* records */
.records-card { max-width: 520px; width: 100%; }
.records .r-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 14px; }
.records .r-stat { background: var(--paper); border-radius: 14px; padding: 10px; text-align: center; }
.records .r-num { font-family: var(--font-head); font-weight: 700; font-size: 1.4rem; }
.records .r-lab { font-size: .74rem; color: var(--ink-soft); font-weight: 800; text-transform: uppercase; letter-spacing: .5px; }
.records table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.records th { text-align: left; color: var(--ink-soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; padding: 4px 6px; }
.records td { padding: 6px; border-top: 1px solid #ece4d9; font-weight: 700; }
.records td.r-time { font-variant-numeric: tabular-nums; text-align: right; }
.records .r-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; }

.puzzle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.pcard {
  position: relative; background: var(--card); color: var(--ink); border-radius: var(--radius); padding: 14px; cursor: pointer;
  box-shadow: var(--shadow); border: 2px solid transparent; text-align: left;
  display: flex; flex-direction: column; gap: 6px;
  transition: transform var(--dur) cubic-bezier(.34,1.56,.64,1), box-shadow var(--dur);
  font-family: var(--font-body);
}
.pcard:hover:not(.locked) { transform: translateY(-4px) rotate(-1deg); box-shadow: var(--shadow-lift); }
.pcard.locked { cursor: not-allowed; background: #f2ece4; color: #b0a396; }
.pcard .pc-top { display: flex; justify-content: space-between; align-items: center; }
.pcard .pc-theme { width: 32px; height: 32px; }
.pcard .pc-title { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; }
.pcard .pc-size { font-size: .85rem; color: var(--ink-soft); font-weight: 700; }
.pcard .pc-lock { position: absolute; right: 10px; bottom: 8px; font-size: 1rem; opacity: .55; line-height: 1; }
.pcard.solved { border-color: var(--mint); }
.stars { display: inline-flex; gap: 3px; }
.stars .st { width: 16px; height: 16px; opacity: .25; filter: grayscale(1); }
.stars .st.on { opacity: 1; filter: none; }
.stars.big .st { width: 36px; height: 36px; }
.stars.big .st.on { animation: starin 500ms cubic-bezier(.34,1.56,.64,1) both; }
.stars.big .st.on:nth-child(2) { animation-delay: 150ms; }
.stars.big .st.on:nth-child(3) { animation-delay: 300ms; }
@keyframes starin { from { transform: scale(0) rotate(-40deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }

/* ---------- play screen ---------- */
.top-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.play-title { margin: 0; font-size: 1.5rem; font-weight: 600; }
.chip { background: var(--butter); padding: 4px 12px; border-radius: 999px; font-weight: 600; font-size: .9rem; }
.spacer { flex: 1; }
.stat { font-weight: 800; background: var(--card); padding: 6px 12px; border-radius: 999px; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; }

.play-layout {
  display: grid; grid-template-columns: 290px 1fr 170px; gap: 16px; align-items: start;
}
.col-suspects { display: flex; flex-direction: column; gap: 10px; }
.general-box { background: var(--butter); border-radius: var(--radius); padding: 10px 14px; font-weight: 700; box-shadow: var(--shadow); }
.general-box p { margin: 4px 0; }
.suspect-list { display: flex; flex-direction: column; gap: 10px; }
.scard {
  position: relative; display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: start;
  background: var(--card); border-radius: var(--radius); padding: 10px; cursor: pointer;
  box-shadow: var(--shadow); border: 2px solid transparent;
  transition: transform var(--dur) cubic-bezier(.34,1.56,.64,1), box-shadow var(--dur), border-color var(--dur), opacity var(--dur);
  font-family: var(--font-body);
}
.scard:hover { transform: translateY(-2px); }
.scard.selected { transform: translateY(-4px) scale(1.02); border-color: var(--ink); box-shadow: 0 0 0 5px var(--sky), var(--shadow-lift); }
.scard.placed { opacity: .72; }
.scard.placed .portrait { outline: 3px solid var(--mint); }
.scard.broken { border-color: var(--coral); animation: wobble 500ms ease-in-out; }
.scard.victim { background: linear-gradient(135deg, #fff, #f0e9df); }
.scard .portrait { width: 56px; height: 56px; border-radius: 12px; background: var(--lilac); }
.scard .s-name { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: 6px; }
.scard .s-num { font-size: .7rem; background: var(--lilac); border-radius: 6px; padding: 0 6px; color: var(--ink-soft); font-family: var(--font-body); font-weight: 800; }
.scard .s-clue { margin: 2px 0 0; font-size: .92rem; }
.scard .s-clue b { color: #7b3f6e; }
.scard .s-dot { position: absolute; right: 10px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--mint); opacity: 0; transform: scale(0); transition: all var(--dur); }
.scard.placed .s-dot { opacity: 1; transform: scale(1); }

.bubble {
  position: relative; grid-column: 1 / -1; margin-top: 4px;
  background: var(--sky); border-radius: 14px; padding: 8px 12px; font-weight: 700; font-size: .9rem;
  box-shadow: var(--shadow); animation: popin 300ms cubic-bezier(.34,1.56,.64,1); transform-origin: top left;
}
.bubble::before { content: "\1F4A1  "; }
.bubble::after { content: ""; position: absolute; left: 24px; top: -8px; border: 8px solid transparent; border-bottom-color: var(--sky); border-top: 0; }
@keyframes popin { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* board */
.col-board { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; }
.board-wrap { width: 100%; display: flex; justify-content: center; }
.board { position: relative; border-radius: 14px; box-shadow: var(--shadow-lift); background: var(--card); overflow: visible; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.board.wobble { animation: wobble 600ms ease-in-out; }
@keyframes wobble { 0%,100% { transform: translateX(0) rotate(0); } 20% { transform: translateX(-8px) rotate(-1deg); } 40% { transform: translateX(7px) rotate(1deg); } 60% { transform: translateX(-5px) rotate(-.6deg); } 80% { transform: translateX(3px) rotate(.4deg); } }
.board-canvas { display: block; border-radius: 14px; }
.cells { position: absolute; left: 0; top: 0; display: grid; }
.cell { position: relative; cursor: pointer; }
.cell:hover::before { content: ""; position: absolute; inset: 3px; border-radius: 8px; background: rgba(255,255,255,.35); box-shadow: inset 0 0 0 2px rgba(44, 38, 35,.35); }
.cell.blocked { cursor: default; }
.cell.blocked:hover::before { display: none; }
.cell.pulse::after { content: ""; position: absolute; inset: 2px; border-radius: 10px; box-shadow: 0 0 0 3px var(--gold); animation: pulse 900ms ease-in-out 3; }
@keyframes pulse { 0%,100% { opacity: .3; transform: scale(.9); } 50% { opacity: 1; transform: scale(1); } }
.cell.shake { animation: shake 300ms ease-in-out; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.cell .piece { position: absolute; inset: 7%; width: 86%; height: 86%; pointer-events: none; border-radius: 22%; box-shadow: 0 2px 6px rgba(44, 38, 35,.28); }
.cell .piece.drop { animation: drop 450ms cubic-bezier(.34,1.56,.64,1); }
@keyframes drop { 0% { transform: translateY(-40%) scale(1.3); opacity: 0; } 60% { transform: translateY(4%) scale(.95); opacity: 1; } 100% { transform: translateY(0) scale(1); } }
.cell .xmark { position: absolute; inset: 3%; width: 94%; height: 94%; pointer-events: none; opacity: .8; }
.cell .xmark.stamp-in { animation: stamp 260ms cubic-bezier(.2,.9,.3,1.2); }
@keyframes stamp { 0% { transform: scale(1.6) rotate(-14deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: .85; } }
.cell .note { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; justify-content: flex-start; flex-wrap: wrap-reverse; gap: 0 .14em; padding: 5% 7%; font-size: clamp(9px, calc(var(--cell, 60px) * .2), 15px); line-height: 1.1; letter-spacing: 0; font-weight: 800; color: #6a3560; opacity: .9; pointer-events: none; font-family: var(--font-body); text-shadow: 0 0 2px rgba(250, 245, 238, .9); }
.cell.hi { background: rgba(123,63,110,.09); box-shadow: inset 0 0 0 2px rgba(123,63,110,.38); }
.cell.holding::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; border: 3px solid var(--ink); opacity: .55; animation: holdring 450ms linear forwards; pointer-events: none; }
@keyframes holdring { from { transform: scale(.2); opacity: .15; } to { transform: scale(1); opacity: .7; } }
.cell .ring { position: absolute; inset: 4%; border-radius: 50%; border: 3px solid var(--ink); pointer-events: none; }
.fx-canvas { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 4; }
.labels { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; }
.rlabel {
  position: absolute; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(255,255,255,.9); color: var(--ink); border-radius: 999px; padding: 1px 6px;
  font-family: var(--font-body); font-weight: 700; line-height: 1.4; box-shadow: 0 1px 0 rgba(44, 38, 35,.15);
}
.stamp {
  position: absolute; left: 50%; top: 50%; z-index: 6;
  transform: translate(-50%, -50%) rotate(-8deg);
  font-family: var(--font-head); font-weight: 700; font-size: clamp(1.6rem, 6vw, 3rem); letter-spacing: 3px;
  color: #7b3f6e; border: 6px solid #7b3f6e; border-radius: 14px; padding: 6px 18px; background: rgba(255,255,255,.75);
  animation: stampbig 500ms cubic-bezier(.2,.9,.3,1.2) both;
}
@keyframes stampbig { 0% { transform: translate(-50%,-50%) rotate(-30deg) scale(2.2); opacity: 0; } 100% { transform: translate(-50%,-50%) rotate(-8deg) scale(1); opacity: 1; } }

.feedback {
  max-width: 560px; background: var(--rose); border-radius: var(--radius); padding: 10px 16px; font-weight: 700;
  box-shadow: var(--shadow); animation: popin 300ms cubic-bezier(.34,1.56,.64,1);
}
.feedback.good { background: var(--mint); }
.feedback.info { background: var(--sky); }

/* tools */
.tools { display: flex; flex-direction: column; gap: 8px; }
.tool {
  position: relative; overflow: hidden; border: 0; cursor: pointer; text-align: left;
  background: var(--card); color: var(--ink); font-size: .98rem; font-weight: 600;
  padding: 11px 14px; border-radius: 14px; box-shadow: var(--shadow);
  transition: transform var(--dur) cubic-bezier(.34,1.56,.64,1), background var(--dur);
}
.tool:hover:not(:disabled) { transform: translateY(-2px) scale(1.02); }
.tool:disabled { opacity: .5; cursor: not-allowed; }
.tool.on { background: var(--sky); box-shadow: inset 0 0 0 2px var(--ink); }
.tool-primary { background: var(--mint); font-size: 1.05rem; }
.tool { display: flex; align-items: center; gap: 8px; }
.tool .ico { width: 18px; height: 18px; flex: 0 0 auto; position: relative; }
.tool .key { margin: 0 0 0 auto; }
.toolbar { display: contents; }
/* Submit when every suspect is placed: rich plum, a light sweep and a soft pulsing glow */
.tool-primary:not(:disabled) {
  background: linear-gradient(135deg, #a05c8e 0%, #7b3f6e 55%, #5e2c54 100%); color: #fff; font-weight: 700; letter-spacing: .05em;
  text-shadow: 0 1px 0 rgba(0,0,0,.25);
  box-shadow: 0 8px 22px rgba(123,63,110,.5), 0 0 0 2px rgba(255,255,255,.55), inset 0 1px 0 rgba(255,255,255,.4);
  animation: submitPop 520ms cubic-bezier(.34,1.56,.64,1), submitGlow 2.2s ease-in-out 520ms infinite;
}
.tool-primary:not(:disabled)::after {
  content: ""; position: absolute; top: -30%; left: -70%; width: 38%; height: 160%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.7), transparent); transform: skewX(-22deg);
  animation: submitShine 2.8s ease-in-out 600ms infinite;
}
.tool-primary:not(:disabled):hover { transform: translateY(-2px) scale(1.04); }
@keyframes submitPop { 0% { transform: scale(.92); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes submitGlow {
  0%, 100% { box-shadow: 0 8px 22px rgba(123,63,110,.45), 0 0 0 2px rgba(255,255,255,.55), inset 0 1px 0 rgba(255,255,255,.4); }
  50% { box-shadow: 0 10px 30px rgba(160,92,142,.75), 0 0 0 4px rgba(184,146,79,.55), inset 0 1px 0 rgba(255,255,255,.5); }
}
@keyframes submitShine { 0% { left: -70%; } 55%, 100% { left: 140%; } }
@media (prefers-reduced-motion: reduce) { .tool-primary:not(:disabled), .tool-primary:not(:disabled)::after { animation: none !important; } }
body.reduce-motion .tool-primary:not(:disabled), body.reduce-motion .tool-primary:not(:disabled)::after { animation: none !important; }
.tool-ghost { background: transparent; box-shadow: none; color: var(--ink-soft); }
.tool .key { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--lilac); font-size: .75rem; margin-right: 6px; font-family: var(--font-body); font-weight: 800; }
.tool .label { position: relative; }
.tool-hold { touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.tool-hold .hold-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--rose); transform: scaleX(0); transform-origin: left; }
.tool-hold.holding .hold-fill { transition: transform 700ms linear; transform: scaleX(1); }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(44, 38, 35,.35); padding: 16px; }
.modal-card { background: var(--card); border-radius: 24px; padding: 24px; max-width: 460px; width: 100%; box-shadow: var(--shadow-lift); animation: popin 350ms cubic-bezier(.34,1.56,.64,1); text-align: center; }
.modal-card h3 { margin: 0 0 10px; font-size: 1.6rem; font-weight: 600; }
.modal-actions { display: flex; justify-content: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.how-list { text-align: left; padding-left: 20px; margin: 0; }
.how-list li { margin: 6px 0; }
.how-list b { color: #7b3f6e; }
.setting { display: flex; align-items: center; gap: 10px; justify-content: flex-start; font-weight: 700; margin: 10px 0; }
.setting input { width: 20px; height: 20px; accent-color: #7b3f6e; }
.result-headline { font-size: 2rem !important; }
.result-line { font-size: 1.15rem; font-weight: 700; margin: 4px 0 10px; }
.result-badge { display: flex; justify-content: center; gap: 8px; margin-bottom: 6px; }
.result-badge img { width: 64px; height: 64px; border-radius: 14px; }
.result-badge img.m { outline: 4px solid var(--gold); }
.tier-celebrate { margin-top: 12px; padding: 10px; background: var(--butter); border-radius: 14px; font-weight: 800; animation: popin 500ms cubic-bezier(.34,1.56,.64,1); }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; image-rendering: auto; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; box-shadow: var(--shadow-lift); animation: popin 300ms cubic-bezier(.34,1.56,.64,1); }

/* ---------- responsive ---------- */
@media (max-width: 980px) and (orientation: portrait), (max-width: 980px) and (min-height: 641px) {
  .play-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  /* single column: the board and the tool strip stick to the top while the suspect cards scroll beneath */
  /* the header (back, title, time, sound) stays put while the page scrolls; the board and tools stick right under it */
  .top-bar { position: sticky; top: 0; z-index: 10; margin: 0 -10px; padding: 6px 10px 6px; background: rgba(239, 231, 220, .95); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
  .col-board { order: -2; position: sticky; top: var(--topbar-h, 52px); z-index: 8; padding: 6px 0 4px; background: var(--paper); border-radius: 0 0 18px 18px; }
  .col-tools { order: -1; position: sticky; top: calc(var(--topbar-h, 52px) + var(--board-stick, 320px)); z-index: 7; background: var(--paper); padding-bottom: 6px; }
  /* under the board: just Submit. The other tools live in an app-style bar fixed to the bottom of the screen. */
  .tools { display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; }
  .tools .tool-primary { min-height: 46px; font-size: 1rem; justify-content: center; text-align: center; }
  .tools .tool-ghost { display: none; }
  .toolbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: rgba(250, 245, 238, .96); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid rgba(44, 38, 35, .14); box-shadow: 0 -6px 18px rgba(44, 38, 35, .08); }
  .toolbar .tool { flex-direction: column; gap: 3px; min-height: 54px; padding: 6px 2px 5px; border-radius: 12px; background: transparent; box-shadow: none; font-size: .66rem; line-height: 1.1; letter-spacing: 0; color: var(--ink-soft); text-align: center; white-space: normal; }
  .toolbar .tool .ico { width: 24px; height: 24px; }
  .toolbar .tool .key { display: none; }
  .toolbar .tool:hover:not(:disabled) { transform: none; }
  .toolbar .tool.on { background: rgba(123, 63, 110, .14); color: #7b3f6e; box-shadow: inset 0 0 0 1.5px #7b3f6e; }
  .toolbar .tool:active:not(:disabled) { background: rgba(123, 63, 110, .2); }
  .toolbar .tool-hold .hold-fill { background: rgba(123, 63, 110, .25); }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .col-suspects { flex-direction: column; position: relative; z-index: 2; }
  .feedback { font-size: .9rem; padding: 8px 12px; }
}
@media (max-width: 520px) {
  .screen { padding: 10px; }
  .top-bar { gap: 8px; margin-bottom: 6px; }
  .top-bar .play-title { font-size: 1.15rem; }
  .stat { padding: 4px 10px; font-size: .9rem; }
  .scard { grid-template-columns: 48px 1fr; padding: 8px; }
  .scard .portrait { width: 48px; height: 48px; }
  .scard .s-clue { font-size: .88rem; }
  .records .r-grid { gap: 6px; }
  .daily .d-streak { display: none; }
}

/* ---------- full-screen play layout (suspects | board | tools) ---------- */
#play.screen { max-width: none; }
.play-layout > * { min-width: 0; }
@media (min-width: 981px), (orientation: landscape) and (max-height: 640px) {
  #play.screen { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; padding: 10px 16px 12px; }
  .top-bar { margin-bottom: 8px; flex-wrap: nowrap; flex: 0 0 auto; }
  .play-layout { flex: 1 1 auto; min-height: 0; grid-template-columns: clamp(280px, 35vw, 600px) minmax(0, 1fr) clamp(130px, 11vw, 190px); gap: 18px; align-items: stretch; }
  .col-suspects { min-height: 0; overflow-y: auto; padding: 6px 8px 10px 4px; scrollbar-width: thin; }
  .suspect-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 12px; align-content: start; }
  .col-board { min-height: 0; justify-content: center; }
  .board-wrap { flex: 1 1 auto; min-height: 0; align-items: center; }
  .col-tools { min-height: 0; overflow-y: auto; padding: 6px 4px; }
  .feedback { flex: 0 0 auto; }
}
@media (max-width: 980px) and (orientation: portrait), (max-width: 980px) and (min-height: 641px) {
  #play.screen { padding: 8px 10px calc(92px + env(safe-area-inset-bottom)); }
}
/* phone turned sideways: slimmer side columns, compact tools */
@media (max-width: 980px) and (orientation: landscape) and (max-height: 640px) {
  #play.screen { padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left)); }
  .top-bar { margin-bottom: 4px; }
  .play-title { font-size: 1.05rem; }
  .chip { display: none; }
  .play-layout { grid-template-columns: minmax(190px, 31vw) minmax(0, 1fr) 104px; gap: 10px; }
  .suspect-list { grid-template-columns: 1fr; gap: 8px; }
  .scard { padding: 6px; grid-template-columns: 40px 1fr; }
  .scard .portrait { width: 40px; height: 40px; }
  .scard .s-clue { font-size: .8rem; }
  .play-layout { grid-template-columns: minmax(190px, 31vw) minmax(0, 1fr) 118px; }
  .tools { gap: 5px; }
  .tool { padding: 7px 8px; font-size: .78rem; line-height: 1.2; }
  .tool .key { display: none; }
  .tool-primary { order: -1; }          /* Submit stays at the top of the column */
  .feedback { display: none; }
}
@media (max-width: 520px) {
  /* phones: cards are two across; portrait + name on one row, the clue underneath */
  .suspect-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .scard { grid-template-columns: 38px 1fr; gap: 4px 8px; align-items: center; padding: 8px; }
  .scard { align-content: start; }
  .scard > div { display: contents; }
  .scard .portrait { width: 38px; height: 38px; max-width: none; aspect-ratio: auto; grid-row: 1; grid-column: 1; }
  .scard .s-name { grid-row: 1; grid-column: 2; font-size: .98rem; }
  .scard .s-clue { grid-column: 1 / -1; margin: 0; font-size: .86rem; line-height: 1.35; }
  .scard .s-dot { right: 8px; top: 8px; }
  .toast { width: max-content; max-width: calc(100vw - 28px); text-align: center; border-radius: 16px; padding: 10px 16px; bottom: 14px; font-size: .9rem; }
  .top-bar { flex-wrap: nowrap; gap: 6px; }
  .play-title { flex: 1 1 auto; min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.05rem; }
  .top-bar .spacer { display: none; }
  .top-bar .btn-icon { width: 38px; height: 38px; flex: 0 0 auto; }
  .top-bar .stat { flex: 0 0 auto; padding: 4px 8px; font-size: .85rem; }
  .chip { display: none; }
  #play.screen { padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); }
}
@media (hover: none) {
  .scard:hover, .pcard:hover:not(.locked), .tool:hover:not(:disabled), .btn:hover, .tier-tab:hover, .daily:hover { transform: none; }
}

/* notes: size by letter count, and tappable letters in Remove note mode */
.cells.removing .cell .nl { pointer-events: auto; cursor: pointer; border-radius: 8px; padding: 0 .08em; outline: 2px dashed rgba(194,65,90,.55); outline-offset: 1px; }
.cells.removing .cell .nl:hover { background: rgba(194,65,90,.18); text-decoration: line-through; }
.cells.removing .cell { cursor: default; }

/* footer + credits */
.site-footer { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; margin: 28px 0 8px; padding: 14px 0 6px; color: var(--ink-soft); font-size: .88rem; border-top: 1px dashed rgba(44, 38, 35,.18); }
.link-btn { background: none; border: 0; padding: 2px 4px; font: inherit; color: #7b3f6e; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { color: var(--ink); }
.credits-list { text-align: left; margin: 8px 0 4px; padding-left: 18px; font-size: .95rem; line-height: 1.45; }
.credits-list li { margin: 8px 0; }
.credits-list a { color: #7b3f6e; }

.tier-summary.captured { color: var(--coral); }

/* account */
.avatar-mini { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.acct-user { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.gsi-slot { min-height: 44px; margin: 12px 0; display: flex; justify-content: center; }
.gsi-head { display: inline-flex; align-items: center; min-height: 40px; }
.gsi-head.hidden { display: none; }

/* pulse on a placed suspect when their card or square is tapped */
.cell .piece.find { animation: findPulse 900ms ease-out; }
@keyframes findPulse { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(123, 63, 110, .6); } 35% { transform: scale(1.14); box-shadow: 0 0 0 8px rgba(123, 63, 110, .25); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(123, 63, 110, 0); } }
@media (prefers-reduced-motion: reduce) { .cell .piece.find { animation: none; outline: 3px solid #7b3f6e; } }

/* daily mission: a slim strip under the missions (header, levels and missions come first) */
.daily { margin: 18px 0 4px; padding: 8px 14px; gap: 10px; border-radius: 14px; box-shadow: none; background: rgba(255, 255, 255, .55); border: 1px solid rgba(123, 63, 110, .22); }
.daily:hover { transform: none; background: rgba(255, 255, 255, .85); border-color: rgba(123, 63, 110, .5); }
.daily.done { background: rgba(255, 255, 255, .4); }
.daily .d-icon { width: 28px; height: 28px; flex: 0 0 28px; }
.daily .d-text { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.daily .d-kicker { font-size: .72rem; color: #7b3f6e; }
.daily .d-title { font-size: 1rem; }
.daily .d-sub { font-size: .8rem; font-weight: 600; }
.daily .d-streak { font-size: .85rem; padding: 3px 10px; background: rgba(123, 63, 110, .1); }
.daily::after { content: '\203A'; font-size: 1.4rem; line-height: 1; color: #7b3f6e; margin-left: 2px; }
@media (max-width: 520px) { .daily .d-streak { display: inline-block; } .daily .d-sub { display: none; } }

/* Remove-note mode: the small corner letters become comfortable tap targets */
.cells.removing .cell .note { font-size: clamp(13px, calc(var(--cell, 60px) * .3), 22px); gap: 0 .1em; padding: 4% 5%; }
.cells.removing .cell .nl { padding: .08em .16em; }
