/* 閱讀理解小樂園 · reading-p1-v1 */
@font-face {
  font-family: "Free HK Kai";
  src: url("../fonts/Free-HK-Kai_4700-v1.02.woff2") format("woff2"),
       url("../fonts/Free-HK-Kai_4700-v1.02.ttf") format("truetype");
  font-display: swap;
}
:root {
  --bg: #fff4e2;
  --bg2: #ffe8c8;
  --paper: #fffdf8;
  --ink: #3a2c24;
  --muted: #7a6558;
  --line: #f0d9b8;
  --sun: #ffd166;
  --sky: #6ec7f0;
  --mint: #7ed9a3;
  --coral: #ff8a70;
  --pink: #ff9eb5;
  --lilac: #c9b6ff;
  --leaf: #3d8b6a;
  --warn: #c45c3e;
  --shadow: 0 10px 28px rgba(80, 50, 20, 0.10);
  --kai: "Free HK Kai", "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", sans-serif;
  --sc: "PingFang SC", "Noto Sans SC", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --radius: 22px;
  --tap: 48px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
#app { min-height: 100dvh; }
body[data-screen="practice"],
body[data-screen="similar"] {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
body[data-screen="practice"] #app,
body[data-screen="similar"] #app {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
body {
  font-family: var(--kai);
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, #ffe3a3 0 80px, transparent 81px),
    radial-gradient(circle at 92% 4%, #ffc2d4 0 70px, transparent 71px),
    radial-gradient(circle at 80% 92%, #bfe9ff 0 90px, transparent 91px),
    linear-gradient(180deg, var(--bg), var(--bg2));
  background-attachment: fixed;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}
body[data-script="simp"] .cjk-content,
body[data-script="simp"] .char-card-char,
body[data-script="simp"] .ex-text {
  font-family: var(--sc);
}
button, input, textarea, select { font-family: inherit; font-size: 1rem; color: inherit; }
button {
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  min-height: var(--tap);
  padding: 0.45rem 1.1rem;
  background: var(--sun);
  color: var(--ink);
  box-shadow: 0 3px 0 rgba(180, 120, 20, 0.25);
}
button:active { transform: translateY(1px); box-shadow: none; }
button.secondary { background: #fff; border: 2px solid var(--line); box-shadow: none; }
button.sky { background: var(--sky); color: #07364a; }
button.mint { background: var(--mint); color: #114028; }
button.coral { background: var(--coral); color: #4a160c; }
button.pink { background: var(--pink); color: #4a1020; }
button.quiet {
  background: transparent;
  box-shadow: none;
  min-height: 40px;
  color: var(--muted);
  font-size: 0.9rem;
}
button[disabled] { opacity: 0.45; cursor: not-allowed; }
button.current { outline: 3px solid var(--ink); outline-offset: 2px; }
.icon-btn { width: var(--tap); min-width: var(--tap); padding: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
body[data-screen="practice"] .app,
body[data-screen="similar"] .app {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.topbar, .foot { flex-shrink: 0; }
.topbar, .parent-corner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar { justify-content: space-between; margin-bottom: 12px; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand h1 { margin: 0; font-size: 1.55rem; font-weight: 400; letter-spacing: 0.04em; }
.badge { font-size: 0.78rem; color: var(--muted); }
.parent-corner { margin-left: auto; justify-content: flex-end; }
.parent-corner .danger {
  background: transparent;
  border: 1px dashed #d8b89a;
  color: var(--muted);
  font-size: 0.82rem;
  min-height: 36px;
  padding: 0.25rem 0.7rem;
  box-shadow: none;
}
.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem;
  border: 2px solid #ffe9c4;
}
.hero { text-align: center; padding: 1.6rem 1.2rem 1.3rem; }
.hero .emoji { font-size: 3rem; line-height: 1; }
.hero p { margin: 0.4rem 0 0; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grid { display: grid; gap: 12px; }
.grades { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 800px) { .grades { grid-template-columns: repeat(6, 1fr); } }
.grade-btn {
  border-radius: 18px;
  min-height: 88px;
  background: #fff;
  border: 3px solid var(--line);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
}
.grade-btn strong { font-size: 1.4rem; font-weight: 400; }
.grade-btn span { font-size: 0.85rem; color: var(--muted); }
.grade-btn.open { background: #fff6c8; border-color: #f0c44a; }
.grade-btn.locked { background: #f6f1ea; color: var(--muted); }
.filters { margin: 12px 0; }
.pass-list { grid-template-columns: 1fr; }
@media (min-width: 720px) { .pass-list { grid-template-columns: 1fr 1fr; } }
.pass-card {
  text-align: left;
  border-radius: 18px;
  background: #fff;
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  padding: 0.9rem 1rem;
  min-height: 96px;
  display: flex; flex-direction: column; gap: 4px;
}
.pass-card .lv { display: inline-block; font-size: 0.78rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: #e8f8ee; }
.pass-card .lv.mid { background: #fff3c4; }
.pass-card .lv.hard { background: #ffe0d4; }
.done-tag { color: var(--leaf); font-size: 0.85rem; }
.source { font-size: 0.8rem; color: var(--muted); }
.practice {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(34vh, 42vh) 1fr auto;
  gap: 10px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
body[data-screen="practice"] .practice,
body[data-screen="similar"] .practice {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
@media (min-width: 900px) and (orientation: landscape) {
  .practice {
    grid-template-columns: 1.05fr 0.95fr;
    grid-template-rows: 1fr auto;
  }
  .practice .passage-pane { grid-row: 1 / span 1; }
  .practice .quest-pane { grid-row: 1 / span 1; }
  .practice .foot { grid-column: 1 / -1; }
}
.passage-pane, .quest-pane {
  position: relative;
  background: var(--paper);
  border-radius: var(--radius);
  border: 2px solid #ffe9c4;
  box-shadow: var(--shadow);
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.pane-head {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff8ec;
  border-radius: calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0 0;
  flex-shrink: 0;
}
.pane-body { position: relative; overflow: auto; padding: 12px 14px 18px; flex: 1; min-height: 0; }
.passage-text { font-size: 1.22rem; letter-spacing: 0.03em; }
.passage-text p { margin: 0 0 0.9em; }
.sent { border-radius: 6px; transition: background 0.15s; }
.sent.on { background: #fff3a0; }
.ch {
  cursor: pointer;
  border-radius: 4px;
  padding: 0 1px;
}
.ch:hover { background: #d8f1ff; }
.ch.on { background: #ffb4e0; box-shadow: 0 0 0 2px #ff7eb3; }
.vocab { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.vocab button { background: #efe5ff; min-height: 42px; }
.q-item { margin-bottom: 1rem; padding-bottom: 0.8rem; border-bottom: 1px dashed var(--line); }
.q-item h3 { margin: 0 0 0.4rem; font-size: 1.08rem; font-weight: 400; }
.opts { display: grid; gap: 8px; }
.opt {
  text-align: left;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  box-shadow: none;
  min-height: 52px;
}
.opt.picked { background: #d8f3ff; border-color: #4aa8d8; }
.opt.read-btn { min-width: 42px; width: 42px; padding: 0; background: #fff3c8; }
.opt-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: stretch; }
.order-box { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.order-slot {
  width: 3rem; height: 3rem; border: 2px dashed #d2b48c; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; background: #fff;
}
.draw-layer {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 3;
}
.draw-layer.on { pointer-events: auto; touch-action: none; }
.char-modal {
  position: fixed; inset: 0; background: rgba(40, 24, 10, 0.35);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 40;
}
.char-card {
  max-height: 88dvh;
  overflow: auto;
  background: #fffdf6;
  border-radius: 28px;
  padding: 1.2rem 1.3rem 1.1rem;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.18);
  border: 3px solid #ffd166;
  text-align: center;
}
.char-card-char {
  font-size: 6rem;
  line-height: 1.05;
  margin: 0.2rem 0 0.1rem;
}
.pinyin { font-size: 1.35rem; color: #315c8a; letter-spacing: 0.08em; font-family: "PingFang TC", "Noto Sans", sans-serif; }
.examples { text-align: left; margin-top: 0.8rem; display: grid; gap: 8px; }
.ex {
  background: #fff8e8;
  border-radius: 14px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
}
.ex-text { font-size: 1.05rem; }
.ex-src { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.foot { font-size: 0.82rem; color: var(--muted); text-align: center; padding: 8px 4px 0; }
.modal-actions { display: flex; justify-content: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.code-box {
  font-family: "SF Mono", "Menlo", "Courier New", monospace;
  font-size: 1.6rem;
  letter-spacing: 0.12em;
  background: #fff6c8;
  border-radius: 14px;
  padding: 0.6rem 0.8rem;
  border: 2px dashed #f0c44a;
  text-align: center;
}
.field { width: 100%; padding: 0.7rem 0.8rem; border-radius: 14px; border: 2px solid var(--line); background: #fff; min-height: var(--tap); }
.icons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.icon-pick {
  width: 72px; height: 72px; border-radius: 20px; font-size: 2rem;
  background: #fff; border: 3px solid var(--line); box-shadow: var(--shadow);
}
.icon-pick.current { border-color: #f0c44a; background: #fff6c8; }
.notice { background: #eef8ff; border-radius: 14px; padding: 0.7rem 0.9rem; font-size: 0.92rem; }
.warnbox { background: #fff1e8; border-radius: 14px; padding: 0.7rem 0.9rem; }
.result-score { font-size: 2rem; text-align: center; margin: 0.4rem 0; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
