/* 共用樣式：1600×900 的舞台（由 stage.js 等比縮放，電視全螢幕也一樣），剪紙拼貼風。 */
/* @font-face:begin（node tools/font.mjs 產生，不要手改） */
@font-face { font-family: "Lesson Round"; src: url("fonts/lesson-round.fdde1c47.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
/* @font-face:end */
:root {
  --ink: #4a2f1d;
  --paper: #fff8ea;
  --accent: #f08a24;
  --accent-dark: #c96a10;
  --green: #6baa5b;
  --shadow: rgba(59, 36, 20, 0.24);
  /* Lesson Round＝開源圓體「jf open 粉圓」的子集（shared/fonts/，OFL）：每一台電腦看到的字都一樣，Windows 不會退回正黑體 */
  --font: "Lesson Round", "Yuanti TC", "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
  --bold: 0.03em;
  --font-zy: "BiauKaiTC", "BiauKai", "Kaiti TC", "DFKai-SB", "Lesson Round", "PingFang TC", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;   /* 觸控板兩指左右滑不要變成瀏覽器的上一頁（另見 shared/kiosk.js） */
  background: #1f150f;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  -webkit-user-select: none;
  user-select: none;
}

/* 粉圓只有一種粗細，比原本的圓體粗體細 → 用描邊把筆畫加粗一點（各家瀏覽器畫出來一樣；瀏覽器自己的假粗體每家不同）。
   寫在每個元素上（*）而不是讓它繼承：寬度用 em，繼承下去的會是上層算好的固定值，大字就不會跟著變粗。
   改用別的字型的區塊（注音、給大人看的說明）在各自的規則裡設回 0。 */
.stage, .stage * { -webkit-text-stroke: var(--bold) currentColor; }

button { font: inherit; color: inherit; border: 0; padding: 0; cursor: pointer; background: none; }

.viewport {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, #46301f, #1f150f);
}

.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1600px;
  height: 900px;
  margin: -450px 0 0 -800px;
  overflow: hidden;
  border-radius: 28px;
  background: #e6f6ea;
}

.scene { position: absolute; inset: 0; }
.scene svg.art { position: absolute; inset: 0; width: 1600px; height: 900px; display: block; }

/* 紙的顆粒感 */
.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45  0 0 0 0 .32  0 0 0 0 .2  0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── 注音 ───────────────────────────────────────── */
.zy-g { display: inline-flex; align-items: center; white-space: nowrap; }
.zy { display: inline-flex; align-items: center; }
.zy-c, .zy-p { display: inline-block; }
.zy-b {
  display: inline-flex;
  align-items: center;
  width: 0.52em;
  height: 1.2em;
  margin: 0 0.04em 0 0.02em;
}
.zy-col, .zy-col * { -webkit-text-stroke: 0; }   /* 注音用楷體，不描粗 */
.zy-col {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-zy);
  font-size: 0.32em;
  font-weight: 400;
  line-height: 1;
}
.zy-col.n3 { font-size: 0.29em; }
.zy-col i { display: block; width: 1em; height: 1em; font-style: normal; text-align: center; }
.zy-col em { position: absolute; font-style: normal; line-height: 1; }
.zy-col em.tone { left: 0.9em; bottom: 0.3em; }
.zy-col em.light { left: 0; right: 0; top: -0.72em; text-align: center; }
.zy-miss .zy-c { outline: 4px dashed #e63946; }

/* ── 上方工具列 ─────────────────────────────────── */
.topbar {
  position: absolute;
  top: 18px;
  left: 24px;
  right: 24px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.top-group { display: flex; gap: 12px; }

.ibtn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--shadow);
  text-decoration: none;
  transition: transform 0.1s;
}
.ibtn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--shadow); }
.ibtn .icon { width: 36px; height: 36px; }
.ibtn:focus-visible, .nav:focus-visible, .big-btn:focus-visible { outline: 6px solid #fff; outline-offset: 3px; }

.progress {
  display: flex;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 40px;
  background: rgba(255, 248, 234, 0.85);
  box-shadow: 0 5px 0 var(--shadow);
}
.progress button {
  width: 34px;
  height: 22px;
  border-radius: 50% 46% 52% 44%;
  background: #e2cfae;
  transition: transform 0.2s, background 0.2s;
}
.progress button.done { background: #d98a9c; }
.progress button.now { background: #b8475e; transform: scale(1.35) rotate(-8deg); }

/* ── 對話框 ─────────────────────────────────────── */
.panel {
  position: absolute;
  left: 40px;
  right: 40px;
  bottom: 20px;
  height: 224px;
  padding: 18px 170px 0 60px;
  display: flex;
  align-items: center;
  border-radius: 40px;
  background: var(--paper);
  box-shadow: 0 8px 0 var(--shadow);
  transition: opacity 0.25s, transform 0.25s;
}
.panel.hidden { opacity: 0; transform: translateY(40px); pointer-events: none; }

.who {
  position: absolute;
  left: 34px;
  top: -58px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.who .face {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: 7px solid var(--paper);
  background: #ffe3b3;
  overflow: hidden;
  box-shadow: 0 5px 0 var(--shadow);
}
.who .face svg { width: 100%; height: 100%; display: block; }
.who .name {
  margin-bottom: 22px;
  padding: 4px 22px 6px;
  border-radius: 24px;
  font-size: 30px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 4px 0 var(--shadow);
}
.who[data-who="agong"] .face { background: #cfe8d5; }
.who[data-who="agong"] .name { background: #4f8f5e; }
.who[data-who="kid"] .face { background: #cfe3f7; }
.who[data-who="kid"] .name { background: #4f86c6; }
.who[data-who="narrator"] .face { background: #ffe9c7; padding: 16px; }

.text { font-size: 58px; line-height: 1.4; letter-spacing: 0.01em; text-wrap: balance; }
.text.pop { animation: textIn 0.3s ease-out; }
@keyframes textIn { from { opacity: 0; transform: translateY(14px); } }

.nav {
  position: absolute;
  right: 68px;
  bottom: 70px;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 0 var(--accent-dark);
  transition: transform 0.1s, opacity 0.2s;
}
.nav .icon { width: 60px; height: 60px; }
.nav:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--accent-dark); }
.nav.wait { opacity: 0.45; }
.nav.ready { animation: pulse 1.1s ease-in-out infinite; }
.nav.hidden { display: none; }
@keyframes pulse { 50% { transform: scale(1.12); box-shadow: 0 8px 0 var(--accent-dark), 0 0 0 16px rgba(240, 138, 36, 0.25); } }
.nudge { animation: nudge 0.4s; }
/* 用獨立的 translate／rotate：.prompt 靠 transform: translateX(-50%) 置中，動畫若寫 transform 會把它蓋掉，泡泡往右跳半個身長 */
@keyframes nudge { 25% { translate: -10px 0; rotate: -2deg; } 75% { translate: 10px 0; rotate: 2deg; } }

/* ── 「輪到你了」提示 ───────────────────────────── */
.prompt {
  position: absolute;
  top: 104px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 34px 8px 22px;
  border-radius: 50px;
  font-size: 40px;
  white-space: nowrap;
  background: #fff;
  border: 6px solid var(--green);
  color: #2f5d2a;
  box-shadow: 0 6px 0 var(--shadow);
  transition: opacity 0.25s, margin-top 0.25s;
}
.prompt { cursor: pointer; }   /* 點一下再聽一次（shared/stage.js） */
.prompt.hidden { opacity: 0; margin-top: -30px; pointer-events: none; }
.prompt .icon { width: 56px; height: 56px; color: #2f5d2a; animation: tapHint 1s ease-in-out infinite; }
@keyframes tapHint { 50% { transform: translateY(8px) scale(0.92); } }

/* ── 新詞小卡 ───────────────────────────────────── */
.tray { position: absolute; left: 24px; top: 108px; display: flex; flex-direction: column; gap: 10px; }
.chip {
  padding: 2px 16px 4px;
  border-radius: 18px;
  font-size: 34px;
  background: #fff;
  border: 4px solid var(--accent);
  box-shadow: 0 4px 0 var(--shadow);
  animation: chipIn 0.4s ease-out;
}
@keyframes chipIn { from { opacity: 0; transform: translateX(-40px); } }

.cards { position: absolute; inset: 0; pointer-events: none; }
.cards > * { pointer-events: auto; }

.vcard {
  position: absolute;
  left: 50%;
  top: 116px;
  width: 820px;
  margin-left: -410px;
  padding: 22px 40px 28px;
  border-radius: 40px;
  text-align: center;
  background: #fff;
  border: 8px solid var(--accent);
  box-shadow: 0 10px 0 var(--shadow);
  animation: cardIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.vcard.out { animation: cardOut 0.35s ease-in forwards; }
@keyframes cardIn { from { opacity: 0; transform: scale(0.6) rotate(-4deg); } }
@keyframes cardOut { to { opacity: 0; transform: translate(-560px, -40px) scale(0.2); } }
.vcard .tag { display: inline-block; padding: 2px 20px 4px; border-radius: 20px; font-size: 26px; color: #fff; background: var(--accent); }
.vcard .zh { font-size: 124px; line-height: 1.3; margin: 2px 0 8px; }
.vcard .rows { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.vcard .row { padding: 10px 14px 14px; border-radius: 24px; background: #fff3dc; }
.vcard .row.en { background: #e3f1fb; }
.vcard .row small { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 24px; opacity: 0.75; }
.vcard .row small .icon { width: 30px; height: 30px; }
.vcard .row b { display: block; font-size: 50px; line-height: 1.2; }
.vcard .row span { display: block; font-size: 34px; color: #a0522d; -webkit-text-stroke: 0; }   /* 台羅：用粉圓（有台羅的聲調符號），不描粗，聲調符號才清楚 */
.vcard .row.en b { font-size: 46px; color: #2b6a9b; padding: 14px 0 6px; }

.ask {
  position: absolute;
  left: 50%;
  top: 124px;
  width: 1180px;
  margin-left: -590px;
  padding: 26px 44px 26px 150px;
  border-radius: 40px;
  background: #fff;
  border: 8px solid #4f86c6;
  box-shadow: 0 10px 0 var(--shadow);
  animation: cardIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.ask::before {
  content: "？";
  position: absolute;
  left: 30px;
  top: 50%;
  width: 96px;
  height: 96px;
  margin-top: -48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 66px;
  color: #fff;
  background: #4f86c6;
  animation: wiggle 1.6s ease-in-out infinite;
}
@keyframes wiggle { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
.ask .q { font-size: 52px; line-height: 1.42; text-wrap: balance; }
.ask .tip { margin-top: 10px; font-size: 25px; font-weight: 400; font-family: "PingFang TC", "Microsoft JhengHei", sans-serif; color: #7a6a5c; }
.ask .tip, .ask .tip * { -webkit-text-stroke: 0; }
.ask .tip::before { content: "給大人："; font-weight: 600; }

.big-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 44px 14px;
  border-radius: 60px;
  font-size: 54px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 9px 0 var(--accent-dark);
  text-decoration: none;
}
.big-btn:active { transform: translateY(6px); box-shadow: 0 3px 0 var(--accent-dark); }
.big-btn.green { background: var(--green); box-shadow: 0 9px 0 #4a8040; }

/* ── 特效 ───────────────────────────────────────── */
.fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; width: 18px; height: 26px; border-radius: 4px; animation: confetti 1.5s ease-out forwards; }
@keyframes confetti {
  from { transform: translate(0, 0) rotate(0); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; }
}

.curtain { position: absolute; inset: 0; background: var(--paper); opacity: 0; pointer-events: none; transition: opacity 0.22s; }
.curtain.on { opacity: 1; }

/* ── 場景裡的通用動畫（SVG 元素用 class 套） ─────── */
.tappable { cursor: pointer; }
.tappable:focus { outline: none; }
/* hint-bounce / float 只動 translate（獨立屬性），所以可以直接套在用 KY.put 或 transform 屬性定位的節點上。
   wobble / pop-in 會旋轉、縮放 → 要套在「沒有任何 transform 的內層子節點」上，否則位置會被蓋掉。 */
.hint-bounce { animation: hintBounce 0.9s ease-in-out infinite; }
@keyframes hintBounce { 50% { translate: 0 -16px; } }
.wobble { animation: wobble 0.45s; transform-box: fill-box; transform-origin: 50% 80%; }
@keyframes wobble { 20% { transform: rotate(-9deg); } 50% { transform: rotate(8deg); } 80% { transform: rotate(-4deg); } }
.pop-in { animation: popIn 0.4s cubic-bezier(0.2, 1.5, 0.4, 1) both; transform-box: fill-box; transform-origin: 50% 60%; }
@keyframes popIn { from { transform: scale(0); opacity: 0; } }
.float { animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { translate: 0 -10px; } }

.cloud { animation: drift linear infinite alternate; }
@keyframes drift { to { translate: 120px 0; } }

/* idle：身體很輕地呼吸（腳在原點不動，只有往上伸縮 1.2%）、眼睛偶爾眨一下。
   下面 .char.talking / .char.jump 的選擇器比較具體，說話與跳起來時會蓋過呼吸；
   jump 這個 class 播完不會被拿掉，所以它的動畫清單裡要把 breathe 帶著，跳完才接得回去。
   三個角色眨眼的週期與起點都不同，才不會一起眨。 */
.char-body { animation: breathe 3.4s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes breathe { 50% { transform: scaleY(1.012); } }
.char-kid .eyes { animation: blink 4.2s 1.1s infinite; }
.char-agong .eyes { animation: blink 5.3s 2.4s infinite; }
.char-dog .eyes { animation: blink 3.7s 0.5s infinite; }
@keyframes blink { 0%, 95.5%, 100% { transform: scaleY(1); } 97.5% { transform: scaleY(0.1); } }

.char.talking .char-body { animation: talkBob 0.5s ease-in-out infinite; }
@keyframes talkBob { 50% { transform: translateY(-7px); } }
.char.talking .mouth { animation: talk 0.26s ease-in-out infinite alternate; }
@keyframes talk { from { transform: scaleY(0.45); } to { transform: scaleY(1.35); } }
.char-dog .tail { animation: wag 0.45s ease-in-out infinite alternate; }
@keyframes wag { from { transform: rotate(-12deg); } to { transform: rotate(16deg); } }
.char.jump .char-body { animation: breathe 3.4s ease-in-out infinite, jump 0.6s ease-out; }
.char.talking.jump .char-body { animation: talkBob 0.5s ease-in-out infinite, jump 0.6s ease-out; }
@keyframes jump { 40% { transform: translateY(-46px); } 70% { transform: translateY(0); } 85% { transform: translateY(-10px); } }

.flame { animation: flicker 0.42s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.flame.f2 { animation-duration: 0.31s; }
@keyframes flicker { from { transform: scale(1, 1) skewX(-3deg); } to { transform: scale(0.92, 1.1) skewX(4deg); } }
.steam { animation: steam 2.2s ease-out infinite; transform-box: fill-box; }
.steam.s2 { animation-delay: 0.7s; }
.steam.s3 { animation-delay: 1.4s; }
@keyframes steam { from { transform: translateY(0) scale(0.7); opacity: 0.9; } to { transform: translateY(-70px) scale(1.5); opacity: 0; } }

/* 燒紅的窯（KY.kiln）：光暈明暗呼吸＋窯頂的熱氣波紋。fire.js 會把整座窯重畫，
   所以週期都很短，而且 art.js 會依「現在幾點」寫負的 animation-delay，重畫後相位接得上、不會跳回起點。
   .kiln-halo 只動 opacity；.kiln-wave 的外層 <g> 才有 transform 屬性，動畫套在裡面那層。 */
.kiln-halo { animation: kilnHalo 1.5s ease-in-out infinite; }
@keyframes kilnHalo { 50% { opacity: 0.6; } }
.kiln-wave { animation: kilnWave 1.9s ease-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes kilnWave { 0% { transform: translateY(0) scaleY(0.8); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateY(-64px) scaleY(1.3); opacity: 0; } }

/* 白鷺鷥偶爾低頭啄兩下（6 秒一輪，大部分時間不動）。.egret-neck 沒有 transform 屬性，origin 在脖子根部。 */
.egret-neck { animation: peck 6s ease-in-out infinite; }
@keyframes peck {
  0%, 60%, 100% { transform: rotate(0deg); }
  63% { transform: rotate(-6deg); }
  67% { transform: rotate(36deg); }
  70% { transform: rotate(8deg); }
  74% { transform: rotate(38deg); }
  82% { transform: rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .float, .hint-bounce { animation: none; }
  .char-body, .char .eyes, .kiln-halo, .egret-neck { animation: none; }
  .char.jump .char-body { animation: jump 0.6s ease-out; }   /* jump 的清單裡帶著 breathe，這裡拿掉 */
  .kiln-wave { animation: none; opacity: 0; }
}

/* ── 大游標（shared/kiosk.js）──────────────────────── */
html.has-kcursor, html.has-kcursor * { cursor: none !important; }
.kcursor {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  will-change: transform;
}
.kcursor.on { opacity: 1; }
.kcursor svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 3px 0 rgba(59, 36, 20, 0.35)); transition: transform 0.12s; }
.kcursor.hot svg { transform: scale(1.2); }      /* 移到可以點的東西上面會變大 */
.kcursor.down svg { transform: scale(0.85); }
.kripple {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  border-radius: 50%;
  border: 6px solid #ffd166;
  box-shadow: 0 0 0 3px rgba(74, 47, 29, 0.25);
  animation: kripple 0.45s ease-out forwards;
}
@keyframes kripple {
  from { transform: translate(-50%, -50%) scale(0.3); opacity: 0.95; }
  to { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}

/* ── 小螢幕提示（shared/kiosk.js）：蓋在整個視窗上，不跟著舞台縮放，手機上才讀得到 ── */
.small-note {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 21, 15, 0.94);
  color: var(--paper);
  text-align: center;
  font-family: "PingFang TC", "Heiti TC", "Microsoft JhengHei", sans-serif;
  font-weight: 500;
  -webkit-text-stroke: 0;
  font-size: 17px;
  line-height: 1.7;
}
.small-note b { display: block; font-size: 24px; margin-bottom: 6px; }
.small-note p { margin: 0 auto 18px; max-width: 22em; }
.small-note button { padding: 10px 26px; border-radius: 999px; background: var(--paper); color: var(--ink); font-size: 17px; font-weight: 700; }

/* ── 載入中（shared/…的程式還沒到之前先看到的畫面）：三顆跳動的點。過 0.5 秒才淡入，網路快的時候根本看不到 ── */
.boot { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; gap: 18px; opacity: 0; animation: bootIn 0.3s 0.5s forwards; pointer-events: none; }
.boot i { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); animation: bootDot 0.9s ease-in-out infinite; }
.boot i:nth-child(2) { background: #ffd166; animation-delay: 0.15s; }
.boot i:nth-child(3) { background: var(--green); animation-delay: 0.3s; }
@keyframes bootIn { to { opacity: 1; } }
@keyframes bootDot { 50% { translate: 0 -18px; } }
