/* ═══════════════════════════════════════════
   CatMap – Arena (stili specifici)
   ═══════════════════════════════════════════ */

/* Variabili gold locali (premio) */
:root {
  --gold:       #D4A827;
  --gold-light: #F0C84A;
  --gold-pale:  #FAF0D0;
}

/* Layout */
.arena-layout {
  padding: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.arena-main   { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(var(--nav-h) + 24px); scrollbar-width: thin; scrollbar-color: var(--sand) transparent; }
.arena-main::-webkit-scrollbar { width: 4px; }
.arena-main::-webkit-scrollbar-thumb { background: var(--sand); border-radius: 2px; }

/* ── HERO SFIDA CORRENTE ── */
.challenge-hero {
  background: linear-gradient(145deg, #3D2B1F 0%, #6B4C38 60%, #8B4A2B 100%);
  padding: 28px 20px 24px;
  position: relative;
  overflow: hidden;
}
.challenge-hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 80% 20%, rgba(196,112,79,.35) 0%, transparent 60%),
              radial-gradient(ellipse at 10% 80%, rgba(212,168,39,.15) 0%, transparent 50%);
}
.challenge-hero-inner { position: relative; z-index: 1; }

.challenge-status-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.challenge-badge-live {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  color: white;
}
.challenge-badge-live .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ADE80;
  box-shadow: 0 0 0 3px rgba(74,222,128,.3);
  animation: pulse-green 1.6s ease-in-out infinite;
}
@keyframes pulse-green { 0%,100% { box-shadow: 0 0 0 3px rgba(74,222,128,.3); } 50% { box-shadow: 0 0 0 6px rgba(74,222,128,.1); } }

.challenge-edition { font-size: 11px; font-weight: 700; color: rgba(255,255,255,.55); letter-spacing: .4px; }

.challenge-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: white; line-height: 1.15; margin-bottom: 8px; }
.challenge-desc  { font-size: 14px; color: rgba(255,255,255,.75); font-weight: 500; line-height: 1.5; margin-bottom: 20px; }

.challenge-prize {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 13px; font-weight: 800; color: #3D2B1F;
  box-shadow: 0 4px 16px rgba(212,168,39,.4);
  margin-bottom: 22px;
}

/* Countdown */
.challenge-countdown { display: flex; gap: 10px; margin-bottom: 22px; }
.countdown-unit {
  flex: 1; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm); padding: 10px 6px; text-align: center;
}
.countdown-val { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: white; line-height: 1; letter-spacing: -1px; }
.countdown-lbl { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: rgba(255,255,255,.5); margin-top: 3px; }

/* CTA */
.challenge-cta {
  width: 100%; padding: 14px; border-radius: var(--radius-pill);
  background: var(--terra); color: white; border: none; cursor: pointer;
  font-family: var(--font-ui); font-size: 15px; font-weight: 800;
  box-shadow: 0 4px 20px rgba(196,112,79,.5);
  transition: all .2s cubic-bezier(0.34,1.56,0.64,1);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.challenge-cta:hover { transform: scale(1.02); background: var(--terra-dark); }

/* ── SEZIONI ── */
.section-wrap { padding: 20px 16px 0; }
.section-title { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; color: var(--sand-dark); margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--cream-mid); }

/* ── PODIO TOP 3 ── */
.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.podium-item { background: var(--white); border-radius: var(--radius-md); padding: 14px 10px 12px; text-align: center; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.podium-item.first { background: linear-gradient(160deg, var(--gold-pale), var(--white)); border: 1.5px solid var(--gold-light); transform: translateY(-4px); box-shadow: 0 6px 24px rgba(212,168,39,.2); }
.podium-item.second { border: 1px solid var(--cream-mid); }
.podium-item.third  { border: 1px solid var(--cream-mid); }
.podium-medal { font-size: 20px; margin-bottom: 6px; line-height: 1; }
.podium-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--terra); color: white;
  font-family: var(--font-display); font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 6px; border: 3px solid var(--white);
  box-shadow: var(--shadow-sm);
}
.podium-item.first .podium-avatar { border-color: var(--gold-light); box-shadow: 0 0 0 3px var(--gold-pale); }
.podium-name { font-size: 12px; font-weight: 800; color: var(--brown); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.podium-score { font-size: 11px; font-weight: 700; color: var(--terra); margin-top: 2px; }
.podium-rank-lbl { font-size: 9px; font-weight: 700; color: var(--sand-dark); text-transform: uppercase; letter-spacing: .3px; margin-top: 3px; }

/* ── CLASSIFICA COMPLETA ── */
.rank-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.rank-item { background: var(--white); border-radius: var(--radius-md); padding: 12px 14px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-sm); }
.rank-pos { width: 26px; text-align: center; font-size: 13px; font-weight: 800; color: var(--sand-dark); flex-shrink: 0; }
.rank-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--terra); color: white; font-family: var(--font-display); font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank-name { flex: 1; font-size: 14px; font-weight: 700; color: var(--brown); }
.rank-sub { font-size: 11px; color: var(--sand-dark); font-weight: 500; margin-top: 1px; }
.rank-score { font-size: 14px; font-weight: 800; color: var(--terra); flex-shrink: 0; }
.rank-item.rank-me { background: var(--terra-pale); border: 1.5px solid var(--terra); }
.rank-item.rank-me .rank-pos { color: var(--terra); }
.rank-me-tag { font-size: 10px; font-weight: 800; color: var(--terra); background: rgba(196,112,79,.15); border-radius: var(--radius-pill); padding: 2px 7px; margin-left: 6px; }

/* ── PROSSIMA SFIDA ── */
.upcoming-card { background: var(--white); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); border: 1.5px dashed var(--sand); display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.upcoming-icon { width: 52px; height: 52px; border-radius: var(--radius-md); background: var(--cream-mid); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.upcoming-info { flex: 1; min-width: 0; }
.upcoming-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--sand-dark); margin-bottom: 3px; }
.upcoming-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--brown); line-height: 1.2; }
.upcoming-date  { font-size: 11px; font-weight: 600; color: var(--brown-mid); margin-top: 4px; }
.upcoming-pill  { font-size: 11px; font-weight: 800; color: var(--brown-mid); background: var(--cream-mid); border-radius: var(--radius-pill); padding: 5px 12px; flex-shrink: 0; }

/* ── SFIDE PASSATE ── */
.past-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.past-item { background: var(--white); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm); cursor: pointer; border: 1.5px solid transparent; transition: border-color .18s; }
.past-item:hover { border-color: var(--terra); }
.past-item-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.past-item-icon { width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; background: var(--cream-mid); }
.past-item-meta { flex: 1; }
.past-item-title { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--brown); line-height: 1.2; }
.past-item-dates { font-size: 11px; font-weight: 600; color: var(--sand-dark); margin-top: 3px; }
.past-item-prize-tag { font-size: 10px; font-weight: 800; color: var(--gold); background: var(--gold-pale); border-radius: var(--radius-pill); padding: 4px 10px; white-space: nowrap; flex-shrink: 0; border: 1px solid var(--gold-light); }

/* Vincitore */
.past-winner { display: flex; align-items: center; gap: 10px; background: var(--cream); border-radius: var(--radius-md); padding: 10px 12px; }
.past-winner-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--terra); color: white; font-family: var(--font-display); font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.past-winner-label { font-size: 11px; font-weight: 700; color: var(--sand-dark); }
.past-winner-name  { font-size: 13px; font-weight: 800; color: var(--brown); }
.past-winner-score { font-size: 12px; font-weight: 700; color: var(--terra); margin-left: auto; flex-shrink: 0; }
.trophy-icon { font-size: 16px; flex-shrink: 0; }

/* ── MODALE DETTAGLIO SFIDA ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(61,43,31,.52); z-index: 600; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 480px; overflow: hidden; box-shadow: var(--shadow-lg); animation: fadeUp .25s ease; max-height: 90vh; overflow-y: auto; }
.modal-head { padding: 22px 22px 0; display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--brown); }
.modal-close { width: 34px; height: 34px; border-radius: 50%; background: var(--cream); display: flex; align-items: center; justify-content: center; color: var(--brown-mid); font-size: 18px; transition: background .15s; flex-shrink: 0; cursor: pointer; border: none; }
.modal-close:hover { background: var(--cream-mid); }
.modal-body { padding: 18px 22px 26px; display: flex; flex-direction: column; gap: 14px; }
.modal-section-title { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--sand-dark); margin-bottom: 6px; }
.modal-detail-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--cream-mid); }
.modal-detail-row:last-child { border-bottom: none; }
.modal-detail-icon { font-size: 18px; width: 28px; text-align: center; flex-shrink: 0; }
.modal-detail-label { font-size: 12px; font-weight: 600; color: var(--sand-dark); }
.modal-detail-val { font-size: 13px; font-weight: 700; color: var(--brown); margin-top: 1px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── ARENA SIDEBAR INTERNA ── */
/* Su mobile è nascosta, viene mostrata solo su desktop tramite media query
   (sostituisce il workaround JS checkDesktop dell'originale) */
.arena-sidebar { display: none; }
.arena-sidebar-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.arena-sidebar-head { padding: 16px 18px; border-bottom: 1px solid var(--cream-mid); font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--brown); }
.arena-sidebar-body { padding: 14px 18px 18px; }
.stats-row { display: flex; gap: 8px; margin-bottom: 12px; }
.stat-mini { flex: 1; background: var(--cream); border-radius: var(--radius-sm); padding: 12px 8px; text-align: center; }
.stat-mini-val { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--terra); }
.stat-mini-lbl { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; color: var(--sand-dark); margin-top: 2px; }
.rule-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--cream-mid); font-size: 13px; }
.rule-item:last-child { border-bottom: none; }
.rule-num { font-weight: 800; color: var(--terra); flex-shrink: 0; width: 18px; }
.rule-text { color: var(--brown-mid); font-weight: 500; line-height: 1.4; }

/* ══ DESKTOP ══ */
@media (min-width: 768px) {
  .arena-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: start;
    padding: 28px;
    max-width: 1080px;
    margin: 0 auto;
  }
  .arena-main { min-width: 0; padding-bottom: 32px; }

  /* Hero desktop */
  .challenge-hero { border-radius: var(--radius-lg); }
  .challenge-title { font-size: 30px; }
  .challenge-cta { padding: 13px; }

  /* Podio desktop più grande */
  .podium-avatar { width: 54px; height: 54px; font-size: 20px; }

  /* Sezioni senza padding extra (lo dà arena-layout) */
  .section-wrap { padding: 0; }
  .past-list { gap: 12px; }

  /* Arena sidebar interna visibile su desktop */
  .arena-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 0;
  }
}
