/* YouppyHealth. I colori stanno tutti qui sotto, una volta per il tema chiaro e una per lo scuro. Accento: verde salute #22a06b. */
[data-tema="chiaro"] {
  --sfondo: #f4f6f2; --carta: #ffffff; --testo: #17201b; --tenue: #66736b; --linea: #e2e9e4;
  --accento: #22a06b; --accento-forte: #158a57; --su-accento: #ffffff; --accento-tenue: #dcf3e7;
  --rosso: #d8392f; --verde: #1a9d55; --blu: #2f6bd8; --viola: #7a52d6;
  --ombra: 0 2px 14px rgba(10, 60, 35, .08); --campo: #ebf0ec;
  /* colori dei mazzi */
  --m0: #f2b705; --m1: #2f6bd8; --m2: #1a9d55; --m3: #d8392f; --m4: #7a52d6; --m5: #e0781e; --m6: #d6418e; --m7: #159b9b; --m8: #5a6b7a; --m9: #8a9b1e;
}
[data-tema="scuro"] {
  --sfondo: #15171d; --carta: #1f222b; --testo: #eef0f5; --tenue: #949aa8; --linea: #2d313d;
  --accento: #3ddc97; --accento-forte: #6be8b0; --su-accento: #0d1f17; --accento-tenue: #173a2a;
  --rosso: #ff6b60; --verde: #45d08f; --blu: #7d9bff; --viola: #b79bff;
  --ombra: 0 2px 14px rgba(0, 0, 0, .4); --campo: #2a2e38;
  --m0: #ffce3a; --m1: #7d9bff; --m2: #45d08f; --m3: #ff6b60; --m4: #b79bff; --m5: #ffa04d; --m6: #ff7fb8; --m7: #4fcfcf; --m8: #9aabbd; --m9: #c3d44a;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--sfondo); color: var(--testo); font: 16px/1.45 system-ui, 'Segoe UI', Roboto, sans-serif; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--blu); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
p { margin: 0; }
[hidden] { display: none !important; }
.cifre { font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

#app { height: 100dvh; max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; background: var(--sfondo); position: relative; overflow: hidden; }
#vista { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
/* sfondo uniforme anche ai lati dello schermo largo (niente bande marroni) */
@media (min-width: 660px) { body { background: var(--sfondo); } }

/* ---- barra in basso ---- */
#barra { display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--carta); border-top: 1px solid var(--linea); z-index: 2; }
#barra button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0 3px; color: var(--tenue); font-size: 11px; font-weight: 600; border-radius: 14px; }
#barra button.attiva { color: var(--accento-forte); }
#barra button .ic { width: 44px; height: 27px; padding: 3px 11px; border-radius: 12px; transition: background .2s; }
#barra button.attiva .ic { background: var(--accento-tenue); }
#barra svg { width: 100%; height: 100%; display: block; }

/* ---- pezzi comuni ---- */
.pagina { padding: calc(14px + env(safe-area-inset-top)) 16px 26px; display: flex; flex-direction: column; gap: 14px; }
.testata { display: flex; align-items: center; gap: 10px; min-height: 44px; }
/* i titoli nel carattere del marchio Youppy (Baloo 2), come lo store e la faccia dell'icona */
@font-face { font-family: "Baloo 2"; src: url("/caratteri/Baloo2.ttf") format("truetype"); font-weight: 400 800; font-display: swap; }
.testata h1 { flex: 1; min-width: 0; font-family: "Baloo 2", system-ui, sans-serif; font-size: clamp(24px, 7.5vw, 29px); font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.testata h1 b { color: var(--accento-forte); }
.sotto { color: var(--tenue); font-size: 13.5px; margin-top: -8px; }
.tondo { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; color: var(--tenue); background: var(--carta); box-shadow: var(--ombra); transition: transform .1s, background .15s; }
.tondo:active { transform: scale(.92); }
.tondo.pieno { background: var(--accento); color: var(--su-accento); box-shadow: 0 6px 16px color-mix(in srgb, var(--accento) 45%, transparent); }
.tondo svg { width: 22px; height: 22px; }
.carta { background: var(--carta); border-radius: 20px; padding: 16px; box-shadow: var(--ombra); }
.nota { color: var(--tenue); font-size: 14px; }
.nota.centro { text-align: center; }
.bottone { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px; border-radius: 16px; background: var(--accento); color: var(--su-accento); font-weight: 700; font-size: 17px; transition: transform .1s, background .15s; }
.bottone:active { transform: scale(.97); }
.bottone:disabled { opacity: .4; transform: none; }
.bottone.secondario { background: var(--accento-tenue); color: var(--accento-forte); }
.bottone.chiaro { background: var(--campo); color: var(--testo); }
.bottone.pericolo { background: none; color: var(--rosso); }
.bottone.largo { width: 100%; }
.bottone svg { width: 20px; height: 20px; }
.pillola { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 13px; border-radius: 999px; background: var(--campo); color: var(--tenue); font-weight: 700; font-size: 13px; white-space: nowrap; }
.pillola.forte { background: var(--accento-tenue); color: var(--accento-forte); }
.pillola svg { width: 15px; height: 15px; }
.vuoto { text-align: center; padding: 40px 20px; color: var(--tenue); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.vuoto svg { width: 54px; height: 54px; color: var(--linea); }
.vuoto h3 { color: var(--testo); font-size: 19px; font-weight: 800; }
.vuoto .bottone svg { width: 20px; height: 20px; color: inherit; }   /* l'icona del pulsante resta della misura dei pulsanti */

.campo { width: 100%; background: var(--campo); border: 1px solid transparent; border-radius: 14px; padding: 13px 14px; font-size: 16px; }
.campo:focus { border-color: var(--accento); outline: none; background: var(--carta); }
textarea.campo { resize: vertical; min-height: 90px; line-height: 1.5; }
.etichetta { display: block; font-size: 13px; font-weight: 700; color: var(--tenue); margin: 2px 2px 6px; }

/* ---- elenco mazzi ---- */
.griglia { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }   /* minmax: un nome lungo non allarga la colonna oltre lo schermo */
.mazzo { display: flex; align-items: center; gap: 14px; text-align: left; width: 100%; background: var(--carta); border-radius: 18px; padding: 14px; box-shadow: var(--ombra); transition: transform .1s; }
.mazzo:active { transform: scale(.98); }
.mazzo .bollo { width: 46px; height: 46px; flex: none; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px; background: var(--c); }
.mazzo .cuore { flex: 1; min-width: 0; }
.mazzo > svg { width: 22px; height: 22px; flex: none; color: var(--accento-forte, var(--tenue)); }
.mazzo .cuore h3 { font-size: 16.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mazzo .cuore .riga2 { display: flex; gap: 8px; align-items: center; color: var(--tenue); font-size: 13px; margin-top: 3px; flex-wrap: wrap; }
.punto { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .5; }
.badge { background: var(--accento); color: var(--su-accento); border-radius: 999px; min-width: 22px; height: 22px; padding: 0 7px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 800; }

/* ---- scheda mazzo ---- */
.statline { display: flex; gap: 10px; }
.statbox { flex: 1; background: var(--carta); border-radius: 16px; padding: 12px; text-align: center; box-shadow: var(--ombra); }
.statbox .n { font-size: 26px; font-weight: 800; line-height: 1; }
.statbox .e { font-size: 12px; color: var(--tenue); margin-top: 4px; }
.cartaRiga { display: flex; gap: 10px; align-items: flex-start; background: var(--carta); border-radius: 14px; padding: 12px 14px; box-shadow: var(--ombra); }
.cartaRiga .f { flex: 1; min-width: 0; }
.cartaRiga .f .fr { font-weight: 700; word-break: break-word; }
.cartaRiga .f .rt { color: var(--tenue); font-size: 14px; margin-top: 3px; word-break: break-word; }
.cartaRiga .box { font-size: 11px; font-weight: 700; color: var(--tenue); background: var(--campo); border-radius: 8px; padding: 3px 7px; white-space: nowrap; }

/* ---- studio flashcard ---- */
.studioWrap { position: fixed; inset: 0; background: var(--sfondo); z-index: 40; display: flex; flex-direction: column; }
.studioTop { display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 14px 8px; }
.studioTop .barraAv { flex: 1; height: 8px; border-radius: 4px; background: var(--campo); overflow: hidden; }
.studioTop .barraAv i { display: block; height: 100%; background: var(--accento); transition: width .25s; }
.flash { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 16px; }
.flashCard { width: 100%; max-width: 440px; min-height: 58dvh; background: var(--carta); border-radius: 26px; box-shadow: var(--ombra); padding: 26px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; cursor: pointer; position: relative; }
.flashCard .etich { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 700; color: var(--tenue); letter-spacing: .08em; text-transform: uppercase; }
.flashCard .contenuto { font-size: clamp(20px, 6vw, 28px); font-weight: 700; word-break: break-word; }
.flashCard .suggerimento { color: var(--tenue); font-size: 14px; }
.flashCard .divisore { width: 70%; height: 1px; background: var(--linea); }
.flashCard .retroT { font-size: clamp(18px, 5vw, 24px); word-break: break-word; }
.studioAzioni { padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.studioAzioni .bottone { flex: 1; min-height: 56px; flex-direction: column; gap: 1px; font-size: 16px; }
.studioAzioni .bottone small { font-weight: 600; font-size: 11px; opacity: .8; }
.studioAzioni .no { background: color-mix(in srgb, var(--rosso) 16%, transparent); color: var(--rosso); }
.studioAzioni .si { background: color-mix(in srgb, var(--verde) 18%, transparent); color: var(--verde); }
.fine { text-align: center; padding: 40px 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.fine .big { font-size: 54px; }
.fine h2 { font-size: 24px; font-weight: 800; }

/* ---- gioco ---- */
.giocoWrap { position: fixed; inset: 0; background: var(--sfondo); z-index: 40; display: flex; flex-direction: column; padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); gap: 14px; }
.giocoTop { display: flex; align-items: center; gap: 12px; }
.tempo { font-size: 30px; font-weight: 800; }
.tempo.poco { color: var(--rosso); }
.punti { margin-left: auto; font-size: 15px; font-weight: 700; color: var(--tenue); }
.domanda { background: var(--carta); border-radius: 22px; box-shadow: var(--ombra); padding: 26px 20px; text-align: center; font-size: clamp(20px, 5.5vw, 26px); font-weight: 700; display: grid; place-items: center; min-height: 28dvh; word-break: break-word; }
.opzioni { display: grid; gap: 10px; }
.opz { background: var(--carta); border-radius: 16px; box-shadow: var(--ombra); padding: 16px; font-size: 16px; font-weight: 600; text-align: left; word-break: break-word; transition: transform .08s; }
.opz:active { transform: scale(.98); }
.opz.giusta { background: color-mix(in srgb, var(--verde) 22%, var(--carta)); box-shadow: inset 0 0 0 2px var(--verde); }
.opz.sbagliata { background: color-mix(in srgb, var(--rosso) 20%, var(--carta)); box-shadow: inset 0 0 0 2px var(--rosso); }

/* ---- appunti ---- */
.appRiga { display: block; width: 100%; text-align: left; background: var(--carta); border-radius: 16px; padding: 14px; box-shadow: var(--ombra); }
.appRiga h3 { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appRiga .ante { color: var(--tenue); font-size: 14px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.appRiga .meta { color: var(--tenue); font-size: 12px; margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.editWrap { position: fixed; inset: 0; background: var(--sfondo); z-index: 40; display: flex; flex-direction: column; }
.editTop { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 8px; }
.editTop .titolo { flex: 1; min-width: 0; }
.editCorpo { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.editCorpo textarea { flex: 1; min-height: 40dvh; }
.regBarra { display: flex; align-items: center; gap: 10px; background: var(--carta); border-radius: 16px; padding: 12px 14px; box-shadow: var(--ombra); }
.regBarra .stato { flex: 1; font-size: 14px; }
.pointRosso { width: 11px; height: 11px; border-radius: 50%; background: var(--rosso); animation: pulsa 1s infinite; }
@keyframes pulsa { 50% { opacity: .3; } }
.regLista { display: flex; flex-direction: column; gap: 8px; }
.regItem { display: flex; align-items: center; gap: 10px; background: var(--campo); border-radius: 12px; padding: 8px 12px; font-size: 14px; }
.regItem audio { height: 34px; max-width: 170px; }

/* ---- condivisione ---- */
.codiceBig { font-size: 34px; font-weight: 800; letter-spacing: .14em; text-align: center; color: var(--accento-forte); background: var(--accento-tenue); border-radius: 16px; padding: 18px; }

/* ---- strati (fogli e avvisi) ---- */
#strati { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.velo { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .2s; pointer-events: auto; }
.velo.on { opacity: 1; }
.foglio { position: absolute; left: 0; right: 0; bottom: 0; max-width: 620px; margin: 0 auto; background: var(--carta); border-radius: 24px 24px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 40px rgba(0,0,0,.25); transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1); pointer-events: auto; max-height: 90dvh; overflow-y: auto; }
.foglio.on { transform: translateY(0); }
.foglio h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.manico { width: 40px; height: 4px; border-radius: 2px; background: var(--linea); margin: -6px auto 12px; }
.campoRiga { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.coloriScelta { display: flex; gap: 10px; flex-wrap: wrap; }
.coloriScelta button { width: 34px; height: 34px; border-radius: 50%; background: var(--c); position: relative; }
.coloriScelta button[aria-pressed="true"]::after { content: '✓'; color: #fff; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; }
.toast { position: absolute; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--testo); color: var(--sfondo); padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: 90%; text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.segmento { display: flex; background: var(--campo); border-radius: 14px; padding: 3px; gap: 3px; }
.segmento button { flex: 1; padding: 9px 0; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--tenue); }
.segmento button.on { background: var(--carta); color: var(--testo); box-shadow: var(--ombra); }

/* ---- il teatro (scheda Gioco): video del palco reso in Blender + sipario, scintille e zone da toccare dal vivo ---- */
.teatroWrap { margin: 2px 0 8px; }
.teatro { position: relative; aspect-ratio: 4 / 3; border-radius: 22px; overflow: hidden; overflow: clip;   /* clip: il fuoco su una zona non deve far scorrere il palco */
  background: #0b0814; box-shadow: 0 10px 34px rgba(30, 10, 40, .35);
  perspective: 900px; isolation: isolate; }
.scena { position: absolute; inset: 0; --gx: 0; --gy: 0; transform: rotateY(calc(var(--gx) * 5deg)) rotateX(calc(var(--gy) * -4deg)) scale(1.035);
  transform-origin: 50% 25%; transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
.palcoVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.scintille { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.zona { position: absolute; width: 8.5%; height: 36%; transform: translate(-50%, -52%); border-radius: 40%; }
.zona .occhio { position: absolute; left: -45%; right: -45%; bottom: -6%; height: 22%; border-radius: 50%; opacity: 0; transition: opacity .25s;
  background: radial-gradient(closest-side, rgba(255, 220, 140, .75), rgba(255, 190, 80, .25) 60%, transparent); filter: blur(2px); }
.zona::before { content: ''; position: absolute; inset: -10% -40%; border-radius: 50%; opacity: 0; transition: opacity .25s;
  background: radial-gradient(closest-side, rgba(255, 236, 190, .28), transparent); }
.zona.accesa .occhio, .zona:hover .occhio, .zona:focus-visible .occhio, .zona.accesa::before, .zona:hover::before, .zona:focus-visible::before { opacity: 1; }
.zona:focus-visible { outline: none; }
/* il sipario si apre una volta, all'ingresso */
.tenda { position: absolute; top: 0; bottom: 0; width: 51%; z-index: 2; pointer-events: none; transition: transform 1.5s cubic-bezier(.65, 0, .25, 1);
  background: repeating-linear-gradient(90deg, #4a0612 0 5%, #8e1428 9%, #b01c33 11%, #7a0f21 14%, #4a0612 19%), #6e0c1c;
  box-shadow: inset 0 -40px 60px rgba(0, 0, 0, .45); }
.tenda::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 7px; background: linear-gradient(#ffd27a, #b9852c); }
.tenda.sx { left: 0; transform-origin: left; } .tenda.dx { right: 0; transform-origin: right; }
.teatro.aperto .tenda.sx { transform: translateX(-102%) scaleX(.6); } .teatro.aperto .tenda.dx { transform: translateX(102%) scaleX(.6); }
.biglietti { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-top: 10px; }
.biglietto { position: relative; padding: 6px 14px; border-radius: 10px; font-size: 13px; font-weight: 800; letter-spacing: .01em; color: #3b2400;
  background: linear-gradient(#ffe39a, #f2b705); box-shadow: 0 2px 0 #b98500, 0 4px 10px rgba(180, 120, 0, .25); transition: transform .15s; }
.biglietto::before, .biglietto::after { content: ''; position: absolute; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--sfondo); }
.biglietto::before { left: -4px; } .biglietto::after { right: -4px; }
.biglietto:hover, .biglietto.acceso { transform: translateY(-2px) rotate(-1.5deg); }
.biglietto.tuo { background: linear-gradient(#f4ecff, #c9b2ff); color: #2b1a55; box-shadow: 0 2px 0 #8e72d8, 0 4px 10px rgba(110, 80, 200, .25); }
@media (prefers-reduced-motion: reduce) { .scena { transform: none; transition: none; } .tenda { display: none; } }
