:root {
  --m3-border: rgba(15, 23, 42, 0.12);
}

.m3Card {
  width: min(860px, 100%);
}

.m3TopRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.m3Mode {
  display: flex;
  gap: 8px;
}

.m3ModeBtn {
  padding: 8px 10px;
  font-weight: 1100;
  border-radius: 999px;
}

.m3ModeBtn.isOn {
  border-color: rgba(37, 99, 235, 0.25);
  background: rgba(37, 99, 235, 0.10);
  color: rgba(37, 99, 235, 0.95);
}

.m3Hud {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.m3Stat {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.65);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.06);
}
.m3Label {
  font-size: 12px;
  font-weight: 1000;
  color: rgba(100, 116, 139, 0.95);
}
.m3Value {
  margin-top: 6px;
  font-size: 16px;
  font-weight: 1100;
}

.m3Stage {
  display: grid;
  place-items: center;
}

.m3Board {
  width: min(520px, 100%);
  aspect-ratio: 1 / 1;
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--m3-border);
  background: radial-gradient(circle at 12% 10%, rgba(59, 130, 246, 0.10), transparent 45%),
    radial-gradient(circle at 88% 12%, rgba(34, 197, 94, 0.08), transparent 45%),
    rgba(255, 255, 255, 0.55);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.08);
  /* 允许我们接管“滑动挪动”手势 */
  touch-action: none;
  user-select: none;
}

.m3Cell {
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  place-items: center;
  font-weight: 1200;
  font-size: 22px;
  color: rgba(15, 23, 42, 0.88);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
  overflow: hidden;
}

.m3Cell:hover {
  filter: brightness(1.02);
}

.m3Cell:active {
  transform: scale(0.98);
}

.m3Cell::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 12px;
  background: var(--m3-color, rgba(148, 163, 184, 0.45));
  opacity: 0.65;
}

.m3Cell > span {
  position: relative;
  z-index: 3;
}

.m3Cell.isSelected {
  outline: 3px solid rgba(37, 99, 235, 0.55);
  transform: scale(1.02);
}

.m3Cell.isHint {
  outline: 3px dashed rgba(34, 197, 94, 0.70);
}

.m3Cell.isHintTo {
  outline: 3px dashed rgba(34, 197, 94, 0.70);
}

.m3Cell.isHintFrom {
  outline: 3px solid rgba(34, 197, 94, 0.65);
}

.m3HintArrow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1; /* 不要挡住数字 */
}

.m3HintArrow::before {
  content: "";
  position: absolute;
  left: 82%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-right: 4px solid rgba(34, 197, 94, 0.95);
  border-bottom: 4px solid rgba(34, 197, 94, 0.95);
  transform: translate(-50%, -50%) rotate(-45deg);
  filter: drop-shadow(0 6px 10px rgba(2, 6, 23, 0.18));
}

.m3HintArrow.dir-L::before {
  left: 18%;
  transform: translate(-50%, -50%) rotate(135deg);
}
.m3HintArrow.dir-U::before {
  left: 50%;
  top: 18%;
  transform: translate(-50%, -50%) rotate(225deg);
}
.m3HintArrow.dir-D::before {
  left: 50%;
  top: 82%;
  transform: translate(-50%, -50%) rotate(45deg);
}

.m3HintArrow::after {
  content: "";
  position: absolute;
  left: 70%;
  top: 50%;
  width: 20px;
  height: 4px;
  background: rgba(34, 197, 94, 0.90);
  border-radius: 999px;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 10px rgba(2, 6, 23, 0.18));
}
.m3HintArrow.dir-L::after {
  left: 30%;
}
.m3HintArrow.dir-U::after,
.m3HintArrow.dir-D::after {
  left: 50%;
  width: 4px;
  height: 20px;
}
.m3HintArrow.dir-U::after {
  top: 30%;
}
.m3HintArrow.dir-D::after {
  top: 70%;
}

/* 题目高亮框（圈出那一组数字） */
.m3GroupBox {
  position: absolute;
  pointer-events: none;
  border-radius: 16px;
  border: 4px solid rgba(255, 122, 0, 0.95);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.14);
  opacity: 0;
  transform: scale(0.995);
  transition: opacity 120ms ease, transform 120ms ease;
}
.m3GroupBox.isOn {
  opacity: 1;
  transform: scale(1);
}

/* 算术题弹窗 */
.m3Quiz {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  padding: 18px;
}
.m3Quiz.isOn {
  display: grid;
}
.m3QuizBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
}
.m3QuizPanel {
  position: relative;
  width: min(520px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(2, 6, 23, 0.22);
  padding: 14px;
}
.m3QuizTitle {
  font-weight: 1100;
  font-size: 16px;
  margin-bottom: 8px;
}
.m3QuizExpr {
  font-size: 22px;
  font-weight: 1200;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 1);
  white-space: pre-wrap;
}
.m3QuizInputRow {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.m3QuizInputRow .restInput {
  font-weight: 1100;
  font-size: 16px;
}
.m3Picker {
  margin-top: 10px;
  display: none; /* 由 JS 控制：手机显示 */
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.m3Picker.isOn {
  display: grid;
}
.m3PickBtn {
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 10px 0;
  font-weight: 1100;
  font-size: 14px;
}
.m3QuizHint {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 900;
  color: rgba(100, 116, 139, 0.95);
}

.m3QuizPanel.isShake {
  animation: shake 220ms ease-in-out;
}
@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

.m3Cell.isPopping {
  animation: pop 220ms ease-in-out;
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  60% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

.m3Cell.isClearing {
  animation: vanish 200ms ease forwards;
}

@keyframes vanish {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  70% {
    transform: scale(1.12);
    opacity: 0.85;
  }
  100% {
    transform: scale(0.75);
    opacity: 0;
  }
}

.m3Controls {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.m3Foot {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

/* toast */
.modal#toast {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: start center;
  padding-top: 18px;
}
.toastPanel {
  pointer-events: none;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 40px rgba(2, 6, 23, 0.12);
  font-weight: 1100;
  color: rgba(15, 23, 42, 0.86);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.modal#toast.isOn .toastPanel {
  opacity: 1;
  transform: translateY(0);
}

.modal#toast.isBig .toastPanel {
  font-size: 22px;
  padding: 14px 18px;
  border-radius: 18px;
}

@media (max-width: 480px) {
  .m3Hud {
    grid-template-columns: repeat(3, 1fr);
  }
  .m3Board {
    gap: 6px;
    padding: 8px;
  }
  .m3Cell {
    border-radius: 12px;
    font-size: 20px;
  }
}

/* 结算大字 */
.m3End {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  place-items: center;
  padding: 18px;
}
.m3End.isOn {
  display: grid;
}
.m3EndBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.45);
}
.m3EndPanel {
  position: relative;
  width: min(520px, 100%);
  border-radius: 22px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(2, 6, 23, 0.22);
  padding: 16px;
  text-align: center;
}
.m3EndText {
  font-size: 82px;
  font-weight: 1200;
  letter-spacing: 6px;
  line-height: 1;
  margin: 8px 0 10px;
}
.m3EndText.isWin {
  background: linear-gradient(180deg, #fde68a, #f59e0b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 14px 40px rgba(245, 158, 11, 0.28);
}
.m3EndText.isLose {
  color: rgba(148, 163, 184, 0.95);
  text-shadow: 0 14px 40px rgba(2, 6, 23, 0.12);
}
.m3EndSub {
  font-size: 14px;
  font-weight: 1000;
  color: rgba(71, 85, 105, 0.95);
  margin-bottom: 14px;
}
.m3EndActions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
