@font-face { font-family: "Andika"; src: url("fonts/Andika-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Andika"; src: url("fonts/Andika-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --bg: #FFF8EE;
  --card: #FFFFFF;
  --ink: #2B1E16;
  --muted: #7A6A5E;
  --line: #E9DCCD;
  --pink: #F7A8C4;
  --pink-strong: #E2557F;
  --brown: #6B4226;
  --ok: #2F9E5B;
  --bad: #D64545;
  --hint: #FFC93C;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Andika", system-ui, sans-serif; font-size: 16px; line-height: 1.4; }
button { font: inherit; color: inherit; cursor: pointer; }
#app { max-width: 620px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }

/* barra in alto */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 8px;
  padding: 10px 0 8px; border-bottom: 1px solid var(--line); }
.top .grow { flex: 1; min-width: 0; }
.top .meta { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .case { font-weight: 700; font-size: 17px; }
.btn { border: 1.5px solid var(--ink); background: var(--card); border-radius: 999px; padding: 7px 14px; font-weight: 700;
  font-size: 15px; min-height: 40px; }
.btn.icon { padding: 0; width: 40px; display: inline-grid; place-items: center; }
a.btn { color: var(--ink); text-decoration: none; }
a.btn.primary { color: #fff; }
.btn.primary { background: var(--pink-strong); border-color: var(--pink-strong); color: #fff; }
.btn.ghost { border-color: var(--line); }
.btn:disabled { opacity: .4; }
.timer { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }

/* home: testata con il titolo VERO della cover (ritaglio, build.py) */
.hero { position: relative; margin: 16px 0 0; border-radius: 22px; overflow: hidden; border: 3px solid var(--ink);
  background: #E8327F; box-shadow: 0 6px 0 var(--ink); }
.hero-title { margin: 0; line-height: 0; }
.hero-title img { width: 100%; height: auto; display: block; }
.hero-plain { margin: 0; padding: 26px 0; text-align: center; font-size: 44px; color: #FFE53B; -webkit-text-stroke: 2px var(--ink); }
.hero-doku { position: absolute; right: -6px; bottom: -14px; width: 26%; max-width: 130px; transform: rotate(-8deg);
  filter: drop-shadow(0 3px 0 rgba(0,0,0,.25)); }
.hero-doku img { width: 100%; height: auto; display: block; }
.intro { text-align: center; padding: 18px 0 4px; }
.intro .tag { margin: 0 0 12px; font-size: 17px; line-height: 1.35; }
.pills { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.pill { background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: 14px; color: var(--muted); }
.pill b { color: var(--ink); font-size: 16px; }
.intro .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.btn.big { min-height: 48px; padding: 8px 20px; font-size: 16px; }

/* il libro */
.book { background: #FFF1C1; border: 3px solid var(--ink); border-radius: 22px; padding: 16px 16px 14px; margin: 22px 0 6px;
  box-shadow: 0 6px 0 var(--ink); }
.book-row { display: flex; align-items: center; gap: 10px; }
.book-txt { flex: 1 1 auto; min-width: 0; position: relative; padding-bottom: 46px; }
.book .from { margin: 0; font-size: 16px; line-height: 1.3; }
.book-name { margin: 6px 0 0; font-size: 26px; font-weight: 700; line-height: 1; letter-spacing: .5px; }
.book-name span { display: block; font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-top: 4px; }
.book .arrow { position: absolute; right: -6px; bottom: 0; width: 86px; height: 50px; }
.book-cover { flex: none; width: 40%; max-width: 170px; transform: rotate(4deg); }
.book-cover img { width: 100%; height: auto; display: block; border-radius: 6px; border: 2px solid var(--ink);
  box-shadow: 4px 6px 0 rgba(43,30,22,.35); }
.book-note { margin: 12px 0 10px; font-size: 13.5px; color: var(--muted); }
.book-cta { display: flex; gap: 8px; flex-wrap: wrap; }
.book-cta .btn { flex: 1 1 auto; text-align: center; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.soon { border-style: dashed; color: var(--muted); background: transparent; cursor: default; }

/* invito alla recensione nel «Case closed!» */
.ask { background: #FFF1C1; border-radius: 14px; padding: 10px 12px 8px; margin: 10px 0 0; }
.ask p { margin: 0 0 8px; }
.ask .btn { text-decoration: none; display: inline-flex; align-items: center; }
.ask .ask-note { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.pack { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); margin: 12px 0; padding: 0 12px; }
.pack summary { cursor: pointer; padding: 14px 2px; font-size: 18px; list-style-position: inside; }
.pack summary span { color: var(--muted); font-size: 14px; margin-left: 4px; }
.pack[open] { padding-bottom: 12px; }
.pack .part h2 { margin-top: 8px; }
.part h2 { font-size: 18px; margin: 22px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.part h2 small { color: var(--muted); font-weight: 400; font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.tile { background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 8px 4px 6px; text-align: center;
  min-height: 64px; position: relative; }
.tile b { display: block; font-size: 18px; }
.tile span { font-size: 11px; color: var(--muted); }
.tile.done { border-color: var(--ok); background: #EFFAF3; }
.tile.done::after { content: "✓"; position: absolute; top: 2px; right: 6px; color: var(--ok); font-weight: 700; font-size: 13px; }
.tile.started { border-color: var(--pink); }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }

/* caso */
.story h1 { font-size: 22px; margin: 12px 0 2px; line-height: 1.2; }
.story p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.board-wrap { margin: 12px 0 6px; }
svg.board { width: 100%; height: auto; display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
svg.board .cell { cursor: pointer; }
svg.board text { font-family: "Andika", system-ui, sans-serif; }
.status { min-height: 22px; font-size: 14px; color: var(--muted); text-align: center; }
.status b { color: var(--ink); }

.tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; margin: 8px 0 4px; }
.sus { background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: 6px 2px 5px; text-align: center; }
.sus img { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid var(--ink); background: #fff; display: block; margin: 0 auto; }
.sus .nm { font-weight: 700; font-size: 14px; display: block; margin-top: 2px; }
.sus .rl { font-size: 11px; color: var(--muted); display: block; line-height: 1.15; min-height: 25px; }
.sus .at { font-size: 11px; font-weight: 700; color: var(--brown); }
.sus.sel { border-color: var(--pink-strong); background: #FFEAF1; box-shadow: 0 0 0 2px var(--pink-strong) inset; }
.sus.placed img { opacity: .55; }
.sus.bad { border-color: var(--bad); }

.actions { display: flex; gap: 6px; justify-content: space-between; margin: 10px 0; flex-wrap: wrap; }
.actions .btn { flex: 1 1 auto; }

.clues { list-style: none; padding: 0; margin: 6px 0 0; counter-reset: c; }
.clues li { counter-increment: c; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px 9px 40px;
  margin-bottom: 6px; position: relative; cursor: pointer; }
.clues li::before { content: counter(c); position: absolute; left: 10px; top: 9px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; display: grid; place-items: center; }
.clues li.done { color: var(--muted); text-decoration: line-through; background: transparent; }
.clues li.done::before { background: var(--muted); }
.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 4px; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 26px; height: 26px; display: inline-grid; place-items: center; background: #fff; border: 1.5px solid var(--ink); }
.legend i.sq { border-radius: 5px; } .legend i.ci { border-radius: 50%; }
.legend i img { width: 20px; height: 20px; }
.legend i.doku { border: none; background: transparent; }
.legend i.doku img { width: 26px; height: 26px; }
.note { font-size: 12.5px; color: var(--muted); margin-top: 6px; text-align: center; }
.tips { font-size: 13px; color: var(--muted); margin: 4px 0 0; }

/* modale */
.modal-bg { position: fixed; inset: 0; background: rgba(43,30,22,.45); z-index: 20; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--card); border-radius: 20px; padding: 22px 20px 18px; max-width: 420px; width: 100%; text-align: center;
  max-height: calc(100vh - 32px); overflow: auto; }
.modal h2 { margin: 6px 0 4px; font-size: 26px; }
.modal .face { width: 96px; height: 96px; border-radius: 50%; border: 2px solid var(--ink); }
.modal .doku { width: 80px; height: 80px; }
.modal .verdict { font-style: italic; margin: 10px 0; }
.modal .row { display: flex; gap: 8px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.modal.how { text-align: left; }
.modal.how ul, .modal.how ol { padding-left: 20px; }
.modal.how li { margin-bottom: 4px; }

/* foglio del How to Play: testata e bottone fissi, solo il testo scorre (dentro, mai la pagina sotto) */
html.noscroll, html.noscroll body { overflow: hidden; }
.modal.sheet { display: flex; flex-direction: column; padding: 0; overflow: hidden;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 10px 20px;
  border-bottom: 1px solid var(--line); flex: none; }
.sheet-top h2 { margin: 0; font-size: 22px; }
.sheet-top .btn.icon { width: 44px; min-height: 44px; font-size: 18px; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 6px 20px 14px; touch-action: pan-y; }
.sheet-foot { flex: none; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet-foot .btn { width: 100%; min-height: 50px; font-size: 17px; }
@media (max-width: 600px) {
  /* iPhone (11/11/2026): il foglio sta CENTRATO e alto quanto lo schermo PIU' PICCOLO (svh = barre del browser
     visibili), cosi' «Got it» non finisce mai sotto la barra di Brave/Safari */
  .modal-bg.sheet-bg { padding: 12px; place-items: center stretch; }
  .modal.sheet { max-width: none; border-radius: 20px; max-height: calc(100vh - 110px); max-height: calc(100svh - 40px); }
}

#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(40px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; opacity: 0; transition: .2s;
  pointer-events: none; z-index: 30; max-width: calc(100% - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes pulse { 0%,100% { opacity: .95; } 50% { opacity: .35; } }
.hintcell { animation: pulse 1.1s ease-in-out infinite; }
.sec.center { text-align: center; }

/* animazioni della home (Andrea 10/11/2026: freccia animata, «animare qualcosa in quella schermata»);
   ferme per chi ha chiesto meno movimento al telefono */
@media (prefers-reduced-motion: no-preference) {
  .book .arrow .arrow-line { stroke-dasharray: 100; stroke-dashoffset: 100; animation: freccia-linea 3.2s ease-in-out infinite; }
  .book .arrow .arrow-head { opacity: 0; animation: freccia-punta 3.2s ease-in-out infinite; }
  .book .arrow { animation: freccia-spinta 3.2s ease-in-out infinite; }
  .book-cover { animation: libro-ondeggia 4s ease-in-out infinite; }
  .hero-title img { animation: titolo-respira 5s ease-in-out infinite; transform-origin: 50% 55%; }
  .btn.pulse { animation: bottone-pulsa 2.4s ease-in-out infinite; }
}
@keyframes freccia-linea { 0% { stroke-dashoffset: 100; opacity: 1; } 38% { stroke-dashoffset: 0; } 85% { stroke-dashoffset: 0; opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@keyframes freccia-punta { 0%, 34% { opacity: 0; } 42%, 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes freccia-spinta { 0%, 40% { transform: translate(0, 0); } 55% { transform: translate(6px, -1px); } 70%, 100% { transform: translate(0, 0); } }
@keyframes libro-ondeggia { 0%, 100% { transform: rotate(4deg) translateY(0); } 50% { transform: rotate(1.5deg) translateY(-7px); } }
@keyframes titolo-respira { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes bottone-pulsa { 0%, 100% { box-shadow: 0 0 0 0 rgba(226,85,127,.45); } 60% { box-shadow: 0 0 0 12px rgba(226,85,127,0); } }

/* testata: DOKU piccolo + scritta (sostituisce la fascia ritagliata dalla cover) */
.hero-top { text-align: center; padding: 22px 0 0; }
.hero-top .doku-logo { width: 92px; height: 92px; display: block; margin: 0 auto; }
.hero-top h1 { font-size: 42px; letter-spacing: 1px; margin: 4px 0 0; line-height: 1; }
@media (prefers-reduced-motion: no-preference) {
  .hero-top .doku-logo { animation: doku-saltella 2.6s ease-in-out infinite; transform-origin: 50% 100%; }
}
@keyframes doku-saltella { 0%, 60%, 100% { transform: translateY(0) scale(1, 1); } 70% { transform: translateY(0) scale(1.08, .9); }
  80% { transform: translateY(-14px) scale(.95, 1.06); } 90% { transform: translateY(0) scale(1.05, .95); } }
.pack.hardcore { border-color: var(--pink-strong); background: #FFF0F5; }
.book-review { margin-top: 14px; padding-top: 12px; border-top: 2px dashed rgba(43,30,22,.25); text-align: center; }
.book-review p { margin: 0 0 8px; font-weight: 700; font-size: 17px; }
.book-review .btn { width: 100%; display: inline-flex; align-items: center; justify-content: center; }
.book-note { text-align: center; }
.buy-lbl { margin: 0 0 8px; text-align: center; font-weight: 700; font-size: 16px; width: 100%; }
.flags { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; }
.btn.flag { padding: 6px 4px; min-height: 48px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1.1; gap: 2px; text-decoration: none; }
.btn.flag .fl { font-size: 24px; line-height: 1; }
.btn.flag.soon { opacity: .55; }
.hero-top { position: relative; }
.hero-top .snd { position: absolute; top: 14px; right: 0; }
.btn.snd { font-size: 18px; }
/* DOKU toccabile nella testata, con nuvoletta */
.doku-tap { position: relative; display: block; margin: 0 auto; padding: 0; border: 0; background: none; cursor: pointer; width: 92px; }
.doku-tap .bubble { position: absolute; right: 86px; top: -2px; white-space: nowrap; background: #fff; border: 2px solid var(--ink);
  border-radius: 14px; padding: 5px 10px; font-weight: 700; font-size: 14px; opacity: 0; transform: scale(.6) translateY(6px);
  transform-origin: 100% 100%; transition: opacity .15s, transform .15s; pointer-events: none; }
.doku-tap .bubble::after { content: ""; position: absolute; right: -8px; bottom: 6px; border: 7px solid transparent;
  border-left-color: var(--ink); border-right: 0; }
.doku-tap.talk .bubble { opacity: 1; transform: scale(1) translateY(0); }
.doku-tap.squish .doku-logo { animation: doku-splat .45s ease-out; }
@keyframes doku-splat { 0% { transform: scale(1, 1); } 25% { transform: scale(1.3, .6); } 55% { transform: scale(.9, 1.12); } 100% { transform: scale(1, 1); } }
/* freccia piu' bassa, staccata dal sottotitolo (Andrea 10/11/2026: «troppo attaccata alla parola mystery») */
.book-txt { padding-bottom: 50px; }
.book .arrow { bottom: 0; right: -10px; width: 92px; }
/* DOKU che cambia forma, nello spazio a sinistra della freccia */
.doku-cycle { position: absolute; left: 0; bottom: -4px; width: 58px; height: 58px; padding: 0; border: 0; background: none; cursor: pointer; }
.doku-cycle img { width: 100%; height: 100%; display: block; }
.doku-cycle.pop { animation: doku-pop .35s ease-out; }
@media (prefers-reduced-motion: no-preference) {
  .doku-cycle:not(.tried) img { animation: doku-invito 2.2s ease-in-out infinite; }
}
@keyframes doku-invito { 0%, 70%, 100% { transform: rotate(0); } 78% { transform: rotate(-10deg); } 86% { transform: rotate(9deg); } 93% { transform: rotate(-4deg); } }
.doku-say { position: relative; display: inline-block; margin: 12px 0 0; background: #fff; border: 2px solid var(--ink);
  border-radius: 14px; padding: 6px 12px; font-weight: 700; font-size: 14px; }
.doku-say::before { content: ""; position: absolute; left: 18px; top: -9px; border: 8px solid transparent; border-top: 0;
  border-bottom-color: var(--ink); }
.doku-say::after { content: ""; position: absolute; left: 20px; top: -6px; border: 6px solid transparent; border-top: 0;
  border-bottom-color: #fff; }
html.noscroll .doku-cycle img { animation-play-state: paused !important; }
@keyframes doku-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* mentre una finestra e' aperta le animazioni della pagina sotto si fermano (scorrimento fluido su telefono) */
html.noscroll .book-cover, html.noscroll .book .arrow, html.noscroll .book .arrow path, html.noscroll .doku-logo,
html.noscroll .btn.pulse, html.noscroll .hero-title img { animation-play-state: paused !important; }
.modal-bg { overscroll-behavior: contain; }
/* filtro per difficolta' */
.filters { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 22px 0 4px; }
.chip { border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: 14px; min-height: 38px; }
.chip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
/* interruttori MUSIC / SOUND FX (sostituiscono il vecchio 🔊) */
.snd-toggles { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.hero-top .snd-toggles { position: absolute; top: 12px; right: 0; }
.tog { border: 1.5px solid var(--ink); background: var(--card); border-radius: 999px; padding: 5px 10px; font-weight: 700;
  font-size: 11.5px; letter-spacing: .04em; min-height: 32px; min-width: 104px; }
.tog.off { border-color: var(--line); color: var(--muted); background: transparent; }
.case-sound { display: flex; justify-content: center; margin: 22px 0 6px; }
.case-sound .snd-toggles { flex-direction: row; align-items: center; }
/* interruttori audio nella barra del caso, accanto a «Case N» (Andrea 11/11/2026: in fondo nessuno li vedeva) */
.bar-snd .snd-toggles { gap: 3px; }
.bar-snd .tog { font-size: 9.5px; min-height: 22px; min-width: 0; padding: 2px 7px; letter-spacing: .02em; white-space: nowrap; }
.top .timer { min-width: 34px; text-align: right; }
.story .story-meta { margin: 2px 0 0; font-size: 14px; font-weight: 700; color: var(--muted); }
/* contatore della community */
.community { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; margin: -4px 0 14px; font-size: 13.5px; color: var(--muted); }
.community[hidden] { display: none; }
.community b { color: var(--ink); }
/* nuvoletta di DOKU sempre visibile, su due righe se serve (Andrea 11/11/2026) */
.doku-tap .bubble { opacity: 1; transform: none; white-space: normal; width: 132px; text-align: center; line-height: 1.2; top: 4px; }
/* niente zoom col doppio tocco (Andrea: «se clicco troppo veloce su doku mi zooma il browser»); lo zoom a due dita resta */
html, body, button, a, .doku-tap, svg.board, .tile, .sus, .chip, .tog { touch-action: manipulation; }
/* note a matita e istruzione degli indizi */
.btn#notes.on { background: #FFEAF1; border-color: var(--pink-strong); color: var(--pink-strong); }
.sec-hint { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12.5px; margin-left: 6px; }
.doku-tap .bubble:empty { display: none; }
