/* ===== Unisci e cresci =====
   Regola del progetto: dentro il gioco NON si scorre mai. Solo CSS che i Chrome vecchi conoscono. */

.an { height: 100%; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 6px; overflow: hidden; }

.an-header { position: relative; z-index: 30; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.an-centro { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; }
.an-punti { background: #d0ebff; }
.an-livello { background: #e5dbff; }
.an-su { font-size: .75em; opacity: .7; font-weight: bold; margin-left: 1px; }

/* la tavola 4x4: un quadrato centrato, grande quanto lo spazio permette (misurato dal gioco) */
.an-arena { position: relative; min-height: 0; border-radius: var(--raggio); overflow: hidden; box-shadow: var(--ombra); background: #fff5fb; display: flex; align-items: center; justify-content: center; }
.an-tavola { position: relative; background: #c9a7ff; border-radius: 16px; touch-action: none; }
/* sfondo: 16 celle vuote in griglia */
.an-sfondo { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: 6px; padding: 6px; box-sizing: border-box; }
.an-cella { border-radius: 12px; background: rgba(255,255,255,.45); }
/* tessere: posizionate con transform, così scivolano quando si muovono */
.an-tessere { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.an-tessera { position: absolute; left: 0; top: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; line-height: 1; user-select: none; box-shadow: inset 0 -4px 0 rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.1); transition: transform .15s ease-out; z-index: 1; will-change: transform; }
.an-dentro { display: block; line-height: 1; }
.an-tessera.nuova .an-dentro { animation: anNuova .2s ease-out both; }
.an-tessera.unita { z-index: 2; animation: anBagliore .35s ease-out; }
.an-tessera.unita .an-dentro { animation: anUnita .3s ease-out both; }
@keyframes anNuova { from { transform: scale(.2); } to { transform: scale(1); } }
@keyframes anUnita { 0% { transform: scale(.8); } 50% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes anBagliore { 0% { box-shadow: 0 0 0 0 rgba(255,210,63,.95); } 100% { box-shadow: 0 0 0 14px rgba(255,210,63,0); } }
/* scelta del modo: a livelli o classico */
.an-modi { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
.an-modo { padding: 8px 4px; cursor: pointer; font: inherit; font-weight: 900; font-size: .85rem; color: var(--testo); }
.an-punteggio { font-size: clamp(1.6rem, 8vmin, 2.8rem); font-weight: 900; color: var(--ttitolo); }
.an-punti { background: #fff3bf; }
/* scelta del tema: numeri, animali, frutta, gioielli */
.an-temi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; width: 100%; }
.an-tema { min-width: 0; padding: 4px 2px; cursor: pointer; font: inherit; color: var(--testo); display: flex; flex-direction: column; align-items: center; gap: 1px; }
.an-tema-e { font-size: clamp(1.3rem, 5vmin, 1.9rem); line-height: 1.1; }
.an-tema-n { font-size: .66rem; font-weight: bold; letter-spacing: 0; }
/* numeri lunghi: più piccoli per stare nella tessera */
.an-dentro.num3 { font-size: .72em; font-weight: 900; }
.an-dentro.num4 { font-size: .55em; font-weight: 900; }
.an-dentro.num1, .an-dentro.num2 { font-weight: 900; }
.an-catena { font-size: clamp(1rem, 4vmin, 1.5rem); letter-spacing: 1px; }
.an-meta b { font-size: 1.2em; }

.an-overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 5; display: flex; align-items: center; justify-content: center; background: rgba(255, 245, 251, .82); padding: 8px; }
.an-overlay[hidden] { display: none; }
.an-card { background: #fff; border-radius: 26px; padding: 14px 18px; width: min(420px, 100%); max-height: 100%; overflow: hidden; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.an-big { font-size: clamp(2.2rem, 10vmin, 4rem); line-height: 1.1; }
.an-h2 { font-size: clamp(1.1rem, 4.5vmin, 1.7rem); font-weight: 900; color: var(--ttitolo); }
.an-p { margin: 0; font-size: clamp(.8rem, 3vmin, 1rem); font-weight: bold; opacity: .85; }
.an-punteggio { font-size: clamp(1.6rem, 8vmin, 2.8rem); font-weight: 900; color: var(--verde); }
.an-record { background: var(--sfondo); border-radius: 999px; padding: 4px 14px; font-weight: bold; }
/* scelta del personaggio: i bloccati mostrano il prezzo in stelline */
.an-armi { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; width: 100%; }
.an-start { font-size: 1.2rem; padding: 12px 28px; }

/* tablet piccolo (1024x600): finestra un po' più compatta */
@media (max-height: 640px) { .an-card { padding: 8px 14px; gap: 4px; } .an-start { padding: 9px 24px; } }
@media (max-height: 520px) {
  .an-card { padding: 8px 12px; gap: 3px; border-width: 4px; }
  .an-p { display: none; }
  .an-tema-n { display: none; }
  .an-modo { padding: 4px; font-size: .75rem; }
  .an-start { font-size: 1rem; padding: 8px 20px; }
  .an-big { font-size: 1.7rem; line-height: 1; }
}

.an-riprova[hidden] { display: none; }
