/* ============================================================
   modal.css  -  Spelling challenge modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(74, 48, 72, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 32px 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(74, 48, 72, 0.3);
  position: relative;
  animation: modal-pop 0.35s ease;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--pink-dark);
}

/* ---------- Spelling content ---------- */
.spell-word-display {
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--purple-dark);
  margin: 16px 0 8px;
  letter-spacing: 3px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spell-instruction {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.spell-input-wrap {
  margin: 20px 0;
}

.spell-input {
  font-family: 'Quicksand', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: 2px;
  width: 100%;
  padding: 12px 16px;
  border: 3px solid var(--pink-light);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text);
  transition: border-color var(--transition);
}

.spell-input:focus {
  border-color: var(--pink);
}

.spell-input.error {
  border-color: #FF6B6B;
  animation: shake 0.5s ease;
}

.spell-input.success {
  border-color: var(--mint-dark);
}

.spell-feedback {
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 28px;
  margin: 8px 0;
}

.spell-feedback.error {
  color: #FF6B6B;
}

.spell-feedback.success {
  color: var(--mint-dark);
}

.spell-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}

.spell-item-preview {
  font-size: 3rem;
  margin-bottom: 4px;
}

.spell-attempts {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 12px;
}

.spell-attempts .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--pink-light);
  transition: background var(--transition);
}

.spell-attempts .dot.used {
  background: #FF6B6B;
}

.spell-reveal {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--purple-dark);
  letter-spacing: 2px;
  margin: 12px 0;
}

/* ---------- Math problem ---------- */
.math-problem {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--purple-dark);
  margin: 16px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.math-instruction {
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 600;
  width: 100%;
  margin-bottom: 8px;
}

.math-problem .math-op {
  color: var(--pink-dark);
}

/* Wide enough for a 3-digit answer (825, 202) without clipping */
.math-problem .math-blank {
  width: 88px;
  font-size: 2rem;
  text-align: center;
  border: 3px dashed var(--pink);
  border-radius: var(--radius-sm);
  padding: 4px;
  background: var(--pink-light);
  font-weight: 700;
  color: var(--purple-dark);
  font-family: 'Quicksand', sans-serif;
}

.math-problem .math-blank:focus {
  border-color: var(--purple);
  border-style: solid;
  outline: none;
}

.math-problem .math-blank.error {
  border-color: #FF6B6B;
  animation: shake 0.5s ease;
}

.math-problem .math-blank.success {
  border-color: var(--mint-dark);
  background: #E8F8F0;
}

/* ---------- Price track (stars paid for this item) ---------- */
.price-track {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 6px 0 2px;
  font-size: 1.3rem;
  line-height: 1;
}

.price-star {
  opacity: 0.45;
  filter: grayscale(1);
  transition: transform 0.2s ease;
}

.price-star.paid {
  opacity: 1;
  filter: none;
  transform: scale(1.15);
}

.price-track-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
  margin-left: 6px;
}

/* ---------- Word / unit text inside a math problem ---------- */
.math-problem .math-text {
  font-size: 1.4rem;
  color: var(--purple-dark);
  line-height: 1.3;
}

/* "7 hundreds" stays on one line */
.math-problem .math-unit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* ---------- Multiple choice answers ---------- */
.math-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 4px;
}

.math-choice {
  font-family: 'Quicksand', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--purple-dark);
  background: var(--pink-light);
  border: 3px solid var(--pink);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.math-choice:hover:not(:disabled) {
  transform: translateY(-2px);
  background: #fff;
}

.math-choice:disabled {
  cursor: default;
  opacity: 0.55;
}

.math-choice.error {
  border-color: #FF6B6B;
  background: #FFECEC;
  animation: shake 0.5s ease;
  opacity: 1;
}

.math-choice.success {
  border-color: var(--mint-dark);
  background: #E8F8F0;
  opacity: 1;
}

/* ---------- Animations ---------- */
@keyframes modal-pop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* ---------- Confirm remove modal ---------- */
.confirm-remove-name { font-size: 1.1rem; font-weight: 700; color: var(--purple-dark); margin-bottom: 8px; }
.confirm-remove-text { font-size: 1.1rem; color: var(--text-light); margin-bottom: 20px; }
.confirm-remove-actions { display: flex; gap: 16px; justify-content: center; }
.confirm-remove-actions .btn { min-width: 100px; font-size: 1.1rem; padding: 10px 24px; }

/* ---------- Trash animation ---------- */
.trash-animation {
  position: relative;
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 12px;
  overflow: hidden;
}

.trash-item-float {
  font-size: 2.5rem;
  animation: item-to-trash 1.8s ease-in-out infinite;
  position: absolute;
  top: 0;
}

.trash-item-float svg {
  width: 60px;
  height: 60px;
}

.trash-can {
  font-size: 3rem;
  position: relative;
  z-index: 2;
}

@keyframes item-to-trash {
  0% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
  50% { transform: translateY(50px) scale(0.7) rotate(15deg); opacity: 0.8; }
  75% { transform: translateY(65px) scale(0.3) rotate(25deg); opacity: 0.4; }
  85% { transform: translateY(68px) scale(0.1); opacity: 0; }
  86%, 100% { transform: translateY(0) scale(0); opacity: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .modal {
    padding: 24px 18px;
  }
  .spell-word-display {
    font-size: 2rem;
  }
  .spell-input {
    font-size: 1.2rem;
  }
}

/* ---------- Grade 2 bank: write in words ---------- */
.bank-text-wrap {
  margin: 8px 0 4px;
}

.bank-text-input {
  width: 100%;
  box-sizing: border-box;
  font-family: 'Quicksand', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  color: var(--purple-dark);
  background: var(--pink-light);
  border: 3px dashed var(--pink);
  border-radius: var(--radius-sm);
  padding: 10px 8px;
}

.bank-text-input:focus {
  border-color: var(--purple);
  border-style: solid;
  outline: none;
}

.bank-text-input.error {
  border-color: #FF6B6B;
  animation: shake 0.5s ease;
}

/* ---------- Grade 2 bank: one box per place ---------- */
.bank-multi {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.bank-multi-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
}

.bank-multi-input {
  width: 76px;
  font-family: 'Quicksand', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  color: var(--purple-dark);
  background: var(--pink-light);
  border: 3px dashed var(--pink);
  border-radius: var(--radius-sm);
  padding: 6px 2px;
}

.bank-multi-input:focus {
  border-color: var(--purple);
  border-style: solid;
  outline: none;
}

.bank-multi-input.error {
  border-color: #FF6B6B;
  animation: shake 0.5s ease;
}

.bank-multi-plus {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--pink-dark);
  padding-top: 8px;
}

/* ---------- Grade 2 bank: ordering cards ---------- */
.bank-order {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}

.bank-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
}

/* While two cards trade places nothing responds to a tap, so a second
   press cannot land in the middle of the movement */
.bank-order.swapping {
  pointer-events: none;
}

.bank-order.swapping .bank-move {
  opacity: 0.3;
}

/* The travelling cards ride above the rest and lift slightly, so the
   swap reads as two cards passing each other */
.bank-card.swapping {
  z-index: 3;
}

.bank-card.swapping .bank-card-num {
  border-color: var(--purple);
  box-shadow: 0 6px 14px rgba(74, 48, 72, 0.22);
}

.bank-card-num {
  font-family: 'Quicksand', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--purple-dark);
  background: #fff;
  border: 3px solid var(--pink);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  min-width: 58px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.bank-card-num:hover {
  transform: translateY(-2px);
}

.bank-card.picked .bank-card-num {
  background: var(--yellow, #FFD93D);
  border-color: var(--purple);
  transform: translateY(-4px);
}

.bank-card-moves {
  display: flex;
  gap: 3px;
}

.bank-move {
  font-size: 0.75rem;
  line-height: 1;
  color: var(--purple-dark);
  background: var(--pink-light);
  border: 2px solid var(--pink);
  border-radius: 6px;
  padding: 4px 7px;
  cursor: pointer;
}

.bank-move:disabled {
  opacity: 0.3;
  cursor: default;
}

.bank-order-help {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 4px;
}

/* Hint text reads as guidance, not as an error */
.spell-feedback.hint {
  color: var(--purple-dark);
}
