/* ============================================================
   答題畫面、數字鍵盤、選項、回饋、分步面板、計算紙
   ============================================================ */
.screen--play { padding-bottom: 8px; }
.play-head { display: flex; align-items: center; gap: 12px; padding: 10px var(--gutter) 4px; padding-right: calc(var(--sys-w) + 8px); padding-top: calc(10px + env(safe-area-inset-top)); }
.play-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.play-title span { font-size: 14px; font-weight: 800; color: var(--ink-soft); }
.play-title strong { font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.play-sub { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; align-items: center; padding: 4px var(--gutter) 8px; max-width: 1180px; margin: 0 auto; }
.play-stats { display: flex; gap: 6px; }
.pill--score { background: #fff3cf; }
.pill--combo { background: #ffe3dc; }
.dots { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: center; }
.dot { width: 18px; height: 18px; background: #fff; border: 3px solid var(--ink); border-radius: 50%; }
.dot.is-current { background: var(--sky); transform: scale(1.25); }
.dot--gold { background: #ffc21a; }
.dot--silver { background: #cfd6ea; }
.dot--bronze { background: #e9a76b; }
.dots--small { justify-content: center; margin: 4px 0 8px; }

/* 計時：齒輪感的能量條 */
.timer { position: relative; height: 34px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; overflow: hidden; }
.timer__fill { position: absolute; inset: 0; transform-origin: left center; background: linear-gradient(90deg, var(--green), #b6e04b); transition: background .3s; }
.timer.is-warn .timer__fill { background: linear-gradient(90deg, #ffb43b, #ffd166); }
.timer.is-danger .timer__fill { background: linear-gradient(90deg, var(--coral), #ff9a6b); animation: danger .5s ease-in-out infinite; }
.timer.is-over .timer__fill { background: repeating-linear-gradient(45deg, #cfe4ff 0 12px, #e8f2ff 12px 24px); }
.timer__text { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: 18px; text-shadow: 0 1px 0 rgba(255, 255, 255, .8); }

.play-stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); align-items: start; }
.visual-panel { position: sticky; top: 8px; padding: 10px; background: rgba(255, 250, 240, .96); border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 6px 0 rgba(36, 48, 85, .8); }
.visual { min-height: 200px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.visual svg.vz { width: 100%; height: auto; max-height: 52dvh; }
.visual .mascot { width: min(180px, 50%); }
.visual.is-highlight { box-shadow: inset 0 0 0 4px rgba(255, 194, 26, .8); border-radius: 16px; }

.qa-panel { display: flex; flex-direction: column; gap: 10px; }
.question-card { padding: 12px 16px; background: rgba(255, 250, 240, .97); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 5px 0 rgba(36, 48, 85, .8); }
.question-card.is-right { background: #e9fbe6; }
.question-card__top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.tag { padding: 1px 12px; background: var(--accent); border: 2px solid var(--ink); border-radius: 999px; font-weight: 800; font-size: 14px; }
.q-index { flex: 1; font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.question-card__prompt { font-size: 21px; font-weight: 800; line-height: 1.5; }

.hint-box { padding: 10px 14px; background: #fff7d6; border: 3px solid #e8a400; border-radius: 16px; font-weight: 700; }
.hint-box__formula { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; padding: 8px 10px; background: #fff; border: 2px dashed var(--ink); border-radius: 12px; font-size: 16px; }
.hint-box__formula b { color: #b06a00; }

.answer-area { min-height: 120px; }
.play-actions { display: flex; gap: 10px; }
.play-actions .btn { flex: 1; }

/* 選擇題 */
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 12px; text-align: left;
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); font-size: 19px; font-weight: 800; cursor: pointer;
  transition: transform .08s, box-shadow .08s, background .15s;
}
.choice:hover { background: #fff3cf; }
.choice:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.choice__key { flex: none; width: 30px; height: 30px; display: grid; place-items: center; background: var(--sun); border: 2px solid var(--ink); border-radius: 50%; font-size: 16px; }
.choice__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.choice small { font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.choice.is-wrong { background: #ffe9d6; border-style: dashed; opacity: .6; text-decoration: line-through; }
.choice.is-right { background: #c9f3c8; border-color: #2c8a3c; opacity: 1; }
.choice:disabled { cursor: default; }

/* 數字鍵盤 */
.numpad.is-disabled { opacity: .6; pointer-events: none; }
.np-display { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-height: 58px; padding: 0 14px; background: #fff; border: 4px solid var(--ink); border-radius: 16px; }
.np-label { margin-right: auto; font-size: 14px; font-weight: 800; color: var(--ink-soft); }
.np-value { font-size: 32px; font-weight: 900; font-variant-numeric: tabular-nums; }
.np-value[data-empty="1"] { color: #aab2cf; }
.np-value.is-bump { animation: pop .2s ease-out; }
.np-unit { font-size: 17px; font-weight: 800; color: var(--ink-soft); }
.np-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.np-key {
  min-height: 52px; padding: 0 4px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink);
  font-size: 24px; font-weight: 900; cursor: pointer; transition: transform .06s, box-shadow .06s, background .12s;
}
.np-key:hover { background: #fff3cf; }
.np-key:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); background: var(--sun); }
.np-key:disabled { opacity: .35; cursor: not-allowed; }
.np-key--clear, .np-key--back { background: #ffe3dc; font-size: 19px; }
.np-key--submit { grid-column: span 2; background: var(--green); font-size: 21px; }
.numpad.is-shake { animation: shake .4s; }

/* 塗色題 */
.paint-bar { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: #fff; border: 4px solid var(--ink); border-radius: 18px; }
.paint-count { font-size: 24px; font-weight: 900; text-align: center; }
.paint-count b { color: #e8483a; font-size: 34px; }
.paint-btns { display: flex; gap: 10px; }
.paint-btns .btn { flex: 1; }

/* 回饋泡泡 */
.feedback { position: fixed; left: 50%; top: 24%; z-index: 60; transform: translate(-50%, -10px) scale(.9); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.feedback.is-show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.feedback__bubble { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 200px; padding: 12px 28px; background: #fff; border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 6px 0 var(--ink); text-align: center; }
.feedback__face { font-size: 42px; line-height: 1.1; }
.feedback__text { font-size: 30px; font-weight: 900; }
.feedback__sub { font-size: 16px; font-weight: 700; color: var(--ink-soft); }
.feedback--good .feedback__bubble { background: #d9fbd5; }
.feedback--oops .feedback__bubble { background: #ffe9c9; }
.feedback--info .feedback__bubble { background: #dff2ff; }

/* 解說與分步面板 */
.sheet { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px 16px calc(var(--footer-h) + 16px); background: rgba(36, 48, 85, .55); overflow: auto; }
.sheet__card { width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 18px 20px 20px; background: var(--cream); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 8px 0 rgba(36, 48, 85, .8); }
.sheet__kicker { display: inline-block; padding: 2px 14px; background: var(--accent); border: 3px solid var(--ink); border-radius: 999px; font-weight: 900; font-size: 15px; }
.sheet__title { margin: 8px 0 6px; font-size: 24px; line-height: 1.35; }
.sheet__title b { color: #e8483a; }
.sheet__text { font-size: 18px; font-weight: 600; margin-bottom: 14px; }
.sheet__orig { margin-top: 6px; font-size: 14.5px; font-weight: 600; color: var(--ink-soft); }
.sheet__msg { min-height: 1.6em; margin-top: 8px; font-weight: 800; color: #b06a00; text-align: center; }
.sheet__actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

/* 計算紙 */
.scratch-overlay { position: fixed; inset: 0; z-index: 80; display: flex; padding: 12px 12px calc(var(--footer-h) + 12px); background: rgba(36, 48, 85, .5); }
.scratch { flex: 1; display: flex; flex-direction: column; background: #fff; border: 4px solid var(--ink); border-radius: 22px; overflow: hidden; }
.scratch__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; background: var(--sun); border-bottom: 3px solid var(--ink); }
.scratch__tip { flex: 1; font-size: 14px; font-weight: 700; min-width: 120px; }
.scratch__tools { display: flex; gap: 8px; flex-wrap: wrap; }
.scratch__tools .btn[aria-pressed="true"] { background: var(--sky); }
.scratch__canvas { flex: 1; width: 100%; min-height: 0; touch-action: none; cursor: crosshair; background-color: #fffdf6; background-image: linear-gradient(rgba(63, 178, 245, .22) 1px, transparent 1px), linear-gradient(90deg, rgba(63, 178, 245, .22) 1px, transparent 1px); background-size: 32px 32px; }

/* 視覺教具裡的 HTML 型態 */
.vz-card { width: 100%; padding: 14px; text-align: center; background: #fff; border: 3px solid var(--ink); border-radius: 18px; }
.vz-table-wrap { width: 100%; overflow-x: auto; }

@media (max-width: 900px) {
  .play-stage { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .visual-panel { position: static; padding: 6px; }
  .visual { min-height: 140px; }
  .visual svg.vz { max-height: 32dvh; }
  .question-card__prompt { font-size: 19px; }
  .answer-area { min-height: 0; }
}
@media (max-width: 520px) {
  .choices { grid-template-columns: minmax(0, 1fr); }
  .choice { min-height: 54px; font-size: 18px; }
  .np-key { min-height: 50px; }
  .np-value { font-size: 28px; }
  .feedback { top: 20%; }
  .feedback__text { font-size: 26px; }
}

@media (min-width: 901px) {
  .feedback { left: 27%; top: 36%; }
}

@media (max-width: 900px) {
  .play-head { padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: 0; }
  .play-sub { padding-bottom: 4px; gap: 4px 10px; }
  .timer { height: 30px; }
  .dot { width: 14px; height: 14px; border-width: 2px; }
  .visual { min-height: 0; }
  .visual svg.vz { max-height: 25dvh; }
  .question-card { padding: 8px 12px; border-width: 3px; }
  .question-card__prompt { font-size: 18px; line-height: 1.45; }
  .np-display { min-height: 50px; }
  .np-key { min-height: 46px; }
  .play-actions .btn { min-height: 46px; }
}

@media (max-width: 520px) {
  .choices--short { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 手機直式、畫面較矮時：壓縮教具區，讓數字鍵盤的「送出」與選項不被擠到頁尾下面 */
@media (max-width: 900px) and (max-height: 860px) {
  .play-stage { gap: 8px; }
  .qa-panel { gap: 8px; }
  .visual svg.vz { max-height: 21dvh; }
  .vz-card { padding: 6px 10px !important; }
  .vz-card__emoji { display: inline-block; vertical-align: middle; font-size: 30px !important; }
  .vz-card__title { display: inline-block; vertical-align: middle; font-size: 17px !important; margin: 0 0 2px 6px !important; }
  .vz-card__lines { font-size: 15.5px !important; line-height: 1.35 !important; }
  .np-display { min-height: 44px; }
  .np-value { font-size: 26px; }
  .np-grid { gap: 6px; margin-top: 6px; }
  .np-key { min-height: 44px; }
  .choice { min-height: 48px; }
}
@media (max-width: 900px) and (max-height: 720px) {
  .visual svg.vz { max-height: 17dvh; }
  .question-card__prompt { font-size: 17px; line-height: 1.4; }
  .play-actions .btn { min-height: 44px; }
}
