/* Verso il Monte Fato: stesso tema scuro dell'app Android */
@font-face { font-family: 'Onciale'; src: url('../font/onciale.ttf') format('truetype'); font-display: swap; }

:root {
  --notte: #14100b; --legno: #221a12; --legno2: #30251a; --bordo: #5a4a35;
  --oro: #d4af37; --oro2: #f1d77a; --pergamena: #efe3c4; --cenere: #b3a389;
  --brace: #c0562b; --elfico: #8db36b; --rosso: #b3261e;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --alto: env(safe-area-inset-top, 0px); --basso: env(safe-area-inset-bottom, 0px);
}

/* Tavolozze per zona del viaggio: i colori cambiano con la regione raggiunta */
:root[data-zona="0"] { /* La Contea: verde dei campi, oro del grano */
  --notte: #0f140c; --legno: #1b2415; --legno2: #26321e; --bordo: #4a5a38;
  --oro: #d8b84a; --oro2: #f0dc88; --cenere: #aab08c; --pergamena: #eee6c8; }
:root[data-zona="1"] { /* Eriador: brughiere d'autunno, ambra e ruggine */
  --notte: #15100b; --legno: #25190f; --legno2: #332316; --bordo: #634a30;
  --oro: #dc9a3c; --oro2: #f3c77e; --cenere: #b9a283; --pergamena: #f0e2c8; }
:root[data-zona="2"] { /* Montagne Nebbiose e Lórien: neve, pietra e argento */
  --notte: #0e1116; --legno: #181e27; --legno2: #222a36; --bordo: #465164;
  --oro: #cdbb7e; --oro2: #ece0b0; --cenere: #a4acb8; --pergamena: #e9ecef; }
:root[data-zona="3"] { /* Il Grande Fiume: acqua, nebbia e verde-azzurro */
  --notte: #0b1417; --legno: #132229; --legno2: #1b2e37; --bordo: #37545e;
  --oro: #8fc2c4; --oro2: #c7e6e2; --cenere: #9fb3b3; --pergamena: #e4eeea; }
:root[data-zona="4"] { /* La Terra d'Ombra: cenere e brace */
  --notte: #110908; --legno: #21110d; --legno2: #2e1812; --bordo: #5c2d20;
  --oro: #e2682c; --oro2: #f4a266; --cenere: #b99a8d; --pergamena: #efdcd0; }
html, body, .barra-alta, .barra-schede, .pannello, .impresa { transition: background-color .6s, border-color .6s, color .6s; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--notte); }
body { margin: 0; background: var(--notte); color: var(--pergamena); font: 16px/1.45 var(--serif); -webkit-font-smoothing: antialiased; }
a { color: var(--oro); }
h1 { font-size: 1.45rem; margin: .1rem 0 .6rem; }
h2 { font-size: 1.15rem; margin: .2rem 0 .5rem; }
h3 { font-size: 1.02rem; margin: 0 0 .15rem; }
p { margin: .35rem 0; }
.occhiello { color: var(--oro); text-transform: uppercase; letter-spacing: .16em; font-size: .75rem; font-weight: 600; margin: 0; display: flex; justify-content: space-between; }
.tenue { color: var(--cenere); } .piccolo { font-size: .85rem; } .oro { color: var(--oro); } .elfico { color: var(--elfico); } .brace { color: var(--brace); }
.grande { font-size: 1.15rem; font-weight: 600; margin: 0; }
.morale { font-style: italic; color: var(--oro2); }
.nota { background: var(--legno2); border-left: 3px solid var(--oro); padding: .5rem .7rem; border-radius: 6px; font-size: .88rem; color: var(--cenere); }
.caricamento { text-align: center; color: var(--cenere); margin-top: 30vh; }
.titolo-onciale { font-family: 'Onciale', var(--serif); color: var(--oro); text-align: center; font-weight: normal; letter-spacing: .04em; }

/* Barre fisse */
.barra-alta { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(.5rem + var(--alto)) 1rem .5rem; background: var(--notte); border-bottom: 1px solid var(--legno2); }
.marchio { font-family: 'Onciale', var(--serif); color: var(--oro); text-decoration: none; font-size: 1.45rem; letter-spacing: .04em; }
@media (min-width: 700px) { .marchio { font-size: 1.8rem; } }
.profilo { text-decoration: none; display: flex; }
.profilo .avatar { width: 44px; height: 44px; font-size: 1.2rem; box-shadow: 0 0 0 2px var(--oro); }

/* Immagine del profilo: personaggio, foto o iniziale */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; flex: none; object-fit: cover; }
.avatar svg { width: 100%; height: 100%; display: block; }
.avatar.iniziale { background: var(--legno2); color: var(--oro); font-weight: 700; }
.avatar.grande { width: 96px; height: 96px; font-size: 2.4rem; box-shadow: 0 0 0 3px var(--oro); }
.testa-profilo { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.scelta-personaggi { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .6rem; margin: .8rem 0; }
.personaggio { background: none; padding: 0; border-radius: 12px; color: var(--cenere); font-size: .78rem; display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.personaggio svg { width: 64px; height: 64px; border-radius: 50%; box-shadow: 0 0 0 2px var(--legno2); transition: transform .15s; }
.personaggio:hover svg { transform: scale(1.06); }
.personaggio.scelto svg { box-shadow: 0 0 0 3px var(--oro); }
.personaggio.scelto span { color: var(--oro); font-weight: 600; }
.carica-foto { cursor: pointer; }
.barra-schede { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--legno); border-top: 1px solid var(--legno2); padding-bottom: var(--basso); }
.barra-schede a { flex: 1; text-align: center; text-decoration: none; color: var(--cenere); font-size: .72rem; padding: .45rem 0 .5rem; }
.barra-schede a span { display: block; font-size: 1.2rem; filter: grayscale(.6); }
.barra-schede a.attiva { color: var(--oro); }
.barra-schede a.attiva span { filter: none; }
body.pubblica .barra-schede, body.pubblica .barra-alta { display: none; }
main { max-width: 720px; margin: 0 auto; padding: 1rem 1rem calc(5.5rem + var(--basso)); }
main.vista-mappa { max-width: 1600px; }
main.vista-imprese { max-width: 1180px; }
main.vista-statistiche { max-width: 900px; }

/* Pannelli, pulsanti, moduli */
.pannello { display: block; background: var(--legno); border: 1px solid color-mix(in srgb, var(--oro) 25%, transparent); border-radius: 16px; padding: 1rem; margin: 0 0 1rem; color: inherit; text-decoration: none; }
button, .pulsante { font: inherit; border-radius: 999px; padding: .6rem 1.2rem; border: 0; cursor: pointer; display: inline-block; text-decoration: none; text-align: center; }
.primario { background: var(--oro); color: #1c1407; font-weight: 600; }
.secondario { background: #4a2616; color: var(--pergamena); }
.testo { background: none; color: var(--oro); padding: .4rem .5rem; }
.testo.brace { color: var(--brace); }
.largo { display: block; width: 100%; margin: .2rem 0 1rem; }
button:disabled { opacity: .45; cursor: default; }
label { display: block; margin: .55rem 0; font-size: .92rem; color: var(--cenere); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input:not([type]) {
  display: block; width: 100%; margin-top: .25rem; padding: .6rem .7rem; font: inherit; color: var(--pergamena);
  background: var(--notte); border: 1px solid var(--bordo); border-radius: 10px; }
input:focus { outline: 2px solid var(--oro); border-color: transparent; }
label.spunta { display: flex; gap: .55rem; align-items: flex-start; color: var(--pergamena); }
label.spunta input { margin-top: .3rem; accent-color: var(--oro); }
fieldset { border: 1px solid var(--bordo); border-radius: 12px; margin: .8rem 0; padding: .4rem .8rem .6rem; }
legend { color: var(--oro); padding: 0 .3rem; }
.errore-modulo { color: #e0735a; min-height: 1.2em; }
.avviso { position: fixed; left: 50%; bottom: calc(5.5rem + var(--basso)); transform: translate(-50%, 1rem); opacity: 0; transition: .25s;
  background: var(--legno2); border: 1px solid var(--bordo); padding: .6rem 1rem; border-radius: 12px; z-index: 20; pointer-events: none; max-width: 90vw; }
.avviso.visibile { opacity: 1; transform: translate(-50%, 0); }
.avviso.errore { border-color: #e0735a; } .avviso.ok { border-color: var(--elfico); }

/* Accesso */
.accesso { max-width: 420px; margin: 0 auto; padding-top: calc(2rem + var(--alto)); }
.stemma { text-align: center; font-size: 3rem; }
.accesso form .primario { width: 100%; margin-top: .6rem; }
.piede-accesso { text-align: center; color: var(--cenere); }

/* Oggi */
.centro { display: flex; justify-content: center; }
.anello { width: 230px; height: 230px; }
.anello circle { fill: none; stroke-width: 17; stroke-linecap: round; }
.anello-fondo { stroke: var(--bordo); } .anello-valore { stroke: var(--oro); transition: stroke-dasharray .8s; } .anello-valore.pieno { stroke: var(--oro2); }
.anello text { text-anchor: middle; fill: var(--pergamena); font-family: var(--serif); }
.anello-numero { font-size: 38px; font-weight: 700; } .anello-testo { font-size: 14px; fill: var(--cenere) !important; } .anello-nota { font-size: 13px; fill: var(--elfico) !important; }
.dati-riga { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; margin: .2rem 0 1rem; }
.nota-calorie { margin-top: .8rem; }
.dati-riga b { display: block; font-size: 1.15rem; } .dati-riga span { font-size: .78rem; color: var(--cenere); }
.barra { height: 8px; border-radius: 4px; background: var(--bordo); overflow: hidden; margin: .5rem 0; }
.barra span { display: block; height: 100%; background: var(--oro); border-radius: 4px; }
.percentuale { font-size: 2rem; font-weight: 700; color: var(--oro); }
.percentuale:not(.oro) { color: var(--pergamena); }
.fonti { text-align: center; color: var(--cenere); font-size: .8rem; }
.collegamento .freccia { text-transform: none; letter-spacing: 0; }
.invito { border-color: var(--oro); }

/* Grafici */
.barre { width: 100%; height: auto; max-height: 260px; display: block; margin-top: .5rem; }
.barre .colonna { fill: rgba(179, 163, 137, .5); } .barre .colonna.piena { fill: var(--oro); }
.barre .selezionata { stroke: var(--pergamena); stroke-width: 2; }
.barre .colonna-futura { fill: rgba(90, 74, 53, .4); }
.barre .linea-obiettivo { stroke: rgba(212, 175, 55, .6); stroke-width: 1.5; stroke-dasharray: 8 8; vector-effect: non-scaling-stroke; }
.barre .etichetta-barra { fill: var(--cenere); font-size: 11.5px; text-anchor: middle; font-family: var(--serif); }
.barre .etichetta-barra.selezionata { fill: var(--oro); stroke: none; font-weight: 700; }
.barre .tocco { cursor: pointer; }
.calore { height: 150px; min-width: 460px; }
.calore rect.liv-1 { fill: transparent; } .calore .liv0 { fill: #2a2118; } .calore .liv1 { fill: #4a3d27; } .calore .liv2 { fill: #7d6a2c; } .calore .liv3 { fill: var(--oro); } .calore .liv4 { fill: var(--oro2); }
.calore text { fill: var(--cenere); font-size: 10px; font-family: var(--serif); }
.scorrevole { overflow-x: auto; }
.legenda span { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin: 0 .25rem 0 .6rem; vertical-align: -1px; }
.legenda .liv1 { background: #4a3d27; } .legenda .liv2 { background: #7d6a2c; } .legenda .liv3 { background: var(--oro); } .legenda .liv4 { background: var(--oro2); }
.schede-periodo { display: flex; background: var(--legno); border: 1px solid var(--bordo); border-radius: 999px; margin-bottom: 1rem; overflow: hidden; }
.schede-periodo button { flex: 1; background: none; color: var(--pergamena); border-radius: 0; }
.schede-periodo button.attiva { background: var(--oro); color: #1c1407; font-weight: 600; }
.navigatore { display: flex; align-items: center; }
.navigatore h2 { flex: 1; text-align: center; margin: 0; }
.navigatore button { background: none; color: var(--oro); font-size: 1.8rem; padding: 0 .8rem; }
.cifre { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem .4rem; text-align: center; margin-top: .6rem; }
.cifre b { display: block; font-size: 1.1rem; } .cifre span { font-size: .75rem; color: var(--cenere); }

/* Mappa */
.testa-mappa h1 { font-size: 1.1rem; }
.area-mappa { display: grid; gap: 1rem; }
.riquadro-mappa { height: calc(100dvh - 12.5rem - var(--alto) - var(--basso)); min-height: 320px; border-radius: 12px; overflow: hidden; background: #e8d9b8; touch-action: none; }
@media (min-width: 1100px) {
  .area-mappa { grid-template-columns: 1fr 360px; align-items: start; }
  .area-mappa .compagnie { max-height: calc(100dvh - 10rem - var(--alto) - var(--basso)); overflow-y: auto; margin: 0; }
}
.carta .compagno-bordo { fill: #efe3c4; stroke: #302216; }
.carta .nome.compagno { fill: #1f4a73; }
.carta .iniziale-sfondo { fill: #5a4a35; } .carta .iniziale-testo { fill: #efe3c4; font-family: var(--serif); font-weight: 700; text-anchor: middle; }

/* Compagnie */
.compagnie h2 { margin-bottom: .6rem; }
.compagnia { border-top: 1px solid var(--legno2); padding-top: .7rem; margin-bottom: .8rem; }
.compagnia h3 { color: var(--oro); }
.viaggiatori { list-style: none; padding: 0; margin: .4rem 0; }
.viaggiatori li { display: flex; align-items: center; gap: .6rem; padding: .35rem .3rem; border-radius: 10px; cursor: pointer; }
.viaggiatori li:hover { background: var(--legno2); }
.viaggiatori li.io { cursor: default; background: color-mix(in srgb, var(--oro) 10%, transparent); }
.viaggiatori li > div { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.viaggiatori .avatar { width: 38px; height: 38px; font-size: 1rem; }
.viaggiatori .percento { color: var(--oro); font-weight: 600; }
.riga-modulo { display: flex; gap: .5rem; align-items: flex-end; margin-top: .6rem; }
.riga-modulo label { flex: 1; margin: 0; }
.centro { text-align: center; }
.carta { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.carta .percorso { fill: none; stroke: rgba(179, 38, 30, .85); stroke-width: 2.5; stroke-dasharray: 7 5; vector-effect: non-scaling-stroke; }
.carta .percorso-fondo { fill: none; stroke: rgba(255, 255, 255, .7); stroke-width: 7; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.carta .percorso-fatto { fill: none; stroke: var(--rosso); stroke-width: 4.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.carta .tappa { fill: #fff; stroke: #302216; } .carta .tappa.fatta { fill: var(--rosso); } .carta .luogo { fill: #fff; stroke: #302216; }
.carta .nome { font-family: 'Onciale', serif; fill: #302216; text-anchor: middle; letter-spacing: .06em; paint-order: stroke; stroke: rgba(234, 220, 188, .92); stroke-linejoin: round; }
.carta .nome.prossima { fill: var(--rosso); } .carta .nome.luogo { fill: #3f3020; }
.carta .alone-anello { fill: rgba(212, 175, 55, .35); } .carta .anello-scuro { fill: none; stroke: #7a5a0e; } .carta .anello-oro { fill: none; stroke: var(--oro); }
.comandi-mappa { display: flex; justify-content: space-between; align-items: center; padding-top: .6rem; }

/* Tappe e imprese */
.diario { list-style: none; padding: 0; margin: 0; }
.diario .capitolo { color: var(--oro); font-size: 1.2rem; font-weight: 600; margin: 1.3rem 0 .4rem; }
.tappa-diario { position: relative; padding: 0 0 1.1rem 1.9rem; border-left: 2px solid var(--bordo); margin-left: .6rem; }
.tappa-diario::before { content: ''; position: absolute; left: -8px; top: .2rem; width: 14px; height: 14px; border-radius: 50%; background: var(--notte); border: 2px solid var(--bordo); }
.tappa-diario.fatta { border-left-color: var(--brace); } .tappa-diario.fatta::before { background: var(--brace); border-color: var(--brace); }
.tappa-diario.prossima::before { border-color: var(--oro); } .tappa-diario.prossima h3 { color: var(--oro); }
.tappa-diario.chiusa h3 { color: var(--cenere); } .tappa-diario.maggiore h3 { font-size: 1.2rem; }
.griglia-imprese { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .9rem; margin-top: .6rem; }
@media (min-width: 900px) { .griglia-imprese { grid-template-columns: repeat(5, 1fr); } }
.gruppo-imprese { margin: 1.6rem 0 0; }
.gruppo-imprese h2 { color: var(--oro); margin-bottom: 0; }
.gruppo-imprese .conteggio { font-size: .85rem; color: var(--cenere); font-weight: normal; margin-left: .4rem; }
.impresa { background: var(--legno); border: 1px solid rgba(90, 74, 53, .5); border-radius: 14px; padding: .8rem; text-align: center; }
.impresa.fatta { background: var(--legno2); border-color: color-mix(in srgb, var(--oro) 70%, transparent); } .impresa.fatta h3 { color: var(--oro); }
.impresa .emoji { font-size: 2rem; opacity: .35; } .impresa.fatta .emoji { opacity: 1; }

/* Profilo e dispositivi */
.dispositivi { list-style: none; padding: 0; margin: 0 0 .8rem; }
.dispositivi li { display: flex; justify-content: space-between; align-items: center; padding: .5rem 0; border-bottom: 1px solid #2a2016; }
.scelta-disp { display: flex; gap: 1rem; align-items: center; }
.scelta-disp .emoji { font-size: 2.2rem; }
.codice { background: var(--notte); border: 1px dashed var(--bordo); border-radius: 10px; padding: .5rem .7rem; margin: .5rem 0; display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .6rem; }
.codice small { width: 100%; color: var(--cenere); } .codice code { flex: 1; word-break: break-all; color: var(--oro2); }
.guida ol { padding-left: 1.2rem; } .guida li { margin: .45rem 0; } .guida code { color: var(--oro2); }
