/* 2-3 分數的四則運算 步步練共用樣式（版型同 2-2 步步練） */
body {
  font-family: 'Noto Sans TC', sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
}

.katex {
  font-size: 1.15em;
  white-space: nowrap !important;
}

/* 題目原式永不換行 + 動態自適應等比縮放 */
#q-math-display {
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
#q-math-display .q-line {
  width: 100%;
  display: flex;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
}
#q-math-display .katex {
  font-size: 1.9em !important;
  font-weight: 800;
  display: inline-block !important;
  transform-origin: center center;
  color: #f8fafc !important;
}

.slot {
  min-width: 48px;
  min-height: 40px;
  padding: 2px 10px;
  border: 2.5px solid #93c5fd;
  border-radius: 10px;
  background: #eff6ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #1d4ed8;
  cursor: pointer;
  font-size: 20px;
  font-weight: 800;
  transition: all 0.15s ease;
  user-select: none;
  vertical-align: middle;
}
.slot.active {
  animation: pulseSlot 1s infinite;
  background: #dbeafe;
  border-color: #2563eb;
}
.slot.correct {
  background: #dcfce7;
  border-color: #22c55e;
  color: #166534;
  cursor: default;
}
.slot.error {
  background: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}
@keyframes pulseSlot {
  0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.option-btn {
  transition: all 0.15s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.option-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

/* 題目看板：深色螢幕顯示題目，步驟星星顯示進度 */
.board {
  border-radius: 22px;
  padding: 14px;
  background: linear-gradient(145deg, #0ea5e9 0%, #0c4a6e 100%);
  border: 4px solid #0f172a;
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.25), 0 10px 20px -8px rgba(15, 23, 42, 0.5);
}
.board-screen {
  background: #0f172a;
  border: 3px solid #020617;
  border-radius: 14px;
  padding: 12px 10px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6);
}
.board-visual { width: 100%; }
.board-visual svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.star-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  background: rgba(15, 23, 42, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.35);
  color: #cbd5e1;
}
.star-icon.got {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
  animation: checkPop 0.35s ease-out;
}
.reward {
  display: none;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  color: #fff;
}
.reward.show { display: inline-flex; animation: checkPop 0.4s ease-out; }
.reward .reward-char {
  min-width: 40px;
  padding: 0 6px;
  height: 40px;
  border-radius: 10px;
  background: #fde68a;
  color: #92400e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.secret-char {
  min-width: 46px;
  padding: 0 6px;
  height: 46px;
  border-radius: 12px;
  border: 2px dashed #f59e0b;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  color: #92400e;
}
.secret-char.got {
  border-style: solid;
  background: #fde68a;
}

/* 輸入格：學生用數字鍵盤打出來的數字 */
.slot.typing { border-style: dashed; background: #fff7ed; border-color: #f97316; color: #9a3412; }

/* 頁面上的大按鍵數字鍵盤（平板不會被系統鍵盤遮住） */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 300px;
}
.keypad button {
  height: 52px;
  border-radius: 14px;
  font-size: 24px;
  font-weight: 900;
  background: #fff;
  border: 2px solid #cbd5e1;
  color: #1e293b;
  box-shadow: 0 3px 0 #cbd5e1;
  transition: transform 0.08s ease;
}
.keypad button:active { transform: translateY(2px); box-shadow: none; }
.keypad .key-del { background: #f1f5f9; font-size: 20px; }
.keypad .key-ok { background: #2563eb; border-color: #1d4ed8; color: #fff; box-shadow: 0 3px 0 #1e40af; }
.keypad .key-ok:disabled { background: #cbd5e1; border-color: #cbd5e1; box-shadow: none; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.shake { animation: shake 0.3s ease; }

@keyframes checkPop {
  0% { transform: scale(0); opacity: 0; }
  80% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* 分數選項與空格：直式分數比較高 */
.slot { min-height: 48px; }
.slot .katex, .option-btn .katex { font-size: 1em; }
.slot { min-height: 64px; }
.option-btn { min-height: 52px; }
.step-math .katex { font-size: 1.1em; }

/* 直式分數 {{分子|分母}}：分子、分母各自可以是空格 */
.hfrac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 2px; }
.hfrac > .hfrac-n, .hfrac > .hfrac-d { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 3px 4px; }
.hfrac > .hfrac-n { border-bottom: 2.5px solid #1e293b; align-self: stretch; }
.hfrac .slot { min-height: 40px; min-width: 44px; padding: 0 8px; font-size: 19px; }

/* 上標（指數）{{^內容}}：裡面可以放 [slotN] */
.hsup { display: inline-flex; align-items: center; gap: 2px; font-size: 0.78em; vertical-align: super; position: relative; top: -0.42em; margin: 0 2px; }
.hsup .slot { min-height: 30px; min-width: 34px; padding: 0 6px; font-size: 16px; border-radius: 8px; }
