/* ================================================================
   statistiche.css — REDESIGN v2.0
   ================================================================ */

   .modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
  }
  .modal.hidden { display: none; }
  
  .modal-content {
    background: var(--bg-card);
    border-radius: var(--r-xl);
    width: 92%; max-width: 600px;
    box-shadow: var(--shadow-modal);
    border: 1px solid var(--border-soft);
    position: relative;
    display: flex; flex-direction: column;
    max-height: 90vh; overflow: hidden;
    padding: 20px 18px;
  }
  
  .modal-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 10px; flex: 0 0 auto;
  }
  .modal-title {
    font-family: 'Sora', sans-serif;
    font-size: 1.1rem; font-weight: 800; color: var(--text-primary); display: block;
  }
  .modal-tabs {
    flex: 0 0 auto; margin-top: 14px;
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--border-subtle); padding-bottom: 0;
    overflow-x: auto; scrollbar-width: none;
  }
  .modal-tabs::-webkit-scrollbar { display: none; }
  .tab-button {
    background: none; border: none; color: var(--text-muted);
    font-size: 13px; font-weight: 600; padding: 8px 14px; cursor: pointer;
    border-bottom: 2px solid transparent; transition: all .2s; white-space: nowrap;
    font-family: inherit; position: relative;
  }
  .tab-button:hover { color: var(--text-primary); }
  .tab-button.active { color: var(--brand-orange); border-bottom-color: var(--brand-orange); }
  
  .modal-body {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    margin-top: 14px; padding-right: 4px;
    scrollbar-width: thin; scrollbar-color: var(--bg-elevated) transparent;
  }
  .modal-body::-webkit-scrollbar { width: 5px; }
  .modal-body::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 4px; }
  
  .tab-content { display: none; margin-top: 10px; color: var(--text-primary); }
  .tab-content.active { display: block; }
  
  .close-modal {
    position: absolute; top: 14px; right: 16px;
    background: transparent; border: none; font-size: 22px;
    color: var(--text-muted); cursor: pointer;
    width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
    border-radius: 6px; transition: all .2s;
  }
  .close-modal:hover { background: var(--bg-elevated); color: var(--text-primary); }
  body.modal-open { overflow: hidden; }
  
  /* ===== STORICO ===== */
  .storico-scroll {
    max-height: 200px; overflow-y: auto; padding-right: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .storico-grid { display: flex; flex-wrap: wrap; gap: 4px; }
  .numero-storico {
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; border-radius: 5px; color: #fff;
  }
  .numero-storico.rosso { background: #dc2626; }
  .numero-storico.nero  { background: #1e2535; }
  .numero-storico.verde { background: #16a34a; }
  
  /* Evidenzia uguali */
  .storico-grid.equal-highlighting .numero-storico { opacity: .3; transition: opacity .12s, transform .12s; }
  .storico-grid.equal-highlighting .numero-storico.hl {
    opacity: 1; transform: scale(1.06);
    outline: 2px solid rgba(249,115,22,.4); outline-offset: 2px; border-radius: 6px;
  }
  
  .download-btn {
    margin-top: 8px; padding: 8px 14px;
    background: var(--brand-blue); color: #fff; border: none;
    border-radius: var(--r-md); cursor: pointer; display: block;
    font-size: 13px; font-weight: 600; transition: all .2s;
  }
  .download-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
  .img-fantan-storico { width: 22px; height: 22px; object-fit: contain; }
  
  /* ===== ROULETTE SECTIONS ===== */
  .rs-section { margin: 6px 0; padding: 5px 0; }
  .rs-section h3 { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--text-primary); }
  .rs-scroll {
    display: flex; gap: 10px;
    padding: 6px 0 12px; overflow-x: auto; overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent;
  }
  .rs-scroll.center { justify-content: center; }
  .rs-scroll::-webkit-scrollbar { height: 5px; }
  .rs-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
  
  .rs-chip {
    width: 32px; height: 32px; border-radius: var(--r-sm);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; position: relative; flex-shrink: 0;
  }
  .rs-chip.red   { background: #dc2626; color: #fff; }
  .rs-chip.black { background: #1e2535; color: #fff; }
  .rs-chip.green { background: #16a34a; color: #fff; }
  .rs-chip small {
    position: absolute; bottom: -14px; left: 0; right: 0;
    text-align: center; font-size: 10px; color: var(--text-muted);
  }
  
  .rs-group {
    min-width: 68px; padding: 8px 10px 6px;
    border-radius: var(--r-md); background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-subtle);
    display: flex; flex-wrap: wrap; justify-content: center; align-items: center;
    gap: 3px; position: relative; flex-shrink: 0;
  }
  .rs-group.rs-labelbox { font-weight: 600; font-size: 13px; color: var(--text-primary); }
  .rs-group small {
    position: absolute; bottom: -16px; left: 0; right: 0;
    text-align: center; font-size: 10px; color: var(--text-muted);
  }
  .rs-group .mini {
    padding: 3px 5px; border-radius: 5px; min-width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff; flex: 0 0 auto;
  }
  .rs-group .mini.red   { background: #dc2626; }
  .rs-group .mini.black { background: #000 !important; }
  .rs-group .mini.green { background: #16a34a; }
  .mini {
    padding: 3px 5px; border-radius: 5px; min-width: 22px; height: 22px;
    font-size: 13px; font-weight: 700; line-height: 1; color: #fff;
    margin-right: 4px; margin-left: 4px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  #pairs-strong {
    margin-top: 12px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--border-subtle);
    background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.018));
  }
  #pairs-strong > h3 {
    margin-bottom: 12px;
    font-size: 15px;
  }
  #pairs-strong .rs-section,
  #pairs-tally.rs-section {
    margin: 0;
    padding: 10px 12px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.06);
    background: rgba(9, 13, 21, 0.62);
  }
  #pairs-strong .rs-section + .rs-section {
    margin-top: 10px;
  }
  #pairs-strong .rs-subtitle,
  #pairs-tally .rs-subtitle {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-secondary);
  }
  #pairs-strong .tags-row,
  #pairs-tally .tags-row {
    gap: 8px;
    padding: 2px 0 4px;
    flex-wrap: wrap;
  }
  #pairs-strong .tag-suggest,
  #pairs-tally .tag-suggest {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.07);
    background: rgba(255,255,255,.04);
    color: var(--text-primary);
  }
  #pairs-strong .tag-suggest small,
  #pairs-tally .tag-suggest small {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
  }
  #pairs-strong .arrow {
    color: var(--text-muted);
    font-weight: 700;
  }
  #pairs-strong .mini.red, #pairs-tally .mini.red { background: #dc2626; }
  #pairs-strong .mini.black, #pairs-tally .mini.black { background: #000 !important; }
  #pairs-strong .mini.green, #pairs-tally .mini.green { background: #16a34a; }
  @media (max-width: 767.98px) {
    #pairs-strong {
      padding: 12px;
      border-radius: 16px;
    }
    #pairs-strong .rs-section,
    #pairs-tally.rs-section {
      padding: 10px;
      border-radius: 12px;
    }
    #pairs-strong .tags-row,
    #pairs-tally .tags-row {
      flex-wrap: nowrap;
      padding-bottom: 8px;
    }
    #pairs-strong .tag-suggest,
    #pairs-tally .tag-suggest {
      flex: 0 0 auto;
    }
  }
  
  /* ===== CRAZYTIME ===== */
  .ct-kpi-header { display: flex; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }
  .ct-kpi-header .k {
    background: var(--bg-elevated); border: 1px solid var(--border-subtle);
    border-radius: var(--r-md); padding: 8px 12px; min-width: 82px; text-align: center;
  }
  .ct-kpi-header .v { font-size: 17px; font-weight: 800; line-height: 1; color: var(--text-primary); }
  .ct-kpi-header .t { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
  .ct-section { margin: 12px 0; }
  .ct-section > h3 { font-size: 13px; font-weight: 700; margin: 0 0 8px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .4px; }
  .ct-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .ct-row::-webkit-scrollbar { display: none; }
  .ct-chip {
    display: flex; align-items: center; gap: 7px;
    background: var(--bg-elevated); border: 1px solid var(--border-subtle);
    border-radius: var(--r-md); padding: 6px 9px; min-width: 140px; flex-shrink: 0;
  }
  .ct-ico { width: 20px; height: 20px; object-fit: contain; flex: 0 0 auto; }
  .ct-meta { display: flex; align-items: center; gap: 4px; width: 100%; }
  .ct-lbl { font-weight: 600; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
  .ct-kpi b { font-weight: 800; color: var(--text-primary); }
  .ct-kpi small { display: block; font-size: 10px; color: var(--text-muted); }
  
  /* ===== GENERALE ===== */
  .generale-toprow {
    display: flex; align-items: center; gap: 18px; margin: 10px 0 18px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.04); border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
  }
  .generale-toprow .hotcold-col { display: flex; flex-direction: column; gap: 5px; flex: 1; justify-content: center; margin-left: -10px; }
  .generale-toprow .hotcold-col .rs-section { margin: 0; }
  .generale-toprow .rs-range {
    display: flex; flex-direction: column; align-items: flex-start;
    padding: 8px 10px; border-radius: var(--r-md); min-width: 130px;
  }
  .generale-toprow .rs-range label {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    margin-bottom: 6px; color: var(--text-muted);
  }
  .generale-toprow .rs-range select {
    background: var(--bg-elevated); color: var(--text-primary);
    border: 1px solid var(--border-soft); border-radius: var(--r-sm);
    padding: 6px 8px; font-size: 13px; cursor: pointer; width: 100%;
    outline: none; font-family: inherit;
  }
  .generale-toprow .rs-range select:focus { border-color: rgba(249,115,22,.4); }
  .generale-body { transition: opacity .25s ease; }
  .generale-body.updating { opacity: .3; }
  @media (max-width: 600px) {
    .generale-toprow { flex-direction: column; gap: 10px; }
    .generale-toprow .rs-range { align-self: stretch; min-width: auto; }
  }
  
  /* ===== SuperColorGame ===== */
  #modaleStatistiche .tab-content { display: none; }
  #modaleStatistiche .tab-content.active { display: block; }
  #modaleStatistiche .cg-info { font-size: .85rem; color: var(--text-muted); margin-bottom: 6px; }
  #modaleStatistiche .storico-scroll-x { overflow-x: auto; padding-bottom: 6px; }
  #modaleStatistiche .cg-row { display: flex; gap: 5px; }
  #modaleStatistiche .cg-col { display: flex; flex-direction: column; gap: 2px; align-items: center; }
  #modaleStatistiche .cg-cube { width: 13px; height: 13px; border-radius: 3px; }
  #modaleStatistiche #tab-generale,
  #modaleStatistiche #tab-ritardi { display: grid; gap: 8px; }
  #modaleStatistiche .rs-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 4px 0; border-bottom: 1px solid var(--border-subtle);
  }
  #modaleStatistiche .rs-title { font-size: .9rem; color: var(--text-primary); font-weight: 600; }
  #modaleStatistiche .rs-tags { display: flex; gap: 5px; flex-wrap: wrap; }
  #modaleStatistiche .tag {
    font-size: .75rem; padding: 2px 8px;
    border: 1px solid var(--border-soft); border-radius: 999px;
    color: var(--text-secondary); background: var(--bg-elevated);
  }
  #modaleStatistiche .color-grid { display: grid; gap: 5px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  #modaleStatistiche .color-item {
    display: flex; align-items: center; gap: 7px; padding: 4px 0;
    border-bottom: 1px solid var(--border-subtle);
  }
  #modaleStatistiche .color-item:last-child { border-bottom: 0; }
  #modaleStatistiche .color-name { text-transform: capitalize; font-size: 13px; color: var(--text-secondary); }
  #modaleStatistiche .rs-wrap { display: grid; gap: 5px; }
  #modaleStatistiche .rs-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border-subtle);
  }
  #modaleStatistiche .rs-row:last-child { border-bottom: 0; }
  #modaleStatistiche .rs-left { display: flex; align-items: center; gap: 7px; }
  #modaleStatistiche .rs-label { text-transform: capitalize; font-size: 13px; color: var(--text-secondary); }
  #modaleStatistiche .rs-val { font-weight: 700; color: var(--text-primary); }
  #modaleStatistiche .rs-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9rem; }
  #modaleStatistiche .rs-section-title {
    font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
    color: var(--text-muted); margin: 2px 0 4px;
    border-bottom: 1px solid var(--border-subtle); padding-bottom: 4px;
  }
  #modaleStatistiche .rs-kpi { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9rem; }
  #modaleStatistiche .rs-kpi .kpi b { font-weight: 700; color: var(--text-primary); }
  #modaleStatistiche .sector-grid {
    display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  @media (max-width: 900px) { #modaleStatistiche .sector-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); } }
  #modaleStatistiche .sector-card { padding: 4px 0; }
  #modaleStatistiche .sector-title { font-weight: 700; font-size: 12px; color: var(--text-secondary); margin: 2px 0 4px; }
  #modaleStatistiche .sector-list { display: grid; gap: 4px; }
  #modaleStatistiche .cg-chart-wrap canvas { background: rgba(255,255,255,.03); }
  #modaleStatistiche .cg-chart-wrap select:focus { outline: none; }
  .rs-icon { height: 26px; margin-right: 5px; flex-shrink: 0; align-self: center; }
  .storico-scroll, .rs-scroll { will-change: transform; transform: translateZ(0); contain: paint; }
