/* multiply-divide.css — Little Big Math: Multiplication, Division & Remainders */

/* Topic groups layout */
.md-groups {
  grid-template-columns: 1.15fr 1.15fr .7fr;
  gap: 16px;
  margin-bottom: 26px;
}
@media (max-width: 980px) {
  .md-groups {
    grid-template-columns: 1fr;
  }
}

/* Story visual container */
.story-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 0 18px;
  min-height: 80px;
}

/* ---------- 1. Break-Apart Array Visuals ---------- */
.split-array-wrap {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.array-dimension-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  padding: 0 10px;
}
.part-left-label {
  color: #275239;
}
.part-right-label {
  color: #9c4f24;
}
.array-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 230px;
  border-radius: 12px;
  background: #ffffff99;
  border: 1px solid #d9dfcd;
}
.array-cell-left {
  fill: #d2e7c5;
  stroke: #adc99d;
  stroke-width: 1;
}
.array-cell-right {
  fill: #fae0cf;
  stroke: #e2b69e;
  stroke-width: 1;
}
.array-cell-neutral {
  fill: #dce8e0;
  stroke: #b3c9bc;
  stroke-width: 1;
}
.array-cut-line {
  stroke: #df6d38;
  stroke-width: 2.5;
  stroke-dasharray: 4 3;
}
.array-text {
  font-family: Manrope, system-ui, sans-serif;
  font-weight: 800;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* ---------- 2. Area Box Model (2-Digit × 2-Digit) ---------- */
.box-model-wrap {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.box-grid {
  display: grid;
  grid-template-columns: 56px 1fr 1fr;
  grid-template-rows: auto 1fr 1fr;
  gap: 8px;
  align-items: stretch;
}
.box-corner-spacer {
  background: transparent;
}
.box-header-col {
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  color: #2e4a3b;
  padding: 6px 0;
  background: #eef2e7;
  border-radius: 8px;
  border: 1px solid #d4dec9;
}
.box-header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #2e4a3b;
  background: #eef2e7;
  border-radius: 8px;
  border: 1px solid #d4dec9;
  padding: 0 4px;
}
.box-room {
  border-radius: 12px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 68px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.room-p1 {
  background: #e1eed8;
  border: 1.5px solid #9fc190;
}
.room-p2, .room-p3 {
  background: #fbf3d8;
  border: 1.5px solid #dec88f;
}
.room-p4 {
  background: #fae4d5;
  border: 1.5px solid #e1ab91;
}
.room-calc {
  font-size: 11px;
  color: #55675b;
  margin-bottom: 2px;
}
.room-val {
  font-size: 18px;
  font-weight: 800;
  color: #1f372c;
  font-family: Manrope, system-ui, sans-serif;
}
.box-room.glow-room {
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(49, 91, 72, 0.2);
  border-width: 2.5px;
}
.box-add-stack {
  margin-top: 12px;
  padding: 10px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #d9dfcd;
  font-size: 13px;
  text-align: center;
  font-weight: 700;
}

/* ---------- 3. Division with Remainders Visuals ---------- */
/* Variant A: Boats */
.boats-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.boats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.boat-card {
  background: #fff;
  border: 1.5px solid #bed2b8;
  border-radius: 12px;
  padding: 8px 10px;
  min-width: 90px;
  text-align: center;
}
.boat-card.boat-extra {
  background: #fff8ee;
  border: 2px dashed #e2a249;
}
.boat-card.boat-extra .boat-title {
  color: #9e5b0e;
}
.boat-title {
  font-size: 11px;
  font-weight: 700;
  color: #3b5847;
  margin-bottom: 6px;
}
.boat-passengers {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  align-items: center;
}
.camper-token {
  font-size: 18px;
  line-height: 1;
}
.empty-seat {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px dashed #c8d3c1;
  display: grid;
  place-items: center;
  font-size: 9px;
  color: #8fa08b;
  font-weight: 700;
}

/* Variant B: Ribbons */
.ribbon-wrap {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ribbon-bar {
  display: flex;
  height: 42px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid #8cae7d;
  background: #fff;
}
.ribbon-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-weight: 700;
  font-size: 12px;
  background: #d4e7cb;
  border-right: 2px dashed #82a871;
  min-width: 0;
  padding: 0 4px;
}
.ribbon-segment:last-child {
  border-right: none;
}
.ribbon-leftover {
  background: #fae0cf;
  color: #924722;
  border-right: none;
}
.ribbon-legend {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

/* Variant C: Max Remainder Scale */
.rem-rule-wrap {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #d9dfcd;
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.rem-equation-badge {
  font-size: 16px;
  font-weight: 800;
  color: #244133;
}
.rem-equation-badge span {
  padding: 2px 7px;
  border-radius: 6px;
  background: #edf2e5;
  border: 1px solid #c8d6bf;
}
.rem-scale-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}
.rem-scale-item {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #cad4c0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: #f7f9f3;
  color: #3b5042;
}
.rem-scale-item.max-rem {
  background: #f0cd65;
  border-color: #be9c30;
  color: #49390a;
  transform: scale(1.14);
  box-shadow: 0 2px 8px rgba(240, 205, 101, 0.45);
}
.rem-scale-item.too-big {
  background: #fce8e6;
  border-color: #e29f98;
  color: #963f35;
  opacity: 0.55;
  text-decoration: line-through;
}
.rem-rule-text {
  font-size: 12px;
  line-height: 1.5;
  color: #455a4b;
}

/* ---------- 4. Cycles & Repeating Patterns ---------- */
.cycle-model-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 440px;
  margin: 0 auto;
}
.cycle-stamp-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff;
  border: 1.5px solid #d4dec9;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
}
.cycle-stamp-items {
  display: flex;
  gap: 6px;
  font-size: 20px;
}
.cycle-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
}
.cycle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: #fff;
  border: 1px solid #dbe2d2;
  border-radius: 10px;
}
.cycle-row-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  width: 60px;
  flex-shrink: 0;
}
.cycle-row-cells {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.cycle-cell {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: #f5f8f1;
  border: 1px solid #d4dfcc;
}
.cycle-cell.target {
  background: #fdf1cd;
  border: 1.5px solid #e0ba46;
  box-shadow: 0 0 0 2px rgba(240, 205, 101, 0.4);
}
.cycle-row.cycle-leftovers {
  background: #fff9ed;
  border: 1.5px dashed #df9e38;
}
.cycle-summary-chip {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #3b5042;
  padding: 6px;
  background: #edf2e5;
  border-radius: 8px;
}

/* ---------- 5. Cryptarithm (Vertical Math 竖式) ---------- */
.vm-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}
.vm-card {
  background: #fff;
  border: 1px solid #d9dfcd;
  border-radius: 16px;
  padding: 16px 24px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}
.vm-grid {
  display: grid;
  grid-template-columns: 28px repeat(var(--vm-cols, 3), 36px);
  gap: 4px;
  align-items: center;
  justify-items: center;
}
.vm-carry-cell {
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vm-carry-dot {
  font-size: 11px;
  font-weight: 800;
  color: #b0542c;
  background: #fce7dc;
  border-radius: 50%;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 1px solid #e2a688;
}
.vm-cell {
  width: 36px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  font-family: Manrope, monospace, sans-serif;
  color: #233a30;
}
.vm-op {
  font-size: 22px;
  font-weight: 800;
  color: #556c5c;
}
.vm-divider {
  grid-column: 1 / -1;
  width: 100%;
  height: 3px;
  background: #263f37;
  border-radius: 2px;
  margin: 4px 0;
}
.mystery-star {
  background: #fef2d0;
  color: #a4670c;
  border: 2px solid #e2b245;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 19px;
  box-shadow: 0 2px 6px rgba(226, 178, 69, 0.25);
}
.mystery-tri {
  background: #ddead9;
  color: #215438;
  border: 2px solid #6b9e78;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 19px;
  box-shadow: 0 2px 6px rgba(107, 158, 120, 0.25);
}
.vm-solved {
  background: #eaf3e4;
  color: #256037;
  border: 2px solid #82b67f;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
}

/* Responsive tweaks */
@media (max-width: 640px) {
  .box-grid {
    grid-template-columns: 46px 1fr 1fr;
    gap: 6px;
  }
  .box-header-col, .box-header-row {
    font-size: 13px;
  }
  .room-val {
    font-size: 16px;
  }
  .vm-cell {
    font-size: 20px;
    width: 30px;
    height: 34px;
  }
  .vm-grid {
    grid-template-columns: 24px repeat(var(--vm-cols, 3), 30px);
  }
}
