/* Wasted Years. Un solo sistema: una scala di spazi, un raggio, una coppia di bottoni. */

/* Font locali, licenza SIL Open Font (vedi assets/fonts). Gli stessi servono all'immagine del verdetto. */
@font-face {
  font-family: "Anton";
  src: url("assets/fonts/anton-latin-400.woff2") format("woff2");
  font-weight: 400 900; /* un solo peso: così il browser non lo ingrassa da sé */
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("assets/fonts/jetbrains-mono-latin-700.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* colori, dai riferimenti: crepuscolo viola-rosa-pesca su blu notte */
  --bg: #0b0a1f;
  --bg-alt: #121030;
  --panel: #1b1840;
  --panel-line: #3b3880;
  --shadow: #04030c;
  --ink: #fdfdfd;
  --muted: #b9b6d8;
  --line: rgba(255, 255, 255, 0.14);
  --pink: #ffb2c6;
  --peach: #ffd4a8;
  --hot: #ff5c93;
  --cyan: #6fe4ff;
  --action: var(--pink);

  /* spazi */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* ritmo */
  --nav: 56px;
  --gut: 16px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-btn: 1000px;
  --btn-h: 52px;

  /* caratteri */
  --f-display: "Anton", "Avenir Next Condensed", "HelveticaNeue-CondensedBlack", Impact, "Roboto Condensed", "sans-serif-condensed", "Arial Narrow", sans-serif;
  --f-text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, "Roboto Mono", Consolas, monospace;
  --t-h1: clamp(34px, 7.2vw, 76px);
  --t-h2: clamp(30px, 5.4vw, 56px);
  --t-h3: clamp(22px, 3vw, 28px);
  --t-lead: clamp(17px, 1.6vw, 20px);
  --t-body: 16px;
  --t-label: 13px;
}

@media (min-width: 640px) {
  :root {
    --nav: 72px;
    --gut: 32px;
  }
}

@media (min-width: 1024px) {
  :root {
    --gut: 80px;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

html {
  /* niente scorrimento laterale, nemmeno per un attimo durante le animazioni dei tocchi */
  overflow-x: clip;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav) + var(--s-4));
}

body {
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--ink);
  font: 400 var(--t-body) / 1.6 var(--f-text);
  padding-top: var(--nav);
}

.wrap {
  width: 100%;
  max-width: calc(1280px + 2 * var(--gut));
  margin: 0 auto;
  padding: 0 var(--gut);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-wrap: balance;
}

h1 {
  font-size: var(--t-h1);
}

h2 {
  font-size: var(--t-h2);
}

h3 {
  font-size: var(--t-h3);
}

p {
  margin: 0;
}

a {
  color: var(--action);
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.lead {
  max-width: 46ch;
  font-size: var(--t-lead);
  line-height: 1.5;
  color: var(--ink);
}

/* testata */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  height: var(--nav);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.nav__row {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.skip-link {
  position: absolute;
  left: var(--gut);
  top: 6px;
  z-index: 11;
  padding: var(--s-2) var(--s-4);
  background: var(--action);
  color: var(--bg);
  border-radius: var(--r-btn);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.brand {
  margin-right: auto;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
}

.brand__accent {
  color: var(--pink);
}

/* il segno: due mani che stringono le sbarre. Il disegno sta in un <symbol id="mark"> in index.html:
   gli stili del contenuto si scrivono su #mark, non su .brand__mark. Lo stesso disegno sta in js/card.js,
   assets/favicon.svg, tools/icon.html e tools/og.html. */
.brand__mark {
  width: 1.8em;
  height: 1.35em;
  flex: none;
}

#mark .bars {
  fill: none;
  stroke: var(--pink);
  stroke-width: 1.8;
  stroke-linecap: round;
}

#mark .hand {
  fill: var(--pink);
  stroke: var(--bg);
  stroke-width: 1.3;
  stroke-linejoin: round;
  paint-order: stroke;
}

#mark .gap {
  fill: none;
  stroke: var(--bg);
  stroke-width: 1;
  stroke-linecap: round;
}

.tabs {
  display: flex;
  gap: 2px;
}

.tab,
.lang__button {
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  background: none;
  color: var(--ink);
  font: 600 15px / 1 var(--f-text);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s;
}

.tab:hover,
.lang__button:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

.tab[aria-current="page"] {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.5);
}

/* selettore della lingua: bottone con la sigla e menu disegnato da noi */
.lang {
  position: relative;
  flex: none;
}

.lang__button {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 14px;
  border-color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  letter-spacing: 0.04em;
}

/* la freccetta, come quella di Condividi */
.lang__button::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border: solid currentColor;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
  transition: transform 0.15s;
}

.lang__button[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.12);
}

.lang__button[aria-expanded="true"]::after {
  margin-top: 3px;
  transform: rotate(225deg);
}

.lang__list {
  position: absolute;
  top: calc(100% + var(--s-2));
  right: 0;
  z-index: 20;
  min-width: 176px;
  margin: 0;
  padding: var(--s-1);
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--r-md);
  box-shadow: 4px 4px 0 var(--shadow);
}

.lang__option {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 44px;
  padding: 0 var(--s-3);
  border: 0;
  border-radius: calc(var(--r-md) - var(--s-1));
  background: none;
  color: var(--ink);
  font: 600 15px / 1 var(--f-text);
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
}

.lang__option:hover,
.lang__option:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

.lang__option[aria-current="true"] {
  color: var(--pink);
}

/* la spunta accanto alla lingua scelta */
.lang__option[aria-current="true"]::after {
  content: "";
  width: 6px;
  height: 11px;
  margin: -3px 2px 0 auto;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.lang__code {
  width: 22px;
  color: var(--muted);
  font: 700 12px / 1 var(--f-mono);
  letter-spacing: 0.04em;
}

.lang__option[aria-current="true"] .lang__code {
  color: inherit;
}

/* telefoni: la testata deve reggere anche "Confiesa · Sentencias" senza uscire dallo schermo */
@media (max-width: 479px) {
  .brand {
    font-size: clamp(14px, 4.2vw, 20px);
  }

  .tab {
    padding: 0 5px;
    font-size: 14px;
  }

  .lang__button {
    padding: 0 10px;
    gap: 6px;
  }
}

@media (max-width: 359px) {
  .brand {
    font-size: 12.5px;
  }

  .tab {
    padding: 0 4px;
    font-size: 13px;
  }

  .lang__button {
    padding: 0 7px;
    gap: 4px;
  }

  .nav__row {
    gap: 2px;
  }
}

@media (min-width: 640px) {
  .brand {
    font-size: 26px;
  }

  .tab {
    padding: 0 var(--s-4);
  }

  .nav__row {
    gap: var(--s-3);
  }
}

/* viste */

.view {
  padding: var(--s-5) 0 var(--s-7);
}

.notice {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  padding-bottom: var(--s-3);
  color: var(--peach);
}

/* apertura */

.hero {
  display: grid;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}

.hero__art {
  display: block;
  width: 100%;
  height: clamp(120px, 34vw, 340px);
  object-fit: cover;
  object-position: 50% 12%;
  border: 2px solid var(--panel-line);
  border-radius: var(--r-lg);
  background: var(--panel);
}

.hero__text {
  display: grid;
  gap: var(--s-3);
}

@media (min-width: 900px) {
  .hero {
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: var(--s-7);
  }

  .hero__art {
    order: 2;
    height: 340px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  /* una volta sola, al caricamento: main.js toglie la classe subito dopo */
  .is-entering .hero__art {
    animation: enter 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }

  .is-entering .hero__text {
    animation: enter 0.7s 0.08s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}

/* stato della sessione: sempre visibile */

.status {
  position: sticky;
  top: var(--nav);
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--s-4);
  margin: 0 calc(-1 * var(--gut)) var(--s-3);
  padding: var(--s-3) var(--gut);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.stat {
  display: grid;
  gap: 2px;
}

.stat--wide {
  grid-column: 1 / -1;
  margin-top: var(--s-2);
  padding-top: var(--s-2);
  border-top: 1px solid var(--line);
}

.stat__label {
  font-size: var(--t-label);
  font-weight: 500;
  color: var(--muted);
}

.stat__value {
  font: 700 24px / 1.1 var(--f-mono);
  font-variant-numeric: tabular-nums;
}

.stat__value--accent {
  /* largo quanto il testo: l'ingrandimento a ogni tocco non deve spingere oltre il bordo dello schermo */
  justify-self: start;
  max-width: 100%;
  font: 800 clamp(24px, 7.2vw, 44px) / 1 var(--f-display);
  text-transform: uppercase;
  color: var(--pink);
  /* spazio fisso per due righe: quando il livello cambia, i tasti sotto non si spostano mentre tocchi */
  min-height: 2em;
}

/* le frasi lunghe (battute comprese) un po' più piccole, così stanno sempre in due righe */
.stat__value--accent.is-long {
  font-size: clamp(19px, 5.6vw, 34px);
  min-height: calc(2 * clamp(24px, 7.2vw, 44px));
}

/* "Ricomincia": piccolo, in alto a destra accanto a Tempo e Reati; compare solo con almeno un reato */
.status {
  grid-template-columns: 1fr 1fr auto;
}

.restart {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--r-btn);
  background: none;
  color: var(--ink);
  font: 600 14px / 1 var(--f-text);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.restart:hover {
  border-color: var(--pink);
  color: var(--pink);
}

/* telefoni molto stretti: solo l'icona; il nome resta per i lettori di schermo */
@media (max-width: 359px) {
  .restart {
    padding: 0 13px;
  }

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

.restart svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (min-width: 640px) {
  .status {
    grid-template-columns: auto auto 1fr auto;
    gap: 0 var(--s-7);
    align-items: end;
  }

  .restart {
    order: 1; /* in fondo alla riga, dopo il livello */
  }

  .stat--wide {
    grid-column: auto;
    margin: 0;
    padding: 0 0 0 var(--s-7);
    border-top: 0;
    border-left: 1px solid var(--line);
  }
}

/* il tuo Paese: bandiere sotto "Modalità rapida" */

.country {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-2);
}

.country__label {
  font-size: var(--t-label);
  font-weight: 500;
  color: var(--muted);
}

.country__flags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.flag-btn {
  width: 62px;
  height: 46px;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--panel-line);
  border-radius: 10px;
  background: var(--panel);
  opacity: 0.7;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.08s;
}

.flag-btn img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.flag-btn:hover {
  opacity: 1;
  border-color: var(--ink);
}

.flag-btn:active {
  transform: scale(0.95);
}

.flag-btn[aria-pressed="true"] {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(255, 178, 198, 0.35);
  opacity: 1;
}

.stat__flag {
  width: 24px;
  height: 16px;
  margin-right: var(--s-2);
  border-radius: 3px;
  vertical-align: -2px;
  object-fit: cover;
}

@media (prefers-reduced-motion: no-preference) {
  .stat__value--accent.is-growing {
    animation: grow 0.3s ease-out;
    transform-origin: left center;
  }
}

@keyframes grow {
  40% {
    transform: scale(1.08);
  }
}

/* bottoni delle azioni */

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}

@media (min-width: 640px) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s-4);
  }
}

@media (min-width: 1024px) {
  .tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.tile {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 2px solid var(--panel-line);
  border-radius: var(--r-md);
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--shadow);
  color: #fff;
  font: 700 16px / 1.15 var(--f-text);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.08s, box-shadow 0.08s, border-color 0.15s;
}

/* il video riempie il tasto; una sfumatura scura in basso tiene leggibile il nome */
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to top, rgba(4, 3, 12, 0.92) 0%, rgba(4, 3, 12, 0.6) 30%, rgba(4, 3, 12, 0) 62%);
}

.tile:hover {
  border-color: var(--pink);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--shadow);
}

.tile:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--shadow);
}

.tile__media {
  position: absolute;
  inset: 0;
}

.tile__media img,
.tile__media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ripiego se il video o il fermo-immagine non si carica */
.tile__emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding-bottom: 28px;
  background: var(--panel);
  font-size: 56px;
  line-height: 1;
}

.tile__name {
  position: absolute;
  z-index: 2;
  left: var(--s-3);
  right: var(--s-3);
  bottom: var(--s-2);
  hyphens: auto;
  overflow-wrap: break-word;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.tile__count {
  position: absolute;
  z-index: 2;
  top: var(--s-2);
  right: var(--s-2);
  min-width: 38px;
  padding: 3px 9px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--r-btn);
  background: rgba(11, 10, 31, 0.72);
  color: #fff;
  font: 700 17px / 1.3 var(--f-mono);
  text-align: center;
}

.tile[data-count]:not([data-count="0"]) {
  border-color: var(--pink);
}

.tile[data-count]:not([data-count="0"]) .tile__count {
  border-color: var(--pink);
  background: var(--pink);
  color: var(--bg);
}

@media (prefers-reduced-motion: no-preference) {
  .tile.is-hit .tile__count {
    animation: pop 0.25s ease-out;
  }
}

@keyframes pop {
  40% {
    transform: scale(1.35);
  }
}

/* bottoni */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--btn-h);
  padding: 0 var(--s-5);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--r-btn);
  background: transparent;
  color: var(--ink);
  font: 600 16px / 1.1 var(--f-text);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s, border-color 0.15s, transform 0.08s;
}

.btn--primary {
  background: var(--pink);
  border-color: var(--pink);
  color: var(--bg);
}

.btn--primary:hover {
  background: #ffc6d5;
  border-color: #ffc6d5;
}

.btn--secondary:hover {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

.btn-row {
  display: grid;
  gap: var(--s-3);
  margin-top: var(--s-6);
}

@media (min-width: 640px) {
  .btn-row {
    display: flex;
  }
}

/* barra in fondo alla vista live */

.bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
  margin: var(--s-5) calc(-1 * var(--gut)) 0;
  padding: var(--s-3) var(--gut) calc(var(--s-3) + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
}

.bar .btn {
  min-height: 64px;
  padding: 0 var(--s-3);
}

@media (min-width: 640px) {
  .bar {
    grid-template-columns: repeat(2, minmax(0, 260px));
    justify-content: end;
  }
}

/* modalità rapida */

.view--quick h2 {
  margin-bottom: var(--s-4);
}

.view--quick .lead {
  margin-bottom: var(--s-5);
}

.quick {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s-2);
}

@media (min-width: 900px) {
  .quick {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-3) var(--s-5);
  }
}

.qrow {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3);
  border: 2px solid var(--panel-line);
  border-radius: var(--r-md);
  background: var(--panel);
}

.qrow:not([data-count="0"]) {
  border-color: var(--pink);
}

.qrow__icon {
  display: flex;
  align-items: center;
  width: 36px;
  font-size: 28px;
  line-height: 1;
}

img.qrow__icon {
  height: 36px;
  border-radius: 9px;
  background: var(--bg);
  object-fit: cover;
}

.qrow__name {
  font-weight: 600;
  line-height: 1.25;
  hyphens: auto;
  overflow-wrap: break-word;
}

.stepper {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.step {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--r-btn);
  background: none;
  color: var(--ink);
  font: 700 24px / 1 var(--f-text);
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s, border-color 0.15s, transform 0.08s;
}

.step:hover:not(:disabled) {
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

.step:active:not(:disabled) {
  transform: scale(0.94);
}

.step:disabled {
  opacity: 0.3;
  cursor: default;
}

.qrow__count {
  min-width: 34px;
  text-align: center;
  font: 700 20px / 1 var(--f-mono);
  font-variant-numeric: tabular-nums;
}

.qrow:not([data-count="0"]) .qrow__count {
  color: var(--pink);
}

.bar.bar--quick {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.bar__total {
  font: 800 28px / 1 var(--f-display);
  text-transform: uppercase;
  color: var(--pink);
}

@media (min-width: 640px) {
  .bar.bar--quick {
    grid-template-columns: auto 260px;
    gap: var(--s-6);
  }
}

.hero__quick {
  justify-self: start;
}

/* verdetto */

/* "Sentenza": il titolo della sezione con l'immagine, centrato come l'immagine */
.verdict__title {
  font-size: var(--t-h1);
  margin-bottom: var(--s-5);
  text-align: center;
}

.verdict__title:focus,
#history-title:focus {
  outline: none;
}

.sessions,
.charges {
  list-style: none;
  margin: 0;
  padding: 0;
}

.flag {
  grid-row: 1 / 3;
  width: 54px;
  height: 36px;
  border: 2px solid var(--shadow);
  border-radius: 6px;
  object-fit: cover;
}

/* immagine da condividere */

/* immagine al centro, con sotto Condividi e il caffè, nella stessa colonna */
.share {
  display: grid;
  gap: var(--s-4);
  max-width: 420px;
  margin-inline: auto;
}

.share__preview {
  display: block;
  width: 100%;
  height: auto;
  border: 2px solid var(--panel-line);
  border-radius: var(--r-md);
  box-shadow: 4px 4px 0 var(--shadow);
}

.share__actions {
  display: grid;
  gap: var(--s-3);
}

.share__options {
  display: grid;
  gap: var(--s-2);
}

.share__options .btn {
  padding: var(--s-3) var(--s-5);
  line-height: 1.25;
}

/* la freccetta dice che il bottone apre una scelta */
#share-main::after {
  content: "";
  width: 8px;
  height: 8px;
  margin: -4px 0 0 var(--s-3);
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  transition: transform 0.15s;
}

#share-main[aria-expanded="true"]::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}

.share__status {
  min-height: 1.6em;
  margin-top: var(--s-3);
  color: var(--muted);
}

.detail {
  margin-top: var(--s-7);
}

.detail h3 {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.flag--title {
  width: 36px;
  height: 24px;
}

/* un blocco per ogni Paese: il tuo aperto, gli altri richiusi */
.detail__block + .detail__block {
  margin-top: var(--s-6);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}

.detail__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-1) var(--s-4);
  min-height: 48px;
  cursor: pointer;
  list-style: none;
}

.detail__summary::-webkit-details-marker {
  display: none;
}

.detail__summary h3 {
  margin-bottom: 0;
}

.detail__penalty {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font: 800 20px / 1.1 var(--f-display);
  text-transform: uppercase;
  color: var(--pink);
}

/* la freccetta dice che si apre */
.detail__penalty::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border: solid var(--ink);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  transition: transform 0.15s;
}

details[open] > .detail__summary .detail__penalty::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}

details[open] > .detail__summary {
  margin-bottom: var(--s-4);
}

.charges {
  border-top: 1px solid var(--line);
}

.charge {
  display: grid;
  gap: var(--s-1);
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--line);
}

.charge__head {
  display: flex;
  gap: var(--s-3);
  align-items: baseline;
  font-weight: 600;
  font-size: 18px;
}

.charge__count {
  font-family: var(--f-mono);
  color: var(--pink);
}

.charge__law {
  width: fit-content;
  font-size: 15px;
}

.charge__penalty {
  font-size: 15px;
  color: var(--muted);
}

.totals {
  display: grid;
  gap: 0;
  margin: var(--s-5) 0 0;
}

.totals div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-1) var(--s-4);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--line);
}

.totals dt {
  color: var(--muted);
}

.totals dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.totals .is-main dd {
  color: var(--pink);
}

.detail__note {
  margin-top: var(--s-4);
  color: var(--peach);
}

/* storico */

#history-title {
  margin-bottom: var(--s-5);
}

.sessions {
  display: grid;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}

.session {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4);
  border: 2px solid var(--panel-line);
  border-radius: var(--r-lg);
  background: var(--panel);
}

.session__count {
  font: 800 28px / 1 var(--f-display);
  text-transform: uppercase;
  color: var(--pink);
}

.session__meta {
  font-size: 15px;
  color: var(--muted);
}

.session__actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-2);
}

.session__actions .btn {
  min-height: 48px;
  padding: 0 var(--s-4);
}

.empty {
  color: var(--muted);
}

@media (min-width: 640px) {
  .session {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

/* caffè, sotto "Condividi" */

.coffee {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-5);
}

#coffee-link[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.coffee__text {
  font-weight: 600;
  text-align: center;
}

/* tazza a tratto: nostra, non il logo di Buy Me a Coffee */
.coffee__icon {
  width: 22px;
  height: 22px;
  margin-right: var(--s-2);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (min-width: 640px) {
  .coffee {
    max-width: 420px;
  }
}

/* come calcoliamo */

.how {
  padding: var(--s-8) 0;
  background: var(--bg-alt);
  border-top: 1px solid var(--line);
}

.how .lead {
  margin: var(--s-4) 0 var(--s-6);
  max-width: 62ch;
}

.how__grid {
  display: grid;
  gap: var(--s-5);
}

@media (min-width: 900px) {
  .how__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--s-6);
  }
}

.how__item h3 {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.how__item .flag {
  width: 36px;
  height: 24px;
}

.how__item ul {
  margin: 0 0 var(--s-3);
  padding-left: 1.1em;
  display: grid;
  gap: var(--s-2);
}

.how__sources {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1) var(--s-4);
  font-size: 15px;
}

.how__sources a {
  display: inline-block;
  padding: var(--s-2) 0;
}

/* piede */

.footer {
  padding: var(--s-7) 0 calc(var(--s-7) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
  font-size: 14px;
  color: var(--muted);
}

.footer .wrap {
  display: grid;
  gap: var(--s-2);
}

.footer p {
  max-width: 78ch;
}

.brand--footer {
  margin: 0 0 var(--s-2);
  font-size: 28px;
  min-height: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* finestra di conferma: pannello scuro, titolo condensato, due bottoni a pillola */
.dialog {
  width: min(420px, calc(100vw - 2 * var(--gut)));
  margin: auto;
  padding: clamp(var(--s-5), 6vw, var(--s-6));
  border: 2px solid var(--panel-line);
  border-radius: var(--r-lg);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--shadow);
  color: var(--ink);
}

.dialog::backdrop {
  background: rgba(4, 3, 12, 0.78);
}

.dialog__title {
  margin: 0 0 var(--s-3);
  font: 800 clamp(30px, 8vw, 40px) / 1 var(--f-display);
  text-transform: uppercase;
  color: var(--pink);
}

.dialog__text {
  margin: 0 0 var(--s-6);
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
}

.dialog__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.dialog__actions .btn {
  padding: 0 var(--s-3);
}

/* telefoni molto stretti: bottoni uno sotto l'altro, così nessun testo va a capo */
@media (max-width: 359px) {
  .dialog__actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .dialog[open] {
    animation: dialog-in 0.18s ease-out;
  }

  .dialog[open]::backdrop {
    animation: fade-in 0.18s ease-out;
  }
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* "Installa l'app": nella pagina iniziale, sotto le bandiere */
.install {
  margin-top: var(--s-4);
}

.install__button {
  gap: var(--s-2);
}

.install__button svg,
.dialog__steps svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dialog__steps {
  display: grid;
  gap: var(--s-2);
  margin: 0 0 var(--s-4);
  padding-left: 1.4em;
  font-size: 17px;
  line-height: 1.45;
}

.dialog__note {
  margin: 0 0 var(--s-5);
  font-size: 15px;
  line-height: 1.45;
  color: var(--muted);
}

.dialog__actions.dialog__actions--single {
  grid-template-columns: 1fr;
}
