:root {
  --bg: #fffdf5; --card: #ffffff; --ink: #1b1b1f; --muted: #6b6b76; --line: #ece8dc;
  --brand: #ffd400; --brand-ink: #1b1b1f; --ok: #22a447; --no: #e0322f; --accent: #2f6bff; --soft: #fff6c7;
  --radius: 18px; --shadow: 0 6px 20px rgba(30, 25, 0, .08);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121216; --card: #1d1d23; --ink: #f2f2f5; --muted: #a0a0ad; --line: #2c2c35; --soft: #2b2710; --shadow: 0 6px 20px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
a { color: inherit; }
button { font: inherit; cursor: pointer; border: 0; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 900; text-decoration: none; font-size: 18px; }
.logo-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--brand); color: #111; display: grid; place-items: center; font-weight: 900; }
.stats { display: flex; align-items: center; gap: 10px; }
.stat { font-size: 15px; white-space: nowrap; }
.pro-btn { background: #111; color: #ffd400; font-weight: 800; padding: 7px 14px; border-radius: 999px; font-size: 14px; }
.pro-btn.is-pro { background: var(--ok); color: #fff; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
.foot { max-width: 760px; margin: 24px auto 40px; padding: 0 16px; display: flex; gap: 16px; color: var(--muted); font-size: 14px; }

.hero { background: var(--brand); color: #111; border-radius: var(--radius); padding: 22px 20px; box-shadow: var(--shadow); }
.hero h1 { margin: 0 0 6px; font-size: 28px; line-height: 1.2; font-weight: 900; }
.hero p { margin: 0 0 14px; font-size: 16px; }
.goal { display: flex; align-items: center; gap: 12px; }
.bar { flex: 1; height: 12px; background: rgba(0,0,0,.12); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: #111; border-radius: 99px; transition: width .3s; }
.section-title { margin: 26px 0 10px; font-size: 20px; font-weight: 900; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.lesson { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; display: block; border: 1px solid var(--line); }
.lesson .cover { aspect-ratio: 16/9; background: #ddd center/cover; position: relative; }
.lesson .tag { position: absolute; bottom: 8px; left: 8px; background: var(--ok); color: #fff; font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 99px; }
.lesson .tag.pro { background: #111; color: #ffd400; }
.lesson .body { padding: 10px 14px 14px; }
.lesson h3 { margin: 0; font-size: 17px; font-weight: 900; }
.lesson .meta { color: var(--muted); font-size: 13px; }
.mini-bar { height: 6px; background: var(--line); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.mini-bar > i { display: block; height: 100%; background: var(--ok); }

.cta-card { margin-top: 18px; background: var(--soft); border: 2px dashed #e5c200; border-radius: var(--radius); padding: 16px; display: flex; gap: 14px; align-items: center; }
.cta-card .big { font-size: 34px; }
.cta-card h4 { margin: 0; font-size: 17px; }
.cta-card p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 18px; border-radius: 14px; font-weight: 800; text-decoration: none; }
.btn-dark { background: #111; color: #fff; }
.btn-brand { background: var(--brand); color: #111; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn-block { width: 100%; }

.back { display: inline-block; margin-bottom: 10px; color: var(--muted); text-decoration: none; }
.lesson-head h1 { margin: 0; font-size: 24px; font-weight: 900; }
.lesson-head .meta { color: var(--muted); }
.video { margin: 14px 0; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; background: #000 center/cover; position: relative; box-shadow: var(--shadow); }
.video button { position: absolute; inset: 0; background: rgba(0,0,0,.25); color: #fff; font-size: 18px; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.video button .play { width: 76px; height: 54px; border-radius: 14px; background: #ff0000; display: grid; place-items: center; font-size: 26px; }
.video iframe { width: 100%; height: 100%; border: 0; }

.tabs { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; margin: 10px 0 14px; }
.tabs button { flex: 1; padding: 9px 4px; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 800; }
.tabs button.on { background: var(--brand); color: #111; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card .sec { color: var(--muted); font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; }
.ask { margin-top: 10px; display: flex; gap: 8px; align-items: flex-start; }
.ask .bubble { background: var(--line); border-radius: 14px 14px 14px 4px; padding: 8px 12px; font-size: 15px; }
.icon-btn { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; background: var(--line); color: var(--ink); font-size: 15px; }
.dont { margin-top: 12px; color: var(--no); font-weight: 700; }
.dont s { color: var(--muted); font-weight: 600; }
.en { margin: 12px 0 4px; font-size: 25px; line-height: 1.3; font-weight: 800; }
.zh { color: var(--muted); font-size: 16px; }
.hidden-en { margin: 12px 0 4px; font-size: 22px; letter-spacing: 3px; color: var(--muted); }
.controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.controls .btn { padding: 12px 6px; font-size: 15px; }
.rec { margin-top: 10px; }
.rec .btn { width: 100%; font-size: 17px; padding: 15px; }
.rec .btn.live { background: var(--no); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .75; } }
.result { margin-top: 12px; padding: 12px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); }
.score { font-size: 30px; font-weight: 900; }
.w-ok { color: var(--ok); font-weight: 700; } .w-near { color: #e08a00; text-decoration: underline dotted; font-weight: 700; } .w-no { color: var(--no); text-decoration: underline wavy; font-weight: 700; }
.dict input { width: 100%; font: inherit; font-size: 18px; padding: 13px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); margin-top: 12px; }
.dict input:focus { outline: none; border-color: var(--accent); }
.nav { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; gap: 10px; }
.dots { display: flex; flex-wrap: wrap; gap: 5px; margin: 14px 0 0; }
.dots button { width: 22px; height: 22px; border-radius: 6px; background: var(--line); font-size: 10px; color: var(--muted); padding: 0; }
.dots button.done { background: var(--ok); color: #fff; }
.dots button.cur { outline: 2px solid var(--accent); }
.dots button.lock { background: transparent; border: 1px dashed var(--line); }
.locked { text-align: center; padding: 26px 18px; }
.locked .big { font-size: 46px; }
.list .row { display: flex; gap: 10px; padding: 12px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.list .row .num { color: var(--muted); width: 26px; flex: 0 0 auto; font-weight: 700; }
.list .row .t { flex: 1; } .list .row .t b { display: block; }
.list .row .t span { color: var(--muted); font-size: 14px; }

.modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet { background: var(--card); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 22px 18px 28px; max-height: 92vh; overflow: auto; }
@media (min-width: 600px) { .modal { align-items: center; } .sheet { border-radius: 22px; } }
.sheet h2 { margin: 0 0 6px; font-size: 23px; font-weight: 900; }
.sheet .perks { padding-left: 0; list-style: none; margin: 12px 0; }
.sheet .perks li { padding: 4px 0; }
.plan { display: block; border: 2px solid var(--line); border-radius: 16px; padding: 14px; margin: 10px 0; text-decoration: none; position: relative; }
.plan.best { border-color: var(--brand); background: var(--soft); }
.plan .p-name { font-weight: 900; } .plan .p-price { font-size: 22px; font-weight: 900; } .plan .p-note { color: var(--muted); font-size: 14px; }
.plan .flag { position: absolute; top: -11px; right: 12px; background: var(--no); color: #fff; font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 99px; }
.code-row { display: flex; gap: 8px; margin-top: 12px; }
.code-row input { flex: 1; font: inherit; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.close { float: right; background: transparent; font-size: 22px; color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; }
.ad { margin: 18px 0; min-height: 90px; text-align: center; }
.ad-label { font-size: 11px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 700; z-index: 30; }

/* ---------- 牛皇國牧場 (wood + cream, 養豬場 style) ---------- */
.ranch { --wood: #a8733f; --wood-d: #6e4421; --cream: #fff6dc; --brown: #5a3a1a; color: var(--brown); margin: -16px -16px 0; padding: 0 0 20px;
  background: #f3e3bf; min-height: 100vh; font-weight: 600; }
.ranch .muted { color: #8a6a45; }
.wood { background: repeating-linear-gradient(0deg, #b07a43 0 6px, #a46e3a 6px 7px, #b98450 7px 13px); border-bottom: 3px solid var(--wood-d); }
.top-board { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #fff; }
.ranch-back { color: #fff; text-decoration: none; font-size: 22px; font-weight: 900; }
.ranch-title { flex: 1; font-size: 20px; font-weight: 900; text-shadow: 0 2px 0 var(--wood-d); }
.pt { background: #4a2d14; color: #ffe28a; padding: 4px 12px; border-radius: 10px; font-size: 16px; }
.wood-tabs { display: flex; gap: 4px; padding: 8px 8px 0; background: #8d5a2b; overflow-x: auto; scrollbar-width: none; }
.wood-tabs button { flex: 1 0 auto; padding: 8px 10px; border-radius: 10px 10px 0 0; background: #6e4421; color: #f3e3bf; font-weight: 900; font-size: 15px; white-space: nowrap; }
.wood-tabs button.on { background: #ffe28a; color: var(--brown); }
.cream { background: var(--cream); border: 3px solid var(--wood); border-radius: 16px; padding: 14px; margin: 12px; box-shadow: 0 3px 0 var(--wood-d); }
.cream h3 { margin: 0 0 8px; font-size: 19px; font-weight: 900; }
.center-box { text-align: center; }
.wood-btn { display: inline-block; text-align: center; background: linear-gradient(#ffd85c, #f4b92a); color: var(--brown); border: 2px solid var(--wood-d); border-radius: 12px;
  padding: 9px 14px; font-weight: 900; box-shadow: 0 3px 0 var(--wood-d); text-decoration: none; line-height: 1.2; }
.wood-btn small { font-weight: 700; } .wood-btn[disabled] { filter: grayscale(1); opacity: .6; }
.link-btn { background: none; color: #3b6fd8; text-decoration: underline; padding: 2px 4px; font-weight: 700; }
.ghost-link { color: var(--brown); font-weight: 800; }
.ranch-foot { display: flex; justify-content: space-between; align-items: center; margin: 14px 12px 0; }
.pasture { position: relative; height: 440px; overflow: hidden; border-bottom: 4px solid var(--wood-d); }
.pasture-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.pasture-front { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 40px; pointer-events: none; }
.head-count { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: var(--cream); border: 2px solid var(--wood-d); border-radius: 8px; padding: 2px 12px; font-size: 13px; }
.truck { position: absolute; right: 10px; top: 92px; background: none; padding: 0; }
.truck.ready { animation: bob 1.2s ease-in-out infinite; }
.bubble-tip { position: absolute; top: -26px; left: 4px; background: #fff; border: 2px solid var(--wood-d); border-radius: 10px; padding: 1px 8px; font-size: 12px; font-weight: 900; color: var(--brown); white-space: nowrap; }
.cow { position: absolute; background: none; padding: 0; transform: translate(-50%, -50%); animation: wander 12s ease-in-out infinite; display: flex; flex-direction: column; align-items: center; }
.cow-flip { display: block; animation: face 12s steps(1) infinite; }
@keyframes wander { 0%, 5% { translate: 0 0; } 45%, 55% { translate: var(--d) 0; } 95%, 100% { translate: 0 0; } }
@keyframes face { 0% { transform: scaleX(1); } 50% { transform: scaleX(-1); } }
.cow.sel .cow-svg { filter: drop-shadow(0 0 0 #fff) drop-shadow(0 0 4px #ffd400) drop-shadow(0 0 2px #ffd400); }
.cow-name { font-size: 12px; background: rgba(255,246,220,.9); border-radius: 8px; padding: 0 6px; margin-top: -4px; color: var(--brown); font-weight: 800; }
.cow-mood { position: absolute; top: -18px; right: -8px; font-size: 16px; }
.poop { position: absolute; background: none; padding: 0; }
.feed-tray { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; padding: 8px; background: repeating-linear-gradient(90deg, #b07a43 0 40px, #a46e3a 40px 42px); border-bottom: 3px solid var(--wood-d); }
.feed { background: var(--cream); border: 2px solid var(--wood-d); border-radius: 10px; padding: 4px 0; display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--brown); font-weight: 800; }
.feed-ico { font-size: 24px; line-height: 1.2; } .feed.locked { opacity: .55; }
.cow-card-head { display: flex; gap: 10px; align-items: center; }
.cow-title { font-size: 18px; } .cow-title .muted { font-size: 13px; }
.meter, .stat-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; font-size: 14px; }
.stat-row span:first-child { width: 64px; }
.m-bar { flex: 1; height: 12px; border-radius: 99px; background: #ead7ad; border: 2px solid var(--wood-d); overflow: hidden; }
.m-bar > i { display: block; height: 100%; background: #f4b92a; }
.trophies { margin-top: 4px; }
.warn { color: #b3471d; margin-top: 6px; }
.shop-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 2px dashed #e6cf9f; }
.shop-row:last-child { border-bottom: 0; }
.contest-row { display: flex; align-items: center; gap: 10px; }
.contest-ico { font-size: 36px; }
.crown-box { margin-top: 8px; font-size: 20px; font-weight: 900; text-align: center; background: #ffe28a; border-radius: 12px; padding: 8px; }
.pick-cows { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin: 8px 0; }
.pick-cow { background: #fff; border: 2px solid var(--wood); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; align-items: center; color: var(--brown); font-size: 13px; }
.pick-cow.on { background: #ffe28a; border-color: var(--wood-d); } .pick-cow[disabled] { opacity: .5; }
.quiz-opt { display: block; width: 100%; text-align: left; background: #fff; border: 2px solid var(--wood); border-radius: 12px; padding: 12px; margin: 8px 0; font-size: 17px; color: var(--brown); font-weight: 700; }
.arena { text-align: center; } .arena-cow { animation: bob 1s ease-in-out infinite; }
.log-line { background: #fff; border-radius: 10px; padding: 8px 10px; margin: 6px 0; text-align: left; animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.board { width: 100%; border-collapse: collapse; margin: 10px 0; }
.board td { padding: 6px; border-bottom: 1px dashed #e6cf9f; text-align: left; } .board tr.me { background: #ffe28a; font-weight: 900; }
.result-msg { font-size: 18px; font-weight: 900; margin: 8px 0 12px; }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.dex-cell { background: #fff; border: 2px solid var(--wood); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; align-items: center; font-size: 13px; }
.dex-cell.unknown svg { filter: brightness(0) opacity(.25); }
.pop { position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); width: 82%; max-width: 320px; background: var(--cream); border: 4px solid var(--wood-d);
  border-radius: 16px; padding: 12px; box-shadow: 0 6px 0 var(--wood-d), 0 12px 30px rgba(0,0,0,.3); z-index: 3; }
.pop-head { display: flex; align-items: center; gap: 8px; font-size: 18px; } .pop-ico { font-size: 34px; } .pop-price { margin-left: auto; color: #d9433a; font-weight: 900; }
.pop-label { background: #ffe28a; border-radius: 6px; padding: 2px 10px; margin: 8px 0 4px; font-weight: 900; }
.pop-text { background: #fff; border-radius: 8px; padding: 8px 10px; font-size: 14px; }
.pop-q { text-align: center; margin: 10px 0 6px; font-weight: 900; }
.pop-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; } .pop-btns .wood-btn { font-size: 18px; }
.sex-badge { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: #fff; font-weight: 900; border: 2px solid #fff; box-shadow: 0 0 0 2px var(--wood-d); }
.sex-badge.m { background: #2f7de1; } .sex-badge.f { background: #ec6b9a; }
.stars { color: #f0a020; letter-spacing: 1px; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 6px 0; font-size: 13px; }
.info-grid span { background: #ffe28a; border-radius: 4px; padding: 0 6px; text-align: center; } .info-grid b { background: #fff; border-radius: 4px; padding: 0 6px; }
.plaza-scene { position: relative; height: 90px; background: linear-gradient(#cfeefa 0 55%, #c6e3a0 55%); border-bottom: 4px solid var(--wood-d); }
.heart-tree { position: absolute; bottom: 10px; transform: translateX(-50%); filter: hue-rotate(-10deg) saturate(.7); }

@keyframes bob { 50% { transform: translateY(-4px); } }
.mini-game { position: relative; display: inline-flex; align-items: center; gap: 3px; padding: 4px 9px; border-radius: 99px; background: #f3e3bf;
  border: 2px solid #a8733f; box-shadow: 0 2px 0 #6e4421; text-decoration: none; font-size: 16px; line-height: 1; white-space: nowrap; }
.mini-game span { font-size: 12px; font-weight: 900; color: #5a3a1a; }
.mini-game[hidden] { display: none; }
.mini-game.alert-dot::after { content: ''; position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; border-radius: 50%; background: #e0322f; border: 2px solid #fff; }
.logo, .pro-btn { white-space: nowrap; }
@media (max-width: 420px) {
  .top { padding: 10px 10px; } .stats { gap: 6px; } .logo { font-size: 16px; gap: 6px; }
  .pro-btn { padding: 6px 10px; font-size: 13px; } .mini-game { padding: 4px 7px; }
}
/* Cow Kingdom: English first, small Chinese hint */
.ranch small.zh { display: block; font-size: .74em; font-weight: 600; color: #8a6a45; opacity: .9; margin-top: 1px; line-height: 1.3; }
.ranch small.zh-i { font-size: .74em; font-weight: 600; color: #8a6a45; opacity: .9; }
.ranch .wood-tabs small.zh { color: inherit; opacity: .75; font-size: 11px; }
.ranch .ranch-title small.zh { color: #ffe9c2; font-size: 12px; text-shadow: none; }
.ranch .wood-btn small { display: block; }
.ranch .log-line small.zh { margin-top: 3px; }
.ranch .info-grid small.zh { font-size: 10px; }

/* ---------- English first, Chinese supporting ---------- */
small.t-zh { display: block; font-size: .72em; font-weight: 600; opacity: .72; line-height: 1.35; margin-top: 1px; }
small.t-zhi { font-size: .78em; font-weight: 600; opacity: .72; }
.hero-zh { font-size: 15px; font-weight: 700; opacity: .75; margin: 2px 0 8px; }
.logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.logo-text small { font-size: 11px; font-weight: 700; opacity: .65; }
.mini-game span { display: flex; flex-direction: column; line-height: 1; }
.mini-game span small { font-size: 9px; opacity: .75; font-weight: 700; }
.zh-toggle { display: inline-flex; border: 2px solid var(--line); border-radius: 99px; overflow: hidden; flex: 0 0 auto; }
.zh-toggle button { background: transparent; color: var(--muted); font-weight: 800; font-size: 13px; padding: 4px 8px; }
.zh-toggle button.on { background: var(--brand); color: #111; }
.lesson h3 small.t-zh { font-size: 13px; }
.tabs button small.t-zh { font-size: 11px; }
.controls .btn { flex-direction: column; } .controls .btn small.t-zh { font-size: 11px; }
.nav .btn { flex-direction: column; }
.btn small.t-zh { color: inherit; }
@media (max-width: 420px) {
  .logo-text { display: none; }
  .zh-toggle button { padding: 4px 6px; font-size: 12px; }
}
.new-badge { position: absolute; top: 8px; right: 8px; background: #e0322f; color: #fff; font-size: 12px; font-weight: 900; padding: 2px 9px; border-radius: 99px; letter-spacing: .5px; }
.growing { font-size: 13px; font-weight: 700; color: var(--ok); margin-left: 6px; }
