:root {
  /* the colours of Animorio: petrol and tungsten */
  --p900: #041b1a;
  --p800: #072a29;
  --p700: #0b3b39;
  --p600: #0f4f4c;
  --tungsteno: #ff8a3d;
  --tungsteno-ombra: #d9602a;
  --tungsteno-chiaro: #ffb27a;
  --tungsteno-testo: #a8440c;
  --menta: #86cfc4;
  --pesca: #ffc896;
  --bianco: #f6f7f3;
  --inchiostro: #07201f;
  --tenue: #3f5452;
  --e-elastico: cubic-bezier(0.34, 1.9, 0.45, 1);
  --e-uscita: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
}

body {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--p800);
  color: var(--bianco);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.nascosto {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* the whole game: the bar on top, the sheet of paper below */
.gioco {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: clamp(6px, 1.4vmin, 14px);
  width: 100%;
  height: 100%;
  padding: clamp(8px, 2vmin, 20px);
  padding-top: max(clamp(8px, 2vmin, 20px), env(safe-area-inset-top));
  padding-bottom: max(clamp(8px, 2vmin, 20px), env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------- the bar */
.testa {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 4px;
}
.punti {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.punti__nome {
  color: var(--menta);
  font-size: 0.82rem;
  font-weight: 560;
  font-stretch: 108%;
}
.punti__num {
  --w: 112;
  font-size: clamp(1.45rem, 1rem + 1.6vmin, 2.3rem);
  font-weight: 700;
  font-stretch: calc(var(--w) * 1%);
  letter-spacing: -0.03em;
  line-height: 1;
}
.livello {
  --w: 104;
  margin: 0;
  color: var(--tungsteno-chiaro);
  font-size: 0.95rem;
  font-weight: 620;
  font-stretch: calc(var(--w) * 1%);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.destra {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.vite {
  display: flex;
  gap: 4px;
  margin-right: 6px;
}
.vite svg {
  width: 20px;
  height: 20px;
  display: block;
}
.tasto {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--bianco);
  box-shadow: inset 0 0 0 1px rgba(246, 247, 243, 0.2);
  cursor: pointer;
  touch-action: manipulation;
  transition: box-shadow 0.32s ease, transform 0.5s var(--e-elastico);
}
.tasto svg {
  width: 20px;
  height: 20px;
}
.tasto[aria-pressed='true'] .tasto__muto,
.tasto[aria-pressed='false'] .tasto__onde {
  display: none;
}
.tasto:focus-visible {
  outline: 2px solid var(--tungsteno-chiaro);
  outline-offset: 2px;
}
.tasto:active {
  transform: scale(0.92);
}
@media (hover: hover) and (pointer: fine) {
  .tasto:hover {
    box-shadow: inset 0 0 0 1.5px var(--tungsteno-chiaro);
    transform: scale(1.06);
  }
}

/* narrow phones: the level name leaves the bar (it is on the shutter anyway) */
@media (max-width: 520px) {
  .testa {
    grid-template-columns: 1fr auto;
  }
  .livello {
    display: none;
  }
  .punti__nome {
    font-size: 0.74rem;
  }
  .vite svg {
    width: 17px;
    height: 17px;
  }
  .tasto {
    width: 36px;
    height: 36px;
  }
}

/* ---------------------------------------------------------------- the sheet */
.campo {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: clamp(12px, 2.2vmin, 22px);
  background: var(--bianco);
  color: var(--inchiostro);
  container-type: size;
  touch-action: none;
}
.tela {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* the paddle is a real Animorio pill: the label widens on the wdth axis and the body swells when the diamond lands */
.racchetta {
  --g: 0;
  --s: 0;
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  will-change: transform;
}
.racchetta__fondo {
  position: absolute;
  inset: calc(var(--g) * -3px) calc(var(--g) * -11px);
  border-radius: 999px;
  background: var(--inchiostro);
  transform: scale(calc(1 + var(--s) * 0.05), calc(1 - var(--s) * 0.2));
  transition: background-color 0.4s ease;
}
.racchetta__testo {
  position: relative;
  color: var(--bianco);
  font-weight: 640;
  font-stretch: calc(100% + var(--g) * 25%);
  letter-spacing: -0.01em;
  line-height: 1;
  transform: scale(1, calc(1 - var(--s) * 0.12));
  transition: color 0.4s ease;
}
.racchetta.is-larga .racchetta__testo {
  color: var(--tungsteno-chiaro);
}
.racchetta.is-lampo .racchetta__fondo {
  background: var(--p600);
}

.cenno {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  margin: 0;
  color: var(--tenue);
  font-size: 0.86rem;
  font-weight: 540;
  font-stretch: 106%;
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

/* the shutter of the site: four petrol columns that fall like a staircase */
.otturatore {
  position: absolute;
  inset: -2px;
  display: flex;
  pointer-events: none;
  z-index: 3;
}
.otturatore i {
  display: block;
  height: 100%;
  margin-right: -1px;
  background: var(--p700);
  transform: translateY(-101%);
}
.otturatore i:nth-child(1) { flex: 22; }
.otturatore i:nth-child(2) { flex: 18; }
.otturatore i:nth-child(3) { flex: 38; }
.otturatore i:nth-child(4) { flex: 22; margin-right: 0; }
.otturatore__nome {
  --w: 100;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 16px;
  color: var(--bianco);
  font-size: min(9cqw, 13cqh);
  font-weight: 680;
  font-stretch: calc(var(--w) * 1%);
  letter-spacing: -0.04em;
  line-height: 0.9;
  text-align: center;
  opacity: 0;
}

/* ---------------------------------------------------------------- the veils: start, pause, end */
.velo {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(246, 247, 243, 0.86);
}
.velo[hidden] {
  display: none;
}
.velo__dentro {
  display: grid;
  justify-items: center;
  gap: clamp(10px, 3cqh, 22px);
  max-width: 100%;
  text-align: center;
}
.velo__rombo {
  width: clamp(26px, 6cqmin, 44px);
  height: clamp(26px, 6cqmin, 44px);
}
.titolo {
  margin: 0;
  color: var(--inchiostro);
  font-size: min(15cqw, 19cqh);
  font-weight: 680;
  font-stretch: 112%;
  letter-spacing: -0.045em;
  line-height: 0.86;
}
.titolo--medio {
  font-size: min(10.5cqw, 13cqh);
}
.titolo .parola-m {
  display: inline-block;
  overflow: clip;
  padding: 0.04em 0.03em 0.12em;
  margin: -0.04em -0.03em -0.12em;
  vertical-align: top;
}
.titolo .parola-m > span {
  --w: 112;
  display: inline-block;
  font-stretch: calc(var(--w) * 1%);
}
.come {
  max-width: 34em;
  margin: 0;
  color: var(--tenue);
  font-size: clamp(0.88rem, 0.7rem + 1.2cqmin, 1.08rem);
  font-weight: 470;
  line-height: 1.7;
  text-wrap: balance;
}
.k {
  display: inline-grid;
  place-items: center;
  min-width: 1.85em;
  height: 1.7em;
  padding: 0 0.42em;
  margin: 0 0.12em;
  border-radius: 0.42em;
  box-shadow: inset 0 0 0 1.5px rgba(7, 32, 31, 0.28), inset 0 -2px 0 rgba(7, 32, 31, 0.18);
  color: var(--inchiostro);
  font-size: 0.86em;
  font-weight: 600;
  font-stretch: 106%;
  line-height: 1;
  vertical-align: 0.04em;
}
.k svg {
  width: 0.95em;
  height: 0.95em;
}
.esito {
  display: grid;
  justify-items: center;
  gap: 2px;
  margin: 0;
}
.esito__nome {
  color: var(--tenue);
  font-size: 0.9rem;
  font-weight: 560;
}
.esito__num {
  --w: 112;
  color: var(--inchiostro);
  font-size: min(17cqw, 20cqh);
  font-weight: 700;
  font-stretch: calc(var(--w) * 1%);
  letter-spacing: -0.05em;
  line-height: 0.9;
}
.record {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  color: var(--tenue);
  font-size: 0.92rem;
  font-weight: 540;
}
.record[hidden] {
  display: none;
}
.record b {
  color: var(--inchiostro);
  font-weight: 680;
}
.bollino {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--tungsteno);
  color: var(--inchiostro);
  font-size: 0.8rem;
  font-weight: 650;
  font-stretch: 110%;
}

/* the elastic pill of the site: the label widens on the wdth axis, the body swells with a bounce */
.pillola {
  --gonfia: 7px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--bianco);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 640;
  font-stretch: 100%;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.pillola::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--inchiostro);
  transition: inset 0.6s var(--e-elastico), transform 0.16s var(--e-uscita);
}
.pillola__testo {
  display: inline-grid;
  text-align: center;
  transition: font-stretch 0.6s var(--e-elastico);
}
.pillola__testo::before {
  content: attr(data-testo);
  grid-area: 1 / 1;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 125%;
}
.pillola__segno {
  width: 16px;
  height: 16px;
  flex: none;
  color: var(--tungsteno);
  transition: transform 0.6s var(--e-elastico);
}
@media (hover: hover) and (pointer: fine) {
  .pillola:hover::before {
    inset: -2px calc(var(--gonfia) * -1);
  }
  .pillola:hover .pillola__testo {
    font-stretch: 125%;
  }
  .pillola:hover .pillola__segno {
    transform: translateX(3px) rotate(-14deg);
  }
}
.pillola:active::before {
  transform: scale(1.03, 0.88);
}
.pillola:focus-visible {
  outline: 2px solid var(--tungsteno-testo);
  outline-offset: 4px;
}

/* small sheets (a phone held low, the preview): everything a step smaller */
@container (max-height: 420px) {
  .pillola { min-height: 46px; padding: 0 22px; }
  .velo__dentro { gap: 10px; }
}

/* ---------------------------------------------------------------- the preview tile */
.anteprima .gioco {
  padding: 12px;
  gap: 8px;
}
.anteprima .racchetta__fondo,
.anteprima .racchetta__testo {
  transition: none;
}
.anteprima .otturatore {
  position: fixed;
}
.anteprima .tasto {
  display: none;
}
.anteprima .vite {
  margin-right: 0;
}
.anteprima .testa {
  grid-template-columns: 1fr auto 1fr;
  min-height: 32px;
}
.anteprima .livello {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .pillola::before,
  .pillola__testo,
  .pillola__segno,
  .tasto {
    transition: none;
  }
}
