/* Elysium Cassa — tema «GUI di gioco a blocchi».
   Tutto disegnato a mano con CSS e SVG: nessun asset copiato dal gioco. */

/* ───────────────────────── font ───────────────────────── */
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('font/pixelify-sans-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Pixelify Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('font/pixelify-sans-latin-ext-400-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Nota: del Pixelify Sans si usa solo il peso 400. Nel grassetto la «C» si chiude e sembra una «O»
   («Cassa» → «Oassa»): niente file a peso 700 e niente grassetto sintetico (font-synthesis qui sotto). */

/* ───────────────────────── variabili ───────────────────────── */
:root {
  --sfondo: #1d1a17;
  --pannello: #c6c6c6;
  --pannello-chiaro: #e6e6e6;
  --smusso-chiaro: #ffffff;
  --smusso-scuro: #555555;
  --testo: #2b2b2b;
  --testo-tenue: #474747;
  --titolo: #3f3f3f;
  --slot: #8b8b8b;
  --slot-scuro: #373737;
  --pietra: #7a7a7a;
  --pietra-chiara: #a9a9a9;
  --pietra-scura: #4a4a4a;
  --passaggio: #8791c4;
  --verde: #3c8527;
  --rosso: #a32f2f;
  --aumento: #1b6e1b;
  --calo: #a31515;
  --oro: #e8b923;
  --argento: #dcdcdc;
  --bronzo: #b87333;
  --fuoco: #10227a;
  --pixel: 'Pixelify Sans', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  /* le cifre del font pixel si confondono (2/5/8): i numeri usano un monospazio di sistema */
  --numeri: ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, Consolas, 'Roboto Mono', 'DejaVu Sans Mono', monospace;
  --lettura: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --alt-barra: 64px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--lettura);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--testo);
  background-color: var(--sfondo);
  /* trama «terra e pietra»: blocchi di 4 px fatti di due gradienti incrociati */
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .04) 0 4px, transparent 4px 8px, rgba(0, 0, 0, .16) 8px 12px, transparent 12px 20px, rgba(255, 255, 255, .025) 20px 24px, transparent 24px 32px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .16) 0 4px, transparent 4px 12px, rgba(255, 255, 255, .035) 12px 16px, transparent 16px 28px, rgba(0, 0, 0, .1) 28px 32px, transparent 32px 44px),
    repeating-linear-gradient(0deg, #2a221b 0 16px, #241d17 16px 32px);
  overflow-wrap: break-word;
  font-synthesis: none;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: #173a9c; }
strong { font-weight: 700; }

.solo-lettori {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.salta {
  position: absolute;
  left: 8px; top: -80px;
  z-index: 50;
  padding: 10px 14px;
  background: #000;
  color: #fff;
  font-family: var(--pixel);
}
.salta:focus { top: 8px; }

/* fuoco da tastiera sempre visibile: blu scuro sui pannelli chiari, bianco sullo sfondo scuro */
:focus-visible { outline: 3px solid var(--fuoco); outline-offset: 2px; }
.testata :focus-visible,
.navigazione :focus-visible,
.pagina > a:focus-visible,
.pagina > .testa-pagina :focus-visible,
.elenco-schede :focus-visible,
.avvisi :focus-visible { outline-color: #ffffff; }
main:focus { outline: none; }

/* ───────────────────────── testata ───────────────────────── */
.testata {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  padding: 10px 12px 8px;
  color: #ffffff;
  /* blocco d'erba: striscia verde sopra, terra sotto */
  background-color: #4a3424;
  background-image:
    linear-gradient(180deg, #6bb53a 0 4px, #4c8a2a 4px 8px, transparent 8px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .18) 0 4px, transparent 4px 12px, rgba(255, 255, 255, .06) 12px 16px, transparent 16px 24px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .14) 0 4px, transparent 4px 12px);
  box-shadow: 0 4px 0 #000000;
}
.marchio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding-top: 6px;
  color: #ffffff;
  text-decoration: none;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 1.35rem;
  text-shadow: 2px 2px 0 #1a1a1a;
}
.marchio .icona { width: 32px; height: 32px; }
.ogg-marchio { --tinta: #c98b3a; }
.testata-utente {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 6px;
  font-family: var(--pixel);
  text-shadow: 2px 2px 0 #1a1a1a;
}
.testata-data::before { content: 'Giorno '; color: #e6d6b8; }
.testata-nome { font-weight: 700; color: #ffe08a; }
.testata-data { font-family: var(--numeri); font-weight: 700; text-shadow: 0 2px 0 #1a1a1a; }
.testata-data::before { font-family: var(--pixel); font-weight: 400; }

/* ───────────────────────── navigazione ───────────────────────── */
.navigazione {
  background-color: #2f2f2f;
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, .04) 0 4px, transparent 4px 8px);
  box-shadow: 0 4px 0 #000000;
  font-family: var(--pixel);
}
.navigazione-voci {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 10px 6px;
}
.navigazione-collegamento {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  background: transparent;
  color: #ededed;
  text-decoration: none;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: inset 0 -4px 0 transparent;
}
.navigazione-collegamento .icona { width: 24px; height: 24px; color: #cfcfcf; }
.navigazione-collegamento:hover { background-color: #474747; color: #ffffff; }
.navigazione-collegamento.attivo {
  background-color: #505050;
  color: #ffffff;
  font-weight: 700;
  box-shadow: inset 0 -4px 0 #6bb53a;
}
.navigazione-collegamento.attivo .icona { color: #ffffff; }
.voce-altro { display: none; }

/* ───────────────────────── pagina ───────────────────────── */
.contenuto {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 12px 48px;
}
.pagina > * + * { margin-top: 18px; }
.titolo-pagina {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1.15;
  color: #ffffff;
  text-shadow: 3px 3px 0 #000000;
}
.titolo-pagina .tier { font-size: 1rem; vertical-align: middle; text-shadow: none; }
.titolo-sezione {
  font-family: var(--pixel);
  font-size: 1.3rem;
  color: #e9e9e9;
  text-shadow: 2px 2px 0 #000000;
}
.testa-pagina {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* ───────────────────────── pannello inventario ───────────────────────── */
.pannello {
  margin-left: 2px;
  margin-right: 2px;
  padding: 16px 16px 18px;
  background-color: var(--pannello);
  color: var(--testo);
  box-shadow:
    inset 4px 4px 0 var(--smusso-chiaro),
    inset -4px -4px 0 var(--smusso-scuro),
    0 0 0 2px #000000;
}
.pannello > * + * { margin-top: 12px; }
.pannello-titolo {
  font-family: var(--pixel);
  font-weight: 400;
  font-size: 1.3rem;
  line-height: 1.2;
  color: var(--titolo);
}
.titolo-grande { font-size: 1.9rem; font-weight: 700; text-align: center; }
.sottotitolo { text-align: center; color: var(--testo-tenue); }
.pannello-testa {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.titoletto {
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 1.08rem;
  color: var(--titolo);
  margin-top: 16px;
}
.inventari > * + * { margin-top: 18px; }
.due-colonne {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 14px;
  align-items: start;
}
.segnaposto {
  padding: 14px 10px;
  text-align: center;
  color: var(--testo-tenue);
  font-family: var(--pixel);
  font-size: 1.05rem;
}
.segnaposto-scuro { color: #e0e0e0; text-shadow: 2px 2px 0 #000; }
.senza-script {
  margin: 20px;
  padding: 16px;
  background: var(--pannello);
  font-family: var(--pixel);
}
.nota-campo { color: var(--testo-tenue); font-size: 1rem; }
.in-evidenza { font-size: 1.1rem; }

.pannello-accesso { max-width: 420px; margin: 6vh auto 0; }
.accesso-stemma { display: flex; justify-content: center; }
.accesso-stemma .icona { width: 64px; height: 64px; }

/* ───────────────────────── icone ───────────────────────── */
.icona {
  display: inline-block;
  width: 48px;
  height: 48px;
  flex: none;
  color: var(--tinta, #bdbdbd);
  shape-rendering: crispEdges;
}
.icona-piccola { width: 24px; height: 24px; vertical-align: middle; }
.nome-oggetto { display: inline-flex; align-items: center; gap: 6px; }

/* tinta di ogni oggetto */
.ogg-tin { --tinta: #b9c7cc; }
.ogg-rame { --tinta: #c8703a; }
.ogg-ferro { --tinta: #dedede; }
.ogg-oro { --tinta: #f2c531; }
.ogg-diamante { --tinta: #4fe0d8; }
.ogg-argento { --tinta: #c9d6e8; }
.ogg-nero_acciaio { --tinta: #3d3f4a; }
.ogg-smeraldo { --tinta: #2fbf5a; }
.ogg-core_fragment { --tinta: #9b5de5; }
.ogg-revival_star { --tinta: #ffe45c; }
.ogg-lapis { --tinta: #2a52be; }
.ogg-brim_powder { --tinta: #e0a11b; }
.ogg-carne_marcia { --tinta: #a0623c; }
.ogg-carbone { --tinta: #303030; }
.ogg-quarzo { --tinta: #efe6dd; }
.ogg-therium { --tinta: #3fb6a8; }
.ogg-occhio_ragno { --tinta: #b0263a; }
.ogg-ametista { --tinta: #9d6ad6; }
.ogg-blaze_powder { --tinta: #ff9d1e; }
.ogg-membrana_phantom { --tinta: #cfc8a8; }
.ogg-anthracite { --tinta: #3a4160; }
.ogg-prismarine { --tinta: #5fb8a5; }
.ogg-slimeball { --tinta: #7bd957; }
.ogg-withering_dust { --tinta: #4a4450; }
.ogg-lost_soul { --tinta: #7fd6e8; }
.ogg-demon_heart { --tinta: #b3122a; }
.ogg-fire_stone { --tinta: #e2492b; }
.ogg-scheggia_risonanza { --tinta: #57c7ff; }
.ogg-end_shard { --tinta: #c9a6f0; }
.ogg-demonic_slab { --tinta: #7a2533; }
.ogg-healing_catalyst { --tinta: #ff6fa5; }
.ogg-carbonella { --tinta: #54463a; }
.ogg-pozione_t1 { --tinta: #f27272; }
.ogg-pozione_t2 { --tinta: #d42a2a; }
.ogg-pozione_t3 { --tinta: #8f0f1f; }
.ogg-antidoto { --tinta: #5cc94a; }
.ogg-revivify { --tinta: #ffb52e; }
.ogg-revivify_supportivo { --tinta: #ff8ad4; }
.ogg-bronzini { --tinta: #b87333; }

/* ───────────────────────── slot e griglie ───────────────────────── */
.griglia-slot {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px 8px;
}
.griglia-contatori {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px 8px;
}
.cella {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 2px;
  border: 0;
  background: transparent;
  color: var(--testo);
  text-align: center;
}
.cella-bottone { cursor: pointer; }
.slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  flex: none;
  background-color: var(--slot);
  box-shadow: inset 3px 3px 0 var(--slot-scuro), inset -3px -3px 0 #ffffff;
}
.slot::after {
  /* velo bianco al 30% per lo stato attivo o selezionato */
  content: '';
  position: absolute;
  inset: 3px;
  background: #ffffff;
  opacity: 0;
  pointer-events: none;
}
.cella-bottone:hover .slot::after,
.cella-bottone:focus-visible .slot::after,
.cella.selezionata .slot::after { opacity: .3; }
.cella.selezionata .slot { box-shadow: inset 3px 3px 0 var(--slot-scuro), inset -3px -3px 0 #ffffff, 0 0 0 3px var(--fuoco); }
.slot-quantita {
  position: absolute;
  right: 6px;
  bottom: 2px;
  z-index: 1;
  font-family: var(--numeri);
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  color: #ffffff;
  text-shadow: 2px 2px 0 #3f3f3f;
}
.cella-nome {
  font-family: var(--pixel);
  font-size: 1rem;
  line-height: 1.1;
  max-width: 100%;
}
.cella-giacenza { font-size: 1rem; color: var(--testo-tenue); }
.cella.attenuata .slot .icona { opacity: .3; }
.cella.attenuata .slot-quantita { color: #d6d6d6; }
.cella.attenuata .cella-nome { color: var(--testo-tenue); }

/* ───────────────────────── bottoni di pietra ───────────────────────── */
.bottone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  margin: 2px;
  padding: 8px 16px;
  border: 0;
  border-radius: 0;
  background-color: var(--pietra);
  /* trama a puntini */
  background-image:
    radial-gradient(rgba(0, 0, 0, .2) 1px, transparent 1.4px),
    radial-gradient(rgba(255, 255, 255, .14) 1px, transparent 1.4px);
  background-size: 8px 8px, 8px 8px;
  background-position: 0 0, 4px 4px;
  color: #ffffff;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
  text-shadow: 0 2px 0 #3a3a3a;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  box-shadow:
    inset 3px 3px 0 var(--pietra-chiara),
    inset -3px -3px 0 var(--pietra-scura),
    0 0 0 2px #000000;
}
.bottone:hover,
.bottone:focus-visible {
  background-color: var(--passaggio);
  box-shadow:
    inset 3px 3px 0 #b9c1ea,
    inset -3px -3px 0 #5a639a,
    0 0 0 2px #ffffff;
}
.bottone:active {
  box-shadow:
    inset 3px 3px 0 var(--pietra-scura),
    inset -3px -3px 0 var(--pietra-chiara),
    0 0 0 2px #000000;
}
.bottone.primario { background-color: var(--verde); box-shadow: inset 3px 3px 0 #63b34a, inset -3px -3px 0 #245c14, 0 0 0 2px #000000; }
.bottone.primario:hover, .bottone.primario:focus-visible { background-color: #2f9a3c; box-shadow: inset 3px 3px 0 #7bd485, inset -3px -3px 0 #1c6a27, 0 0 0 2px #ffffff; }
.bottone.pericoloso { background-color: var(--rosso); box-shadow: inset 3px 3px 0 #cf5d5d, inset -3px -3px 0 #6e1717, 0 0 0 2px #000000; }
.bottone.pericoloso:hover, .bottone.pericoloso:focus-visible { background-color: #c23a3a; box-shadow: inset 3px 3px 0 #e58484, inset -3px -3px 0 #7d1c1c, 0 0 0 2px #ffffff; }
.bottone.primario:active, .bottone.pericoloso:active { box-shadow: inset 3px 3px 0 rgba(0, 0, 0, .45), inset -3px -3px 0 rgba(255, 255, 255, .35), 0 0 0 2px #000000; }
.bottone.scelto {
  background-color: #36498f;
  box-shadow: inset 3px 3px 0 #1d2a5e, inset -3px -3px 0 #7f8fd0, 0 0 0 2px #ffffff;
}
.bottone:disabled,
.bottone:disabled:hover {
  background-color: #3a3a3a;
  background-image: none;
  color: #a0a0a0;
  text-shadow: none;
  cursor: not-allowed;
  box-shadow: inset 3px 3px 0 #505050, inset -3px -3px 0 #262626, 0 0 0 2px #000000;
}
.bottone.piccolo { padding: 6px 10px; font-size: 1rem; }
.bottone-largo { width: calc(100% - 4px); }

.azioni {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.azioni-inizio { justify-content: flex-start; margin-top: 0; }
.azioni-centro { justify-content: center; }
td .azioni, th .azioni { margin-top: 0; }

.scelta-unica, .schede {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.scelta-unica .bottone, .schede .bottone { flex: 1 1 auto; }
.linguetta-conto { font-family: var(--numeri); }

/* ───────────────────────── campi ───────────────────────── */
.modulo > * + * { margin-top: 12px; }
.griglia-campi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 14px;
  align-items: start;
}
.gruppo-campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.etichetta, .mini-etichetta {
  font-family: var(--pixel);
  font-size: 1.05rem;
  color: var(--titolo);
}
.mini-etichetta { font-size: 1rem; }
.campo {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 2px solid #a0a0a0;
  border-radius: 0;
  background-color: #000000;
  color: #ffffff;
  font-family: var(--lettura);
  font-size: 1.05rem;
  line-height: 1.2;
  color-scheme: dark;
  box-shadow: 0 0 0 2px #000000;
}
textarea.campo { font-family: var(--lettura); font-size: 1rem; resize: vertical; }
.campo::placeholder { color: #9a9a9a; opacity: 1; }
.campo:focus-visible { outline: 3px solid var(--fuoco); outline-offset: 3px; border-color: #ffffff; }
.campo:disabled { background-color: #3a3a3a; color: #a0a0a0; }
.campo-errato { border-color: #ff6b6b; }
select.campo { padding-right: 6px; cursor: pointer; }
.spunta { width: 26px; height: 26px; flex: none; accent-color: var(--verde); cursor: pointer; }
.spunta-etichetta { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-family: var(--pixel); font-weight: 700; }
.tier-accanto { display: inline-flex; align-items: center; min-height: 28px; color: var(--testo-tenue); }
.errore-modulo {
  padding: 8px 10px;
  background-color: #f6dada;
  color: #7d0f0f;
  font-weight: 600;
  box-shadow: 0 0 0 2px var(--calo);
}

.importo-anteprima { min-height: 1.45em; color: var(--testo-tenue); }
.importo-anteprima.non-valido { color: #8c1010; font-weight: 700; }
.campo-importo.compatto .importo-anteprima { min-height: 0; }

/* contatore − / numero / + */
.contatore {
  display: flex;
  align-items: stretch;
  gap: 2px;
  width: 100%;
  max-width: 190px;
}
.contatore-tasto { flex: none; width: 44px; padding: 0; margin: 2px; font-size: 1.5rem; }
.contatore-campo { flex: 1 1 0; min-width: 0; margin: 2px 0; padding: 4px 2px; text-align: center; font-family: var(--numeri); font-weight: 700; font-size: 1.2rem; }
.contatore.pieno .contatore-campo { border-color: #7bd485; color: #b8f5bf; }

/* ───────────────────────── monete e tier ───────────────────────── */
.monete { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-family: var(--numeri); font-weight: 700; white-space: nowrap; }
.monete-parte { display: inline-flex; align-items: center; gap: 4px; }
.pallino {
  display: inline-block;
  width: 12px;
  height: 12px;
  flex: none;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, .55), inset -2px -2px 0 rgba(0, 0, 0, .35), 0 0 0 2px #1a1a1a;
}
.pallino-oro { background-color: var(--oro); }
.pallino-argento { background-color: var(--argento); }
.pallino-bronzo { background-color: var(--bronzo); }
.monete-grandi { font-size: 1.5rem; }
.monete-grandi .pallino { width: 16px; height: 16px; }

.tier {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--lettura);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  color: #ffffff;
  white-space: nowrap;
  box-shadow: 0 0 0 2px #000000;
}
.tier-0 { background-color: #5c5c5c; }
.tier-1 { background-color: #2a7a2e; }
.tier-2 { background-color: #17698f; }
.tier-3 { background-color: #6f3fb0; }
.tier-4 { background-color: #e8b923; color: #2b2b2b; }
.tier-5 { background-color: #a32f2f; }

/* ───────────────────────── riquadro cassa ───────────────────────── */
.riquadro-cassa {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 0 2px;
}
.cassa-voce {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px 14px;
  background-color: var(--pannello);
  box-shadow: inset 4px 4px 0 var(--smusso-chiaro), inset -4px -4px 0 var(--smusso-scuro), 0 0 0 2px #000000;
}
.cassa-saldo { background-color: #f1e3b5; box-shadow: inset 4px 4px 0 #fff7da, inset -4px -4px 0 #8a7333, 0 0 0 2px #000000; }
.cassa-titolo { font-family: var(--pixel); font-size: 1.05rem; color: var(--titolo); }

/* ───────────────────────── storico ───────────────────────── */
.barra-filtri { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.barra-filtri .campo { width: auto; min-width: 180px; }
.filtro-attivo { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filtro-attivo:empty { display: none; }
.elenco-operazioni > * + * { margin-top: 10px; }
.operazione {
  padding: 10px 12px 12px;
  background-color: var(--pannello-chiaro);
  box-shadow: 0 0 0 2px #6f6f6f;
  border-left: 8px solid #6f6f6f;
}
.operazione > * + * { margin-top: 6px; }
.tipo-abisso { border-left-color: #5b3fa8; }
.tipo-riparazione { border-left-color: #8a5a2b; }
.tipo-pozioni { border-left-color: #c2267a; }
.tipo-vendita { border-left-color: #b08900; }
.tipo-ritiro { border-left-color: #a31515; }
.tipo-rettifica { border-left-color: #17698f; }
.tipo-annullamento { border-left-color: #2b2b2b; }
.operazione-testata { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; font-family: var(--pixel); }
.operazione-tipo { font-weight: 700; font-size: 1.15rem; }
.operazione-numero, .operazione-autore { color: var(--testo-tenue); }
.operazione-numero, .operazione-data { font-family: var(--numeri); font-weight: 700; }
.operazione-dettagli { color: var(--testo-tenue); }
.operazione-nota { font-style: italic; }
.operazione-stato { font-weight: 700; color: #8c1010; }
.operazione.annullata .movimenti,
.operazione.annullata .operazione-tipo,
.operazione.annullata .operazione-nota { text-decoration: line-through; }
.operazione.annullata { background-color: #d2d2d2; }
.operazione-dettaglio summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  font-family: var(--pixel);
  font-weight: 700;
  color: #173a9c;
  cursor: pointer;
}
.movimenti {
  padding: 6px 8px;
  background-color: var(--pannello-chiaro);
}
.operazione .movimenti { padding: 0; }
.mov { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; padding: 2px 0; }
.mov-quantita { font-family: var(--numeri); font-weight: 700; font-size: 1.1rem; min-width: 3ch; white-space: nowrap; }
.mov-nome { font-family: var(--pixel); font-weight: 700; }
.mov-piu .mov-quantita, .mov-piu .mov-nome { color: var(--aumento); }
.mov-meno .mov-quantita, .mov-meno .mov-nome { color: var(--calo); }
.mov-motivo { color: #333333; }

/* ───────────────────────── tabelle ───────────────────────── */
.tabella { width: 100%; border-collapse: collapse; background-color: var(--pannello-chiaro); }
.tabella th, .tabella td { padding: 8px 10px; text-align: left; vertical-align: middle; border: 2px solid #9a9a9a; }
.tabella thead th { background-color: #a9a9a9; font-family: var(--pixel); font-weight: 700; color: #222222; }
.tabella tbody th { font-weight: 600; }
.tabella-stretta { max-width: 420px; }
.tabella-stretta td { font-family: var(--numeri); font-weight: 700; font-size: 1.15rem; text-align: right; }

/* ───────────────────────── elenchi vari ───────────────────────── */
.elenco-semplice > li, .elenco-quantita > li { padding: 4px 0; }
.elenco-quantita, .elenco-esiti, .elenco-passi, .tappe, .elenco-semplice { padding: 8px 10px; background-color: var(--pannello-chiaro); }
.elenco-quantita > li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.elenco-quantita strong { font-family: var(--numeri); font-size: 1.1rem; }
.elenco-passi { list-style: decimal inside; }
.elenco-passi > li { padding: 3px 0; }
.tappe > li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 5px 0; }
.tappa-matura { font-weight: 700; }
.esito { display: flex; gap: 8px; padding: 5px 0; }
.esito-segno { flex: none; width: 1.4em; font-family: var(--pixel); font-weight: 700; font-size: 1.2rem; text-align: center; }
.esito-ok .esito-segno, .esito-ok .esito-stato { color: var(--aumento); }
.esito-parziale .esito-segno, .esito-parziale .esito-stato { color: #7a4b00; }
.esito-no .esito-segno, .esito-no .esito-stato { color: var(--calo); }
.esito-stato { font-weight: 600; }
.esito-testo .nome-oggetto { vertical-align: middle; }
.coppie { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.coppie dt { font-family: var(--pixel); color: var(--titolo); }
.coppie dd { min-width: 0; white-space: pre-line; }

.stato { display: inline-block; padding: 1px 8px; font-weight: 700; box-shadow: 0 0 0 2px currentColor; }
.stato-aperta { color: #173a9c; }
.stato-parziale { color: #7a4b00; }
.stato-evasa { color: var(--aumento); }
.stato-annullata { color: #555555; text-decoration: line-through; }

/* indicatore «1 Minerali → 2 Reagenti» */
.indicatore-passi { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-family: var(--pixel); font-size: 1.15rem; color: #cfcfcf; text-shadow: 2px 2px 0 #000; }
.tappa { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; }
.tappa-numero { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; background-color: #4a4a4a; color: #fff; box-shadow: 0 0 0 2px #000; font-weight: 700; }
.tappa.attuale { color: #ffffff; font-weight: 700; background-color: rgba(255, 255, 255, .12); box-shadow: 0 0 0 2px #ffffff; }
.tappa.attuale .tappa-numero { background-color: var(--verde); }
.tappa.fatta .tappa-numero { background-color: #2a7a2e; }

/* ───────────────────────── vendita ───────────────────────── */
.righe-vendita > * + * { margin-top: 8px; }
.riga-vendita {
  display: grid;
  grid-template-columns: minmax(150px, 1.4fr) 190px minmax(150px, 1.2fr) minmax(110px, .9fr);
  gap: 8px 12px;
  align-items: start;
  padding: 10px;
  background-color: var(--pannello-chiaro);
  box-shadow: 0 0 0 2px #8a8a8a;
}
.riga-vendita-nome { display: flex; flex-direction: column; gap: 2px; font-family: var(--pixel); font-weight: 700; font-size: 1.1rem; }
.riga-vendita-nome .nota-campo { font-family: var(--lettura); font-weight: 400; }
.riga-vendita-campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.riga-totale { display: flex; align-items: center; min-height: 44px; font-size: 1.1rem; font-family: var(--numeri); }
.barra-totale {
  position: sticky;
  bottom: 8px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  padding: 12px 14px;
  background-color: #f1e3b5;
  box-shadow: inset 4px 4px 0 #fff7da, inset -4px -4px 0 #8a7333, 0 0 0 2px #000000, 0 0 0 6px rgba(0, 0, 0, .45);
}
.barra-totale > * + * { margin-top: 0; }
.barra-totale-testo { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.totale-avviso { color: var(--testo-tenue); }

/* ───────────────────────── PG ───────────────────────── */
.elenco-schede {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin: 0 2px;
}
.scheda-pg {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 14px 16px 16px;
  background-color: var(--pannello);
  color: var(--testo);
  text-decoration: none;
  box-shadow: inset 4px 4px 0 var(--smusso-chiaro), inset -4px -4px 0 var(--smusso-scuro), 0 0 0 2px #000000;
}
a.scheda-pg:hover, a.scheda-pg:focus-visible { background-color: #dfe3f6; box-shadow: inset 4px 4px 0 #ffffff, inset -4px -4px 0 #5a639a, 0 0 0 2px #ffffff; }
.scheda-pg.attenuata { background-color: #9c9c9c; }
.scheda-pg-nome { font-family: var(--pixel); font-weight: 700; font-size: 1.4rem; line-height: 1.1; }
.scheda-pg-passo { color: #2b2b2b; }

/* barra di avanzamento (stile barra dell'esperienza) */
.barra-passo {
  display: block;
  width: 100%;
  height: 20px;
  border: 0;
  border-radius: 0;
  background-color: #1f1f1f;
  box-shadow: inset 0 0 0 2px #000000, 0 0 0 2px #000000;
  -webkit-appearance: none;
  appearance: none;
  overflow: hidden;
}
.barra-passo::-webkit-progress-bar { background-color: #1f1f1f; }
.barra-passo::-webkit-progress-value { background-color: #7bd13c; box-shadow: inset 0 4px 0 #b6f07f, inset 0 -4px 0 #3f8a17; }
.barra-passo::-moz-progress-bar { background-color: #7bd13c; box-shadow: inset 0 4px 0 #b6f07f, inset 0 -4px 0 #3f8a17; }

/* ───────────────────────── pozioni ───────────────────────── */
.righe-scorta > * + * { margin-top: 8px; }
.riga-scorta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; background-color: var(--pannello-chiaro); }
.riga-scorta .campo { flex: 1 1 160px; width: auto; }
.riga-scorta .contatore { flex: 0 0 170px; width: 170px; }

/* ───────────────────────── impostazioni ───────────────────────── */
.griglia-prezzi { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 8px 14px; }
.riga-prezzo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, 150px); align-items: start; gap: 8px; padding: 6px 8px; background-color: var(--pannello-chiaro); }
.riga-prezzo .nome-oggetto { min-height: 44px; font-family: var(--pixel); }

/* ───────────────────────── dialoghi ───────────────────────── */
.dialogo {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  border: 0;
  margin: auto;
  overflow: auto;
}
.dialogo::backdrop { background-color: rgba(0, 0, 0, .68); }
.dialogo-corpo > * + * { margin-top: 12px; }

/* ───────────────────────── avvisi ───────────────────────── */
.avvisi {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100vw - 20px));
  transform: translateX(-50%);
  pointer-events: none;
}
.avviso {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  color: #ffffff;
  font-family: var(--pixel);
  font-weight: 700;
  font-size: 1.1rem;
  text-align: left;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .55);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: inset 3px 3px 0 rgba(255, 255, 255, .35), inset -3px -3px 0 rgba(0, 0, 0, .4), 0 0 0 2px #000000, 0 6px 0 rgba(0, 0, 0, .4);
  animation: entra-avviso .18s steps(3) both;
}
.avviso-ok { background-color: #2c7a1f; }
.avviso-errore { background-color: #a32f2f; }
.avviso-segno { flex: none; }
@keyframes entra-avviso {
  from { transform: translateY(-16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ───────────────────────── telefono ───────────────────────── */
@media (max-width: 699px) {
  body { padding-bottom: calc(var(--alt-barra) + env(safe-area-inset-bottom, 0px)); }
  .contenuto { padding: 12px 6px 28px; }
  .marchio { font-size: 1.2rem; }
  .marchio .icona { width: 28px; height: 28px; }
  .titolo-pagina { font-size: 1.6rem; }
  .pannello { padding: 14px 12px 16px; }
  .due-colonne { grid-template-columns: minmax(0, 1fr); }
  .riquadro-cassa { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  .cassa-saldo { grid-column: 1 / -1; }
  .cassa-voce { padding: 10px 12px 12px; }
  .cassa-voce:not(.cassa-saldo) .monete-grandi { font-size: 1.2rem; }

  /* barra di navigazione in basso, con «Altro» */
  .navigazione {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 0 #000000;
  }
  .navigazione-voci { flex-wrap: wrap; gap: 0; padding: 0; }
  .navigazione-voce { flex: 1 1 0; min-width: 0; }
  .navigazione-voce.secondaria { display: none; }
  .voce-altro { display: block; }
  .navigazione-collegamento {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    width: 100%;
    min-height: var(--alt-barra);
    padding: 6px 2px;
    font-size: .82rem;
    line-height: 1.1;
    text-align: center;
    box-shadow: inset 0 4px 0 transparent;
  }
  .navigazione-collegamento.attivo { box-shadow: inset 0 4px 0 #6bb53a; }
  .navigazione-collegamento .icona { width: 28px; height: 28px; }
  .navigazione.aperta .navigazione-voce.secondaria {
    display: block;
    flex: 0 0 100%;
    order: -1;
    border-bottom: 2px solid #000000;
  }
  .navigazione.aperta .secondaria .navigazione-collegamento {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-height: 52px;
    padding: 6px 16px;
    font-size: 1.1rem;
    box-shadow: inset 6px 0 0 transparent;
  }
  .navigazione.aperta .secondaria .navigazione-collegamento.attivo { box-shadow: inset 6px 0 0 #6bb53a; }

  .barra-totale { bottom: calc(var(--alt-barra) + env(safe-area-inset-bottom, 0px) + 8px); }
  .barra-totale .bottone { flex: 1 1 100%; }

  .riga-vendita { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .riga-vendita-nome, .riga-vendita-totale { grid-column: 1 / -1; }
  .riga-vendita-totale { flex-direction: row; align-items: center; gap: 10px; }

  .azioni .bottone { flex: 1 1 auto; }
  .azioni-inizio .bottone { flex: 0 1 auto; }
  .barra-filtri { width: 100%; }
  .barra-filtri .campo { flex: 1 1 150px; min-width: 0; }
  .griglia-campi { grid-template-columns: minmax(0, 1fr); }
  .griglia-prezzi { grid-template-columns: minmax(0, 1fr); }
  .contatore { max-width: none; }

  /* le tabelle diventano schede: ogni cella porta la sua etichetta */
  .tabella:not(.tabella-stretta), .tabella:not(.tabella-stretta) tbody, .tabella:not(.tabella-stretta) tr,
  .tabella:not(.tabella-stretta) th, .tabella:not(.tabella-stretta) td { display: block; }
  .tabella:not(.tabella-stretta) { background: transparent; }
  .tabella:not(.tabella-stretta) thead {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .tabella:not(.tabella-stretta) tr { padding: 6px 10px; background-color: var(--pannello-chiaro); box-shadow: 0 0 0 2px #8a8a8a; }
  .tabella:not(.tabella-stretta) tr + tr { margin-top: 10px; }
  .tabella:not(.tabella-stretta) tbody th, .tabella:not(.tabella-stretta) td {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    padding: 5px 0;
    border: 0;
    border-bottom: 2px solid #c9c9c9;
    text-align: right;
  }
  .tabella:not(.tabella-stretta) tr > :last-child { border-bottom: 0; }
  .tabella:not(.tabella-stretta) tbody th::before, .tabella:not(.tabella-stretta) td::before {
    content: attr(data-etichetta);
    flex: none;
    font-family: var(--pixel);
    font-weight: 400;
    color: var(--titolo);
    text-align: left;
  }
  .tabella:not(.tabella-stretta) td .campo { flex: 1 1 150px; width: auto; min-width: 0; }
}

@media (max-width: 380px) {
  .testata-data::before { content: ''; }
  .griglia-contatori { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
