:root {
  --accento: #c8a200;
  --accento-scuro: #9c7e00;
  --accento-tenue: #f6efcf;
  --sfondo: #faf8f2;
  --carta: #ffffff;
  --testo: #211d11;
  --testo-tenue: #6b6450;
  --bordo: #e6e0cf;
  --ombra: 0 1px 3px rgba(40, 33, 0, .08), 0 4px 16px rgba(40, 33, 0, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --accento: #e3be1f;
    --accento-scuro: #c8a200;
    --accento-tenue: #2c2706;
    --sfondo: #16140d;
    --carta: #211e14;
    --testo: #f3eedd;
    --testo-tenue: #a7a083;
    --bordo: #33301f;
    --ombra: 0 1px 3px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}
/* Baloo 2, il carattere del marchio Youppy: per il nome dell'app e i titoli */
@font-face { font-family: 'Baloo 2'; src: url('/caratteri/Baloo2.ttf') format('truetype'); font-weight: 400 800; font-display: swap; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--sfondo);
  color: var(--testo);
  line-height: 1.5;
  overflow-wrap: break-word;
}
#testa {
  max-width: 680px; margin: 0 auto; border-radius: 0 0 20px 20px;
  padding: 22px 16px 16px;
  text-align: center;
  background: linear-gradient(160deg, var(--accento) 0%, var(--accento-scuro) 100%);
  color: #fff;
}
#testa h1 { margin: 0; font-family: 'Baloo 2', system-ui, sans-serif; font-weight: 800; font-size: 1.9rem; line-height: 1.2; }
#testa .sottotitolo { margin: 4px 0 0; font-size: .9rem; opacity: .92; }
#vista { max-width: 680px; margin: 0 auto; padding: 16px; }
#piede { max-width: 680px; margin: 0 auto; padding: 8px 16px 32px; }
#piede p { color: var(--testo-tenue); font-size: .78rem; text-align: center; margin: 0; }

/* ---- controlli / filtri ---- */
.cerca { position: relative; margin-bottom: 12px; }
.cerca input {
  width: 100%; padding: 12px 14px; font-size: 1rem;
  border: 1px solid var(--bordo); border-radius: 12px;
  background: var(--carta); color: var(--testo);
}
.cerca input:focus { outline: 2px solid var(--accento); border-color: var(--accento); }
.filtri { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
/* a 360 px tre menu affiancati tagliavano le scritte ("Ogni prem…"): il premio va su una riga sua, campo e anno sotto */
.filtri select:first-child { flex-basis: 100%; }
.filtri select {
  flex: 1 1 40%; min-width: 0; padding: 9px 10px; font-size: .88rem;
  border: 1px solid var(--bordo); border-radius: 10px; background: var(--carta); color: var(--testo);
}
.schede-rapide { display: flex; gap: 8px; margin-bottom: 12px; }
.schede-rapide button {
  flex: 1; padding: 9px 6px; font-size: .9rem; font-weight: 600;
  border: 1px solid var(--bordo); border-radius: 10px; background: var(--carta); color: var(--testo-tenue); cursor: pointer;
}
/* scritta scura sull'oro: il bianco sull'oro si leggeva poco */
.schede-rapide button.attiva { background: var(--accento); border-color: var(--accento); color: #211d11; }
.conteggio { font-size: .82rem; color: var(--testo-tenue); margin: 2px 0 12px; }

/* ---- lista ---- */
ul.lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.voce {
  display: flex; align-items: stretch; gap: 0;
  background: var(--carta); border: 1px solid var(--bordo); border-radius: 14px;
  box-shadow: var(--ombra); overflow: hidden;
}
.voce a.corpo {
  flex: 1; min-width: 0; display: block; padding: 12px 14px; text-decoration: none; color: inherit;
}
.voce .riga-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.voce .nome { font-weight: 700; font-size: 1.02rem; }
.voce .anno { font-variant-numeric: tabular-nums; color: var(--accento-scuro); font-weight: 700; font-size: .9rem; flex: none; }
.voce .premio { color: var(--testo-tenue); font-size: .83rem; margin-top: 1px; }
.voce .motiv { font-size: .86rem; margin-top: 6px; color: var(--testo); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { display: inline-block; font-size: .7rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accento-tenue); color: var(--accento-scuro); margin-top: 7px; }
.stella {
  flex: none; width: 48px; border: none; border-left: 1px solid var(--bordo); background: transparent;
  font-size: 1.3rem; cursor: pointer; color: var(--testo-tenue); line-height: 1;
}
.stella.on { color: var(--accento); }
.vuoto { text-align: center; color: var(--testo-tenue); padding: 40px 10px; }

/* ---- dettaglio ---- */
.torna { display: inline-block; margin-bottom: 14px; color: var(--accento-scuro); text-decoration: none; font-weight: 600; font-size: .9rem; }
.dett {
  background: var(--carta); border: 1px solid var(--bordo); border-radius: 16px; box-shadow: var(--ombra); padding: 20px 18px;
}
.dett .medaglia { width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(160deg, var(--accento), var(--accento-scuro)); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.4rem; margin-bottom: 12px; }
.dett h2 { margin: 0 0 2px; font-size: 1.5rem; }
.dett .d-premio { color: var(--accento-scuro); font-weight: 700; }
.dett dl { margin: 16px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.dett dt { color: var(--testo-tenue); font-size: .85rem; }
.dett dd { margin: 0; font-size: .95rem; }
.dett .d-motiv { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--bordo); font-size: 1rem; }
.dett .d-azioni { margin-top: 18px; }
.btn-stella {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--accento); background: var(--carta); color: var(--accento-scuro); font-weight: 600; cursor: pointer; font-size: .95rem;
}
.btn-stella.on { background: var(--accento); color: #211d11; }

/* ---- barra in basso ---- */
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
#barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--carta); border-top: 1px solid var(--bordo);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
}
#barra a {
  position: relative; flex: 1; max-width: 110px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; color: var(--testo-tenue); text-decoration: none; font-size: .68rem; font-weight: 600; border-radius: 10px;
}
#barra svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#barra svg .pieno { fill: currentColor; stroke: none; }
#barra a[aria-current] { color: var(--accento-scuro); }
#barra a[aria-current] svg { stroke-width: 2.4; }
#barra a.piu svg { background: var(--accento); border-radius: 9px; stroke: #211d11; }
#barra a.piu svg rect { stroke: none; }
#pallino {
  position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #d93025; color: #fff; font-size: .66rem; line-height: 18px; text-align: center; font-weight: 700;
}
@media (prefers-color-scheme: dark) { #barra a[aria-current] { color: var(--accento); } }

/* ---- titoli e moduli delle nuove sezioni ---- */
.titolo-sez { font-family: 'Baloo 2', system-ui, sans-serif; font-size: 1.5rem; margin: 4px 0 6px; }
.titolo-sez.piccolo { font-size: 1.15rem; margin: 22px 0 10px; }
.nota { color: var(--testo-tenue); font-size: .88rem; margin: 0 0 14px; }
.nota a, .vuoto a { color: var(--accento-scuro); }
.modulo { display: grid; gap: 14px; }
.modulo label { display: grid; gap: 6px; font-size: .88rem; font-weight: 600; color: var(--testo-tenue); }
.modulo input:not([type=file]), .modulo select, .modulo textarea, .riga-nome input {
  width: 100%; padding: 11px 12px; font: inherit; font-size: 1rem; font-weight: 400; color: var(--testo);
  background: var(--carta); border: 1px solid var(--bordo); border-radius: 12px;
}
.modulo textarea { resize: vertical; }
.scegli-file { position: relative; }
.scegli-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.scegli-file:focus-within .anteprima { outline: 2px solid var(--accento); }
.anteprima {
  display: flex; align-items: center; justify-content: center; min-height: 180px; border: 2px dashed var(--bordo); border-radius: 16px;
  background: var(--carta); color: var(--testo-tenue); text-align: center; overflow: hidden; cursor: pointer; font-weight: 600;
}
.anteprima img, .anteprima video { width: 100%; max-height: 360px; object-fit: contain; background: #000; }
.avanzamento { height: 8px; border-radius: 4px; background: var(--bordo); overflow: hidden; }
.avanzamento i { display: block; height: 100%; width: 0; background: var(--accento); transition: width .2s; }
.errore { color: #d93025; font-size: .9rem; margin: 0; }
.btn-pieno {
  display: inline-block; padding: 12px 18px; border: none; border-radius: 12px; background: var(--accento); color: #211d11;
  font: inherit; font-weight: 700; text-decoration: none; text-align: center; cursor: pointer;
}
.btn-pieno:disabled { opacity: .6; }

/* ---- profilo ---- */
.profilo { text-align: center; background: var(--carta); border: 1px solid var(--bordo); border-radius: 16px; padding: 22px 16px; box-shadow: var(--ombra); }
.avatar {
  width: 84px; height: 84px; margin: 0 auto 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--accento), var(--accento-scuro)); color: #211d11; font: 800 2.2rem 'Baloo 2', system-ui, sans-serif;
}
.profilo h2 { margin: 0; font-size: 1.4rem; }
.handle { color: var(--testo-tenue); font-size: .9rem; }
.numeri { display: flex; justify-content: center; gap: 28px; margin: 16px 0; }
.numeri b { display: block; font-size: 1.25rem; }
.numeri span { font-size: .78rem; color: var(--testo-tenue); }
.riga-nome { display: flex; gap: 8px; max-width: 380px; margin: 0 auto; }
.profilo .nota { margin: 0; }
.griglia { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 14px; }
.cella { position: relative; aspect-ratio: 9 / 16; background: #000; border-radius: 8px; overflow: hidden; }
.cella a, .mini { display: block; width: 100%; height: 100%; position: relative; }
.cella img, .cella video, .mini img, .mini video { width: 100%; height: 100%; object-fit: cover; display: block; }
.play { position: absolute; left: 6px; bottom: 4px; color: #fff; font-size: .8rem; text-shadow: 0 1px 3px #000; }
.cella .x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; }

/* ---- menzioni ---- */
.lista-menz { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lista-menz a { display: flex; gap: 12px; padding: 10px; background: var(--carta); border: 1px solid var(--bordo); border-radius: 14px; color: inherit; text-decoration: none; }
.lista-menz li.nuova a { border-color: var(--accento); background: var(--accento-tenue); }
.lista-menz .mini { flex: none; width: 56px; height: 80px; border-radius: 8px; overflow: hidden; background: #000; }
.m-testo { font-size: .9rem; min-width: 0; }
.m-testo small { color: var(--testo-tenue); }
.menz { color: var(--accento-scuro); font-weight: 700; }

/* ---- reel a tutto schermo ---- */
body.modo-reel #testa, body.modo-reel #piede { display: none; }
body.modo-reel { padding-bottom: 0; background: #000; }
body.modo-reel #vista { max-width: none; padding: 0; }
.reel-flusso {
  height: calc(100dvh - 64px - env(safe-area-inset-bottom)); overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain;
  scrollbar-width: none;
}
.reel-flusso::-webkit-scrollbar { display: none; }
.reel-flusso > .vuoto { color: #ccc; }
.reel {
  position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: #000; color: #fff;
}
.reel > video, .reel > img { width: 100%; height: 100%; object-fit: contain; max-width: 560px; }
.reel .audio { position: absolute; top: 14px; right: 14px; font-size: 1.1rem; opacity: .8; pointer-events: none; }
.r-testo {
  position: absolute; left: 0; right: 64px; bottom: 0; padding: 40px 16px 18px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .75)); pointer-events: none;
}
.r-testo a { pointer-events: auto; }
.r-autore { font-weight: 700; font-size: .95rem; }
.r-didascalia { margin: 4px 0 8px; font-size: .92rem; }
.reel .menz { color: #ffd84d; }
.r-chip { display: inline-block; padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, .18); color: #fff; font-size: .78rem; text-decoration: none; }
.r-azioni { position: absolute; right: 10px; bottom: 22px; display: grid; gap: 14px; }
.r-azioni button, .r-azioni a {
  width: 46px; height: 46px; border-radius: 50%; border: none; background: rgba(0, 0, 0, .35); color: #fff; font-size: 1.35rem;
  display: flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer; backdrop-filter: blur(4px);
}
.r-azioni .r-stella.on { color: #ffd84d; }

/* il reel di un premio: racconta la scoperta su uno sfondo colorato dal campo */
.reel-premio { background: radial-gradient(120% 80% at 30% 20%, hsl(var(--h) 60% 34%), hsl(calc(var(--h) + 40) 55% 12%)); }
.rp-dentro { max-width: 520px; padding: 24px 72px 24px 24px; }
.rp-etichetta { text-transform: uppercase; letter-spacing: .14em; font-size: .75rem; font-weight: 700; color: #ffd84d; }
.rp-medaglia { width: 64px; height: 64px; border-radius: 50%; margin: 16px 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #ffe066, #c8a200); color: #211d11; font: 800 1.7rem 'Baloo 2', system-ui, sans-serif; }
.rp-nome { margin: 0; font: 800 2rem/1.15 'Baloo 2', system-ui, sans-serif; }
.rp-premio { opacity: .85; font-size: .92rem; margin-top: 4px; }
.rp-motiv { font-size: 1.35rem; line-height: 1.4; margin: 22px 0 16px; font-weight: 600; }
.rp-tag { background: rgba(255, 255, 255, .18); color: #fff; }
/* entrano uno dopo l'altro quando il reel arriva sullo schermo */
.reel-premio .rp-dentro > * { opacity: 0; transform: translateY(18px); }
.reel-premio.vista .rp-dentro > * { animation: entra .6s cubic-bezier(.2, .7, .2, 1) forwards; }
.reel-premio.vista .rp-dentro > :nth-child(2) { animation-delay: .1s; }
.reel-premio.vista .rp-dentro > :nth-child(3) { animation-delay: .25s; }
.reel-premio.vista .rp-dentro > :nth-child(4) { animation-delay: .35s; }
.reel-premio.vista .rp-dentro > :nth-child(5) { animation-delay: .7s; animation-duration: 1s; }
.reel-premio.vista .rp-dentro > :nth-child(6) { animation-delay: 1.1s; }
.reel-premio.vista .rp-medaglia { animation: entra .6s .1s cubic-bezier(.2, .7, .2, 1) forwards, gira 3s .7s infinite; }
@keyframes entra { to { opacity: 1; transform: none; } }
@keyframes gira { 0%, 100% { transform: none; } 50% { transform: rotateY(180deg); } }
@media (prefers-reduced-motion: reduce) {
  .reel-premio .rp-dentro > * { opacity: 1; transform: none; animation: none !important; }
}
#d-community .btn-pieno { margin-top: 4px; }

/* sotto-sezioni di Premi, categorie, scelta a sorpresa, agenda, salvati */
.sotto-schede, .salv-tab { display: flex; gap: 8px; margin-bottom: 12px; }
.sotto-schede a, .salv-tab button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; text-decoration: none; cursor: pointer;
  border: 1px solid var(--bordo); border-radius: 12px; background: var(--carta); color: var(--testo-tenue); font: inherit; font-size: .82rem; font-weight: 600;
}
.sotto-schede i, .salv-tab i { font-style: normal; font-size: 1.4rem; line-height: 1.2; }
.sotto-schede a.attiva, .salv-tab button.attiva { background: var(--accento); border-color: var(--accento); color: #211d11; }
.chip-cat { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.chip-cat button { flex: none; padding: 7px 12px; border: 1px solid var(--bordo); border-radius: 999px; background: var(--carta); color: var(--testo-tenue); font: inherit; font-size: .84rem; font-weight: 600; cursor: pointer; }
.chip-cat button.attiva { background: var(--accento); border-color: var(--accento); color: #211d11; }
.sorprendi { border: 1px solid var(--bordo); border-radius: 12px; background: var(--carta); padding: 10px 12px; margin-bottom: 12px; }
.sorprendi .s-titolo { font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
.sorprendi .s-riga { display: flex; gap: 8px; }
.sorprendi select { flex: 1; min-width: 0; padding: 9px 10px; border: 1px solid var(--bordo); border-radius: 10px; background: var(--carta); color: var(--testo); font: inherit; font-size: .88rem; }
ul.agenda { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
ul.agenda li { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--bordo); border-radius: 12px; background: var(--carta); }
ul.agenda b { color: var(--accento-scuro); font-size: .85rem; }
ul.agenda .a-t { font-weight: 700; }
ul.agenda small { color: var(--testo-tenue); }
details.storico { margin-bottom: 8px; border: 1px solid var(--bordo); border-radius: 12px; background: var(--carta); }
details.storico summary { padding: 10px 12px; font-weight: 700; cursor: pointer; }
details.storico summary small { color: var(--testo-tenue); font-weight: 400; }
details.storico ul.lista { padding: 0 10px 10px; }
.r-segna:not(.on) span { opacity: .6; }
