:root {
  --bg: #f1ece3; --panel: #fff; --panel2: #faf7f1; --line: #e2dace; --line2: #cfc3b2;
  --tx: #13293d; --tx2: #4a5a6b; --tx3: #63717f;
  --accent: #1b4f7a; --gold: #c9a24b; --red: #b31212; --ok: #2e7d5b; --warn: #96670d;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--tx);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.6;
}
a { color: var(--accent); }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 48px; padding: 10px 20px; border-radius: 10px;
  border: 1.5px solid var(--line2); background: var(--panel); color: var(--tx);
  font-weight: 700; font-size: 17px; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.field {
  width: 100%; min-height: 56px; padding: 12px 14px; border-radius: 10px;
  border: 1.5px solid var(--line2); background: var(--panel); color: var(--tx); font: inherit; font-size: 20px;
}
.err { color: var(--red); font-weight: 700; }

/* ---------- 首頁、說明頁 ---------- */
.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }
.site-head { display: flex; align-items: center; gap: 10px; padding: 16px 0; font-weight: 700; }
.site-head img { width: 32px; height: 32px; }
.site-head a { color: var(--tx); text-decoration: none; }
.hero h1 { font-size: clamp(32px, 6vw, 50px); line-height: 1.25; margin: 20px 0 12px; }
.hero p { font-size: 19px; color: var(--tx2); margin: 0 0 22px; }
.hero .btn { font-size: 20px; min-height: 60px; padding: 12px 32px; }
.join-box { display: flex; gap: 10px; margin-top: 22px; max-width: 460px; flex-wrap: wrap; }
.join-box label { width: 100%; font-weight: 700; }
.join-box .field { flex: 1; min-width: 160px; text-transform: uppercase; letter-spacing: .12em; }
.shot { width: 100%; height: auto; border-radius: 12px; border: 1.5px solid var(--line); display: block; margin: 28px 0; }
.card { background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px; padding: 18px 20px; margin: 16px 0; }
.card h2, .prose h2 { font-size: 24px; margin: 0 0 8px; }
.steps { padding-left: 1.4em; font-size: 18px; margin: 0; }
.steps li { margin: 6px 0; }
.recent a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); text-decoration: none; }
.recent a:first-of-type { border-top: 0; }
.recent .q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prose { font-size: 18px; padding-bottom: 12px; }
.prose h1 { font-size: clamp(30px, 5vw, 42px); line-height: 1.3; margin: 16px 0 12px; }
.prose h2 { margin-top: 32px; }
.site-foot { border-top: 1.5px solid var(--line); margin-top: 32px; padding: 20px 0 40px; color: var(--tx2); font-size: 16px; }
.site-foot a { margin-right: 14px; display: inline-block; padding: 4px 0; }

/* ---------- 學員手機頁 ---------- */
.join { min-height: 100dvh; display: flex; flex-direction: column; padding: 20px 16px 12px; max-width: 520px; margin: 0 auto; }
.join main { flex: 1; }
.join .q { font-size: 28px; font-weight: 800; line-height: 1.35; margin: 12px 0 18px; overflow-wrap: anywhere; }
.join .kicker { color: var(--tx2); font-weight: 700; font-size: 16px; }
.join .field { font-size: 24px; min-height: 64px; font-weight: 700; }
.join .send { width: 100%; min-height: 60px; font-size: 22px; margin-top: 12px; }
.join .meta { display: flex; justify-content: space-between; gap: 12px; min-height: 28px; margin-top: 8px; font-size: 16px; color: var(--tx2); }
.join .count.over { color: var(--red); font-weight: 700; }
.done { background: var(--panel); border: 2px solid var(--ok); border-radius: 14px; padding: 22px; text-align: center; }
.done .my { font-size: 38px; font-weight: 800; overflow-wrap: anywhere; line-height: 1.3; margin: 6px 0 10px; }
.done .ok { color: var(--ok); font-weight: 800; font-size: 20px; }
.notice { background: var(--panel); border: 1.5px solid var(--line2); border-radius: 14px; padding: 26px 18px; text-align: center; font-size: 22px; font-weight: 700; }
.linkbtn { background: none; border: 0; color: var(--accent); text-decoration: underline; font-size: 18px; min-height: 44px; padding: 8px; }
.join footer { text-align: center; font-size: 16px; color: var(--tx2); padding-top: 18px; }
.join footer a { color: var(--tx2); }

/* ---------- 大螢幕 ---------- */
body.screen { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
.qbar { flex: none; padding: 1.6vh 2.5vw 1vh; display: flex; align-items: flex-start; gap: 1.5vw; }
.qbar h1 { flex: 1; margin: 0; font-size: clamp(26px, 4.4vw, 76px); line-height: 1.2; font-weight: 800; overflow-wrap: anywhere; }
.pill { flex: none; margin-top: .5vh; padding: .25em .8em; border-radius: 99px; background: var(--red); color: #fff; font-weight: 800; font-size: clamp(16px, 1.7vw, 30px); }
.stage { flex: 1; min-height: 0; display: flex; gap: 2vw; padding: 0 2.5vw 1.2vh; }
#cloud { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 1.5vh 1.5vw; }
#words { width: 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .12em .55em; }
.w { background: none; border: 0; padding: 0; font-weight: 800; line-height: 1.2; white-space: nowrap; color: var(--tx); font-family: inherit; }
.w sup { font-size: .46em; font-weight: 800; color: var(--tx2); margin-left: .12em; vertical-align: .75em; }
.w.c0 { color: #13293d; } .w.c1 { color: #1b4f7a; } .w.c2 { color: #8a5a00; } .w.c3 { color: #2e6b52; } .w.c4 { color: #6b3f7a; }
.w.top { color: var(--red); }
.w.pop { animation: pop .45s ease-out; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .w.pop { animation: none; } }
.more { position: absolute; right: 16px; bottom: 8px; color: var(--tx2); font-weight: 700; font-size: clamp(15px, 1.5vw, 26px); }
.empty { text-align: center; color: var(--tx2); font-weight: 700; font-size: clamp(22px, 3vw, 52px); line-height: 1.4; }
#rail { flex: none; width: clamp(240px, 25vw, 520px); display: flex; flex-direction: column; align-items: stretch; gap: 1vh; text-align: center; min-height: 0; }
.qrbox { background: #fff; border: 2px solid var(--line); border-radius: 16px; padding: 1.2vh 1vw .6vh; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; color: var(--tx); }
.qrbox .scan { font-size: clamp(18px, 2vw, 36px); font-weight: 800; }
.qr { width: 100%; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; }
.qr svg { height: 100%; width: 100%; max-height: 100%; display: block; }
.urlline { font-weight: 800; font-size: clamp(14px, 1.45vw, 26px); overflow-wrap: anywhere; line-height: 1.25; }
.urlline b { color: var(--red); letter-spacing: .06em; }
.tally { flex: none; background: var(--tx); color: #fff; border-radius: 16px; padding: .6vh 1vw; font-weight: 800; font-size: clamp(18px, 2vw, 36px); }
.tally b { font-size: 2em; line-height: 1.1; margin: 0 .1em; }
.toolbar { flex: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0 2.5vw 1.2vh; align-items: center; transition: opacity .25s; }
.toolbar .btn { min-height: 44px; padding: 6px 14px; font-size: 16px; }
.toolbar .spacer { flex: 1; }
.net { color: var(--red); font-weight: 700; font-size: 15px; }
body.idle .toolbar { opacity: 0; }
body.idle { cursor: none; }

/* 浮層 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(19, 41, 61, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--panel); border-radius: 14px; padding: 22px; width: 100%; max-width: 620px; max-height: calc(100dvh - 32px); overflow: auto; }
.dialog h2 { margin: 0 0 10px; font-size: 26px; }
.dialog textarea.field { min-height: 90px; resize: vertical; }
.dialog .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { min-height: 44px; padding: 6px 14px; border-radius: 99px; border: 1.5px solid var(--line2); background: var(--panel2); color: var(--tx); font-size: 16px; }
.menu-item { display: block; width: 100%; text-align: left; min-height: 52px; padding: 10px 12px; background: none; border: 0; border-top: 1px solid var(--line); font-size: 18px; color: var(--tx); }
.menu-item:first-of-type { border-top: 0; }
.menu-item.danger { color: var(--red); }
.hint { color: var(--tx2); font-size: 16px; margin: 6px 0 0; }
.qr-full { position: fixed; inset: 0; z-index: 60; background: #fff; border: 0; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2vh; color: var(--tx); }
.qr-full .qr { height: 74vh; flex: none; }
.qr-full .scan { font-size: 5vh; font-weight: 800; }
.qr-full .urlline { font-size: 4vh; }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 70; background: var(--tx); color: #fff; padding: 10px 18px; border-radius: 10px; font-weight: 700; max-width: calc(100vw - 32px); }

/* 手機當遙控器：QR 收成小的、題目和詞在上面 */
@media (max-width: 760px) {
  body.screen { height: auto; min-height: 100dvh; overflow: auto; }
  .stage { flex-direction: column; padding: 0 16px 12px; }
  .qbar { padding: 12px 16px 8px; }
  .toolbar { position: sticky; bottom: 0; z-index: 10; background: var(--bg); padding: 8px 16px 12px; border-top: 1.5px solid var(--line); }
  #cloud { height: 50dvh; flex: none; }
  #rail { width: 100%; }
  .qrbox { flex-direction: column; }
  .qr { height: 180px; flex: none; }
}
