﻿  /* v2025 ver. 1.6 */

:root{
  /* Palette principale */
  --bg: #0f1115;                 /* TODO: usa come fallback per lo sfondo oppure rimuovi */
  --text: #e9eef7;
  --muted: #9fb0c7;

  /* Accenti standardizzati */
  --green: #26c281;
  --green-dark: #17a26a;
  --blue: #3b7cff;
  --blue-dark: #2856b7;
  --red: #ff7b51;
  --red-dark: #c24a22;
  --pink: #ff4ddb;
  --pink-dark: #b82488;

  /* Stati */
  --match: #fff74ff1;            /* evidenziazione match (RGBA hex) */
  --bonus-bg: #c8f7c5;           /* evidenziazione bonus */
  --super-bg: #e6d6ff;           /* evidenziazione super bonus */

  /* Pulsanti */
  --btn: #232b3d;
  --btn-text: #ffffff;

  /* Rounding & elevazioni */
  --radius-10: 10px;
  --radius-14: 14px;
  --radius-16: 16px;
  --radius-18: 18px;

  --elev-1: 0 4px 14px rgba(0,0,0,.15);
  --elev-2: 0 10px 40px rgba(0,0,0,.5);

  /* Dimensione fluida del dado */
  --die-size: clamp(88px, 28vw, 148px);
}

/* --------------------------
   Layout base e tipografia
   -------------------------- */
body{
  margin:12px;
  padding-inline:5px;
  color:var(--text);
  font-family:'Montserrat',sans-serif;
  background:center center fixed no-repeat;
  /* Fallback + variabile personalizzabile */
  background-image: linear-gradient(180deg,#111,#191f2a), var(--bg-img);
  background-size:cover;
}

.versione{
  font-size:.6em;
  color:var(--muted);
  text-align:center;
  margin-top:-10px;
}

.card{
  max-width:980px;
  margin:0 auto;
  background:rgba(18,24,38,.75);
  backdrop-filter:blur(3px);
  padding:16px;
  border-radius:var(--radius-18);
  box-shadow:var(--elev-2);
  height: 100dvh;       /* sempre alto come la finestra */
  display: flex;
  flex-direction: column;
  overflow-y: auto;    /* se i contenuti eccedono, scrolla dentro la card */
}

h1{
  text-align:center;
  margin:8px 0;
  font-size:clamp(32px,5.2vw,56px);
  line-height:1.1;
}
.muted{ color:var(--muted); font-size:13px; text-align:center }
#status{ font-size:clamp(18px,3.5vw,28px); font-weight:600; line-height:1.2 }

/* --------------------------
   Barra di progresso
   -------------------------- */
.progress{
  height:clamp(6px,.8vw,12px);
  background:linear-gradient(90deg,var(--blue),var(--red));
  width:0;
  border-radius:10px;
  transition:width .1s ease, opacity .25s;
  margin-top:6px;
}

/* --------------------------
   Griglia dei dadi (centra gli elementi)
   -------------------------- */
.dice{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
  margin-bottom: 6px;
  justify-items:center;   /* centra il dado in ogni colonna */
  align-items:center;
}

/* --------------------------
   Stile base del dado (responsive)
   -------------------------- */
.die{
  width: var(--die-size);
  aspect-ratio: 1 / 1;              /* ⟵ resta sempre quadrato */
  border-radius: var(--radius-14);
  margin: 0 auto;
  height: auto;
  display:flex;
  align-items:center;
  justify-content:center;

  /* scala il contenuto in base alla dimensione del dado */
  font-size: calc(var(--die-size) * 0.78);
  color:#fff;

  border:1px solid rgba(255,255,255,.10);
  box-shadow:
    0 8px 20px rgba(0,0,0,.50),
    inset 0 1px 0 rgba(255,255,255,.08),
    inset 0 0 14px rgba(255,255,255,.04);
  transition: transform .15s ease, box-shadow .2s ease, border-color .2s ease;
  position:relative; /* overlay immagini */
}

.die-box > div {
  display: flex;
  justify-content: center; /* centra orizzontalmente */
}


/* Overlay immagini: resta proporzionato al dado */
.die::after{
  content:"";
  position:absolute; inset:0;
  border-radius:inherit;
  background-image: var(--face-url);
  background-repeat:no-repeat;
  background-position:center;
  background-size:contain;
  pointer-events:none;
}

/* Hover/active (invariato) */
.die:hover,
.die:active{
  transform: translateY(-1px);
  box-shadow:
    0 12px 28px rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,255,255,.10),
    inset 0 0 16px rgba(255,255,255,.06);
}

/* Colori sfondo per dadi */
.green{ background:linear-gradient(145deg,var(--green),var(--green-dark)) }
.blue { background:linear-gradient(145deg,var(--blue),var(--blue-dark)) }
.red  { background:linear-gradient(145deg,var(--red),var(--red-dark)) }

/* --------------------------
   Label (descrizioni sotto i dadi)
   -------------------------- */
.label{
  min-height:44px;
  padding:8px 10px;
  display:flex; align-items:center; justify-content:center;
  text-align:center;
  margin-top:10px;
  border-radius:var(--radius-10);
  background:rgba(255,255,255,.06);
  color:inherit;
  line-height:1.2;
  transition:box-shadow .25s ease, background-color .2s ease, color .2s ease;
}

/* Bordi colorati per label */
#labelV{ border:2px solid var(--green) }
#labelB{ border:2px solid var(--blue) }
#labelR{ border:2px solid var(--red) }

/* Stato match (+ animazione) */
.label.match{
  background:var(--match);
  color:#111;
  box-shadow:0 0 12px rgba(255,245,79,.55), inset 0 0 6px rgba(0,0,0,.2);
  animation:labelPop 380ms ease-out;
}

/* --------------------------
   Pulsanti "Ritira" (variant system)
   -------------------------- */
button{
  padding:10px 14px;
  border-radius:var(--radius-10);
  border:0;
  background:var(--btn);
  color:var(--btn-text);
  font-weight:700;
  cursor:pointer;
  transition:box-shadow .2s ease, transform .15s ease;
}
button.mini{ padding:6px 10px; font-size:12px }
button:disabled{ opacity:.55 }
button:focus-visible{
  outline:2px solid var(--blue);
  outline-offset:2px;
}

.row{ display:flex; gap:8px; align-items:center; flex-wrap:wrap }

/* Varianti reroll (riduce ripetizioni) */
.reroll{ background:transparent }
.reroll:not(:disabled){ color:#fff }
.reroll.is-green{ border:2px solid var(--green); color:var(--green) }
.reroll.is-green:not(:disabled){ background:var(--green); color:#fff }
.reroll.is-blue{ border:2px solid var(--blue); color:var(--blue) }
.reroll.is-blue:not(:disabled){ background:var(--blue); color:#fff  }
.reroll.is-red{ border:2px solid var(--red); color:var(--red) }
.reroll.is-red:not(:disabled){ background:var(--red); color:#fff  }

/* --------------------------
   Box risultati (bonus, super…)
   -------------------------- */
.result{
  background:rgba(255,255,255,.05);
  padding:10px;
  border-radius:var(--radius-10);
  margin-top:12px;
  text-align:center;

  --result-accent: rgba(255,255,255,.18);
  border:2px solid var(--result-accent);
  box-shadow:
    0 0 0 1px rgba(0,0,0,.12) inset,
    var(--elev-1);

  /* Fallback + color-mix */
  background-image: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
  background-image:
    linear-gradient(180deg,
      color-mix(in hsl, var(--result-accent) 18%, transparent),
      rgba(255,255,255,.03));
}

#bonus.bonus{ border:2px solid var(--green); background:var(--bonus-bg) !important; color:#0b3a12 }
#bonus.super{ border:2px solid var(--pink);  background:var(--super-bg) !important; color:#2f1151 }
.result:empty{ border:none }

#extraBox {
  margin: 12px 50px 50 50px; /* sopra, destra, sotto, sinistra */
}

/* --------------------------
   Settings / configurazioni
   -------------------------- */
/* Evita :has() con una classe wrapper .preset-row (consigliato); se non puoi, mantieni :has() */
.field .row.preset-row{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:6px;
}
#settings {
  margin-bottom: 12px;
}
.settings-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:12px; margin-top:10px }
.field{
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.12);
  border-radius:var(--radius-10);
  padding:10px;
}
.field > label{ display:block; margin-bottom:6px }

.weights-group .slider-row{
  display:flex; align-items:center; gap:6px; justify-content:flex-start; margin:4px 0;
}
.weights-group .slider-row span{ min-width:120px; font-size:13px }
.weights-group .slider-row input[type="range"]{ flex:1; max-width:160px }
.weights-group .slider-row output{ min-width:40px; text-align:right }

.edit-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:5px }
.edit-grid .col{
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.12);
  text-align:center;
  border-radius:var(--radius-10);
  padding:10px;
}
.edit-grid .col:nth-child(1) b,
.edit-grid .col:nth-child(1) span{ color:var(--green) }
.edit-grid .col:nth-child(2) b,
.edit-grid .col:nth-child(2) span{ color:var(--blue) }
.edit-grid .col:nth-child(3) b,
.edit-grid .col:nth-child(3) span{ color:#ff4d4d }
.edit-grid input{
  width:95%; padding:3px; border-radius:8px;
  border:1px solid rgba(255,255,255,.15);
  background:rgba(255,255,255,.06);
  color:var(--text);
}

/* Input disabilitati nell'editor */
.edit-grid input:disabled{ opacity:.6; cursor:not-allowed }

/* Titoli colonne editor */
.edit-grid .col b{ display:block; margin-bottom:6px; font-size:14px }

/* --------------------------
   Preset (Soft, Normale, Hard, ecc.)
   -------------------------- */
.preset[aria-pressed="true"]{ color:#0e1a14 }
#presetSoft[aria-pressed="true"]{
  background:linear-gradient(145deg,var(--green),var(--green-dark));
  box-shadow:0 0 0 2px color-mix(in hsl, var(--green) 45%, transparent), 0 6px 18px color-mix(in hsl, var(--green) 35%, transparent);
}
#presetNormale[aria-pressed="true"]{
  background:linear-gradient(145deg,var(--blue),var(--blue-dark));
  box-shadow:0 0 0 2px color-mix(in hsl, var(--blue) 45%, transparent), 0 6px 18px color-mix(in hsl, var(--blue) 35%, transparent);
}
#presetHard[aria-pressed="true"]{
  background:linear-gradient(145deg,var(--red),var(--red-dark));
  box-shadow:0 0 0 2px color-mix(in hsl, var(--red) 45%, transparent), 0 6px 18px color-mix(in hsl, var(--red) 35%, transparent);
}
#presetSuperHard[aria-pressed="true"]{
  background:linear-gradient(145deg,var(--pink),var(--pink-dark));
  box-shadow:0 0 0 2px color-mix(in hsl, var(--pink) 45%, transparent), 0 6px 18px color-mix(in hsl, var(--pink) 35%, transparent);
}
#presetPorno[aria-pressed="true"]{
  background:linear-gradient(145deg,#ff4d4d,#b30000);
  box-shadow:0 0 0 2px rgba(255,77,77,.45), 0 6px 18px rgba(179,0,0,.35);
}
#presetCustom[aria-pressed="true"]{
  background:linear-gradient(145deg,#ffd700,#b8860b);
  box-shadow:0 0 0 2px rgba(255,215,0,.45), 0 6px 18px rgba(184,134,11,.35);
}

/* --------------------------
   Responsive
   -------------------------- */


/* Unica media per 520px */
@media (max-width:520px) {
  .field .row.preset-row { grid-template-columns:repeat(2,1fr) }
  .lang-row { flex-wrap:wrap }
}

/* Ottimizzazione per telefoni stretti */
@media (max-width: 420px) {
  :root {
    --die-size: clamp(70px, 25vw, 100px);
  }
}

/* Riduci animazioni se preferito */
@media (prefers-reduced-motion:reduce) {
  .die.rolling { animation:none }
  * { transition:none !important; scroll-behavior:auto !important }
}

/* --------------------------
   Pulsanti grandi (Tira / Stop)
   -------------------------- */
.big-btn{
  font-size:2.2rem;
  padding:16px 28px;
  border-radius:var(--radius-16);
  min-width:140px;
  text-align:center;
  white-space:pre-line;
}
.row button.big-btn{ flex:1; min-width:0 }
#rollBtn.big-btn{ background:linear-gradient(135deg,#28c328,#46ff46); color:#fff }
#stopBtn.big-btn{ background:linear-gradient(225deg,#c32828,#ff4646); color:#fff }

/* --------------------------
   Pulsante flottante WhatsApp
   -------------------------- */
.wa-fab{
  position:fixed; right:16px; bottom:16px;
  width:58px; height:58px; border-radius:50%;
  background-color:#25D366;
  display:grid; place-items:center;
  box-shadow:0 6px 16px rgba(0,0,0,.35);
  z-index:10000;
  transition:transform .2s, box-shadow .2s;
}
.wa-fab:hover{ transform:translateY(-2px); box-shadow:0 10px 24px rgba(0,0,0,.4) }
.wa-fab img{ display:block; width:28px; height:28px }

/* --------------------------
   Storico / condivisione
   -------------------------- */
#historyDlg{
  border:0; border-radius:12px; padding:14px 16px;
  background:#1a1f2d; color:#e9eef7;
}
.share-row{
  border:1px solid rgba(255,255,255,.12);
  border-radius:var(--radius-10);
  padding:8px; margin-bottom:8px;
  background:rgba(255,255,255,.04);
}
.share-row pre{ white-space:pre-wrap; margin:6px 0 0; font-size:12px; color:#cfe1ff }

/* --------------------------
   Azioni piccole
   -------------------------- */
.actions-small{
  margin-top:10px;
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:8px;
}
.actions-small .mini{ width:100%; justify-content:center; white-space:nowrap }

/* --------------------------
   Heat bar (termometro intensità)
   -------------------------- */
.heat-wrap{ margin-top:8px }
.heat-head{ display:flex; align-items:center; justify-content:space-between; font-size:12px; color:var(--muted); gap:8px }
.heat-flames{ display:flex; gap:6px; align-items:center; justify-content:center; letter-spacing:1px }
.heat-flames .flame{ opacity:.28; transform:translateY(0); transition:opacity .25s ease, transform .25s ease, filter .25s ease; filter:saturate(.8) }
.heat-flames .flame.active{ opacity:1; transform:translateY(-1px); filter:drop-shadow(0 0 6px rgba(255,120,50,.35)) }
.heat-bar{ position:relative; height:10px; border-radius:10px; overflow:hidden; background:rgba(255,255,255,.08) }
.heat-fill{ height:100%; width:0%; background:linear-gradient(90deg,var(--green),var(--red)); transition:width .6s cubic-bezier(.22,.61,.36,1) }
.heat-ticks{
  pointer-events:none; position:absolute; inset:0;
  background-image:repeating-linear-gradient(to right, rgba(255,255,255,.18) 0, rgba(255,255,255,.18) 1px, transparent 1px, transparent calc(10% - 1px));
  mix-blend-mode:screen; opacity:.35
}
.heat-wrap.hot .heat-fill{ box-shadow:0 0 14px rgba(255,123,81,.45) }
.heat-wrap.xxx .heat-fill{ box-shadow:0 0 18px rgba(255,77,219,.40), 0 0 28px rgba(255,77,219,.25) }

/* --------------------------
   Animazioni (shake dadi, flash risultati)
   -------------------------- */
@keyframes dieShake{
  0%{ transform:translate(0,0) rotate(0) }
  20%{ transform:translate(-4px,-3px) rotate(-4deg) }
  40%{ transform:translate(4px,2px) rotate(4deg) }
  60%{ transform:translate(-3px,3px) rotate(-3deg) }
  80%{ transform:translate(3px,-2px) rotate(3deg) }
  100%{ transform:translate(0,0) rotate(0) }
}
.die.rolling{
  will-change:transform, box-shadow;
  animation:dieShake .5s cubic-bezier(.36,.07,.19,.97) infinite;
  box-shadow:0 12px 28px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.10), inset 0 0 18px rgba(255,255,255,.07);
}

@keyframes resFlashBonus{
  0%{ box-shadow:0 0 0 0 rgba(38,194,129,0), 0 0 0 0 rgba(0,0,0,0) }
  25%{ box-shadow:0 0 24px 8px rgba(38,194,129,.45), 0 4px 18px rgba(0,0,0,.25) }
  100%{ box-shadow:0 0 0 0 rgba(38,194,129,0), 0 4px 14px rgba(0,0,0,.15) }
}
@keyframes resFlashSuper{
  0%{ box-shadow:0 0 0 0 rgba(255,77,219,0), 0 0 0 0 rgba(0,0,0,0) }
  25%{ box-shadow:0 0 28px 10px rgba(255,77,219,.45), 0 4px 18px rgba(0,0,0,.25) }
  100%{ box-shadow:0 0 0 0 rgba(255,77,219,0), 0 4px 14px rgba(0,0,0,.15) }
}
.result.flash-bonus{ animation:resFlashBonus 650ms ease-out }
.result.flash-super{ animation:resFlashSuper 700ms ease-out }

/* --------------------------
   Lingua / bandiere
   -------------------------- */
.flag-btn{ display:inline-flex; align-items:center; gap:6px; font-weight:700 }
.flag-btn[aria-pressed="true"]{ outline:2px solid #6cf8; box-shadow:0 0 0 2px #6cf2 inset }

/* --------------------------
   Settings (details/summary)
   -------------------------- */
/* Marker hidden + padding coerente in un unico blocco */
details#settings > summary{
  list-style:none; -webkit-appearance:none; display:block;
  padding:8px 16px 8px 10px;       /* padding-left consolidato */
  background:rgba(255,255,255,.06);
  border-radius:var(--radius-10);
  cursor:pointer;
}
details#settings > summary::marker,
details#settings > summary::-webkit-details-marker{ display:none }


/* Slider accent */
input[type=range]{ flex:1 }
.green-sliders input[type=range]{ accent-color:var(--green) }
.blue-sliders  input[type=range]{ accent-color:var(--blue) }
.red-sliders   input[type=range]{ accent-color:var(--red) }

/* Box sizing globale */
*,*::before,*::after{ box-sizing:border-box }

/* Stato disabilitato coerente per tutti i bottoni principali */
#rollBtn:disabled,
#stopBtn:disabled,
.reroll:disabled{
  opacity:.6; cursor:not-allowed; filter:grayscale(30%);
  transition:opacity .3s ease;
}


/* --------------------------
   Stato attivo per lingua, immagini e durata roll
   -------------------------- */
.lang-row button[aria-pressed="true"] {
  background: linear-gradient(145deg, var(--blue), var(--blue-dark));
  box-shadow:
    0 0 0 2px color-mix(in hsl, var(--blue) 45%, transparent),
    0 6px 18px color-mix(in hsl, var(--blue) 35%, transparent);
  color: #fff;
}
.imgset-row button[aria-pressed="true"] {
  background: linear-gradient(145deg, var(--green), var(--green-dark));
  box-shadow:
    0 0 0 2px color-mix(in hsl, var(--green) 45%, transparent),
    0 6px 18px color-mix(in hsl, var(--green) 35%, transparent);
  color: #fff;
}
.rolltime-row button[aria-pressed="true"] {
  background: linear-gradient(145deg, var(--red), var(--red-dark));
  box-shadow:
    0 0 0 2px color-mix(in hsl, var(--red) 45%, transparent),
    0 6px 18px color-mix(in hsl, var(--red) 35%, transparent);
  color: #fff;
}

/* --------------------------
   Animazione pop label
   -------------------------- */
@keyframes labelPop{
  0%{ transform:scale(1) }
  30%{ transform:scale(1.06) }
  100%{ transform:scale(1) }
}


/* --------------------------
   Pulsante flottante Dona un caffè
   -------------------------- */
.fab-coffee {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 22px;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(145deg, #ff4ddb, #b82488);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
  transition: transform .2s;
}

.fab-coffee:hover { transform: translateY(-2px); }
.fab-coffee:active { transform: translateY(0); }

/* --- FIX overflow e impilamento Impostazioni --- */

/* 1) Permetti alle celle di stringere: evita che “Custom” e “Pesi Blu” escano a destra */
.settings-grid { 
  grid-template-columns: minmax(0,1fr) minmax(0,1fr); /* 2 colonne elastiche */
}
.settings-grid .field,
.settings-grid .field * {
  min-width: 0; /* fondamentale in CSS Grid per evitare overflow orizzontale */
}

/* 2) L’editor interno (3 colonne) non deve spingere fuori */
.edit-grid {
  grid-template-columns: repeat(3, minmax(0,1fr));
}

/* 3) Su schermi medi/piccoli impila tutto su 1 colonna */
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
  .edit-grid     { grid-template-columns: 1fr; }
}

/* 4) Niente scrollbar orizzontale in card (difesa finale) */
.card { overflow-x: hidden; }

/* Nascondi la barra di scorrimento verticale in tutta la pagina */
html, body {
  overflow-y: scroll;        /* mantieni lo scroll verticale attivo */
  scrollbar-width: none;     /* Firefox */
  -ms-overflow-style: none;  /* IE/Edge legacy */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;             /* Chrome, Safari, Edge (Blink/WebKit) */
}
/* Nascondi scrollbar ovunque, anche nei contenitori interni */
* {
  scrollbar-width: none !important;     /* Firefox */
  -ms-overflow-style: none !important;  /* IE/Edge legacy */
}

*::-webkit-scrollbar {
  display: none !important;             /* Chrome, Safari, Edge */
}


