html, body { margin: 0; height: 100%; overflow: hidden; background: #a9c8e8; font-family: system-ui, sans-serif; }
#scena { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#velo { position: fixed; inset: 0; background: #0c0a12; opacity: 0; pointer-events: none; transition: opacity .45s ease; }
#velo.on { opacity: 1; }

#ui { position: fixed; right: 14px; bottom: 14px; display: flex; gap: 8px; }
#ui button, #pad .p {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid #3a2a20; background: #fbf4e6;
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
  -webkit-tap-highlight-color: transparent; touch-action: none;
}
#ui button.on { background: #ffd27a; }
#ui svg { width: 22px; height: 22px; stroke: #3a2a20; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#pad { display: none; }
body.esplora #pad { display: block; }
body.esplora #ui { bottom: auto; top: 14px; }
#pad .p { position: fixed; width: 56px; height: 56px; font-size: 24px; color: #3a2a20; background: rgba(251, 244, 230, .88); }
#pad .p svg { width: 26px; height: 26px; stroke: #3a2a20; fill: none; stroke-width: 2; }
#pad #b-zampa { width: 64px; height: 64px; background: #ffd27a; }
#joy { position: fixed; left: 22px; bottom: 22px; width: 120px; height: 120px; border-radius: 50%; background: rgba(251, 244, 230, .35); border: 2px solid rgba(58, 42, 32, .5); touch-action: none; }
#joy .pomo { position: absolute; left: 36px; top: 36px; width: 48px; height: 48px; border-radius: 50%; background: rgba(251, 244, 230, .92); border: 2px solid #3a2a20; transition: transform .06s; pointer-events: none; }

#viaggio {
  position: fixed; right: 14px; bottom: 70px; width: 260px; background: #fbf4e6; border: 2px solid #3a2a20; border-radius: 16px; padding: 10px 12px;
  font-family: Georgia, serif; color: #3a2a20; box-shadow: 0 6px 20px rgba(30, 20, 10, .25);
  transform: translateY(12px); opacity: 0; pointer-events: none; transition: all .25s;
}
#viaggio.on { transform: none; opacity: 1 !important; pointer-events: auto !important; }
body.esplora #viaggio { bottom: auto; top: 70px; }
#viaggio .titolo { font-weight: bold; font-size: 17px; margin-bottom: 6px; }
#viaggio button { display: flex; justify-content: space-between; align-items: baseline; width: 100%; background: none; border: 0; border-top: 1px solid #e6d6b8; padding: 9px 4px; font: inherit; font-size: 15px; color: inherit; cursor: pointer; text-align: left; }
#viaggio button:hover { background: #f4e6c8; }
#viaggio button small { font-family: system-ui, sans-serif; font-size: 12px; color: #7a5a40; white-space: nowrap; margin-left: 8px; }

#suggerimento { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -10px); max-width: min(460px, calc(100vw - 32px)); box-sizing: border-box;
  background: #fffaf0; border: 2px solid #3a2a20; border-radius: 16px; padding: 12px 18px; font-family: Georgia, serif; font-size: 16px; line-height: 1.45; color: #3a2a20; text-align: center;
  box-shadow: 0 8px 24px rgba(30, 20, 10, .3); opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s cubic-bezier(.2, 1.4, .4, 1); z-index: 20; cursor: pointer; }
#suggerimento.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#suggerimento small { color: #7a5a40; font-size: 13px; }
#suggerimento::before { content: ''; position: absolute; left: 50%; top: -9px; width: 14px; height: 14px; background: #fffaf0; border-left: 2px solid #3a2a20; border-top: 2px solid #3a2a20; transform: translateX(-50%) rotate(45deg); }
body.esplora #suggerimento { top: auto; bottom: 170px; }
body.esplora #suggerimento::before { display: none; }

#segnaposto { position: fixed; inset: 0; pointer-events: none; }
#segnaposto .segno { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; flex-direction: column; align-items: center; background: none; border: 0; padding: 0; cursor: pointer; }
#segnaposto .segno span { background: #fbf4e6; border: 2px solid #3a2a20; border-radius: 14px; padding: 4px 12px; font-family: Georgia, serif; font-size: 15px; color: #3a2a20; white-space: nowrap; box-shadow: 0 3px 10px rgba(30, 20, 10, .3); transition: transform .15s; order: 1; }
#segnaposto .segno i { order: 2; width: 2px; height: 22px; background: #3a2a20; }
#segnaposto .segno:hover span { transform: scale(1.08); background: #ffd27a; }
@media (pointer: coarse) { #segnaposto .segno span { font-size: 17px; padding: 7px 14px; } }

#bocconi { display: none; position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(251, 244, 230, .95); border: 2px solid #3a2a20; border-radius: 20px; padding: 4px 14px 4px 10px; align-items: center; gap: 8px; font-family: Georgia, serif; font-size: 20px; font-weight: bold; color: #3a2a20; }
#bocconi svg { width: 32px; height: 20px; fill: #8ab8d8; stroke: #3a2a20; stroke-width: 1.5; }
#bocconi svg .occhio { fill: #3a2a20; stroke: none; }
body.esplora #bocconi { display: flex; }
#bocconi { transform: translateX(calc(-100% - 6px)); left: 50%; }
#campanelli { display: none; position: fixed; left: calc(50% + 6px); bottom: 18px; background: rgba(251, 244, 230, .95); border: 2px solid #3a2a20; border-radius: 20px; padding: 4px 14px 4px 10px; align-items: center; gap: 8px; font-family: Georgia, serif; font-size: 20px; font-weight: bold; color: #3a2a20; }
#campanelli svg { width: 22px; height: 22px; fill: #f2c050; stroke: #8a5a10; stroke-width: 1.4; }
#campanelli.tutti { background: #ffd27a; box-shadow: 0 0 18px #ffd27a; }
body.esplora #campanelli { display: flex; }
#campanelli.pop { animation: pop2 .5s ease; }
@keyframes pop2 { 40% { transform: scale(1.35); } }
#bocconi.pop { animation: pop .5s ease; }
@keyframes pop { 40% { transform: translateX(calc(-100% - 6px)) scale(1.35); } }

/* tablet e telefono: pulsanti più grandi da toccare */
@media (pointer: coarse) {
  #ui button { width: 52px; height: 52px; }
  #ui svg { width: 26px; height: 26px; }
  #pad .p { width: 66px; height: 66px; }
  #pad #b-zampa { width: 76px; height: 76px; }
  #pad #b-salta { right: 100px !important; bottom: 124px !important; }
  #pad #b-corri { right: 100px !important; bottom: 46px !important; }
  #joy { width: 150px; height: 150px; }
  #joy .pomo { left: 47px; top: 47px; width: 56px; height: 56px; }
  #viaggio { width: 300px; } #viaggio button { padding: 13px 6px; font-size: 17px; }
}

#avviso { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); background: rgba(251, 244, 230, .95); border: 2px solid #3a2a20; border-radius: 14px; padding: 6px 16px; font-family: Georgia, serif; color: #3a2a20; font-size: 16px; opacity: 0; transition: opacity .3s; pointer-events: none; }
#avviso.on { opacity: 1; }

#scheda {
  position: fixed; top: 84px; left: 16px; width: min(330px, calc(100vw - 32px)); box-sizing: border-box;
  background: #fbf4e6; border: 2px solid #3a2a20; border-radius: 16px; padding: 12px 16px 10px;
  font-family: Georgia, 'Times New Roman', serif; color: #3a2a20; box-shadow: 0 6px 20px rgba(30, 20, 10, .25);
  transform: translateY(-20px) scale(.96); opacity: 0; pointer-events: none; transition: transform .45s cubic-bezier(.2, 1.4, .4, 1), opacity .3s;
  cursor: pointer;
}
#scheda.on { transform: none; opacity: 1; pointer-events: auto; }
#scheda .testa { display: flex; align-items: baseline; gap: 10px; }
#scheda .nome { font-size: 26px; font-weight: bold; }
#scheda .eta { font-size: 14px; color: #7a5a40; }
#scheda .razza { font-size: 14px; font-style: italic; color: #6a4a30; margin-top: 2px; }
#scheda .tratti { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
#scheda .tratti span { font-family: system-ui, sans-serif; font-size: 12px; background: #f2dcae; color: #5a3a20; border-radius: 10px; padding: 2px 9px; }
#scheda .storia { font-size: 15px; line-height: 1.45; margin: 6px 0 2px; }
#scheda.chiusa .storia, #scheda.chiusa .tratti, #scheda.chiusa .razza { display: none; }

#errore { position: fixed; left: 12px; bottom: 10px; color: #fff; font-size: 12px; text-shadow: 0 1px 2px #000; }

/* Don Gattone: fumetto da gioco in basso, con ritratto, nome, battuta scritta a macchina e scelte */
#gattone { position: fixed; left: 50%; bottom: 18px; z-index: 25; width: min(720px, calc(100vw - 32px)); box-sizing: border-box;
  display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px 16px; background: #fffaf0; border: 3px solid #3a2a20; border-radius: 22px;
  box-shadow: 0 6px 0 #3a2a20, 0 14px 34px rgba(30, 20, 10, .35); font-family: Georgia, serif; color: #3a2a20;
  transform: translate(-50%, 40px) scale(.92); opacity: 0; pointer-events: none; transition: opacity .3s, transform .45s cubic-bezier(.2, 1.5, .4, 1); }
#gattone.on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
#gattone.obbligo .via { display: none; }
#gattone.scuoti { animation: gattone-scuoti .4s ease-in-out; }
@keyframes gattone-scuoti { 20% { margin-left: -10px; } 40% { margin-left: 9px; } 60% { margin-left: -6px; } 80% { margin-left: 4px; } }
#gattone-velo { position: fixed; inset: 0; z-index: 24; display: none; background: linear-gradient(to top, rgba(30, 20, 10, .35), rgba(30, 20, 10, .08) 60%); }
#gattone-velo.on { display: block; animation: st-entra .4s ease-out; }
#gattone .ritratto { flex: none; width: 92px; height: 92px; margin-top: -40px; border-radius: 50%; background: #f4e3c0; border: 3px solid #3a2a20;
  box-shadow: 0 4px 0 #3a2a20; display: grid; place-items: center; cursor: pointer; overflow: hidden; }
#gattone .ritratto svg { width: 86%; height: 86%; transform-origin: 50% 90%; }
#gattone.parla .ritratto svg { animation: gattone-parla .22s ease-in-out infinite alternate; }
@keyframes gattone-parla { from { transform: rotate(-2deg) translateY(0); } to { transform: rotate(2deg) translateY(-2px); } }
#gattone .nuvola { flex: 1; min-width: 0; }
#gattone .nome { display: inline-block; margin: -30px 0 6px; padding: 3px 12px; background: #c8302a; color: #fff6e0; border: 2px solid #3a2a20; border-radius: 10px;
  font-family: 'Cinzel', Georgia, serif; font-weight: 800; font-size: 14px; letter-spacing: .05em; transform: rotate(-2deg); }
#gattone .testo { margin: 0; font-size: 17px; line-height: 1.45; min-height: 2.9em; cursor: pointer; }
#gattone .scelte { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; justify-content: flex-end; }
#gattone .scelte button { font: inherit; font-size: 15px; color: #3a2a20; background: #ffe7a8; border: 2px solid #3a2a20; border-radius: 12px; padding: 8px 14px;
  box-shadow: 0 3px 0 #3a2a20; cursor: pointer; animation: gattone-entra .35s cubic-bezier(.2, 1.6, .4, 1) both; transition: transform .12s, box-shadow .12s, background .12s; }
#gattone .scelte button:hover { background: #ffd86a; transform: translateY(-2px) rotate(-1deg); box-shadow: 0 5px 0 #3a2a20; }
#gattone .scelte button:active { transform: translateY(2px); box-shadow: 0 1px 0 #3a2a20; }
#gattone .scelte.griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); justify-content: stretch; gap: 6px; }
#gattone .scelte.griglia button { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; background: #fff1cc; padding: 6px 9px; box-shadow: 0 2px 0 #3a2a20; }
#gattone .scelte.griglia button span { font-weight: bold; font-size: 13px; line-height: 1.2; }
#gattone .scelte.griglia button small { display: flex; gap: 2px; height: 14px; align-items: center; font-family: system-ui, sans-serif; font-size: 11px; color: #7a5a40; }
#gattone .scelte.griglia button small svg { width: 14px; height: 14px; fill: #b0643a; }
#gattone .scelte.griglia button.gatto { background: #c8302a; color: #fff6e0; }
#gattone .scelte.griglia button.gatto small svg { fill: #ffe7a8; }
#gattone .scelte.griglia button.gatto:hover { background: #d84a3a; }
@keyframes gattone-entra { from { opacity: 0; transform: translateY(8px) scale(.9); } }
#gattone .via { position: absolute; top: 8px; right: 10px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #3a2a20; background: #fffaf0; color: #3a2a20;
  font-size: 14px; cursor: pointer; line-height: 1; }
#gattone .via:hover { background: #f4e3c0; }
body.esplora #gattone { display: none; }
@media (max-width: 520px) {
  #gattone { gap: 10px; padding: 12px; bottom: 12px; }
  #gattone .ritratto { width: 64px; height: 64px; margin-top: -30px; }
  #gattone .testo { font-size: 15px; }
  #gattone .scelte.griglia { grid-template-columns: 1fr 1fr; max-height: 42vh; overflow-y: auto; }
}

/* uscita dal gatto: pillola con occhio e scritta, così non si confonde con la chiusura della scheda */
#pad #b-esci { width: auto; height: 50px; padding: 0 16px 0 12px; border-radius: 25px; display: flex; align-items: center; gap: 8px; font-family: Georgia, serif; font-size: 15px; font-weight: bold; }
#pad #b-esci svg { width: 24px; height: 24px; fill: none; stroke: #3a2a20; stroke-width: 2; }
#scheda .chiudi { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #3a2a20; background: #fffaf0; color: #3a2a20; font-size: 13px; line-height: 1; cursor: pointer; }
#scheda .chiudi:hover { background: #f2dcae; }
#scheda .testa { padding-right: 30px; }
#scheda.nascosta { opacity: 0; pointer-events: none; transform: translateY(-20px) scale(.96); }

/* Salta Tetti: il mini gioco della Ludoteca, a tutto schermo */
#saltatetti { position: fixed; inset: 0; z-index: 60; background: #8cc4e6; animation: st-entra .35s ease-out; touch-action: none; user-select: none; -webkit-user-select: none; }
#saltatetti.via { opacity: 0; transition: opacity .3s; }
@keyframes st-entra { from { opacity: 0; transform: scale(1.03); } }
#saltatetti canvas { width: 100%; height: 100%; display: block; }
#saltatetti .hud { position: absolute; left: 14px; top: 12px; display: flex; gap: 10px; font-family: Georgia, serif; }
#saltatetti .hud > span { display: flex; align-items: center; gap: 4px; background: #fffaf0; border: 2px solid #3a2a20; border-radius: 14px; padding: 4px 10px; box-shadow: 0 3px 0 #3a2a20; }
#saltatetti .hud b { font-size: 18px; color: #3a2a20; min-width: 1.4em; }
#saltatetti .pesci i { width: 24px; height: 14px; background: #7ab0d8; border-radius: 50% 40% 40% 50%; position: relative; }
#saltatetti .pesci i::after { content: ''; position: absolute; left: -7px; top: 2px; border: 5px solid transparent; border-right: 8px solid #7ab0d8; }
#saltatetti .campanelli i { width: 16px; height: 18px; background: #d8ccb4; border-radius: 8px 8px 3px 3px; transition: background .3s, transform .3s; }
#saltatetti .campanelli i.on { background: #f2c030; transform: scale(1.15); box-shadow: 0 0 8px #ffd84a; }
#saltatetti .cuori i { width: 16px; height: 16px; background: #d8ccb4; clip-path: path('M8 15 L1.5 8.5 A3.8 3.8 0 0 1 8 3 A3.8 3.8 0 0 1 14.5 8.5 Z'); }
#saltatetti .cuori i.on { background: #d8404a; }
#saltatetti .esci { position: absolute; right: 14px; top: 12px; width: 40px; height: 40px; border-radius: 50%; border: 2px solid #3a2a20; background: #fffaf0; color: #3a2a20; font-size: 16px; box-shadow: 0 3px 0 #3a2a20; cursor: pointer; }
#saltatetti .touch { display: none; }
@media (pointer: coarse) {
  #saltatetti .touch { display: block; }
  #saltatetti .touch button { position: absolute; bottom: 22px; width: 74px; height: 74px; border-radius: 50%; border: 3px solid #3a2a20; background: rgba(255, 250, 240, .85); color: #3a2a20; font-size: 28px; box-shadow: 0 4px 0 #3a2a20; touch-action: none; }
  #saltatetti .touch button:active { transform: translateY(3px); box-shadow: 0 1px 0 #3a2a20; }
  #saltatetti .touch .sx { left: 20px; } #saltatetti .touch .dx { left: 108px; } #saltatetti .touch .su { right: 24px; width: 88px; height: 88px; background: #ffe7a8; }
}
#saltatetti .pannello { position: absolute; left: 50%; top: 50%; width: min(460px, calc(100vw - 32px)); box-sizing: border-box; text-align: center;
  background: #fffaf0; border: 3px solid #3a2a20; border-radius: 22px; box-shadow: 0 6px 0 #3a2a20, 0 18px 40px rgba(30, 20, 10, .35); padding: 22px 22px 20px;
  font-family: Georgia, serif; color: #3a2a20; transform: translate(-50%, -40%) scale(.9); opacity: 0; pointer-events: none; transition: opacity .25s, transform .4s cubic-bezier(.2, 1.5, .4, 1); }
#saltatetti .pannello.on { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
#saltatetti .pannello h2 { margin: 0 0 8px; font-family: 'Cinzel', Georgia, serif; font-size: 34px; color: #b8302a; }
#saltatetti .pannello p { margin: 8px 0; font-size: 16px; line-height: 1.45; }
#saltatetti .pannello .comandi { font-size: 14px; color: #7a5a40; }
#saltatetti .pannello .detto { font-style: italic; color: #6a4a30; }
#saltatetti .pannello button { margin: 12px 6px 0; font: inherit; font-size: 18px; font-weight: bold; color: #3a2a20; background: #ffd86a; border: 2px solid #3a2a20; border-radius: 14px; padding: 10px 26px; box-shadow: 0 4px 0 #3a2a20; cursor: pointer; }
#saltatetti .pannello button:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #3a2a20; }
#saltatetti .pannello button.secondo { background: #fffaf0; font-size: 15px; }
#saltatetti .stelle { display: inline-flex; gap: 6px; vertical-align: middle; }
#saltatetti .stelle i { width: 34px; height: 34px; background: #d8ccb4; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
#saltatetti .record .stelle i { width: 18px; height: 18px; }
#saltatetti .stelle i.on { background: #f2c030; }
#saltatetti .stelle i.pop { animation: st-pop .45s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes st-pop { from { transform: scale(0) rotate(-40deg); } }
/* fumetto di Don Gattone: "salta" per andare subito alla scelta */
#gattone .scelte button.salta { background: none; border: 0; box-shadow: none; text-decoration: underline; color: #7a5a40; font-size: 14px; margin-right: auto; padding: 8px 4px; }
#gattone .scelte button.salta:hover { background: none; transform: none; color: #3a2a20; }
#gattone .scelte.griglia button.ludo { background: #ffd86a; }

/* pannello per condividere (dal computer; dal telefono si apre il menu del sistema) */
#condividi { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(20, 14, 8, .45); animation: st-entra .25s ease-out; }
#condividi .riquadro { position: relative; width: min(380px, calc(100vw - 32px)); box-sizing: border-box; background: #fffaf0; border: 3px solid #3a2a20; border-radius: 22px; box-shadow: 0 6px 0 #3a2a20; padding: 20px; font-family: Georgia, serif; color: #3a2a20; text-align: center; }
#condividi h3 { margin: 0 0 6px; font-family: 'Cinzel', Georgia, serif; color: #b8302a; font-size: 20px; }
#condividi p { margin: 0 0 14px; font-size: 14px; color: #6a4a30; line-height: 1.4; }
#condividi .voci { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#condividi .voci a { display: block; padding: 10px; border-radius: 12px; background: var(--c); color: #fff; text-decoration: none; font-family: system-ui, sans-serif; font-weight: 600; border: 2px solid #3a2a20; box-shadow: 0 3px 0 #3a2a20; }
#condividi .voci a:hover { transform: translateY(-2px); }
#condividi .copia { margin-top: 10px; width: 100%; padding: 10px; font: inherit; font-weight: bold; background: #ffe7a8; border: 2px solid #3a2a20; border-radius: 12px; box-shadow: 0 3px 0 #3a2a20; cursor: pointer; color: #3a2a20; }
#condividi .chiudi { position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #3a2a20; background: #fffaf0; cursor: pointer; color: #3a2a20; }

/* Album della colonia */
#ui #b-album { position: relative; }
#ui #b-album b { position: absolute; right: -8px; top: -8px; min-width: 20px; padding: 1px 5px; border-radius: 10px; background: #c8302a; color: #fff6e0; font: bold 10px/16px system-ui, sans-serif; border: 2px solid #3a2a20; }
#ui #b-album.nuovo { animation: album-salta .6s cubic-bezier(.2, 1.8, .4, 1); }
@keyframes album-salta { 40% { transform: scale(1.3) rotate(-8deg); } }
.figurina-nuova { position: fixed; left: 50%; top: 70px; z-index: 30; display: flex; gap: 12px; align-items: center; transform: translateX(-50%); cursor: pointer;
  background: #fffaf0; border: 3px solid #3a2a20; border-radius: 18px; box-shadow: 0 5px 0 #3a2a20, 0 12px 30px rgba(30, 20, 10, .3); padding: 8px 18px 8px 8px; font-family: Georgia, serif; color: #3a2a20;
  animation: figurina-arriva .6s cubic-bezier(.2, 1.6, .4, 1); transition: opacity .4s, transform .4s; }
.figurina-nuova.via { opacity: 0; transform: translate(-50%, -16px); }
@keyframes figurina-arriva { from { opacity: 0; transform: translate(-50%, -30px) rotate(-8deg) scale(.7); } }
.figurina-nuova .ritr { width: 58px; height: 58px; border-radius: 12px; background: #f4e3c0; border: 2px solid #3a2a20; }
.figurina-nuova small { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #b8302a; font-weight: bold; }
.figurina-nuova b { display: block; font-size: 20px; }
.figurina-nuova span { font-size: 13px; color: #6a4a30; }
#album { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(20, 14, 8, .5); animation: st-entra .25s ease-out; }
#album .libro { position: relative; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow-y: auto; box-sizing: border-box; padding: 20px 20px 18px;
  background: #fbf2de; border: 3px solid #3a2a20; border-radius: 22px; box-shadow: 0 6px 0 #3a2a20; font-family: Georgia, serif; color: #3a2a20; }
#album h2 { margin: 0 0 10px; font-family: 'Cinzel', Georgia, serif; color: #b8302a; font-size: 26px; text-align: center; }
#album .avanzamento { height: 12px; border-radius: 8px; background: #e6d6b8; border: 2px solid #3a2a20; overflow: hidden; }
#album .avanzamento i { display: block; height: 100%; background: linear-gradient(90deg, #f2c030, #e8a040); }
#album .conta { text-align: center; font-size: 15px; margin: 10px 0 14px; color: #5a3a20; }
#album .griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
#album .figurina { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 9px; background: #fffaf0; border: 2px solid #3a2a20; border-radius: 14px; box-shadow: 0 3px 0 #3a2a20;
  font: inherit; color: inherit; cursor: pointer; transition: transform .12s; }
#album .figurina:hover { transform: translateY(-3px) rotate(-1deg); }
#album .figurina .ritr { width: 78px; height: 78px; border-radius: 12px; background: radial-gradient(circle at 50% 40%, #fff3d0, #f0d8a8); }
#album .figurina b { font-size: 15px; margin-top: 4px; }
#album .figurina small { font-size: 11px; color: #7a5a40; text-align: center; line-height: 1.25; }
#album .figurina.manca { background: #efe4cc; }
#album .figurina.manca .ritr { background: #d8c8a8; }
#album .figurina.manca b { color: #8a7a60; }
#album .condividi { display: block; margin: 16px auto 0; font: inherit; font-weight: bold; font-size: 16px; color: #3a2a20; background: #ffd86a; border: 2px solid #3a2a20; border-radius: 14px; padding: 10px 22px; box-shadow: 0 4px 0 #3a2a20; cursor: pointer; }
#album .chiudi { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 2px solid #3a2a20; background: #fffaf0; color: #3a2a20; cursor: pointer; z-index: 2; }
#album .scheda-gatto { display: none; position: absolute; inset: 0; background: #fbf2de; padding: 20px; overflow-y: auto; border-radius: 20px; }
#album .scheda-gatto.on { display: block; animation: st-entra .25s ease-out; }
#album .indietro { font: inherit; background: none; border: 0; color: #7a5a40; cursor: pointer; padding: 4px 0; font-size: 15px; }
#album .grande { display: flex; gap: 18px; align-items: center; margin: 10px 0; }
#album .grande .ritr { flex: none; width: 130px; height: 130px; border-radius: 18px; border: 3px solid #3a2a20; background: radial-gradient(circle at 50% 40%, #fff3d0, #f0d8a8); box-shadow: 0 4px 0 #3a2a20; }
#album .grande h3 { margin: 0; font-size: 26px; }
#album .grande .razza { font-style: italic; color: #6a4a30; margin: 2px 0 8px; }
#album .tratti { display: flex; flex-wrap: wrap; gap: 6px; }
#album .tratti span { font-family: system-ui, sans-serif; font-size: 12px; background: #f2dcae; color: #5a3a20; border-radius: 10px; padding: 3px 10px; }
#album .storia { font-size: 16px; line-height: 1.5; }
#album .adesso { font-size: 14px; color: #5a3a20; background: #fff3d6; border-radius: 12px; padding: 8px 12px; border: 1px dashed #c8a878; }
#album .azioni { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
#album .azioni button { font: inherit; font-weight: bold; font-size: 15px; color: #3a2a20; background: #ffd86a; border: 2px solid #3a2a20; border-radius: 14px; padding: 9px 18px; box-shadow: 0 3px 0 #3a2a20; cursor: pointer; }
#album .azioni button.secondo { background: #c8302a; color: #fff6e0; }
@media (max-width: 520px) {
  #album .griglia { grid-template-columns: repeat(3, 1fr); gap: 7px; }
  #album .figurina .ritr { width: 62px; height: 62px; } #album .figurina b { font-size: 13px; }
  #album .grande .ritr { width: 96px; height: 96px; } #album .grande h3 { font-size: 21px; }
}

/* misteri di Don Gattone: pulsante del taccuino, foglietti degli indizi, sospettati */
#b-mistero { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 15; display: flex; align-items: center; gap: 8px; padding: 7px 16px 7px 12px;
  background: #fff3d6; border: 2px solid #3a2a20; border-radius: 20px; box-shadow: 0 3px 0 #3a2a20; font: bold 14px Georgia, serif; color: #3a2a20; cursor: pointer; }
#b-mistero svg { width: 20px; height: 20px; fill: none; stroke: #b8302a; stroke-width: 2.6; stroke-linecap: round; }
#b-mistero.pronto { background: #ffd86a; animation: album-salta 1.2s ease-in-out infinite; }
body.home #b-mistero { display: none; }
body.esplora #b-mistero { top: 74px; }
#foglio { position: fixed; inset: 0; z-index: 72; display: grid; place-items: center; background: rgba(20, 14, 8, .4); animation: st-entra .25s ease-out; }
#foglio .carta { width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; box-sizing: border-box; padding: 22px 22px 18px; transform: rotate(-1deg);
  background: repeating-linear-gradient(#fffaf0 0 27px, #e8dcc4 27px 28px); border: 3px solid #3a2a20; border-radius: 10px 18px 14px 20px; box-shadow: 0 6px 0 #3a2a20, 0 18px 40px rgba(30, 20, 10, .35); font-family: Georgia, serif; color: #3a2a20; }
#foglio small { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #b8302a; font-weight: bold; }
#foglio h3 { margin: 4px 0 8px; font-family: 'Cinzel', Georgia, serif; font-size: 22px; }
#foglio .testo, #foglio li { font-size: 16px; line-height: 1.55; }
#foglio ul { padding-left: 18px; margin: 6px 0; } #foglio li { margin-bottom: 8px; } #foglio li.vuoto { color: #8a7a60; list-style: none; margin-left: -18px; }
#foglio .poi { margin: 10px 0 0; padding: 8px 12px; background: #fff3d6; border: 1px dashed #c8a878; border-radius: 10px; font-size: 15px; }
#foglio .azioni { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
#foglio .azioni button { font: inherit; font-weight: bold; font-size: 15px; color: #3a2a20; background: #ffd86a; border: 2px solid #3a2a20; border-radius: 14px; padding: 9px 18px; box-shadow: 0 3px 0 #3a2a20; cursor: pointer; }
#foglio .azioni button.secondo { background: #fffaf0; }
#gattone .scelte.griglia button.mistero { background: #3a2a4a; color: #fff3d6; }
#gattone .scelte.griglia button.mistero small { color: #e8c88a; }
#gattone .scelte.griglia button.sospetto { align-items: center; text-align: center; }
#gattone .scelte.griglia button.sospetto .ritr { width: 58px; height: 58px; border-radius: 12px; background: radial-gradient(circle at 50% 40%, #fff3d0, #f0d8a8); border: 2px solid #3a2a20; }
#gattone .scelte.griglia button.sospetto small { height: auto; }
#album .premio { text-align: center; margin: -4px auto 12px; width: fit-content; padding: 4px 14px; background: #3a2a4a; color: #fff3d6; border-radius: 12px; font-size: 13px; border: 2px solid #3a2a20; }

#album .azioni button.carta { background: #3a2a4a; color: #ffe7a8; }
/* anteprima della carta da collezione */
#carta-gatto { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; background: rgba(20, 14, 8, .6); animation: st-entra .25s ease-out; }
#carta-gatto .dentro { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 12px; }
#carta-gatto .attesa { color: #fff3d6; font: 18px Georgia, serif; }
#carta-gatto img { height: min(72vh, 900px); max-width: calc(100vw - 32px); object-fit: contain; border-radius: 18px; box-shadow: 0 20px 50px rgba(0, 0, 0, .5); animation: carta-gira .7s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes carta-gira { from { transform: perspective(900px) rotateY(80deg) scale(.8); opacity: 0; } }
#carta-gatto .azioni { display: flex; gap: 10px; }
#carta-gatto .azioni > * { font: bold 16px Georgia, serif; color: #3a2a20; background: #ffd86a; border: 2px solid #3a2a20; border-radius: 14px; padding: 10px 20px; box-shadow: 0 3px 0 #3a2a20; cursor: pointer; text-decoration: none; }
#carta-gatto .azioni .secondo { background: #fffaf0; }
#carta-gatto .chiudi { position: absolute; top: 0; right: 0; width: 36px; height: 36px; border-radius: 50%; border: 2px solid #3a2a20; background: #fffaf0; color: #3a2a20; cursor: pointer; z-index: 2; }

/* telefono stretto: la barra va su due righe da quattro (8 tasti non stanno in una riga) */
@media (max-width: 600px) {
  #ui { display: grid; grid-template-columns: repeat(4, 46px); gap: 7px; right: 10px; bottom: 10px; }
  #ui button { width: 46px; height: 46px; }
  #ui svg { width: 23px; height: 23px; }
  body.esplora #ui { top: 10px; }
  body.esplora #scheda { top: 124px; }
  body.esplora #b-mistero { top: 66px; left: 12px; right: auto; transform: none; padding: 5px 12px 5px 9px; font-size: 13px; }
  body.esplora #pad #b-esci { height: 46px; font-size: 14px; padding: 0 14px 0 11px; left: 12px !important; top: 10px !important; }
  body.esplora #pad #b-esci span { display: none; }
  body.esplora #pad #b-esci::after { content: 'Esci'; }
  #gattone { bottom: 128px; }
  .figurina-nuova { top: 130px; }
  /* da gatto in alto ci sono già tasti e scheda: figurina e avvisi brevi compaiono in basso, sopra i comandi */
  body.esplora .figurina-nuova { top: auto; bottom: 186px; }
  body.esplora #avviso { top: auto; bottom: 186px; max-width: calc(100vw - 40px); text-align: center; }
  body.esplora #suggerimento { width: calc(100vw - 32px); bottom: 186px; font-size: 15px; }
}

/* mini gioco del vicolo: buio attorno alla lanterna, candela e ricordi trovati */
#lanterna-buio { position: fixed; inset: 0; z-index: 5; pointer-events: none; display: none; }
body.in-vicolo #lanterna-buio { display: block; }
#lanterna-hud { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 16; display: none; align-items: center; gap: 12px; padding: 8px 16px; background: rgba(251, 244, 230, .95); border: 2px solid #3a2a20; border-radius: 16px; font-family: Georgia, serif; font-weight: bold; color: #3a2a20; }
body.in-vicolo #lanterna-hud { display: flex; }
#lanterna-hud .candela { width: 120px; height: 12px; border: 2px solid #3a2a20; border-radius: 8px; background: #3a2a20; overflow: hidden; }
#lanterna-hud .candela i { display: block; height: 100%; background: linear-gradient(90deg, #e8803a, #ffe07a); transition: width .3s; }
body.in-vicolo #b-mistero, body.in-vicolo #scheda { display: none; }
@media (max-width: 600px) { #lanterna-hud { top: 66px; left: 12px; transform: none; padding: 5px 10px; font-size: 13px; } #lanterna-hud .candela { width: 80px; } }

/* il film di carta delle storie dei luoghi */
#storia { position: fixed; inset: 0; z-index: 90; display: none; place-items: center; background: rgba(15, 10, 6, .82); }
#storia.on { display: grid; animation: st-entra .3s ease-out; }
#storia .schermo { position: relative; width: min(96vw, calc((100vh - 150px) * 16 / 9)); }
#storia canvas { width: 100%; display: block; border-radius: 14px; border: 3px solid #3a2a20; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); background: #f2e2c4; }
#storia .titolo { position: absolute; left: 16px; top: 12px; padding: 6px 14px; background: rgba(255, 246, 224, .92); border: 2px solid #3a2a20; border-radius: 12px; font-family: 'Cinzel', Georgia, serif; font-weight: 800; color: #3a2a20; font-size: clamp(12px, 1.6vw, 18px); }
#storia .titolo small { display: block; font-family: Georgia, serif; font-weight: normal; font-style: italic; font-size: .75em; color: #7a5a40; }
#storia .testo { margin: 14px auto 0; max-width: 880px; min-height: 3.3em; padding: 0 12px; font-family: Georgia, serif; font-style: italic; font-size: clamp(15px, 1.9vw, 21px); line-height: 1.55; color: #f6ead2; text-align: center; text-shadow: 0 2px 8px rgba(0,0,0,.6); cursor: pointer; }
#storia .testo b { color: #ffd98a; font-style: normal; }
#storia .testo button { font: inherit; font-weight: bold; background: #ffd86a; border: 2px solid #3a2a20; border-radius: 10px; padding: 3px 12px; cursor: pointer; margin-left: 6px; }
#storia .comandi { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; }
#storia .comandi button { width: 38px; height: 38px; border-radius: 50%; border: 2px solid #3a2a20; background: rgba(255, 246, 224, .92); color: #3a2a20; font-size: 16px; cursor: pointer; }
#storia .barra { position: absolute; left: 14px; right: 14px; bottom: calc(100% - 100% + 0px); height: 0; }
#storia .barra i { position: absolute; left: 0; bottom: -2px; height: 4px; border-radius: 2px; background: #e8a850; }
@media (max-width: 600px) { #storia .titolo { top: auto; bottom: 8px; left: 8px; } #storia .comandi { top: 6px; right: 6px; } #storia .comandi button { width: 32px; height: 32px; font-size: 13px; } }
#storia .titolo { display: none; }
