/* ==========================================================
   Palette (cambia i colori qui, in un solo posto)
   ========================================================== */
:root {
  --bg: #fbf6ea;          /* panna */
  --bg-2: #eaf7f3;        /* verdeacqua chiarissimo */
  --ink: #0f4a47;         /* verde petrolio, per i testi */
  --ink-soft: #3f7a75;
  --teal: #38bdb0;        /* verdeacqua */
  --teal-deep: #1f8f86;
  --pine: #2f7d5b;        /* verde abete */
  --gold: #d4a62a;
  --gold-soft: #f3dc93;
  --coral: #ef6f61;       /* rosso */
  --paper: #fffdf6;
  --shadow: 0 10px 24px rgba(15, 74, 71, .16);

  --font-body: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  --font-hand: "Bradley Hand", "Segoe Print", "Comic Sans MS", cursive;
}

* { box-sizing: border-box; }
html { color-scheme: light; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 10% -10%, var(--bg-2), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, #fdf0c8, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
body.lock { overflow: hidden; }

#fx {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 1;
}

.page {
  position: relative; z-index: 2; container-type: inline-size;
  max-width: 760px; margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top)) 16px calc(36px + env(safe-area-inset-bottom));
}

/* ---------- TITOLO e TESTO ---------- */
/* Centrato. Per metterlo a sinistra: in index.html scrivi <header class="hero left"> */
.hero { text-align: center; margin-bottom: 22px; }
.hero.left { text-align: left; }
.hero.left .sub { margin-left: 0; }
.eyebrow {
  margin: 0 0 6px; font-size: .8rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold); font-weight: 700;
}
h1 {
  margin: 0; font-family: var(--font-display); font-weight: 800;
  font-size: clamp(2rem, 8vw, 3.2rem); line-height: 1.05; color: var(--teal-deep);
  /* neve depositata sopra le lettere: copie bianche spostate verso l'alto */
  text-shadow:
    0 -2px 0 #fff, 1px -3px 0 #fff, -1px -3px 0 #fff, 0 -4px 0 #fff,
    0 -5px 0 rgba(150, 205, 228, .75);
}
.sub { margin: 10px auto 0; max-width: 34ch; color: var(--ink-soft); line-height: 1.4; }
.status {
  display: inline-block; margin: 14px 0 0; padding: 8px 16px; border-radius: 999px;
  background: #fff; border: 2px dashed var(--gold); font-weight: 700; font-size: .95rem;
  box-shadow: 0 4px 12px rgba(212, 166, 42, .18);
}

/* ---------- GRID ---------- */
.grid {
  --gap: clamp(8px, 2.4vw, 16px);
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: var(--gap);
  grid-auto-rows: min(17vw, 130px);                          /* se il browser è vecchio */
  grid-auto-rows: calc((100cqw - 4 * var(--gap)) / 5);       /* righe alte quanto una colonna */
}

.tile {
  --a: var(--teal); --b: var(--teal-deep); --rib: var(--gold-soft);
  --nf: clamp(.95rem, 4.6vw, 1.5rem);      /* grandezza del numero */
  --rb: clamp(8px, 2.3vw, 14px);           /* spessore del nastro */
  scale: var(--lens, 1);                   /* effetto "Apple Watch" mentre scorri (lo imposta app.js) */
  position: relative; width: 100%; height: 100%; padding: 0; border: 0; cursor: pointer;
  border-radius: 16px; font: inherit; color: #fff;
  background: linear-gradient(145deg, var(--a), var(--b));
  box-shadow: var(--shadow), inset 0 -4px 0 rgba(0, 0, 0, .08);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  overflow: hidden;
}
.tile.c1 { --a: #4fc9a8; --b: var(--pine); }
.tile.c2 { --a: #fff7dc; --b: #f3dc93; --rib: var(--teal); color: var(--ink); }
.tile.c3 { --a: #ff9a8d; --b: var(--coral); --rib: #fff7dc; }
.tile.c4 { --a: #7ad9d0; --b: #2fa79c; --rib: #fff; }

.tile.c5 { --a: #a63a58; --b: #6b1830; --rib: #f3dc93; }   /* bordeaux */

/* Misure diverse */
.tile.big  { --nf: clamp(1.5rem, 9vw, 2.8rem); --rb: clamp(12px, 3.6vw, 22px); border-radius: 22px; }
.tile.wide, .tile.tall { --nf: clamp(1.15rem, 6vw, 2rem); --rb: clamp(10px, 2.8vw, 18px); }

/* ---------- FIOCCCO PACCO ---------- */
/* l'interno (si vede quando è scartato), 4 lembi di carta e il nastro in croce */
.tile { perspective: 600px; }
.tile .inner {
  position: absolute; inset: clamp(6px, 1.8vw, 11px); z-index: 0; border-radius: 12px;
  background:
    radial-gradient(circle at 22% 28%, rgba(56, 189, 176, .16) 0 7px, transparent 8px),
    radial-gradient(circle at 74% 66%, rgba(212, 166, 42, .18) 0 9px, transparent 10px),
    linear-gradient(180deg, #fffaf0, #f0e7d0);
  box-shadow: inset 0 6px 14px rgba(0, 0, 0, .3), inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.tile .flap {
  position: absolute; inset: 0; z-index: 1; backface-visibility: hidden;
  background: linear-gradient(145deg, var(--a), var(--b));
}
.tile .ft { clip-path: polygon(0 0, 100% 0, 50% 50%);     transform-origin: 50% 0; }
.tile .fr { clip-path: polygon(100% 0, 100% 100%, 50% 50%); transform-origin: 100% 50%; }
.tile .fb { clip-path: polygon(0 100%, 100% 100%, 50% 50%); transform-origin: 50% 100%; }
.tile .fl { clip-path: polygon(0 0, 0 100%, 50% 50%);     transform-origin: 0 50%; }
.tile .rib { position: absolute; z-index: 2; background: var(--rib); opacity: .9; }
.tile .rv { left: 50%; top: 0; bottom: 0; width: var(--rb); transform: translateX(-50%); }
.tile .rh { top: 50%; left: 0; right: 0; height: var(--rb); transform: translateY(-50%); }

/* Scartato: niente più carta né nastro, resta la scatola aperta */
.tile.opened .flap, .tile.opened .rib { display: none; }

/* Animazione di scarto: il nastro scivola via, poi i 4 lembi si aprono */
.tile.unwrapping { pointer-events: none; }
.tile.unwrapping .rv { animation: ribV .5s cubic-bezier(.55, 0, .8, .5) forwards; }
.tile.unwrapping .rh { animation: ribH .5s cubic-bezier(.55, 0, .8, .5) .08s forwards; }
.tile.unwrapping .flap { animation: .7s cubic-bezier(.5, 0, .25, 1) .4s forwards; }
.tile.unwrapping .ft { animation-name: flapT; }
.tile.unwrapping .fr { animation-name: flapR; }
.tile.unwrapping .fb { animation-name: flapB; }
.tile.unwrapping .fl { animation-name: flapL; }
.tile.unwrapping .num { animation: numPop .4s ease 1s; }

@keyframes ribV { to { transform: translate(-50%, -130%) rotate(5deg); opacity: 0; } }
@keyframes ribH { to { transform: translate(130%, -50%) rotate(-4deg); opacity: 0; } }
@keyframes flapT { 60% { transform: rotateX(70deg);   filter: brightness(.8); } 100% { transform: rotateX(105deg);  filter: brightness(.65); opacity: 0; } }
@keyframes flapB { 60% { transform: rotateX(-70deg);  filter: brightness(.8); } 100% { transform: rotateX(-105deg); filter: brightness(.65); opacity: 0; } }
@keyframes flapR { 60% { transform: rotateY(70deg);   filter: brightness(.8); } 100% { transform: rotateY(105deg);  filter: brightness(.65); opacity: 0; } }
@keyframes flapL { 60% { transform: rotateY(-70deg);  filter: brightness(.8); } 100% { transform: rotateY(-105deg); filter: brightness(.65); opacity: 0; } }
@keyframes numPop { 50% { transform: translate(-50%, -50%) scale(1.18); } }

.tile .num {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 4; min-width: 2.1em; padding: .2em .5em; border-radius: 999px;
  background: #fff; color: var(--ink); font-weight: 800; text-align: center; line-height: 1.2;
  font-size: var(--nf); box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}
.tile .mark {
  position: absolute; right: 6%; top: 4%; z-index: 5;
  font-size: clamp(.7rem, 3vw, 1rem); line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.2));
}

.tile:hover:not(.locked) { transform: translateY(-3px) rotate(-1deg); }
.tile:active:not(.locked) { transform: scale(.96); }
.tile:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.tile.locked { filter: saturate(.45) brightness(1.05); opacity: .62; cursor: not-allowed; }
.tile.locked .mark::before { content: "🔒"; }
.tile.opened .mark::before { content: "★"; color: var(--gold); }
.tile.opened { opacity: .92; }

.tile.today {
  animation: pulse 1.9s ease-in-out infinite;
  box-shadow: 0 0 0 3px var(--gold), 0 0 28px rgba(212, 166, 42, .6), var(--shadow);
}
.tile.today .mark::before { content: "✨"; }

/* ---------- 25 ---------- */
.tile.xmas { --a: #f8dc7a; --b: var(--gold); --rib: #fff; }
.tile.xmas .num { color: var(--coral); }

.tile.shake { animation: shake .45s ease; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-2deg); }
  40% { transform: translateX(6px) rotate(2deg); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.foot { margin-top: 28px; text-align: center; color: var(--ink-soft); font-size: .9rem; }
.heart { color: var(--coral); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 420px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: #fff; font-weight: 700; text-align: center;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================
   TIMER (prima del 1° dicembre)
   ========================================================== */
body.is-countdown {
  color: #fff;
  background:
    radial-gradient(800px 560px at 50% 42%, #17604f, transparent 72%),
    #0b3733;
}
body.is-countdown .page { display: none; }

.countdown {
  position: relative; z-index: 2; min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 24px 12px;
}
.countdown[hidden] { display: none; }
.cd { display: flex; align-items: flex-start; justify-content: center; gap: clamp(4px, 2vw, 18px); color: #fff; }
.cd-unit { display: grid; justify-items: center; gap: 10px; }
.cd-unit span, .cd-sep {
  font-size: clamp(2.4rem, 12vw, 6.5rem); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.cd-sep { opacity: .45; }
.cd-wrap { display: grid; justify-items: center; gap: clamp(22px, 6vw, 40px); }
.cd-wrap .remind { color: #fff; border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.08); }

.remind { display: inline-block; margin-top: 12px; padding: 9px 18px; border-radius: 999px; border: 2px solid var(--teal); color: var(--teal-deep); font-weight: 800; font-size: .92rem; text-decoration: none; background: #fff; }
.remind[hidden] { display: none; }
.remind:hover { transform: translateY(-1px); }
.remind:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.cd-unit small { font-size: clamp(.65rem, 2.6vw, 1rem); letter-spacing: .22em; text-transform: uppercase; opacity: .75; font-weight: 700; }

/* ==========================================================
   CASELLA APERTA: busta + lettera
   ========================================================== */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(15, 74, 71, .42); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade .3s ease;
}
.overlay[hidden] { display: none; }

.scene { display: grid; justify-items: center; gap: 22px; cursor: pointer; animation: pop .55s cubic-bezier(.2, 1.4, .4, 1); }
.scene[hidden] { display: none; }
.skip { margin: 0; color: #fff; font-weight: 700; letter-spacing: .08em; opacity: .85; }
.scene.done { animation: sink .35s ease forwards; pointer-events: none; }

.envelope { position: relative; width: min(78vw, 340px); aspect-ratio: 3 / 2; perspective: 900px; }
.envelope > div { position: absolute; }
.env-back {
  inset: 0; background: var(--teal-deep); border-radius: 10px; z-index: 0;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .3);
}
.env-letter {
  left: 6%; right: 6%; top: 6%; bottom: 6%; z-index: 2; border-radius: 6px;
  background: repeating-linear-gradient(#fffdf6 0 22px, #e8f3ef 22px 23px);
  border: 1px solid #e6dfc8; transition: transform .8s cubic-bezier(.3, 1.2, .4, 1);
}
.env-front {
  inset: 0; z-index: 3; border-radius: 10px;
  background: linear-gradient(160deg, var(--teal), var(--teal-deep));
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
}
.env-flap {
  left: 0; right: 0; top: 0; height: 56%; z-index: 4; transform-origin: top center;
  background: linear-gradient(180deg, #53cfc2, var(--teal));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .18));
}
/* sigillo: bastoncino di zucchero messo di traverso sulla punta della busta */
.env-seal {
  left: 50%; top: 56%; z-index: 5; width: 17%; aspect-ratio: 2 / 3; margin: -12% 0 0 -8.5%;
  rotate: -38deg; line-height: 0; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .35));
  transition: transform .55s cubic-bezier(.5, -.2, .8, .4), rotate .55s ease, opacity .45s ease;
}
.env-seal svg { display: block; width: 100%; height: 100%; }
.env-holly { left: 5%; bottom: 8%; width: 25%; z-index: 5; line-height: 0; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }
.env-holly svg { display: block; width: 100%; height: auto; }

.envelope.open .env-flap { animation: flap .7s ease forwards; }
.envelope.open .env-seal { transform: translateY(90%); rotate: 28deg; opacity: 0; }
.envelope.rise .env-letter { transform: translateY(-62%); }

@keyframes flap {
  0%   { transform: rotateX(0); z-index: 4; }
  49%  { transform: rotateX(89deg); z-index: 4; }
  50%  { transform: rotateX(91deg); z-index: 1; }
  100% { transform: rotateX(180deg); z-index: 1; }
}
@keyframes pop { from { transform: scale(.4) translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sink { to { transform: translateY(60px) scale(.9); opacity: 0; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- La lettera ---------- */
.paper {
  position: relative; width: min(94vw, 560px); max-height: 90vh; max-height: 90dvh; overflow: auto;
  border-radius: 6px 6px 18px 18px; background: var(--paper);
  background-image: linear-gradient(180deg, #fffdf6, #fbf6e4);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  animation: paperIn .6s cubic-bezier(.2, 1.1, .3, 1);
  /* bordo a righe rosse e bianche, come un bastoncino di zucchero */
  border-top: 10px solid;
  border-image: repeating-linear-gradient(-45deg, #d42a3f 0 10px, #fff 10px 20px) 10 0 0 0;
  overscroll-behavior: contain;
}
.paper[hidden] { display: none; }
.paper.quick { animation-duration: .3s; }
@keyframes paperIn { from { transform: translateY(60px) scale(.7) rotate(-2deg); opacity: 0; } to { transform: none; opacity: 1; } }

.close {
  position: sticky; top: 8px; float: right; margin: 8px 8px 0 0; z-index: 3;
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink); color: #fff; font-size: 1.5rem; line-height: 1;
}
.close:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.paper-inner { padding: 26px clamp(20px, 6vw, 38px) 34px; }
.day-tag {
  display: inline-block; margin: 0 0 8px; padding: 4px 12px; border-radius: 999px;
  background: #c8283f; color: #fff; font-weight: 800; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase;
}
.paper h2 { margin: 0 0 14px; font-family: var(--font-display); font-size: clamp(1.6rem, 6vw, 2.1rem); color: var(--pine); line-height: 1.1; }
.letter p {
  margin: 0 0 14px; font-family: var(--font-hand); font-size: clamp(1.2rem, 4.6vw, 1.4rem);
  line-height: 32px; color: #24504c;
}
.signature { white-space: pre-line; font-family: var(--font-hand); font-size: 1.7rem; color: var(--coral); text-align: right; margin: 8px 0 0; }

.photos { display: grid; gap: 22px; margin: 24px 0 6px; justify-items: center; }
.polaroid {
  margin: 0; padding: 10px 10px 12px; background: #fff; width: min(100%, 360px);
  box-shadow: 0 8px 18px rgba(15, 74, 71, .22); transform: rotate(var(--r, -2deg));
  position: relative;
}
.polaroid:nth-child(even) { --r: 2.2deg; }
.polaroid::before {
  content: ""; position: absolute; top: -10px; left: 50%; width: 84px; height: 22px; transform: translateX(-50%) rotate(-3deg);
  background: rgba(243, 220, 147, .8);
}
.polaroid img { display: block; width: 100%; height: auto; background: var(--bg-2); }
.polaroid figcaption { margin-top: 8px; text-align: center; font-family: var(--font-hand); font-size: 1.15rem; color: #24504c; }

.extras { display: grid; gap: 16px; margin-top: 24px; }
.coupon {
  position: relative; padding: 16px 18px; border: 2px dashed var(--coral); border-radius: 14px; background: #fff3ef;
}
.coupon small { display: block; color: var(--coral); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: .7rem; }
.coupon strong { display: block; margin: 4px 0; font-size: 1.15rem; }
.quote { margin: 0; padding: 14px 18px; border-left: 5px solid var(--gold); background: #fff8dc; border-radius: 0 12px 12px 0; font-style: italic; }
.quote, .quote cite { white-space: pre-line; }
.quote cite { display: block; margin-top: 6px; font-style: normal; font-weight: 700; color: var(--ink-soft); }
.linkcard { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-radius: 14px; background: var(--teal); color: #fff; text-decoration: none; font-weight: 800; }
.linkcard .link-text { min-width: 0; overflow-wrap: anywhere; }
.linkcard .link-text span { display: block; margin-top: 2px; font-weight: 500; opacity: .9; }
.linkcard .disc { flex: none; width: 46px; height: 46px; display: block; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.linkcard .disc.vinyl { animation: spin 5s linear infinite; }
.linkcard .disc.emoji { display: grid; place-items: center; font-size: 2rem; font-style: normal; line-height: 1; filter: none; background: rgba(255,255,255,.22); border-radius: 50%; }
.linkcard .disc svg { width: 100%; height: 100%; display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { padding: 12px 16px; border-radius: 4px; background: #fff59d; transform: rotate(-1deg); box-shadow: 0 4px 10px rgba(0, 0, 0, .12); font-family: var(--font-hand); font-size: 1.2rem; }

/* ---------- Cumuli di neve in fondo alla pagina ---------- */
.snowbank { position: relative; z-index: 2; width: 100%; height: clamp(90px, 24vw, 170px); pointer-events: none; line-height: 0; }
.snowbank svg { display: block; width: 100%; height: 100%; }
body.is-countdown .snowbank { position: fixed; left: 0; right: 0; bottom: 0; }

/* ---------- Indovinello a crocette e premio ---------- */
.quiz { padding: 16px 18px; border: 2px solid var(--teal); border-radius: 14px; background: #f1fbf8; }
.quiz small { display: block; color: var(--teal-deep); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: .7rem; }
.quiz-q { margin: 6px 0 12px; font-weight: 800; font-size: 1.1rem; line-height: 1.3; }
.quiz-opts { display: grid; gap: 8px; }
.quiz-opt {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  padding: 11px 14px; border: 2px solid #bfe8e2; border-radius: 12px; background: #fff;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--teal); transform: translateX(3px); }
.quiz-opt:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.quiz-opt:disabled { cursor: default; }
.quiz-opt.wrong { border-color: var(--coral); background: #ffefe9; color: #9a4a40; text-decoration: line-through; animation: shake .45s ease; }
.quiz-opt.right { border-color: var(--pine); background: #e4f6ea; font-weight: 800; }
.quiz-msg { margin: 10px 0 0; min-height: 1.4em; font-weight: 800; }
.quiz-msg.ok { color: var(--pine); }
.quiz-msg.no { color: var(--coral); }

.reward { margin-top: 14px; padding: 16px 18px; border: 2px dashed var(--gold); border-radius: 14px; background: #fff; animation: pop .5s cubic-bezier(.2, 1.4, .4, 1); }
.reward small { color: var(--gold); }
.reward strong { display: block; margin: 4px 0; font-size: 1.25rem; color: var(--ink); }
.reward p { margin: 0; line-height: 1.4; white-space: pre-line; }
.reward .quiz-msg { min-height: 0; margin-top: 8px; }
.reward .quiz-msg:empty { display: none; }
.reward-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.btn { font: inherit; font-weight: 800; border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer; background: var(--teal-deep); color: #fff; }
.btn.alt { background: var(--gold); color: var(--ink); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }

/* ---------- traguardi ---------- */
.trophy-btn { position: fixed; z-index: 12; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid var(--gold); background: #fff; color: var(--gold); cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 3px 10px rgba(15, 74, 71, .18); }
.trophy-btn svg { width: 26px; height: 26px; }
.trophy-btn:hover { transform: translateY(-1px); }
.trophy-btn:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.trophy-btn.plat { color: #5b7a8a; border-color: #8da3b0; background: linear-gradient(135deg, #fff, #e3eef3); }
.trophy-count { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--coral); color: #fff; font-size: .72rem; font-weight: 800; display: grid; place-items: center; }
.trophy-count[hidden] { display: none; }
body.is-countdown .trophy-btn { display: none; }

.trophy-banner { position: fixed; z-index: 40; left: 50%; top: max(12px, env(safe-area-inset-top)); width: min(92vw, 380px);
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; background: #0b3733; color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .3); border: 2px solid var(--gold);
  transform: translate(-50%, -140%); opacity: 0; transition: transform .45s cubic-bezier(.2, 1.2, .4, 1), opacity .3s; pointer-events: none; }
.trophy-banner.show { transform: translate(-50%, 0); opacity: 1; }
.tb-ico { font-size: 1.8rem; line-height: 1; }
.tb-txt { flex: 1; min-width: 0; display: grid; }
.tb-txt small { text-transform: uppercase; letter-spacing: .12em; font-size: .62rem; opacity: .75; font-weight: 700; }
.tb-txt strong { font-size: 1.05rem; }
.tb-pts { font-weight: 800; color: var(--gold); font-size: 1.1rem; }

.trophy-win { position: fixed; inset: 0; z-index: 30; display: grid; place-items: end center; background: rgba(15, 74, 71, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .25s ease; }
.trophy-win[hidden] { display: none; }
.trophy-sheet { width: min(100%, 520px); max-height: 88dvh; max-height: 88vh; overflow-y: auto; background: #fffdf6; border-radius: 24px 24px 0 0; padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .2); animation: sheetUp .4s cubic-bezier(.2, 1, .3, 1); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .trophy-win { place-items: center; } .trophy-sheet { border-radius: 24px; } }
.tw-head { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 2px dashed #e6dcc0; }
.tw-cup { width: 48px; height: 48px; border-radius: 50%; background: #fff3cf; color: var(--gold); display: grid; place-items: center; flex: none; }
.tw-cup svg { width: 30px; height: 30px; }
.tw-title { flex: 1; display: grid; min-width: 0; }
.tw-title strong { font-size: 1.35rem; color: var(--pine); }
.tw-title small, .tw-score small { color: var(--ink-soft); font-weight: 600; }
.tw-score { display: grid; justify-items: end; }
.tw-score strong { font-size: 1.5rem; color: var(--coral); line-height: 1; }
.tw-close { flex: none; align-self: flex-start; border: 0; background: transparent; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--ink-soft); padding: 0 4px; }
.tw-list { display: grid; gap: 10px; margin-top: 14px; }
.tw-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: #f4f1e6; }
.tw-row .tw-ico { font-size: 1.7rem; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: #e6e2d4; flex: none; filter: grayscale(1); opacity: .55; }
.tw-row.done { background: #e9f7f1; }
.tw-row.done .tw-ico { background: #fff; filter: none; opacity: 1; box-shadow: 0 0 0 2px var(--gold); }
.tw-row.plat.done { background: linear-gradient(135deg, #eef5f8, #dbe8ee); }
.tw-body { flex: 1; min-width: 0; }
.tw-body strong { display: block; }
.tw-body p { margin: 2px 0 0; font-size: .92rem; color: var(--ink-soft); line-height: 1.35; }
.tw-body small { display: block; margin-top: 4px; color: var(--ink-soft); font-weight: 600; font-size: .78rem; }
.tw-bar { height: 7px; border-radius: 999px; background: #e0dccb; margin-top: 8px; overflow: hidden; }
.tw-bar i { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.tw-pts { font-weight: 800; color: var(--ink-soft); font-size: .9rem; white-space: nowrap; }
.tw-row.done .tw-pts { color: var(--pine); }
.tw-cert { margin-top: 10px; padding-top: 10px; border-top: 2px dashed #b9cdd6; }
.tw-cert-t { font-weight: 800; color: #4a6572 !important; margin: 0 !important; }

/* ---------- password (stessa schermata del timer) ---------- */
.gate-form { width: min(100%, 360px); display: grid; justify-items: center; gap: 14px; text-align: center; }
.gate-title { margin: 0; font-size: clamp(.8rem, 3.2vw, 1rem); letter-spacing: .22em; text-transform: uppercase; font-weight: 700; opacity: .8; }
.gate-input { width: 100%; font: inherit; font-size: clamp(1.4rem, 7vw, 2rem); font-weight: 800; text-align: center; padding: 14px 16px; border-radius: 18px;
  border: 2px solid rgba(255,255,255,.55); background: rgba(255,255,255,.1); color: #fff; letter-spacing: .08em; }
.gate-input:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.gate-err { margin: 0; min-height: 1.4em; color: #ffd0c4; font-weight: 800; }
.gate-btn { min-width: 160px; }
.gate-form.shake { animation: gateShake .4s; }
@keyframes gateShake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- giochi (cruciverba, cerca-parole) ---------- */
.game { padding: 14px 16px 16px; border: 2px solid var(--teal); border-radius: 14px; background: #f1fbf9; }
.game > small { display: block; color: var(--teal-deep); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: .7rem; }
.game-body { margin-top: 10px; }
.game .quiz-msg { margin: 10px 0 0; }
.game-save .reward-actions { margin-top: 12px; }
.cw-now { margin: 0 0 10px; font-weight: 700; color: var(--pine); min-height: 2.6em; font-size: .95rem; line-height: 1.3; }
.cw-grid, .ws-grid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 2px; max-width: 460px; margin: 0 auto; }
.paper-inner > *, .game, .game-body, .cw { min-width: 0; max-width: 100%; }
.cw-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 2px; }
.cw-grid { grid-template-columns: repeat(var(--cols), minmax(30px, 1fr)); }
.cw-hint { margin: 0 0 6px; font-size: .8rem; color: var(--ink-soft); }
.cw-cell { position: relative; aspect-ratio: 1; }
.cw-cell.empty { visibility: hidden; }
.cw-cell input { width: 100%; height: 100%; padding: 0; border: 2px solid var(--teal); border-radius: 6px; background: #fff; text-align: center; text-transform: uppercase;
  font: 800 clamp(1rem, 5vw, 1.5rem) Georgia, serif; color: var(--ink); caret-color: transparent; }
.cw-cell.on input { background: #fff6cf; }
.cw-cell.cur input { background: #ffe58a; border-color: var(--coral); }
.cw-cell.bad input { background: #ffd6d0; border-color: #d42a3f; }
.cw-cell input:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.cw-n { position: absolute; top: 2px; left: 4px; font: 700 .6rem sans-serif; color: var(--coral); pointer-events: none; }
.cw .btn { margin-top: 12px; }
.cw.done .cw-cell input { background: #e5f6ee; border-color: var(--pine); }
.cw-clues { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; font-size: .88rem; line-height: 1.3; }
.cw-col b { color: var(--gold); letter-spacing: .1em; font-size: .72rem; text-transform: uppercase; }
.cw-col ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.cw-col li { cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.cw-col li.on { background: #ffe58a; }
@media (max-width: 420px) { .cw-clues { grid-template-columns: 1fr; } }
.ws-grid { touch-action: none; user-select: none; -webkit-user-select: none; gap: 0; background: #fff; border: 2px solid var(--teal); border-radius: 10px; overflow: hidden; }
.ws-cell { aspect-ratio: 1; display: grid; place-items: center; font: 800 clamp(.9rem, 4.6vw, 1.35rem) Georgia, serif; color: var(--ink); cursor: pointer; }
.ws-cell.pre { background: #ffe58a; }
.ws-cell.found { background: hsla(var(--h, 160), 70%, 70%, .55); }
.ws-cell.miss { background: #ffd6d0; }
.ws-words { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 12px; font-weight: 800; font-size: .9rem; }
.ws-words li { color: var(--ink); }
.ws-words li.got { color: var(--ink-soft); text-decoration: line-through; opacity: .7; }

/* ---------- messaggio vocale ---------- */
.voice { padding: 14px 18px 16px; border: 2px solid var(--coral); border-radius: 14px; background: #fff6f2; }
.voice small { display: block; color: var(--coral); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; font-size: .7rem; }
.voice-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.voice-btn { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer; background: var(--coral); color: #fff; display: grid; place-items: center; box-shadow: 0 3px 0 #c4583f; }
.voice-btn svg { width: 24px; height: 24px; }
.voice-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #c4583f; }
.voice-btn:disabled { opacity: .5; cursor: default; }
.voice-btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.voice-mid { flex: 1; min-width: 0; }
.voice-time { flex: none; font-variant-numeric: tabular-nums; font-size: .85rem; font-weight: 700; color: var(--ink-soft); min-width: 5.2em; text-align: right; }
.voice-note { margin: 10px 0 0; font-size: .95rem; color: var(--ink-soft); }
.voice-bar { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 999px; margin: 0; cursor: pointer;
  background: linear-gradient(to right, var(--coral) var(--p, 0%), #f3d6cc var(--p, 0%)); }
.voice-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 3px solid var(--coral); }
.voice-bar::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--coral); }
.voice-eq { display: none; align-items: flex-end; gap: 3px; height: 22px; }
.voice.playing .voice-eq { display: flex; }
.voice-eq i { width: 4px; border-radius: 2px; background: var(--coral); height: 30%; animation: eq .8s ease-in-out infinite; }
.voice-eq i:nth-child(2) { animation-delay: .15s; } .voice-eq i:nth-child(3) { animation-delay: .3s; }
.voice-eq i:nth-child(4) { animation-delay: .45s; } .voice-eq i:nth-child(5) { animation-delay: .6s; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }

@media (prefers-reduced-motion: reduce) {
  .linkcard .disc.vinyl { animation: none; }
  .voice-eq i { animation: none; height: 60%; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
