/* 來講台語！— 國小風格：圓圓的、厚邊框、貼紙感 */
:root {
  --bg: #fff7e8;
  --paper: #ffffff;
  --ink: #3b2f2a;
  --ink-soft: #7a6a60;
  --line: #3b2f2a;
  --orange: #ff8a3d;
  --orange-soft: #ffe3cf;
  --yellow: #ffd15c;
  --yellow-soft: #fff2c4;
  --teal: #2bb3a3;
  --teal-soft: #d4f3ee;
  --pink: #ff6b8b;
  --pink-soft: #ffe0e7;
  --purple: #a66cff;
  --green: #4cbf5a;
  --green-soft: #dcf5df;
  --red: #ef5350;
  --radius: 22px;
  --shadow: 4px 4px 0 var(--line);
  --font: "Huninn", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-kip: "Noto Sans", "Segoe UI", "Arial Unicode MS", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(#f3e3c6 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  font-size: 18px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 20px 16px 48px; outline: none; }
a { color: inherit; }
button { font-family: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.kip { font-family: var(--font-kip); font-weight: 500; letter-spacing: .01em; }
.hidden { display: none !important; }

/* ---------- 上方列 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--paper);
  border-bottom: 3px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.logo-mark {
  flex: none; width: 46px; height: 46px; border-radius: 15px;
  display: grid; place-items: center;
  background: var(--orange); color: #fff; font-size: 26px; font-weight: 900;
  border: 3px solid var(--line); transform: rotate(-6deg);
}
.logo-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.logo-text b { font-size: 22px; white-space: nowrap; }
.logo-text small { font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.nav { display: flex; align-items: center; gap: 6px; }
.nav a {
  text-decoration: none; padding: 6px 12px; border-radius: 999px;
  border: 2px solid transparent; font-size: 17px; white-space: nowrap;
}
.nav a:hover { background: var(--yellow-soft); }
.nav a.active { background: var(--yellow); border-color: var(--line); }
.star-count {
  padding: 4px 12px; border-radius: 999px; background: var(--yellow-soft);
  border: 2px solid var(--line); font-weight: 700; white-space: nowrap;
}
@media (max-width: 640px) {
  .nav a span { display: none; }
  .nav a { padding: 6px 8px; font-size: 20px; }
  .logo-text small { display: none; }
  .logo-text b { font-size: 19px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .nav { gap: 2px; }
  .logo-mark { width: 40px; height: 40px; font-size: 22px; }
  .star-count { padding: 3px 9px; font-size: 16px; }
}
@media (max-width: 400px) {
  .logo-text { display: none; }
}

/* ---------- 通用元件 ---------- */
.card {
  background: var(--paper); border: 3px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; cursor: pointer;
  font-size: 19px; font-weight: 700; text-decoration: none;
  background: var(--paper); border: 3px solid var(--line); box-shadow: 3px 3px 0 var(--line);
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--line); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--line); }
.btn.primary { background: var(--orange); color: #fff; }
.btn.teal { background: var(--teal); color: #fff; }
.btn.yellow { background: var(--yellow); }
.btn.big { font-size: 22px; padding: 14px 30px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: 3px 3px 0 var(--line); }
.icon-btn {
  flex: none; width: 46px; height: 46px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; font-size: 22px; padding: 0;
  background: var(--paper); border: 2.5px solid var(--line); box-shadow: 2px 2px 0 var(--line);
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.icon-btn.playing { background: var(--yellow); animation: pulse .8s infinite; }
.icon-btn.recording { background: var(--pink); color: #fff; animation: pulse .8s infinite; }
@keyframes pulse { 50% { transform: scale(1.1); } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font-size: 17px;
  background: var(--paper); border: 2.5px solid var(--line);
}
.chip[aria-pressed="true"] { background: var(--yellow); font-weight: 700; }
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 14px;
  border: 2px solid var(--line); background: var(--paper); white-space: nowrap;
}
.section-title { font-size: 26px; margin: 34px 0 14px; display: flex; align-items: center; gap: 10px; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; font-size: 17px; margin-bottom: 12px; color: var(--ink-soft); }
.back:hover { color: var(--ink); }

/* ---------- 首頁 ---------- */
.hero {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 16px;
  padding: 26px 30px; background: var(--orange-soft); overflow: hidden;
}
.hero h1 { margin: 0; font-size: 40px; line-height: 1.25; }
.hero .kip { font-size: 20px; color: var(--orange); font-weight: 700; display: block; margin-top: 2px; }
.hero p { margin: 10px 0 0; font-size: 19px; }
.hero-chars { display: flex; align-items: flex-end; height: 170px; }
.hero-chars img { height: 170px; width: auto; filter: drop-shadow(3px 3px 0 rgba(59, 47, 42, .25)); }
.hero-chars img + img { margin-left: -24px; }
@media (max-width: 640px) {
  .hero { grid-template-columns: 1fr; padding: 20px; }
  .hero h1 { font-size: 30px; }
  .hero-chars { height: 120px; justify-content: center; }
  .hero-chars img { height: 120px; }
}

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 22px; }
@media (max-width: 400px) { .grid { grid-template-columns: 1fr; } }
.ep-card { display: flex; flex-direction: column; overflow: hidden; text-decoration: none; transition: transform .12s; }
.ep-card:hover { transform: translateY(-4px) rotate(-.5deg); }
.ep-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--yellow-soft); border-bottom: 3px solid var(--line); }
.ep-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ep-thumb .tag { position: absolute; left: 10px; top: 10px; }
.ep-thumb .time { position: absolute; left: auto; top: auto; right: 10px; bottom: 10px; background: rgba(59, 47, 42, .8); color: #fff; border-color: transparent; }
.ep-body { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.ep-body h3 { margin: 0; font-size: 24px; line-height: 1.3; }
.ep-body .kip { font-size: 15px; color: var(--ink-soft); }
.ep-meta { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 10px; font-size: 15px; color: var(--ink-soft); }
.stars { font-size: 20px; letter-spacing: 2px; white-space: nowrap; }
.stars .off { filter: grayscale(1); opacity: .3; }
.empty { text-align: center; padding: 40px; color: var(--ink-soft); }

/* ---------- 影片頁 ---------- */
.watch { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .watch { grid-template-columns: 1fr; } }
.player { overflow: hidden; position: sticky; top: 86px; }
@media (max-width: 860px) { .player { position: static; } }
.player video { width: 100%; display: block; background: #000; aspect-ratio: 16 / 9; }
.player-info { padding: 14px 18px 18px; }
.player-info h1 { margin: 0; font-size: 30px; line-height: 1.3; }
.player-info .kip { color: var(--orange); font-weight: 700; }
.player-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.toolbar .label { font-size: 15px; color: var(--ink-soft); margin-right: 2px; }
.lines { display: flex; flex-direction: column; gap: 12px; }
.line {
  display: grid; grid-template-columns: 52px 1fr; gap: 12px; padding: 12px 14px;
  cursor: pointer; transition: background .15s, transform .15s;
}
.line:hover { background: #fffaf0; }
.line.active { background: var(--yellow-soft); transform: scale(1.015); }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--sp, var(--line)); background: var(--paper);
}
.avatar img { width: 100%; height: 160%; object-fit: cover; object-position: top; }
.line-name { font-size: 15px; font-weight: 700; color: var(--sp); }
.line-hanji { font-size: 22px; line-height: 1.5; font-weight: 700; }
.line-kip { font-size: 16px; color: var(--sp); line-height: 1.5; }
.line-zh { font-size: 16px; color: var(--ink-soft); }
.line-tools { display: flex; gap: 8px; margin-top: 8px; }
.line-tools .icon-btn { width: 40px; height: 40px; font-size: 19px; }
.hide-kip .line-kip, .hide-kip .v-kip { display: none; }
.hide-zh .line-zh, .hide-zh .v-zh { display: none; }

.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.v-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.v-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.v-hanji { font-size: 30px; font-weight: 700; line-height: 1.2; }
.v-kip { color: var(--teal); font-size: 17px; font-weight: 700; }
.v-zh { color: var(--ink-soft); }
.v-ex { margin-top: 8px; padding: 10px 12px; border-radius: 14px; background: var(--teal-soft); font-size: 16px; display: flex; gap: 8px; align-items: flex-start; }
.v-ex .icon-btn { width: 36px; height: 36px; font-size: 16px; }
.v-from { font-size: 14px; color: var(--ink-soft); text-decoration: none; margin-top: 6px; }
.v-from:hover { text-decoration: underline; }
.search {
  width: 100%; max-width: 420px; padding: 12px 18px; font-size: 18px; font-family: inherit;
  border: 3px solid var(--line); border-radius: 999px; background: var(--paper); outline: none;
}
.search:focus { box-shadow: 3px 3px 0 var(--line); }

/* ---------- 練習 ---------- */
.quiz { max-width: 720px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.progress { flex: 1; height: 22px; border-radius: 999px; border: 3px solid var(--line); background: var(--paper); overflow: hidden; }
.progress > div { height: 100%; background: var(--green); transition: width .4s; border-right: 3px solid var(--line); }
.progress > div[style="width: 0%;"] { border-right: 0; }
.q-count { font-weight: 700; white-space: nowrap; }
.q-card { padding: 26px 26px 30px; text-align: center; }
.q-type { display: inline-block; padding: 4px 16px; border-radius: 999px; background: var(--teal-soft); border: 2px solid var(--line); font-size: 16px; margin-bottom: 12px; }
.q-prompt { font-size: 26px; font-weight: 700; margin: 6px 0 4px; line-height: 1.5; }
.q-prompt.small { font-size: 21px; }
.q-sub { color: var(--ink-soft); font-size: 17px; }
.q-listen { width: 96px; height: 96px; font-size: 44px; margin: 10px auto; border-width: 3px; box-shadow: 4px 4px 0 var(--line); background: var(--yellow); }
.q-slow { font-size: 15px; background: none; border: none; color: var(--ink-soft); text-decoration: underline; cursor: pointer; }
.q-hint { color: var(--ink-soft); font-size: 16px; margin-top: 4px; }
.choices { display: grid; gap: 12px; margin-top: 22px; text-align: left; }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 18px; font-size: 20px; text-align: left; cursor: pointer; line-height: 1.45;
  background: var(--paper); border: 3px solid var(--line); border-radius: 18px; box-shadow: 3px 3px 0 var(--line);
  transition: transform .08s;
}
.choice:hover:not(:disabled) { background: #fffaf0; }
.choice:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.choice .letter { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--yellow-soft); border: 2px solid var(--line); font-size: 17px; }
.choice .ck { font-size: 15px; display: block; color: var(--ink-soft); }
.choice.correct { background: var(--green-soft); border-color: var(--green); }
.choice.correct .letter { background: var(--green); color: #fff; }
.choice.wrong { background: var(--pink-soft); border-color: var(--red); animation: shake .35s; }
.choice.wrong .letter { background: var(--red); color: #fff; }
.choice:disabled { cursor: default; }
.choice-avatars { display: flex; justify-content: center; gap: 22px; margin-top: 22px; }
.choice-avatar { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 18px 12px; width: 160px; cursor: pointer; border-radius: 20px; }
.choice-avatar .avatar { width: 96px; height: 96px; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.order-slots { min-height: 70px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; padding: 14px; margin-top: 18px; border: 3px dashed #cdb89c; border-radius: 18px; background: #fffaf0; }
.order-pool { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; min-height: 56px; }
.piece { padding: 10px 16px; font-size: 20px; border-radius: 14px; cursor: pointer; background: var(--paper); border: 3px solid var(--line); box-shadow: 2px 2px 0 var(--line); }
.piece.placed { background: var(--yellow-soft); }
.order-slots.correct { border-color: var(--green); background: var(--green-soft); border-style: solid; }
.order-slots.wrong { border-color: var(--red); background: var(--pink-soft); animation: shake .35s; }

.feedback { margin-top: 20px; padding: 14px 18px; border-radius: 18px; font-size: 19px; text-align: left; border: 3px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.feedback.ok { background: var(--green-soft); }
.feedback.no { background: var(--yellow-soft); }
.feedback .big-emoji { font-size: 34px; line-height: 1; }
.feedback .kip { display: block; font-size: 16px; color: var(--ink-soft); }
.quiz-next { margin-top: 22px; text-align: center; }

.result { text-align: center; padding: 36px 24px; }
.result .big-stars { font-size: 64px; letter-spacing: 8px; margin: 10px 0; }
.result .big-stars span { display: inline-block; animation: pop .5s backwards; }
.result .big-stars span:nth-child(2) { animation-delay: .2s; }
.result .big-stars span:nth-child(3) { animation-delay: .4s; }
.result h2 { font-size: 32px; margin: 0; }
.result p { font-size: 20px; }
.result .actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 18px; }
@keyframes pop { from { transform: scale(0) rotate(-30deg); opacity: 0; } 70% { transform: scale(1.3); } }

/* ---------- 給老師 ---------- */
.prose { padding: 26px 30px; max-width: 820px; }
.prose h1 { margin-top: 0; }
.prose h2 { font-size: 22px; margin-top: 28px; }
.prose li { margin: 4px 0; }

.footer { text-align: center; font-size: 14px; color: var(--ink-soft); padding: 20px 16px 30px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%);
  padding: 12px 22px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 17px;
  transition: transform .25s; z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); }
