/* ================= Timeline Logic Sequences ================= */
.timeline-slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.timeline-card {
  background: #ffffff;
  border: 3px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 20px 14px;
  text-align: center;
  box-shadow: var(--shadow-card);
  cursor: grab;
  transition: all 0.2s;
}

.timeline-card.correct {
  border-color: #22c55e;
  background: #f0fdf4;
}

.timeline-emoji {
  font-size: 3rem;
  margin-bottom: 8px;
}


/* ==========================================================================
   ISOLA DELLA LOGICA: PATTERNS, CESTE & SEQUENZE DRAG & DROP
   ========================================================================== */

/* ==========================================================================
   ISOLA DELLA LOGICA: PATTERNS, CESTE & SEQUENZE DRAG & DROP (COMPACT NO-SCROLL)
   ========================================================================== */

.logic-header-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.logic-mode-tab-btn {
  padding: 6px 12px;
  font-size: 0.88rem;
  border-radius: 50px;
  white-space: nowrap;
}

.logic-stage-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow-card);
  max-width: 850px;
  margin: 0 auto;
}

.logic-stage-header {
  text-align: center;
  margin-bottom: 10px;
}

.logic-stage-title {
  font-size: 1.25rem;
  color: #1e293b;
  margin: 0 0 2px 0;
  font-weight: 900;
}

.logic-stage-instructions {
  font-size: 0.92rem;
  color: #64748b;
  font-weight: 700;
  margin: 0;
}

.logic-level-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 8px;
}

.logic-pill-btn {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 50px;
  padding: 3px 10px;
  font-size: 0.8rem;
  font-weight: 800;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}

.logic-pill-btn.active {
  background: #9333ea;
  color: #ffffff;
  border-color: #7e22ce;
  box-shadow: 0 2px 6px rgba(147, 51, 234, 0.3);
  transform: scale(1.03);
}

/* --- PATTERNS (SERIE E RITMI) --- */
.pattern-track-container {
  background: #faf5ff;
  border: 2px dashed #d8b4fe;
  border-radius: 16px;
  padding: 10px 12px;
  margin: 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pattern-arrow {
  font-size: 1.1rem;
  color: #a855f7;
  font-weight: 900;
  flex-shrink: 0;
  user-select: none;
}

.pattern-slot {
  background: #ffffff;
  border: 2px solid #e9d5ff;
  border-radius: 12px;
  padding: 6px 8px;
  min-width: 48px;
  max-width: 72px;
  flex: 1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  transition: transform 0.2s;
  user-select: none;
}

.pattern-slot-emoji {
  font-size: 1.8rem;
  line-height: 1;
}

.pattern-slot-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: #6b21a8;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58px;
  text-align: center;
}

.pattern-slot.missing-slot {
  background: #fefce8;
  border: 2px dashed #facc15;
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.35);
  animation: pulse-border 1.5s infinite;
  cursor: pointer;
  min-width: 54px;
}

.pattern-slot.missing-slot.drag-over {
  background: #fef08a;
  border-color: #ca8a04;
  transform: scale(1.08);
}

.pattern-slot.filled-correct {
  background: #f0fdf4;
  border: 2.5px solid #22c55e;
  animation: pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- DRAGGABLE TRAY / OPTIONS --- */
.logic-options-tray {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 8px 10px;
  margin-top: 10px;
  text-align: center;
}

.logic-tray-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 6px;
}

.logic-items-grid {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.logic-drag-card {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  touch-action: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  min-width: 54px;
}

.logic-drag-card:hover {
  transform: translateY(-2px) scale(1.03);
  border-color: #9333ea;
  box-shadow: 0 4px 10px rgba(147, 51, 234, 0.2);
}

.logic-drag-card:active, .logic-drag-card.dragging {
  cursor: grabbing;
  opacity: 0.4;
  transform: scale(0.95);
}

.logic-drag-card.selected-tap {
  border: 2.5px solid #9333ea;
  background: #faf5ff;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 0 10px rgba(147, 51, 234, 0.35);
}

.logic-card-emoji {
  font-size: 1.8rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logic-icon-img {
  width: 1.8rem;
  height: 1.8rem;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  vertical-align: middle;
  display: inline-block;
  pointer-events: none;
}

.sequence-target-slot .logic-icon-img {
  width: 1.5rem;
  height: 1.5rem;
}

.drag-floating-ghost .logic-icon-img {
  width: 2.6rem;
  height: 2.6rem;
}

.logic-card-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: #1e293b;
  margin-top: 3px;
  white-space: nowrap;
}

/* --- CESTE DI SMISTAMENTO (SORTING - COMPACT SIDE-BY-SIDE) --- */
.sorting-baskets-grid {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  width: 100%;
  justify-content: center;
}

.sorting-basket-card {
  background: #ffffff;
  border: 2.5px dashed #cbd5e1;
  border-radius: 16px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  flex: 1;
  min-width: 0;
  max-width: 280px;
  min-height: 110px;
  max-height: 135px;
  transition: all 0.2s;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.sorting-basket-card.drag-over {
  transform: scale(1.03);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.12);
  border-style: solid;
}

.basket-badge-counter {
  position: absolute;
  top: 4px;
  right: 6px;
  background: #ffffff;
  border: 1.5px solid currentColor;
  border-radius: 50px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 900;
}

.basket-header-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.basket-header-emoji {
  font-size: 1.3rem;
  line-height: 1;
}

.basket-title {
  font-size: 0.88rem;
  font-weight: 900;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.basket-desc {
  font-size: 0.65rem;
  color: #64748b;
  margin: 1px 0 3px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.basket-items-rack {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  flex: 1;
  width: 100%;
  padding: 3px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  min-height: 38px;
}

.basket-accepted-item {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  padding: 2px 4px;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop-in 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- SEQUENZE TEMPORALI (1 ROW OF 4 SLOTS) --- */
.sequence-slots-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 8px 0;
  width: 100%;
}

.sequence-target-slot {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 4px;
  min-height: 90px;
  max-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  transition: all 0.2s;
  box-sizing: border-box;
}

.sequence-target-slot.drag-over {
  background: #faf5ff;
  border-color: #9333ea;
  border-style: solid;
  transform: scale(1.03);
}

.slot-step-badge {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  font-weight: 900;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sequence-target-slot.filled .slot-step-badge {
  background: #9333ea;
  color: #ffffff;
}

.sequence-item-content {
  width: 100%;
  cursor: grab;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.sequence-tray-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
}

.sequence-tray-card {
  padding: 4px 2px !important;
  min-width: 0 !important;
  width: 100% !important;
}

/* Floating Drag Clone */
.drag-floating-ghost {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  background: #ffffff;
  border: 2.5px solid #9333ea;
  border-radius: 14px;
  padding: 6px 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%) scale(1.08);
  opacity: 0.95;
}

@keyframes pulse-border {
  0% { transform: scale(1); box-shadow: 0 0 4px rgba(250, 204, 21, 0.4); }
  50% { transform: scale(1.03); box-shadow: 0 0 12px rgba(250, 204, 21, 0.7); }
  100% { transform: scale(1); box-shadow: 0 0 4px rgba(250, 204, 21, 0.4); }
}

@keyframes pop-in {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .hero-clean-section { padding: 16px 12px 10px; min-height: auto; }
  .hero-cta-top { margin-top: 4px; margin-bottom: 16px; }
  .hero-title { font-size: 1.75rem; margin-bottom: 8px; }
  .hero-subtitle { font-size: 0.95rem; margin-bottom: 20px; padding: 0 6px; }
  .hero-guest-btn { font-size: 1.12rem; padding: 13px 26px; width: 100%; max-width: 320px; }
  .hero-floating-badge { font-size: 1.5rem; }
  .badge-pos-1 { top: 4%; left: 4%; }
  .badge-pos-2 { top: 6%; right: 4%; }
  .badge-pos-3 { bottom: 10%; left: 4%; }
  .badge-pos-4 { bottom: 8%; right: 4%; }
  .badge-pos-5, .badge-pos-6 { display: none; }

  .auth-modal { max-width: 330px; padding: 14px 14px 10px; border-radius: 16px; max-height: 88vh; }
  .auth-tabs { margin-bottom: 10px; padding: 3px; }
  .auth-tab { font-size: 0.88rem; padding: 5px 8px; }
  .form-group { margin-bottom: 7px; }
  .form-group label { font-size: 0.78rem; margin-bottom: 2px; }
  .form-control { padding: 6px 10px; font-size: 0.88rem; }
  .avatar-grid { gap: 4px; }
  .avatar-option { font-size: 1.3rem; padding: 2px 1px; }
  .antibot-box { padding: 6px 8px; margin-bottom: 8px; }
  .antibot-label { font-size: 0.78rem; }
  .antibot-input { max-width: 75px; padding: 4px 6px; font-size: 0.82rem; }
  .auth-submit-btn { font-size: 0.92rem; padding: 8px 12px; }
  .auth-cancel-link { margin-top: 6px; font-size: 0.76rem; }
  .seguin-board-view { grid-template-columns: 1fr; }
  .story-passage { font-size: 1.15rem; }
  .math-choice-btn { font-size: 1.4rem !important; }
  .math-emoji-item { font-size: 1.7rem; }
  
  .logic-stage-card { padding: 10px 8px; border-radius: 14px; }
  .logic-stage-title { font-size: 1.05rem; }
  .logic-stage-instructions { font-size: 0.8rem; }
  .logic-mode-tab-btn { padding: 4px 8px; font-size: 0.78rem; }
  .pattern-slot { min-width: 42px; padding: 4px; }
  .pattern-slot-emoji { font-size: 1.45rem; }
  .pattern-slot-label { font-size: 0.62rem; max-width: 44px; }
  .logic-drag-card { min-width: 46px; padding: 4px 6px; }
  .logic-card-emoji { font-size: 1.5rem; }
  .logic-card-label { font-size: 0.7rem; }
  .sorting-basket-card { min-height: 100px; max-height: 125px; padding: 4px; }
  .basket-desc { display: none; }
  .sequence-target-slot { min-height: 85px; max-height: 110px; padding: 3px; }
}

@media (max-width: 400px) {
  .hero-title { font-size: 1.52rem; }
  .hero-mascot-emblem { font-size: 3.2rem; }
  .hero-subtitle { font-size: 0.88rem; margin-bottom: 20px; }
}
