/* ============================================================
   SHEET — scheda personaggio (drawer sinistro) e iniziativa
   ============================================================ */

#sheet-root { padding: 52px 10px 10px; }
#sheet-root .sh-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#sheet-root .sh-panel .panel-title { justify-content: space-between; }
#sheet-root .sh-close { border: none; padding: 0 .3em; }
#sheet-root .sh-body { flex: 1; min-height: 0; overflow: auto; padding: 10px; }
#sheet-root .sh-empty { text-align: center; padding: 24px 0; }

#sheet-root .sh-card { padding: 14px; display: grid; gap: 14px; }

/* ---------- testa ---------- */
#sheet-root .sh-head { display: flex; gap: 12px; align-items: center; }
#sheet-root .sh-portrait {
  width: 74px; height: 96px;
  flex: none;
  background: rgba(120, 90, 40, .14);
  border: 1px solid #b39c6e;
  border-radius: 3px;
  overflow: hidden;
}
#sheet-root .sh-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
#sheet-root .sh-name { font-size: 1.2rem; color: var(--ink); line-height: 1.15; }
#sheet-root .sh-sub { font-family: var(--font-flavor); font-style: italic; color: var(--ink-dim); font-size: .92rem; }

/* ---------- vitali ---------- */
#sheet-root .sh-vitals { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: end; }
#sheet-root .sh-speed { display: flex; align-items: baseline; gap: 4px; color: var(--ink); font-size: .85rem; }
#sheet-root .sh-speed-in { width: 54px; padding: .3em .4em; text-align: center; }
#sheet-root .sh-hp { display: grid; gap: 4px; }
#sheet-root .sh-hp-row { display: flex; align-items: center; gap: 8px; }
#sheet-root .sh-hpbtn {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  background: rgba(120, 90, 40, .16);
  border: 1px solid #b39c6e;
  border-radius: 50%;
  color: var(--ink);
  line-height: 1;
  transition: background .15s, transform .1s;
}
#sheet-root .sh-hpbtn:hover { background: rgba(179, 61, 43, .25); }
#sheet-root .sh-hpbtn:active { transform: scale(.92); }
#sheet-root .sh-hp-val { font-family: var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums; }
#sheet-root .sh-hp-val b { font-size: 1.25rem; }
#sheet-root .sh-hp-bar {
  height: 6px;
  background: rgba(43, 32, 21, .22);
  border-radius: 999px;
  overflow: hidden;
}
#sheet-root .sh-hp-bar span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--ember), #cf5a41);
  transition: width .3s ease-out;
}

#sheet-root .sh-ac { display: grid; gap: 4px; justify-items: center; }
#sheet-root .sh-shield { position: relative; width: 46px; height: 52px; color: #8a6a12; }
#sheet-root .sh-shield svg { width: 100%; height: 100%; }
#sheet-root .sh-shield b {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding-top: 2px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--ink);
}

/* ---------- caratteristiche ---------- */
#sheet-root .sh-stats-title { margin-bottom: -6px; }
#sheet-root .sh-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#sheet-root .sh-stat {
  display: grid; justify-items: center; gap: 1px;
  padding: 7px 2px 5px;
  background: rgba(255, 252, 240, .4);
  border: 1px solid #b39c6e;
  border-radius: 4px;
  transition: box-shadow .16s, transform .12s, background .16s;
}
#sheet-root .sh-stat:hover {
  background: rgba(255, 252, 240, .75);
  box-shadow: 0 0 0 1px #8a6a12 inset;
  transform: translateY(-1px);
}
#sheet-root .sh-stat-name {
  font-family: var(--font-display);
  font-size: .6rem; letter-spacing: .14em;
  color: var(--ink-dim);
}
#sheet-root .sh-stat-mod {
  font-family: var(--font-display);
  font-size: 1.2rem; font-weight: 700;
  color: var(--ink);
}
#sheet-root .sh-stat-val { font-size: .68rem; color: var(--ink-dim); }

#sheet-root .sh-notes textarea { min-height: 90px; font-size: .9rem; }

/* ---------- lista del master ---------- */
#sheet-root .sh-list { display: grid; gap: 10px; }
#sheet-root .sh-mini { display: flex; gap: 10px; padding: 8px; }
#sheet-root .sh-mini-pic {
  width: 52px; height: 66px; flex: none;
  background: rgba(120, 90, 40, .14);
  border: 1px solid #b39c6e;
  border-radius: 3px;
  overflow: hidden;
}
#sheet-root .sh-mini-pic img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
#sheet-root .sh-mini-info { flex: 1; min-width: 0; display: grid; gap: 3px; align-content: start; }
#sheet-root .sh-mini-name {
  font-family: var(--font-display);
  font-size: .92rem; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#sheet-root .sh-mini-sub { font-size: .76rem; color: var(--ink-dim); }

/* ============================================================
   Iniziativa
   ============================================================ */
#initiative-root {
  position: absolute;
  top: 46px; left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-topbar);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  max-width: min(96vw, 1100px);
  pointer-events: none;
}
#initiative-root > * { pointer-events: auto; }

#initiative-root .in-start { opacity: .75; }
#initiative-root .in-start:hover { opacity: 1; }

#initiative-root .in-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 14px;
  background: linear-gradient(180deg, rgba(30, 21, 10, .95), rgba(16, 11, 5, .95));
  border: 1px solid var(--gold);
  border-radius: 999px;
  box-shadow: var(--shadow), var(--glow-gold);
  animation: rise .25s ease-out;
  max-width: 100%;
}
#initiative-root .in-round {
  display: flex; flex-direction: column; align-items: center; line-height: 1;
  font-family: var(--font-display);
  font-size: .58rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--gold-2);
  white-space: nowrap;
}
#initiative-root .in-round b { font-size: 1.05rem; letter-spacing: 0; }
#initiative-root .in-order {
  display: flex; align-items: stretch; gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

/*
 * Una casella della pista. Non è più un nome con un numero: è un combattente
 * di cui si vede come sta — perché durante uno scontro la domanda vera non è
 * «chi viene dopo» ma «quanto gli resta».
 */
#initiative-root .in-slot {
  position: relative;
  display: inline-flex; align-items: center; gap: .4em;
  padding: .2em .7em .34em;
  font-size: .8rem;
  color: var(--bone-dim);
  background: rgba(0, 0, 0, .35);
  border: 1px solid var(--edge);
  border-radius: 999px;
  white-space: nowrap;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
#initiative-root .in-slot:hover { background: rgba(201, 162, 39, .12); }
#initiative-root .in-slot b { font-family: var(--font-display); font-size: .74rem; }
#initiative-root .in-nome { max-width: 11ch; overflow: hidden; text-overflow: ellipsis; }
#initiative-root .in-now {
  color: var(--gold-2);
  border-color: var(--gold);
  background: rgba(201, 162, 39, .14);
  box-shadow: var(--glow-gold);
}
#initiative-root .in-now .in-nome { max-width: none; }
/* il proprio personaggio resta riconoscibile anche quando non tocca a lui */
#initiative-root .in-mio { border-color: rgba(201, 162, 39, .5); }
#initiative-root .in-giu { opacity: .45; text-decoration: line-through; }

/* filo della salute lungo il fondo della casella */
#initiative-root .in-vita {
  position: absolute; left: .6em; right: .6em; bottom: .18em; height: 2px;
  background: rgba(0, 0, 0, .45);
  border-radius: 2px; overflow: hidden;
}
#initiative-root .in-vita > i {
  display: block; height: 100%;
  transition: width .3s ease-out, background .3s;
}
/* il colore dice come sta: intatto non deve sembrare ferito */
#initiative-root .in-bene { background: linear-gradient(90deg, #5f7f34, #93b24f); }
#initiative-root .in-cosi { background: linear-gradient(90deg, #9a7220, #d0a03c); }
#initiative-root .in-male { background: linear-gradient(90deg, #8d2020, #c94a3a); }
#initiative-root .in-cond { font-style: normal; font-size: .62rem; color: #b98cd8; }
#initiative-root .in-salta {
  border: 0; background: transparent; cursor: pointer;
  color: var(--gold-2); opacity: .35;
  font-size: .8rem; line-height: 1; padding: 0 0 0 .2em;
}
#initiative-root .in-slot:hover .in-salta { opacity: 1; }
#initiative-root .in-ctrl { display: flex; gap: 5px; }

/*
 * La riga del turno. Sta sotto il banner e dice al giocatore quello che prima
 * doveva chiedere a voce: quanto gli resta da camminare e cosa ha già speso.
 */
#initiative-root .in-turno {
  display: flex; align-items: center; gap: 12px;
  padding: 5px 12px;
  font-size: .78rem;
  background: linear-gradient(180deg, rgba(24, 17, 8, .95), rgba(14, 10, 4, .95));
  border: 1px solid var(--edge);
  border-radius: 999px;
  box-shadow: var(--shadow);
  animation: rise .2s ease-out;
}
#initiative-root .in-turno-altri { color: var(--bone-dim); opacity: .8; }
#initiative-root .in-mioturno {
  border-color: var(--gold);
  box-shadow: var(--shadow), var(--glow-gold);
}
#initiative-root .in-tocca {
  font-family: var(--font-display);
  font-size: .7rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--gold-2); white-space: nowrap;
}
#initiative-root .in-mioturno .in-tocca { animation: in-tocca 1.8s ease-in-out infinite; }
@keyframes in-tocca { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
#initiative-root .in-passi { display: flex; align-items: center; gap: .45em; white-space: nowrap; color: var(--bone-dim); }
#initiative-root .in-passi b { color: var(--bone); font-family: var(--font-display); }
#initiative-root .in-barra {
  display: block; width: 84px; height: 4px;
  background: rgba(255, 255, 255, .12);
  border-radius: 3px; overflow: hidden;
}
#initiative-root .in-barra > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
  transition: width .25s ease-out;
}
#initiative-root .in-tacche { display: flex; gap: 4px; }
#initiative-root .in-tacca {
  padding: .12em .6em;
  font-size: .68rem; letter-spacing: .06em; text-transform: uppercase;
  color: var(--gold-2);
  background: rgba(201, 162, 39, .1);
  border: 1px solid rgba(201, 162, 39, .45);
  border-radius: 999px;
  cursor: pointer;
  transition: opacity .2s, background .2s;
}
#initiative-root .in-tacca:hover { background: rgba(201, 162, 39, .22); }
/* spesa: si spegne, ma resta leggibile e ri-accendibile */
#initiative-root .in-spesa {
  opacity: .34;
  text-decoration: line-through;
  border-color: var(--edge);
  background: transparent;
}
@media (prefers-reduced-motion: reduce) {
  #initiative-root .in-mioturno .in-tocca { animation: none; }
}

/* editor iniziativa (nel modal) */
.in-title { font-size: 1.1rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-2); margin-bottom: 8px; }
.in-nota { margin-bottom: 14px; }
.in-head {
  display: grid; grid-template-columns: 1fr 68px 96px 34px; gap: 7px;
  font-size: .62rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--bone-dim); margin-bottom: 5px; padding: 0 2px;
}
.in-rows { display: grid; gap: 7px; max-height: 46vh; overflow: auto; }
.in-row { display: grid; grid-template-columns: 1fr 68px 96px 34px; gap: 7px; align-items: center; }
/* un numero scritto a mano non lo tocca il dado: si vede che è fermo */
.in-row .in-fisso { border-color: var(--gold); color: var(--gold-2); }
.in-add { display: flex; gap: 8px; margin-top: 12px; }
.in-add .input { flex: 1; }
.in-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

@media (max-width: 720px) {
  #initiative-root { top: 44px; max-width: 96vw; }
  #initiative-root .in-order { max-width: 46vw; }
  #initiative-root .in-turno { flex-wrap: wrap; justify-content: center; gap: 8px; border-radius: 14px; }
  .in-head, .in-row { grid-template-columns: 1fr 56px 74px 30px; }
}

/* ---------- modello 3D del personaggio ---------- */
.sh-modello {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 8px;
}
.sh-modello .btn { cursor: pointer; }
.sh-modello-nota { font-size: .72rem; color: var(--ink-dim); }
.sh-mini .sh-modello { margin-top: 6px; }
.sh-mini .sh-modello .btn { padding: .1em .5em; font-size: .62rem; }

/* ============================================================
   IL MANUALE SULLA SCHEDA
   Competenza, prove, salvezze, condizioni, morte, magia, borsa.
   Tutto dentro un cassetto stretto: le parti che non servono a
   ogni tiro stanno in sezioni richiuse.
   ============================================================ */

#sheet-root .sh-comp { margin-top: 2px; font-size: .72rem; }
#sheet-root .sh-sfin { color: #8a3324; font-weight: 700; }

/* ---------- ispirazione: una stella che si accende ---------- */
.sh-isp {
  margin-left: auto; align-self: flex-start;
  width: 30px; height: 30px; flex: none;
  border: 1px solid #b39c6e; border-radius: 50%;
  background: rgba(255, 252, 240, .4);
  color: #b7a98a; font-size: 1rem; line-height: 1;
  cursor: pointer; transition: color .18s, box-shadow .18s, background .18s;
}
.sh-isp.is-on {
  color: #b8860b; background: #fff6d8;
  box-shadow: 0 0 0 1px #b8860b inset, 0 0 10px rgba(201, 162, 39, .55);
}
.sh-isp-mini { width: 20px; height: 20px; font-size: .72rem; margin-left: 6px; vertical-align: middle; }

/* ---------- tiri contro morte ---------- */
#sheet-root .sh-morte {
  display: grid; gap: 6px; justify-items: start;
  padding: 10px; border: 1px solid #8a3324; border-radius: 5px;
  background: rgba(138, 51, 36, .07);
}
#sheet-root .sh-morte-riga { display: flex; align-items: center; gap: 8px; }
#sheet-root .sh-morte-riga i { font-size: .68rem; color: var(--ink-dim); min-width: 66px; }
.sh-morte-pall { letter-spacing: .28em; font-size: 1rem; }
.sh-morte-pall.sh-ok { color: #2f6b46; }
.sh-morte-pall.sh-ko { color: #8a3324; }
#sheet-root .sh-morte-fine { color: #8a3324; text-align: center; }
#sheet-root .sh-morte-stabile { border-color: #2f6b46; background: rgba(47, 107, 70, .08); }

/* ---------- condizioni ---------- */
.sh-cond { display: flex; flex-wrap: wrap; gap: 4px; }
.sh-cond-b {
  width: 28px; height: 28px;
  border: 1px solid #b39c6e; border-radius: 4px;
  background: rgba(255, 252, 240, .35);
  font-size: .84rem; line-height: 1; cursor: pointer;
  filter: grayscale(1) opacity(.45);
  transition: filter .16s, box-shadow .16s, background .16s;
}
.sh-cond-b:hover { filter: grayscale(.4) opacity(.85); }
.sh-cond-b.is-on {
  filter: none; background: #fff6d8;
  box-shadow: 0 0 0 1px #8a6a12 inset;
}
.sh-cond-mini .sh-cond-b { width: 20px; height: 20px; font-size: .62rem; }

/* la scelta nel modal della board mostra anche il nome */
.bd-cond-scelta { gap: 6px; margin: 10px 0; }
.bd-cond-scelta .sh-cond-b {
  width: auto; height: auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
}
.bd-cond-scelta .sh-cond-b i { font-style: normal; font-size: .72rem; }

/* ---------- come si tira: normale, vantaggio, svantaggio ---------- */
#sheet-root .sh-tiro { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
#sheet-root .sh-tiro-b {
  padding: 5px 2px;
  font-family: var(--font-display); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase;
  border: 1px solid #b39c6e; border-radius: 4px;
  background: rgba(255, 252, 240, .35); color: var(--ink-dim);
  cursor: pointer; transition: background .16s, color .16s, box-shadow .16s;
}
#sheet-root .sh-tiro-b.is-on {
  background: #fff6d8; color: var(--ink);
  box-shadow: 0 0 0 1px #8a6a12 inset;
}

/* ---------- sezioni richiudibili ---------- */
#sheet-root .sh-sez { border-top: 1px solid rgba(139, 115, 60, .35); padding-top: 8px; }
#sheet-root .sh-sez > summary {
  cursor: pointer; list-style: none;
  font-family: var(--font-display); font-size: .68rem;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-dim);
}
#sheet-root .sh-sez > summary::-webkit-details-marker { display: none; }
#sheet-root .sh-sez > summary::before { content: '▸ '; }
#sheet-root .sh-sez[open] > summary::before { content: '▾ '; }
#sheet-root .sh-sez[open] > summary { color: var(--ink); margin-bottom: 8px; }

/* ---------- righe di prova: pallino, nome, bonus ---------- */
#sheet-root .sh-righe { display: grid; gap: 2px; }
#sheet-root .sh-riga { display: flex; align-items: center; gap: 8px; }
#sheet-root .sh-pallino {
  width: 12px; height: 12px; flex: none;
  border: 1px solid #8a6a12; border-radius: 50%;
  background: transparent; cursor: pointer;
  transition: background .16s, box-shadow .16s;
}
#sheet-root .sh-pallino.is-on { background: #8a6a12; box-shadow: 0 0 5px rgba(138, 106, 18, .6); }
#sheet-root .sh-riga-nome {
  flex: 1; text-align: left; padding: 3px 6px;
  border: 1px solid transparent; border-radius: 4px;
  background: transparent; color: var(--ink); font: inherit; font-size: .82rem;
  cursor: pointer; transition: background .14s, border-color .14s;
}
#sheet-root .sh-riga-nome:hover { background: rgba(255, 252, 240, .7); border-color: #b39c6e; }
#sheet-root .sh-riga-nome i { font-size: .62rem; color: var(--ink-dim); }
#sheet-root .sh-riga-mod {
  font-family: var(--font-display); font-weight: 700; font-size: .9rem;
  min-width: 28px; text-align: right;
}
#sheet-root .sh-x {
  border: none; background: transparent; color: var(--ink-dim);
  cursor: pointer; padding: 0 4px; font-size: .8rem;
}
#sheet-root .sh-x:hover { color: #8a3324; }

/* ---------- righe per aggiungere ---------- */
#sheet-root .sh-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
#sheet-root .sh-add .input { flex: 1; min-width: 90px; padding: .3em .5em; font-size: .78rem; }
#sheet-root .sh-mini-in { flex: none !important; width: 74px; }
#sheet-root .sh-hint { font-size: .74rem; color: var(--ink-dim); }

/* ---------- magia: caselle degli slot ---------- */
#sheet-root .sh-conc { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#sheet-root .sh-conc .input { flex: 1; padding: .3em .5em; font-size: .78rem; }
#sheet-root .sh-slots { display: grid; gap: 5px; }
#sheet-root .sh-slot-riga { display: flex; align-items: center; gap: 8px; }
#sheet-root .sh-slot-liv { font-size: .72rem; color: var(--ink-dim); min-width: 44px; }
#sheet-root .sh-slot-caselle { display: flex; gap: 4px; flex-wrap: wrap; }
#sheet-root .sh-casella {
  width: 15px; height: 15px;
  border: 1px solid #6a4fa3; border-radius: 3px;
  background: rgba(106, 79, 163, .12);
  cursor: pointer; transition: background .16s;
}
#sheet-root .sh-casella.is-usata { background: #6a4fa3; box-shadow: inset 0 0 0 2px rgba(255, 252, 240, .5); }

/* ---------- borsa e zaino ---------- */
#sheet-root .sh-monete { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
#sheet-root .sh-moneta { display: grid; gap: 2px; justify-items: center; }
#sheet-root .sh-moneta span {
  font-family: var(--font-display); font-size: .58rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim);
}
#sheet-root .sh-moneta .input { width: 100%; text-align: center; padding: .25em .2em; font-size: .8rem; }
#sheet-root .sh-moneta-mp .input { border-color: #8f8f9c; }
#sheet-root .sh-moneta-mo .input { border-color: #b8860b; }
#sheet-root .sh-moneta-ma .input { border-color: #9aa0a6; }
#sheet-root .sh-moneta-mr .input { border-color: #a2673f; }
#sheet-root .sh-obj-nome { cursor: default; }
#sheet-root .sh-obj-nome:hover { background: transparent; border-color: transparent; }
#sheet-root .sh-obj-note { font-size: .68rem; color: var(--ink-dim); }

/* ---------- la compagnia, vista dal Master ---------- */
#sheet-root .sh-mini-giu { box-shadow: 0 0 0 1px #8a3324 inset; }
#sheet-root .sh-mini-morte { gap: 6px; margin-top: 4px; }
#sheet-root .sh-mini-morte .sh-morte-pall { font-size: .8rem; letter-spacing: .18em; }
#sheet-root .sh-conc-nota { margin-top: 2px; }

/* ---------- chi si sta mirando, e da quanto lontano ---------- */
#sheet-root .sh-mira {
  padding: 5px 8px; margin-bottom: 8px;
  font-size: .76rem; text-align: center;
  color: var(--ink-dim);
  border: 1px dashed rgba(139, 115, 60, .5); border-radius: 5px;
}
#sheet-root .sh-mira.is-on {
  color: var(--ink);
  border-style: solid; border-color: #8a6a12;
  background: rgba(255, 246, 216, .6);
}
#sheet-root .sh-att i { font-style: normal; font-size: .62rem; color: var(--ink-dim); }
/* l'attacco che non ci arriva: si vede prima di premerlo */
#sheet-root .sh-att-lontano .sh-riga-nome { opacity: .55; }
#sheet-root .sh-att-lontano .sh-riga-nome::after { content: ' — troppo lontano'; font-size: .6rem; color: #8a3324; }

/* quanto movimento resta in questo turno */
#sheet-root .sh-passi {
  display: block; margin-top: 3px;
  font-size: .64rem; text-align: center; color: var(--ink-dim);
}
#sheet-root .sh-passi.is-fine { color: #8a3324; font-weight: 700; }
