/* =========================================================
   ONESHOT · Scopri la Line Up — stile
   Palette presa dalla locandina. Mobile-first (360–430px).
   ========================================================= */

:root {
  --sky: #A9B6EE;        /* sfondo pagina azzurro-lavanda */
  --pink: #E8436E;       /* sticker */
  --pink-dark: #8E1A40;  /* ombre testo per il contrasto */
  --cream: #F3E6C8;      /* contorno dello sticker */
  --yellow: #F6EE7E;     /* testi, grafiche, mascotte */
  --pink-light: #F08AA6; /* contorno interno della mascotte */

  --pad-x: 26px;         /* spazio interno dal bordo smerlato */
  --pad-y: 28px;
  --key-h: 46px;         /* altezza tasti (>= 44px) */
  --key-gap: 5px;

  /* ombra rosa scuro: migliora la leggibilità del giallo su rosa */
  --txt-shadow: 0 1px 0 rgba(110, 14, 46, .55), 0 0 3px rgba(110, 14, 46, .35);
}

*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;              /* niente scroll, né verticale né orizzontale */
  background: var(--sky);
}

body {
  font-family: 'Anton', 'Bebas Neue', Impact, 'Arial Narrow', sans-serif;
  text-transform: uppercase;
  color: var(--yellow);
  line-height: 1.1;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;    /* niente zoom al doppio tap */
  text-shadow: var(--txt-shadow);
}

button,
a { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

/* ---------- Contenitore pagina (100dvh + safe area iPhone) ---------- */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(6px, env(safe-area-inset-top))
    max(4px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom))
    max(4px, env(safe-area-inset-left));
}

/* ---------- Lo sticker ---------- */
.sticker {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100%;
  max-height: 940px;
}

.sticker-bg,
.sticker-grain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.sticker-bg { z-index: 0; filter: drop-shadow(0 6px 0 rgba(70, 60, 140, .18)); }
.sticker-grain {
  z-index: 5;
  opacity: .32;
  will-change: transform;        /* layer separato: la grana non viene ridisegnata */
}

.sticker-inner {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: var(--pad-y) var(--pad-x);
  display: flex;
  flex-direction: column;
}

/* ---------- Mascotte stile sticker: doppio contorno fustellato ----------
   Ogni silhouette è disegnata 3 volte (vedi index.html):
   contorno esterno crema 4px + contorno interno rosa chiaro 6px + riempimento giallo.
   non-scaling-stroke: lo spessore resta in px reali a qualsiasi dimensione. */
.lay-o2 { fill: var(--cream); stroke: var(--cream); stroke-width: 20px; stroke-linejoin: round; }
.lay-o1 { fill: var(--pink-light); stroke: var(--pink-light); stroke-width: 12px; stroke-linejoin: round; }
.lay-f { fill: var(--yellow); stroke: none; }
.lay-o2 *,
.lay-o1 * { vector-effect: non-scaling-stroke; }

/* ---------- Decorazioni mascotte ai bordi ----------
   Il contenitore è ritagliato con la forma dello sticker (clip-path da game.js),
   così le mascotte sbucano dal bordo come nella locandina. */
.deco { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.deco__m { position: absolute; width: 78px; height: 99px; overflow: visible; }
.deco__m--1 { top: -12px;   left: -14px;   rotate: -30deg; animation: deco-jump 1.1s ease-in-out infinite; }
.deco__m--2 { top: -8px;    right: -10px; rotate: 32deg;  scale: -1 1; animation: deco-sway 1.4s ease-in-out infinite; }
.deco__m--3 { top: 23%;     left: -8px;   rotate: 18deg; animation: deco-sway 1.6s ease-in-out infinite reverse; }
.deco__m--4 { top: 39%;     right: -8px;  rotate: -18deg; animation: deco-jump 1.3s ease-in-out .3s infinite; }
.deco__m--5 { bottom: -38px; left: -6px;  rotate: 22deg; animation: deco-sway 1.5s ease-in-out .2s infinite; }
.deco__m--6 { bottom: -38px; right: -6px; rotate: -22deg; scale: -1 1; animation: deco-jump 1.2s ease-in-out .5s infinite; }
.deco__m--7 { top: 44%;     left: -12px;  rotate: 28deg;  width: 68px; height: 86px; animation: deco-jump 1.4s ease-in-out .1s infinite; }
.deco__m--8 { top: 19%;     right: -12px; rotate: -28deg; width: 68px; height: 86px; animation: deco-sway 1.7s ease-in-out .4s infinite; }
/* durante il round le mascotte in basso coprirebbero i tasti: si nascondono */
.sticker[data-screen="game"] .deco__m--5,
.sticker[data-screen="game"] .deco__m--6 { opacity: 0; transition: opacity .2s ease; }

@keyframes deco-jump {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -6px; }
}
@keyframes deco-sway {
  0%, 100% { transform: rotate(-7deg); }
  50% { transform: rotate(7deg); }
}

/* ---------- Header: logo + mute ---------- */
.top {
  position: relative;
  flex: none;
  display: flex;
  justify-content: center;
  padding: 0 44px;
}

.logo {
  margin: 0;
  font-weight: 400;
  font-size: clamp(56px, 19vw, 88px);
  line-height: .95;
  letter-spacing: .01em;
  text-shadow: 0 2px 0 rgba(110, 14, 46, .45);
  transition: font-size .25s ease;
}
.sticker[data-screen="game"] .logo { font-size: clamp(32px, 9.5vw, 44px); }

.mute {
  position: absolute;
  top: -4px;
  right: -6px;
  width: 44px;
  height: 44px;
  padding: 9px;
  border: 0;
  border-radius: 50%;
  background: var(--pink);
  cursor: pointer;
}
.mute svg { width: 100%; height: 100%; display: block; overflow: visible; }
.mute::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2.5px solid var(--yellow);
  border-radius: 50%;
}
.mute__spk { fill: var(--yellow); }
.mute__on,
.mute__off { fill: none; stroke: var(--yellow); stroke-width: 2.2; stroke-linecap: round; }
.mute__off { display: none; }
.mute[aria-pressed="true"] .mute__on { display: none; }
.mute[aria-pressed="true"] .mute__off { display: inline; }

/* ---------- Componenti: pillole e ovali ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 4px 22px 2px;
  border: 3px solid var(--yellow);
  border-radius: 999px;
  background: transparent;
  color: var(--yellow);
  font-size: 20px;
  letter-spacing: .04em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.pill:active { transform: scale(.95); }
.pill:focus-visible,
.key:focus-visible,
.mute:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }

.pill--solid {
  background: var(--yellow);
  color: var(--pink);
  text-shadow: none;
}
.pill--big { min-height: 60px; font-size: 30px; padding: 6px 48px 3px; }
.pill--static { cursor: default; min-height: 40px; font-size: 19px; }

.oval {
  display: inline-block;
  padding: 3px 13px 1px;
  border: 2.5px solid var(--yellow);
  border-radius: 50%;
  line-height: 1.1;
}
.oval--sm { padding: 1px 9px 0; border-width: 2px; }

/* ---------- Schermate ---------- */
.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: screen-in .35s ease both;
}
@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ===== Schermata iniziale ===== */
.screen--start { justify-content: space-evenly; gap: 8px; text-align: center; }

.tagline {
  margin: 0;
  font-size: clamp(24px, 7.5vw, 32px);
  letter-spacing: .03em;
}

.hero-mascot {
  position: relative;
  flex: 0 1 40%;                 /* circa il 40% dell'altezza disponibile */
  min-height: 0;
  aspect-ratio: 220 / 280;
  max-width: 70%;
}
.hero-mascot__svg { width: 100%; height: 100%; overflow: visible; display: block; }
.hero-mascot__bounce {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: hero-bounce .5s cubic-bezier(.3, 0, .4, 1) infinite;
}
/* le 4 pose si alternano a tempo (una ogni battito, ciclo di 2s) */
.pose { opacity: 0; animation: pose-step 2s step-end infinite; }
.pose--1 { animation-delay: 0s; }
.pose--2 { animation-delay: -1.5s; }
.pose--3 { animation-delay: -1s; }
.pose--4 { animation-delay: -.5s; }
@keyframes pose-step {
  0% { opacity: 1; }
  25%, 100% { opacity: 0; }
}
.hero-mascot__shadow {
  position: absolute;
  left: 26%;
  right: 26%;
  bottom: -4px;
  height: 8px;
  border-radius: 50%;
  background: rgba(110, 14, 46, .35);
  animation: hero-shadow .5s cubic-bezier(.3, 0, .4, 1) infinite;
}
@keyframes hero-bounce {
  0%, 100% { transform: translateY(0) scale(1.05, .95); }
  15% { transform: translateY(0) scale(1, 1); }
  50% { transform: translateY(-9%) scale(.98, 1.03); }
  85% { transform: translateY(0) scale(1, 1); }
}
@keyframes hero-shadow {
  0%, 100% { transform: scaleX(1); opacity: 1; }
  50% { transform: scaleX(.7); opacity: .5; }
}

.info { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.info__times { display: flex; align-items: center; gap: 10px; font-size: 22px; }
.info__dash { opacity: .9; }

.progress-note { margin: 0; font-size: 16px; letter-spacing: .04em; }

/* ===== Round ===== */
.screen--game { align-items: stretch; gap: 6px; }

.status {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}
.status__count { margin: 0; font-size: 17px; letter-spacing: .03em; white-space: nowrap; }

.lives { display: flex; gap: 3px; }
.life {
  width: 20px;
  height: 20px;
  transition: opacity .3s ease, transform .3s ease;
}
.life.is-lost { opacity: .22; transform: scale(.7) rotate(45deg); }

.found-list {
  flex: none;
  margin: 0;
  min-height: 1.2em;
  font-size: 14px;
  letter-spacing: .05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: .95;
}
.found-list:empty::before { content: "NESSUN DJ ANCORA · INDOVINA!"; opacity: .75; }

/* Patibolo + mascotte: riempie tutto lo spazio tra contatore e parola */
.gallows-wrap {
  flex: 1 1 auto;
  min-height: 90px;
  position: relative;
}
.gallows { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.part { opacity: 0; transform: scale(0); transform-box: fill-box; transform-origin: center; }
.part.is-on { animation: pop .55s cubic-bezier(.28, 1.7, .5, 1) forwards; }
@keyframes pop {
  0% { opacity: 0; transform: scale(0); }
  60% { opacity: 1; transform: scale(1.18); }
  100% { opacity: 1; transform: scale(1); }
}

/* mirino colpito: flash + shake */
.mirino { transform-box: fill-box; transform-origin: center; }
.mirino__burst { opacity: 0; transform-box: fill-box; transform-origin: center; }
.mirino.is-hit { animation: shake .5s ease-in-out 2; }
.mirino.is-hit > use { animation: flash .16s steps(1) 6; }
.mirino.is-hit .mirino__burst { animation: burst .6s ease-out 2; }
@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-5px) rotate(-14deg); }
  40% { transform: translateX(5px) rotate(12deg); }
  60% { transform: translateX(-3px) rotate(-6deg); }
  80% { transform: translateX(2px) rotate(4deg); }
}
@keyframes flash {
  0% { opacity: 1; }
  50% { opacity: .15; }
}
@keyframes burst {
  0% { opacity: .9; transform: scale(.6); }
  100% { opacity: 0; transform: scale(2.2); }
}

/* sconfitta: la mascotte oscilla appesa */
.gallows.is-lost .man { transform-box: view-box; transform-origin: 160px 12px; animation: swing 1.6s ease-in-out infinite; }
@keyframes swing {
  0%, 100% { transform: rotate(4deg); }
  50% { transform: rotate(-4deg); }
}

/* vittoria: la mascotte viene liberata, scende e balla alternando 2 pose */
.gallows__rope { transition: opacity .3s ease, transform .3s ease; transform-box: fill-box; transform-origin: top; }
.man { transition: opacity .2s ease .25s; }
.free { opacity: 0; pointer-events: none; }
.free__bounce { transform-box: fill-box; transform-origin: 50% 100%; }
.free__pose--b { opacity: 0; }
.gallows.is-free .gallows__rope { opacity: 0; transform: scaleY(.3); }
.gallows.is-free .man { opacity: 0; }
.gallows.is-free .free { opacity: 1; transition: opacity .2s ease .25s; }
.gallows.is-free .free__bounce { animation: dance-bounce .5s ease-in-out .3s infinite; }
.gallows.is-free .free__pose--a { animation: pose-swap 1s step-end .3s infinite; }
.gallows.is-free .free__pose--b { animation: pose-swap 1s step-end -.2s infinite; }
@keyframes pose-swap {
  0% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes dance-bounce {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-12px) rotate(5deg); }
}

/* Parola da indovinare */
.word-box { flex: none; text-align: center; }
.word {
  --n: 10;                       /* numero di caselle (impostato da game.js) */
  container-type: inline-size;
  display: flex;
  justify-content: center;
  gap: 4px;
  min-height: 46px;
}
.slot {
  flex: 0 1 34px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  font-size: min(32px, calc(100cqi / var(--n) * .95));
  line-height: 1;
}
.slot::after {                  /* trattino giallo spesso */
  content: "";
  width: 100%;
  height: 5px;
  margin-top: 4px;
  border-radius: 3px;
  background: var(--yellow);
  box-shadow: 0 1px 0 rgba(110, 14, 46, .35);
}
.slot--space { flex: 0 0 min(16px, calc(100cqi / var(--n) * .5)); }
.slot--space::after { visibility: hidden; }
.slot__ch { display: block; height: 1em; }
.slot.is-shown .slot__ch { animation: letter-in .4s cubic-bezier(.3, 1.8, .5, 1) both; }
.slot.is-revealed .slot__ch { opacity: .7; }
@keyframes letter-in {
  from { opacity: 0; transform: translateY(8px) scale(.4); }
  to { opacity: 1; transform: none; }
}

.hint { margin: 6px 0 0; font-size: 15px; letter-spacing: .06em; opacity: .95; }

/* Area controlli: tastiera e pannello esito occupano lo stesso spazio */
.controls {
  flex: none;
  display: grid;
  margin-top: 4px;
}
.controls > * { grid-area: 1 / 1; }

/* Tastiera QWERTY a schermo: larghezza tasti calcolata sulla riga da 10,
   uguale per tutte le righe (le righe corte restano centrate con rientro) */
.keyboard { display: flex; flex-direction: column; gap: 6px; }
.keyboard.is-hidden { visibility: hidden; }
.keyboard__row { display: flex; justify-content: center; gap: var(--key-gap); }
.key {
  position: relative;
  flex: 0 0 calc((100% - 9 * var(--key-gap)) / 10);
  height: var(--key-h);
  padding: 2px 0 0;
  border: 2.5px solid var(--yellow);
  border-radius: 999px;
  background: transparent;
  color: var(--yellow);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, opacity .2s ease, transform .1s ease;
}
.key:active:not(:disabled) { transform: scale(.9); }
.key:disabled { cursor: default; }
.key.is-hit {                    /* lettera giusta: pieno giallo */
  background: var(--yellow);
  color: var(--pink);
  text-shadow: none;
  animation: key-pop .3s ease;
}
.key.is-miss { opacity: .38; }   /* lettera sbagliata: semitrasparente e barrata */
.key.is-miss::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 50%;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 2px;
  background: var(--yellow);
  transform: rotate(-35deg);
}
@keyframes key-pop {
  50% { transform: scale(1.12); }
}

/* Pannello esito del round */
.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  animation: screen-in .35s ease both;
}
.panel__title {
  margin: 0;
  font-size: clamp(38px, 12vw, 54px);
  line-height: 1;
  animation: title-in .6s cubic-bezier(.25, 1.6, .5, 1) both;
}
.panel__title small { display: block; font-size: 17px; letter-spacing: .06em; margin-bottom: 4px; }
.panel__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.panel__actions .pill { font-size: 19px; padding: 4px 18px 2px; }
@keyframes title-in {
  0% { opacity: 0; transform: scale(.3) rotate(-6deg); }
  100% { opacity: 1; transform: none; }
}

/* ===== Fine: line up completa ===== */
.screen--end { justify-content: space-evenly; text-align: center; gap: 6px; }
.end__title { margin: 0; font-size: clamp(24px, 7.5vw, 32px); letter-spacing: .03em; }

.lineup {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: clamp(36px, 11.5vw, 56px);
  line-height: 1.04;
}
.lineup li { animation: title-in .55s cubic-bezier(.25, 1.6, .5, 1) both; }
.lineup li:nth-child(2) { animation-delay: .1s; }
.lineup li:nth-child(3) { animation-delay: .2s; }
.lineup li:nth-child(4) { animation-delay: .3s; }
.lineup li:nth-child(5) { animation-delay: .4s; }

.end__actions { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.end__actions > .pill { width: 100%; max-width: 340px; font-size: 22px; }
.end__row { display: flex; gap: 8px; width: 100%; max-width: 340px; }
.end__row .pill { flex: 1; padding: 4px 8px 2px; font-size: 18px; }

/* ---------- Coriandoli ---------- */
.confetti { position: absolute; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; border-radius: 40px; }
.confetti i {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: fall var(--d, 2s) cubic-bezier(.25, .6, .5, 1) var(--delay, 0s) forwards;
}
@keyframes fall {
  from { transform: translate3d(0, 0, 0) rotate(0); opacity: 1; }
  85% { opacity: 1; }
  to { transform: translate3d(var(--x, 0), var(--y, 700px), 0) rotate(var(--r, 540deg)); opacity: 0; }
}

/* ---------- Toast (es. "LINK COPIATO") ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 40px;
  z-index: 6;
  padding: 10px 20px 8px;
  border-radius: 999px;
  background: var(--yellow);
  color: var(--pink);
  text-shadow: none;
  font-size: 18px;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Schermi bassi (es. iPhone SE con barre del browser) ---------- */
@media (max-height: 620px) {
  :root { --pad-y: 24px; --key-h: 44px; }
  .sticker[data-screen="game"] .logo { font-size: 30px; }
  .logo { font-size: clamp(48px, 15vw, 70px); }
  .keyboard { gap: 5px; }
  .hint { margin-top: 3px; font-size: 14px; }
  .pill--big { min-height: 54px; font-size: 26px; }
  .lineup { font-size: clamp(32px, 10vw, 46px); }
}
@media (max-width: 360px) {
  :root { --pad-x: 22px; --key-gap: 4px; }
  .status__count { font-size: 15px; }
  .life { width: 17px; height: 17px; }
}

/* ---------- Accessibilità: riduci le animazioni ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: .01ms !important;
  }
  .confetti { display: none; }
  .pose,
  .free__pose--b { animation: none !important; opacity: 0; }
  .pose--1,
  .gallows.is-free .free__pose--a { animation: none !important; opacity: 1; }
}
