/* ============================================================
   practice.css — 孩子練習畫面
   一次一題、大字、進度點、回饋泡泡、吉祥物、回合結算星星。
   所有操作目標 ≥56px（--tp-touch-kid）。
   ============================================================ */

.tp-practice {
  max-width: 40rem;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--tp-space-5);
}

/* 頂列：回合資訊＋分數（靠左成組；右側留給舞台上方探頭的吉祥物） */
.tp-practice__topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: var(--tp-space-3);
}

.tp-practice__round {
  font-size: var(--tp-fs-small);
  font-weight: var(--tp-fw-medium);
  color: var(--tp-ink-soft);
}

.tp-practice__score {
  font-family: var(--tp-font-serif);
  font-weight: var(--tp-fw-black);
  font-size: var(--tp-fs-h4);
  color: var(--tp-cinnabar-dark);
  font-variant-numeric: tabular-nums;
}

/* 進度點 */
.tp-progress-dots {
  display: flex;
  justify-content: center;
  gap: var(--tp-space-2);
  flex-wrap: wrap;
}

.tp-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--tp-paper-deep);
  border: 1.5px solid var(--tp-line);
  transition: all var(--tp-time-fast) var(--tp-ease-out);
}

.tp-dot--done { background: var(--tp-sage); border-color: var(--tp-sage-deep); }
.tp-dot--current {
  background: var(--tp-cinnabar);
  border-color: var(--tp-cinnabar-dark);
  transform: scale(1.3);
  box-shadow: 0 0 0 4px var(--tp-cinnabar-soft);
}

/* 題目舞台（一次一題） */
.tp-practice__stage {
  position: relative;
  background: var(--tp-surface);
  border: 1px solid var(--tp-line);
  border-radius: var(--tp-radius-xl);
  box-shadow: var(--tp-shadow-2);
  padding: var(--tp-space-10) var(--tp-space-5) var(--tp-space-8);
  text-align: center;
  overflow: visible;
}

@media (min-width: 640px) {
  .tp-practice__stage {
    padding: var(--tp-space-12) var(--tp-space-10) var(--tp-space-10);
  }
}

/* 題目文字（大字） */
.tp-question {
  font-family: var(--tp-font-kai);
  font-weight: var(--tp-fw-bold);
  font-size: clamp(2rem, 1.4rem + 3vw, 3rem);
  line-height: 1.5;
  color: var(--tp-ink);
}

.tp-question .tpz-wrap {
  margin-inline: 0.12em;
}

/* 手機：題目與直式計算（vcalc／longdiv）等比縮小，多位數直式不溢出 */
@media (max-width: 480px) {
  .tp-question { font-size: clamp(1.5rem, 1.2rem + 1.8vw, 2rem); }
  .tp-question .tp-mk-vcalc,
  .tp-question .tp-mk-longdiv { font-size: 0.95em; --tp-mk-cell: 1.15em; }
}

.tp-question__hint {
  margin-top: var(--tp-space-3);
  font-size: var(--tp-fs-small);
  color: var(--tp-ink-faint);
}

/* 選項按鈕（三選一、四選一等） */
.tp-options {
  display: grid;
  gap: var(--tp-space-3);
  margin-top: var(--tp-space-6);
}

.tp-options--2 { grid-template-columns: repeat(2, 1fr); }
.tp-options--3 { grid-template-columns: repeat(3, 1fr); }
.tp-options--4 { grid-template-columns: repeat(2, 1fr); }

@media (min-width: 480px) {
  .tp-options--4 { grid-template-columns: repeat(4, 1fr); }
}

.tp-option {
  min-height: var(--tp-touch-kid);
  padding: var(--tp-space-3) var(--tp-space-4);
  border-radius: var(--tp-radius-l);
  background: var(--tp-paper);
  border: 2px solid var(--tp-line);
  font-family: var(--tp-font-kai);
  font-size: 1.5rem;
  font-weight: var(--tp-fw-bold);
  color: var(--tp-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--tp-space-2);
  transition: all var(--tp-time-fast) var(--tp-ease-out);
  -webkit-tap-highlight-color: transparent;
}

.tp-option:hover {
  border-color: var(--tp-amber);
  background: var(--tp-amber-soft);
}

.tp-option:active { transform: scale(0.97); }

.tp-option--correct {
  background: var(--tp-sage-soft);
  border-color: var(--tp-sage-deep);
  color: var(--tp-sage-deep);
}

.tp-option--wrong {
  background: var(--tp-cinnabar-soft);
  border-color: var(--tp-cinnabar-dark);
  color: var(--tp-cinnabar-dark);
  animation: tp-shake 350ms var(--tp-ease-in-out);
}

@keyframes tp-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 作答輸入（數學填空） */
.tp-answer-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--tp-space-3);
  margin-top: var(--tp-space-6);
  flex-wrap: wrap;
}

.tp-answer-input {
  width: 5.5ch;
  min-height: var(--tp-touch-kid);
  text-align: center;
  font-family: var(--tp-font-kai);
  font-size: 1.75rem;
  font-weight: var(--tp-fw-bold);
  color: var(--tp-ink);
  background: var(--tp-paper);
  border: 2px solid var(--tp-ink-soft);
  border-radius: var(--tp-radius-m);
}

.tp-answer-input:focus {
  outline: none;
  border-color: var(--tp-cinnabar);
  box-shadow: 0 0 0 3px var(--tp-focus-ring-soft);
}

/* 回饋泡泡（對話框尾巴朝舞台） */
.tp-feedback {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 6px);
  transform: translateX(-50%) translateY(4px);
  display: flex;
  align-items: center;
  gap: var(--tp-space-2);
  padding: var(--tp-space-2) var(--tp-space-4);
  border-radius: var(--tp-radius-l);
  font-size: var(--tp-fs-body);
  font-weight: var(--tp-fw-bold);
  white-space: nowrap;
  box-shadow: var(--tp-shadow-2);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--tp-time-fast) var(--tp-ease-out),
              transform var(--tp-time-fast) var(--tp-ease-spring);
  z-index: 2;
}

/* 尾巴 */
.tp-feedback::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
}

.tp-feedback--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tp-feedback--good { background: var(--tp-sage-deep); color: var(--tp-paper); }
.tp-feedback--good::after { border-top-color: var(--tp-sage-deep); }

.tp-feedback--retry { background: var(--tp-amber-deep); color: var(--tp-paper); }
.tp-feedback--retry::after { border-top-color: var(--tp-amber-deep); }

/* 舞台角落的吉祥物 */
.tp-practice__mascot {
  position: absolute;
  right: var(--tp-space-3);
  bottom: calc(100% - 12px);
  width: 84px;
  pointer-events: none;
  transform-origin: bottom center;
  animation: tp-bounce 2.6s ease-in-out infinite;
}

.tp-practice__mascot--left {
  right: auto;
  left: var(--tp-space-3);
}

@keyframes tp-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

/* 底部操作列 */
.tp-practice__actions {
  display: flex;
  justify-content: center;
  gap: var(--tp-space-3);
  flex-wrap: wrap;
}

/* 回合結算 */
.tp-result {
  position: fixed;
  inset: 0;
  z-index: var(--tp-z-dialog);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--tp-space-4);
  background: rgba(59, 53, 44, 0.45);
}

.tp-result--show {
  display: flex;
}

.tp-result__card {
  background: var(--tp-paper);
  border: 1px solid var(--tp-line);
  border-radius: var(--tp-radius-xl);
  box-shadow: var(--tp-shadow-pop);
  padding: var(--tp-space-8) var(--tp-space-6);
  text-align: center;
  max-width: 22rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--tp-space-3);
  animation: tp-dialog-in var(--tp-time-base) var(--tp-ease-spring);
}

.tp-result__mascot {
  width: 110px;
  margin-bottom: var(--tp-space-1);
}

.tp-result__title {
  font-family: var(--tp-font-serif);
  font-weight: var(--tp-fw-black);
  font-size: var(--tp-fs-h2);
}

.tp-result__stats {
  font-size: var(--tp-fs-small);
  color: var(--tp-ink-soft);
}

.tp-result__actions {
  margin-top: var(--tp-space-3);
  display: flex;
  gap: var(--tp-space-3);
  flex-wrap: wrap;
  justify-content: center;
}
