/* 論語朗讀之旅（三則各一頁共用樣式） */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1e2a44; font-family: "Noto Sans TC", sans-serif; color: #2b2118; -webkit-user-select: none; user-select: none; touch-action: none; }
#scene { position: fixed; inset: 0; display: block; }
button { font-family: inherit; cursor: pointer; }
b { background: linear-gradient(transparent 45%, #fde68a 45%); color: #7c2d12; padding: 0 2px; }

/* 頂部列 */
#topbar { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 10px 12px; z-index: 10; pointer-events: none; flex-wrap: wrap; }
#topbar > * { pointer-events: auto; }
.chip { background: rgba(255,251,240,.92); border: 2px solid #c8a46a; border-radius: 999px; padding: 6px 12px; font-size: 15px; font-weight: 700; color: #5b3a1a; box-shadow: 0 2px 6px rgba(0,0,0,.15); text-decoration: none; white-space: nowrap; }
.chip:active { transform: scale(.96); }
#title { font-family: "Noto Serif TC", serif; font-size: 17px; }
#seals { display: flex; gap: 6px; margin-left: auto; }
.seal { width: 36px; height: 36px; border-radius: 8px; border: 2px dashed #b9a07a; display: flex; align-items: center; justify-content: center; font-family: "Noto Serif TC", serif; font-weight: 900; font-size: 16px; color: #b9a07a; background: rgba(255,251,240,.85); }
.seal.on { border: 2px solid #b91c1c; background: #dc2626; color: #fff; transform: rotate(-6deg); box-shadow: 0 2px 6px rgba(185,28,28,.4); }
#roundChip { background: #7c2d12; color: #fde68a; border-color: #fde68a; }
@media (max-width: 720px) { #title { display: none; } .chip { font-size: 14px; padding: 5px 9px; } .seal { width: 30px; height: 30px; font-size: 14px; } }

/* 下方面板 */
#panel { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(880px, calc(100% - 24px)); z-index: 20; display: none; background: #fffbf0; border: 3px solid #a16207; border-radius: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.4); padding: 16px 18px 12px; }
#who { position: absolute; top: -18px; left: 18px; background: #7c2d12; color: #fff; font-weight: 900; font-size: 17px; padding: 4px 14px; border-radius: 10px; border: 2px solid #fde68a; }
#body { font-size: 21px; line-height: 1.75; margin-top: 6px; }
#body.narr { color: #57534e; }
#fb { font-size: 17px; font-weight: 700; min-height: 1.3em; margin-top: 4px; color: #b45309; }
#btns { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.btn { border: none; border-radius: 12px; padding: 10px 18px; font-size: 18px; font-weight: 900; }
.btn:disabled { opacity: .45; }
.btn-main { background: #b45309; color: #fff; box-shadow: 0 3px 0 #78350f; }
.btn-main:active { transform: translateY(2px); box-shadow: 0 1px 0 #78350f; }
.btn-sub { background: #f5e6c8; color: #5b3a1a; }
.btn-mic { background: #dc2626; color: #fff; box-shadow: 0 3px 0 #7f1d1d; font-size: 20px; padding: 12px 24px; }
.btn-mic.rec { background: #16a34a; box-shadow: 0 3px 0 #14532d; animation: pulse 1.1s infinite; }
.btn-teacher { background: #e0e7ff; color: #3730a3; }
@keyframes pulse { 50% { transform: scale(1.05); } }
.opt { display: block; width: 100%; text-align: left; margin: 8px 0; background: #fff; border: 3px solid #e7d3a8; border-radius: 12px; padding: 10px 14px; font-size: 20px; font-weight: 700; color: #3f2a14; }
.opt:hover { border-color: #b45309; }
.opt.wrong { border-color: #dc2626; background: #fef2f2; animation: shake .35s; }
.opt.right { border-color: #16a34a; background: #f0fdf4; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* 課文逐字 */
.verse { font-family: "Noto Serif TC", serif; font-size: 36px; font-weight: 900; line-height: 1.7; color: #a8a29e; text-align: center; }
/* 注音直排在字的右邊（課本格式） */
.ch { display: inline-flex; align-items: center; vertical-align: middle; margin: 2px 1px; transition: color .2s, transform .2s; }
.hz { border-radius: 6px; }
.zy { display: inline-flex; align-items: center; margin-left: 1px; font-family: "Noto Sans TC", sans-serif; font-size: 13px; font-weight: 700; line-height: 1.02; }
.zy .tn { margin-left: 1px; }
.verse.nozy .zy { display: none; }
.ch.cur { color: #3f2a14; }
.ch.lit { color: #d97706; text-shadow: 0 0 10px rgba(251,191,36,.7); transform: translateY(-2px); }
.ch.hid:not(.lit) .hz { color: transparent; background: #e7e5e4; }
.ch.hid:not(.lit) .zy { visibility: hidden; }
.ch.peek .hz { color: #78716c !important; background: transparent !important; }
.ch.p { color: #a8a29e; }
.verse.bai { font-family: "Noto Sans TC", sans-serif; font-size: 28px; font-weight: 700; line-height: 1.6; }
.verse.bai .ch { margin: 2px 0; }
@media (max-width: 640px) { .verse { font-size: 26px; } .verse.bai { font-size: 21px; } .zy { font-size: 10px; } #body { font-size: 18px; } .btn { font-size: 16px; padding: 9px 13px; } .btn-mic { font-size: 18px; padding: 10px 18px; } }
#meter { height: 8px; background: #e7e5e4; border-radius: 99px; margin-top: 6px; overflow: hidden; display: none; }
#meterBar { height: 100%; width: 0; background: #16a34a; transition: width .08s; }
.heard { font-size: 15px; color: #78716c; }

/* 遮罩面板 */
.overlay { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; background: rgba(20,14,8,.6); padding: 16px; }
.overlay.show { display: flex; }
.box { background: #fffbf0; border: 4px solid #a16207; border-radius: 22px; width: min(720px, 100%); max-height: calc(100% - 20px); overflow-y: auto; padding: 22px 24px; box-shadow: 0 16px 40px rgba(0,0,0,.4); }
.box h2 { font-family: "Noto Serif TC", serif; font-size: 28px; margin: 0 0 10px; color: #7c2d12; text-align: center; }
.box p { font-size: 18px; line-height: 1.8; margin: 8px 0; }
.rounds { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.rbtn { border: 3px solid #e7d3a8; background: #fff; border-radius: 14px; padding: 8px 14px; font-size: 16px; font-weight: 900; color: #5b3a1a; min-width: 150px; }
.rbtn small { display: block; font-weight: 400; font-size: 13px; color: #78716c; }
.rbtn.on { border-color: #b45309; background: #fef3c7; }
.rbtn:disabled { opacity: .4; }
.card { display: flex; align-items: center; gap: 14px; width: 100%; margin: 10px 0; padding: 12px 14px; border-radius: 16px; border: 3px solid #e7d3a8; background: #fff; text-align: left; }
.card .sl { flex: none; width: 54px; height: 54px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-family: "Noto Serif TC", serif; font-size: 28px; font-weight: 900; color: #fff; background: #b45309; }
.card .tx { flex: 1; font-size: 19px; font-weight: 900; color: #3f2a14; }
.card .tx small { display: block; font-size: 14px; font-weight: 400; color: #78716c; }
.card .marks { font-size: 13px; color: #16a34a; font-weight: 700; }
.card:hover { border-color: #b45309; }
.setrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0; font-size: 17px; font-weight: 700; }
.setrow .lbl { width: 120px; color: #7c2d12; }
.seg { border: 2px solid #e7d3a8; background: #fff; border-radius: 10px; padding: 6px 12px; font-size: 16px; font-weight: 700; color: #5b3a1a; }
.seg.on { background: #b45309; color: #fff; border-color: #b45309; }
.bars { margin: 12px 0; }
.bar { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 16px; font-weight: 700; }
.bar .l { width: 70px; }
.bar .track { flex: 1; height: 22px; background: #f5e6c8; border-radius: 8px; overflow: hidden; }
.bar .fill { height: 100%; background: linear-gradient(90deg, #f59e0b, #b45309); border-radius: 8px; transition: width .6s; }
.bar .v { width: 70px; text-align: right; }
#flash { position: fixed; left: 50%; top: 34%; transform: translate(-50%,-50%); z-index: 30; font-family: "Noto Serif TC", serif; font-size: 84px; font-weight: 900; color: #b91c1c; text-shadow: 0 4px 0 #fde68a, 0 8px 18px rgba(0,0,0,.3); pointer-events: none; opacity: 0; transition: opacity .25s; white-space: nowrap; }
#stamp { position: fixed; left: 50%; top: 36%; z-index: 45; width: 150px; height: 150px; margin: -75px 0 0 -75px; border: 6px solid #b91c1c; border-radius: 16px; color: #b91c1c; background: rgba(255,251,240,.92); font-family: "Noto Serif TC", serif; font-weight: 900; display: none; flex-direction: column; align-items: center; justify-content: center; font-size: 22px; line-height: 1.2; text-align: center; pointer-events: none; }
#stamp.show { display: flex; animation: stampIn .7s ease-out; }
@keyframes stampIn { 0% { transform: scale(2.4) rotate(-20deg); opacity: 0; } 60% { transform: scale(.92) rotate(-8deg); opacity: 1; } 100% { transform: scale(1) rotate(-8deg); } }
#lookTip { position: fixed; right: 12px; top: 58px; z-index: 8; font-size: 13px; color: #fff; background: rgba(0,0,0,.35); border-radius: 10px; padding: 5px 10px; pointer-events: none; }
@media (max-width: 640px) { #lookTip { display: none; } }
/* 手機橫放：高度很矮時把介面縮小，讓 3D 場景露出來 */
@media (max-height: 500px) {
  #topbar { padding: 6px 8px; gap: 5px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #topbar::-webkit-scrollbar { display: none; }
  .chip { font-size: 12px; padding: 4px 9px; border-width: 1.5px; }
  #title, #lookTip { display: none; }
  .seal { width: 26px; height: 26px; font-size: 13px; }
  #panel { bottom: 6px; padding: 12px 14px 8px; width: min(900px, calc(100% - 16px)); border-radius: 14px; }
  #who { font-size: 13px; top: -14px; padding: 2px 10px; }
  #body { font-size: 16px; line-height: 1.5; margin-top: 2px; }
  .verse { font-size: 24px; line-height: 1.45; }
  .verse.bai { font-size: 19px; }
  .zy { font-size: 9px; }
  #fb { font-size: 13px; margin-top: 2px; }
  #btns { margin-top: 4px; gap: 6px; }
  .btn { font-size: 14px; padding: 6px 12px; }
  .btn-mic { font-size: 15px; padding: 8px 16px; }
  .opt { font-size: 15px; padding: 6px 10px; margin: 4px 0; }
  .overlay { padding: 8px; }
  .box { padding: 12px 16px; }
  .box h2 { font-size: 21px; margin-bottom: 4px; }
  .box p { font-size: 14px; line-height: 1.6; margin: 4px 0; }
  .rbtn { min-width: 120px; padding: 5px 10px; font-size: 14px; }
  .card { padding: 6px 10px; margin: 6px 0; }
  .card .sl { width: 40px; height: 40px; font-size: 22px; }
  .card .tx { font-size: 16px; }
  #flash { font-size: 54px; }
  #stamp { width: 110px; height: 110px; margin: -55px 0 0 -55px; }
}
  
