/* 方塊鎮朗讀測驗：四區共用樣式（方塊 RPG 介面，直角＋硬陰影） */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fd3f0; font-family: "Noto Sans TC", sans-serif; color: #3c2a1c; -webkit-user-select: none; user-select: none; touch-action: none; }
#scene { position: fixed; inset: 0; display: block; }
button { font-family: inherit; cursor: pointer; }
.en { font-family: "Fredoka", "Noto Sans TC", sans-serif; }
mark { background: #ffe27a; color: #8a3f12; padding: 0 4px; font-weight: 700; }

.bt-box { background: #fff4d9; border: 4px solid #4a3424; box-shadow: 0 5px 0 #4a3424; }

#topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; z-index: 10; pointer-events: none; flex-wrap: wrap; }
#topbar > * { pointer-events: auto; }
.chip { background: #fff4d9; border: 3px solid #4a3424; box-shadow: 0 3px 0 #4a3424; padding: 5px 11px; font-size: 15px; font-weight: 900; color: #3c2a1c; text-decoration: none; white-space: nowrap; }
button.chip:active, a.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 #4a3424; }
#title { font-size: 16px; background: #6d4c9f; color: #fff; }
#scoreChip { background: #ffd24d; }
#hudRight { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; max-width: 62%; pointer-events: none; }
#words { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.w { min-width: 30px; height: 30px; padding: 0 7px; border: 3px solid #4a3424; background: rgba(255,244,217,.78); color: #8a7360; font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.w.on { background: #9be26a; color: #23480f; }

#quest { width: min(300px, 100%); padding: 8px 12px; font-size: 16px; font-weight: 700; line-height: 1.4; }
#quest b { display: block; color: #6d4c9f; font-size: 13px; font-weight: 900; }
#sideBtns { position: fixed; right: 12px; bottom: 14px; z-index: 8; display: flex; gap: 8px; }

#prompt { position: fixed; left: 50%; bottom: 112px; transform: translateX(-50%); z-index: 9; display: none; background: #e2553a; color: #fff; border: 4px solid #4a3424; box-shadow: 0 5px 0 #4a3424; padding: 10px 22px; font-size: 21px; font-weight: 900; cursor: pointer; white-space: nowrap; animation: btPulse 1s steps(2) infinite; }
#prompt.talk { background: #4a9c5d; }
@keyframes btPulse { 50% { transform: translateX(-50%) translateY(-4px); } }

#story, #card { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(680px, calc(100% - 20px)); z-index: 20; display: none; padding: 10px 14px; }
#storyWho { display: inline-block; background: #6d4c9f; color: #fff; font-weight: 900; font-size: 15px; padding: 2px 10px; margin-bottom: 6px; }
#storyText { font-size: 22px; line-height: 1.55; font-weight: 700; }
#storyBtns { display: flex; justify-content: flex-end; margin-top: 8px; }

#cardLine { font-size: 17px; font-weight: 700; color: #6b4a2e; margin-bottom: 6px; line-height: 1.4; }
#bossHp { display: none; font-size: 20px; font-weight: 900; color: #b4233a; margin-bottom: 4px; }
#cardTop { display: flex; gap: 14px; align-items: center; }
#cardImg { width: 82px; height: 82px; object-fit: cover; background: #fdebc4; border: 4px solid #4a3424; flex-shrink: 0; }
#cardWord { font-size: 38px; line-height: 1.05; color: #a8451f; font-weight: 700; }
#cardZh { font-size: 19px; font-weight: 900; color: #6b5646; margin-top: 2px; }
#cardSent { font-size: 20px; margin-top: 4px; line-height: 1.4; }
#cardSentZh { font-size: 15px; color: #6b5646; }
#cardBtns { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
#feedback { min-height: 22px; margin-top: 6px; font-size: 16px; font-weight: 900; }
#meter { height: 10px; background: #e2d4b4; border: 2px solid #4a3424; overflow: hidden; margin-top: 6px; display: none; }
#meterBar { height: 100%; width: 0; background: #4a9c5d; transition: width .08s; }

.btn { border: 3px solid #4a3424; padding: 10px 18px; font-size: 19px; font-weight: 900; box-shadow: 0 4px 0 #4a3424; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #4a3424; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-listen { background: #bfead9; color: #1d5c4a; }
.btn-sub { background: #f1e3c4; color: #5b4632; font-size: 16px; padding: 8px 13px; }
.btn-mic { background: #e2553a; color: #fff; }
.btn-mic.rec { background: #a81f3d; animation: btRec 1s steps(2) infinite; }
@keyframes btRec { 50% { outline: 5px solid rgba(226,85,58,.45); } }
.btn-go { background: #ffb545; color: #3c2a1c; }

#joy { position: fixed; left: 20px; bottom: 20px; width: 130px; height: 130px; background: rgba(255,244,217,.4); border: 4px solid rgba(74,52,36,.65); z-index: 8; display: none; touch-action: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; background: rgba(255,181,69,.92); border: 4px solid #4a3424; }
body.touch #joy { display: block; }

#flash { position: fixed; left: 50%; top: 26%; transform: translate(-50%,-50%); z-index: 30; font-size: 52px; font-weight: 900; color: #fff; -webkit-text-stroke: 2px #4a3424; text-shadow: 0 5px 0 #4a3424; pointer-events: none; opacity: 0; transition: opacity .2s; white-space: nowrap; }

.overlay { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; background: rgba(35,25,50,.35); padding: 14px; }
.overlay.show { display: flex; }
.panel { width: min(640px, 100%); max-height: calc(100% - 16px); overflow-y: auto; padding: 18px 22px; touch-action: pan-y; }
.panel h2 { font-size: 30px; margin: 0 0 8px; color: #6d4c9f; text-align: center; }
.panel p { font-size: 18px; line-height: 1.7; margin: 8px 0; }
.ctrl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 16px; background: #fdebc4; border: 3px solid #4a3424; padding: 9px 12px; margin: 10px 0; }
.ctrl span:nth-child(odd) { font-weight: 900; color: #a8451f; }
.rule { font-size: 16px; background: #eadcff; border: 3px solid #4a3424; padding: 8px 12px; line-height: 1.6; }

@media (max-width: 760px) {
  #title, #sideBtns .tip { display: none; }
  #hudRight { max-width: 100%; gap: 5px; }
  .w { min-width: 25px; height: 25px; font-size: 12px; padding: 0 4px; border-width: 2px; }
  #quest { font-size: 14px; width: 210px; padding: 5px 8px; }
  #story, #card { padding: 10px 12px; }
  #storyText { font-size: 18px; }
  #cardImg { width: 84px; height: 84px; }
  #cardWord { font-size: 34px; }
  #cardSent { font-size: 17px; }
  .btn { font-size: 16px; padding: 8px 11px; }
  #flash { font-size: 34px; }
}
/* 手機橫放：卡片縮小，讓場景露出來 */
@media (max-height: 500px) {
  #topbar { padding: 5px 8px; gap: 5px; flex-wrap: nowrap; }
  .chip { font-size: 12px; padding: 3px 7px; }
  #title { display: none; }
  .w { min-width: 20px; height: 22px; font-size: 11px; padding: 0 3px; }
  #hudRight { gap: 3px; }
  #quest { width: 200px; font-size: 12px; padding: 3px 7px; }
  #quest b { display: none; }
  #card, #story { bottom: 5px; padding: 7px 12px; }
  #cardLine { display: none; }
  #cardImg { width: 58px; height: 58px; }
  #cardWord { font-size: 28px; }
  #cardZh { font-size: 15px; }
  #cardSent { font-size: 14px; margin-top: 1px; }
  #cardSentZh { font-size: 12px; }
  #cardBtns { margin-top: 5px; gap: 6px; }
  .btn { font-size: 14px; padding: 5px 10px; }
  #feedback { font-size: 13px; min-height: 0; margin-top: 3px; }
  #storyText { font-size: 15px; line-height: 1.4; }
  #prompt { bottom: 64px; font-size: 15px; padding: 6px 14px; }
  #joy { width: 100px; height: 100px; left: 12px; bottom: 12px; }
  #joyKnob { width: 42px; height: 42px; margin: -21px 0 0 -21px; }
}
