/* 練習簿風格：綠色方格紙、粉圓字體、大按鈕 */
:root {
  --paper: #fbfcf6;
  --grid: #d7e8d9;
  --grid-strong: #b9d6bd;
  --ink: #23343b;
  --ink-soft: #5a6b70;
  --math: #2f6fc0;
  --english: #c98a00;
  --gomoku: #8a5a2b;
  --empathy: #c94f7c;
  --good: #2e8b57;
  --bad: #c0392b;
  --card: #ffffff;
  --line: #d9e2dc;
  --radius-big: 22px;
  --radius-small: 12px;
  --shadow: 0 2px 0 #c7d6ca;
  font-size: 18px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: "Huninn", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 4px solid #f3c33c;
  outline-offset: 2px;
}

a { color: inherit; }

/* 頁首 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: rgba(251, 252, 246, 0.94);
  border-bottom: 2px solid var(--grid-strong);
}
.topbar .back {
  border: 0; background: none; font-size: 1.6rem; line-height: 1;
  padding: 6px 10px; border-radius: 10px;
}
.topbar .back[hidden] { display: none; }
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }
.topbar .stars { font-size: 1rem; white-space: nowrap; }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px 80px; }

/* 首頁 */
.hello { margin: 8px 0 22px; }
.hello h2 { font-size: 2.2rem; margin: 0; line-height: 1.25; }
.hello p { margin: 6px 0 0; color: var(--ink-soft); }

.subjects { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.subject {
  display: flex; flex-direction: column; justify-content: space-between;
  min-height: 150px; padding: 16px;
  border: 3px solid var(--c); border-radius: var(--radius-big);
  background: var(--card); text-decoration: none;
  box-shadow: 0 4px 0 var(--c);
}
.subject:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--c); }
.subject .icon { font-size: 2.6rem; line-height: 1; }
.subject .name { font-size: 1.5rem; font-weight: bold; color: var(--c); }
.subject .meta { font-size: .85rem; color: var(--ink-soft); }
.subject.math { --c: var(--math); }
.subject.english { --c: var(--english); }
.subject.gomoku { --c: var(--gomoku); }
.subject.empathy { --c: var(--empathy); }

.install {
  margin-top: 22px; padding: 14px 16px; border-radius: var(--radius-small);
  background: var(--card); border: 2px dashed var(--grid-strong); font-size: .9rem;
}
.install button { margin-top: 8px; }

/* 單元列表 */
.unit-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.unit-link {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  background: var(--card); border: 2px solid var(--line); border-left: 8px solid var(--c);
  border-radius: var(--radius-small); text-decoration: none;
}
.unit-link .num {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: bold;
  background: var(--c); color: #fff;
}
.unit-link .t { flex: 1; }
.unit-link .t b { display: block; font-size: 1.1rem; }
.unit-link .t span { font-size: .85rem; color: var(--ink-soft); }
.unit-link .got { font-size: 1rem; letter-spacing: 1px; }
.subject-intro { margin: 0 0 16px; color: var(--ink-soft); }

/* 分頁切換 */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button {
  flex: 1; padding: 12px; border-radius: var(--radius-small);
  border: 3px solid var(--c); background: var(--card); font-size: 1.1rem; font-weight: bold;
}
.tabs button[aria-selected="true"] { background: var(--c); color: #fff; }

/* 教學頁 */
.lesson { display: grid; gap: 14px; }
.lesson .block {
  background: var(--card); border-radius: var(--radius-small);
  border: 2px solid var(--line); padding: 16px;
}
.lesson h3 { margin: 0 0 8px; font-size: 1.25rem; color: var(--c); }
.lesson p { margin: 6px 0; }
.lesson .big { font-size: 1.6rem; text-align: center; margin: 10px 0; letter-spacing: 1px; }
.lesson .tip { background: #fff8db; border-color: #f0dc8c; }
.lesson .go {
  justify-self: center; padding: 14px 34px; font-size: 1.2rem; font-weight: bold;
  border: 0; border-radius: 999px; background: var(--c); color: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
}

.speak {
  border: 2px solid var(--line); background: #fff; border-radius: 999px;
  padding: 2px 10px; font-size: .95rem; vertical-align: middle;
}

/* 單字卡 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.wcard {
  border: 2px solid var(--line); border-radius: var(--radius-small); background: #fff;
  padding: 10px 6px; text-align: center;
}
.wcard .pic { font-size: 2.4rem; line-height: 1.2; }
.wcard .en { font-size: 1.15rem; font-weight: bold; }
.wcard .zh { font-size: .85rem; color: var(--ink-soft); }
.swatch { display: inline-block; width: 46px; height: 46px; border-radius: 50%; border: 2px solid #9aa; }

/* 練習 */
.progress { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.progress i {
  width: 16px; height: 16px; border-radius: 50%; background: #e3ebe5; border: 2px solid #c9d7cc;
}
.progress i.ok { background: var(--good); border-color: var(--good); }
.progress i.no { background: var(--bad); border-color: var(--bad); }
.progress i.now { border-color: var(--c); background: #fff; }

.q {
  background: var(--card); border: 3px solid var(--c); border-radius: var(--radius-big);
  padding: 18px 16px; text-align: center;
}
.q .prompt { font-size: 1.45rem; margin: 0 0 12px; line-height: 1.45; }
.q .visual { margin: 6px auto 14px; }
.q .visual.emoji { font-size: 2.1rem; line-height: 1.5; word-break: break-all; }
.q .eq { font-size: 2.4rem; font-weight: bold; margin: 8px 0 14px; letter-spacing: 2px; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.options.one { grid-template-columns: 1fr; }
.options button {
  padding: 14px 8px; min-height: 64px; font-size: 1.35rem;
  border: 3px solid var(--line); border-radius: var(--radius-small); background: #fff;
  box-shadow: var(--shadow);
}
.options.text button { font-size: 1.1rem; text-align: left; padding: 12px 14px; }
.options button.right { border-color: var(--good); background: #e5f5ea; }
.options button.wrong { border-color: var(--bad); background: #fbe7e4; }
.options button:disabled { cursor: default; }

/* 數字鍵盤 */
.answer-box {
  display: inline-block; min-width: 120px; padding: 6px 16px; font-size: 2rem; font-weight: bold;
  border: 3px dashed var(--c); border-radius: var(--radius-small); margin-bottom: 10px; min-height: 64px;
}
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin: 0 auto; }
.pad button {
  padding: 12px 0; font-size: 1.6rem; font-weight: bold; border-radius: var(--radius-small);
  border: 2px solid var(--line); background: #fff; box-shadow: var(--shadow);
}
.pad button.ok { background: var(--c); color: #fff; border-color: var(--c); }

.feedback {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-small);
  text-align: left; font-size: 1.05rem;
}
.feedback.good { background: #e5f5ea; border: 2px solid #9ccfae; }
.feedback.bad { background: #fdf0e6; border: 2px solid #f0c7a4; }
.feedback.soft { background: #f5ecf6; border: 2px solid #d7bde0; }
.feedback .talk { margin-top: 8px; font-size: .95rem; color: var(--ink-soft); }
.next {
  margin-top: 14px; padding: 12px 34px; font-size: 1.15rem; font-weight: bold;
  border: 0; border-radius: 999px; background: var(--c); color: #fff;
}

.result { text-align: center; padding: 20px 10px; }
.result .bigstars { font-size: 3.2rem; letter-spacing: 6px; }
.result h2 { margin: 6px 0; font-size: 1.8rem; }
.result .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.btn {
  padding: 12px 22px; font-size: 1.05rem; font-weight: bold; border-radius: 999px;
  border: 3px solid var(--c); background: #fff;
}
.btn.fill { background: var(--c); color: #fff; }

/* 錢幣與方塊 */
.coin {
  display: inline-grid; place-items: center; border-radius: 50%; margin: 3px;
  font-weight: bold; color: #4a3b10; border: 3px solid #a98a2c;
  background: radial-gradient(circle at 35% 30%, #fff3b8, #e2be4f);
}
.coin.c1 { width: 42px; height: 42px; font-size: .9rem; background: radial-gradient(circle at 35% 30%, #f2f2f2, #b8b8b8); border-color: #8a8a8a; color: #333; }
.coin.c5 { width: 50px; height: 50px; font-size: 1rem; background: radial-gradient(circle at 35% 30%, #f6f6f6, #c2c2c2); border-color: #8a8a8a; color: #333; }
.coin.c10 { width: 56px; height: 56px; font-size: 1.05rem; background: radial-gradient(circle at 35% 30%, #fbf3dc, #d1b46a); }
.coin.c50 { width: 64px; height: 64px; font-size: 1.15rem; }
.blocks { display: flex; gap: 10px; justify-content: center; align-items: flex-end; flex-wrap: wrap; }
.ten { display: grid; grid-template-rows: repeat(10, 12px); gap: 1px; padding: 2px; background: #1f5ea8; border-radius: 4px; }
.ten span { width: 18px; background: #6fa5e6; border-radius: 2px; }
.ones { display: grid; grid-template-columns: repeat(2, 20px); gap: 3px; }
.ones span { width: 20px; height: 20px; background: #f0a33a; border: 2px solid #c47a14; border-radius: 3px; }

/* 五子棋 */
.board-wrap { max-width: 460px; margin: 0 auto; }
.board { width: 100%; height: auto; display: block; touch-action: manipulation; }
.board .cell { cursor: pointer; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .95rem; margin: 10px 0 0; }
.toggle input { width: 22px; height: 22px; }
.dir-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dir-buttons button svg { width: 46px; height: 46px; display: block; margin: 0 auto 2px; }
.dir-buttons button { font-size: .95rem; padding: 8px 2px; }
.play-bar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.status { text-align: center; font-size: 1.15rem; min-height: 1.8em; margin: 6px 0; }
.warn { color: #b03a00; font-weight: bold; }

.parent-note {
  margin-top: 18px; padding: 12px 14px; border-radius: var(--radius-small);
  border: 2px dashed var(--grid-strong); background: #fff; font-size: .9rem; color: var(--ink-soft);
}

.pop { animation: pop .35s ease-out; }
@keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .pop { animation: none; } }

@media (max-width: 420px) {
  :root { font-size: 16px; }
  .subjects { gap: 10px; }
  .subject { min-height: 132px; padding: 12px; }
  .hello h2 { font-size: 1.8rem; }
}

/* 100 元紙鈔 */
.coin.c100 {
  width: 84px; height: 44px; border-radius: 6px; font-size: 1.1rem;
  background: linear-gradient(135deg, #f7c9c4, #e8877d); border-color: #b5544a; color: #5a1d17;
}

/* 月曆 */
.cal { border-collapse: collapse; margin: 6px auto; background: #fff; font-size: 1rem; }
.cal caption { font-weight: bold; padding: 4px; }
.cal th, .cal td { width: 40px; height: 34px; text-align: center; border: 1px solid var(--line); }
.cal th { background: #eef4f0; }
.cal td.we { color: #c0392b; }
.cal td.mk { outline: 3px solid var(--c); outline-offset: -3px; border-radius: 50%; font-weight: bold; }
@media (max-width: 420px) { .cal th, .cal td { width: 36px; height: 30px; font-size: .9rem; } }

/* 帳號：登入、選孩子、家長專區 */
.stack { display: grid; gap: 12px; max-width: 420px; margin: 0 auto; }
.big-btn { display: block; text-align: center; text-decoration: none; padding: 16px 22px; font-size: 1.15rem; width: 100%; }
.small { font-size: .88rem; color: var(--ink-soft); }
.center { text-align: center; }
.form { display: grid; gap: 12px; background: var(--card); border: 2px solid var(--line); border-radius: var(--radius-small); padding: 16px; margin: 12px 0; }
.form h3 { margin: 0; color: var(--c); }
.form label { display: grid; gap: 4px; font-weight: bold; }
.form input[type=email], .form input[type=password], .form input[name=name], .form input[name=ans] {
  font: inherit; font-weight: normal; padding: 10px 12px; border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
.form input:focus { border-color: var(--c); }
.error { color: var(--bad); margin: 0; }
.ok { color: var(--good); margin: 0; }
.error[hidden], .ok[hidden] { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-size: .95rem;
  padding: 4px 12px 4px 6px; border-radius: 999px; background: #fff; border: 2px solid var(--grid-strong);
}
.chip span { font-size: 1.35rem; line-height: 1; }

.kids { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kid {
  display: grid; justify-items: center; gap: 4px; padding: 18px 8px; text-decoration: none;
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius-big); box-shadow: 0 4px 0 var(--grid-strong);
}
.kid span { font-size: 3.6rem; line-height: 1.1; }
.kid b { font-size: 1.2rem; }
.kid.add { border-style: dashed; color: var(--ink-soft); }
.kid.add span { font-size: 2.6rem; padding: 8px 0; }
.kid:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--grid-strong); }

.avatars { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.avatars label { position: relative; }
.avatars input { position: absolute; opacity: 0; }
.avatars span { display: grid; place-items: center; font-size: 1.7rem; aspect-ratio: 1; border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.avatars input:checked + span { border-color: var(--c); background: #eaf2fc; box-shadow: 0 0 0 2px var(--c); }
.avatars input:focus-visible + span { outline: 4px solid #f3c33c; }
@media (max-width: 420px) { .avatars { grid-template-columns: repeat(4, 1fr); } }

.panel { background: var(--card); border: 2px solid var(--line); border-radius: var(--radius-big); padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 10px; font-size: 1.3rem; }
.panel .form { border-style: dashed; }
.kid-rows { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.kid-rows li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border: 2px solid var(--line); border-radius: var(--radius-small); }
.kid-rows .av { font-size: 2rem; }
.kid-rows b { flex: 1; font-size: 1.1rem; }
.kid-rows .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.kid-rows .detail { flex-basis: 100%; }
.kid-rows .detail:empty { display: none; }
.btn.sm { padding: 6px 12px; font-size: .9rem; border-width: 2px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.row-btns .btn { text-decoration: none; }
.report { width: 100%; border-collapse: collapse; font-size: .95rem; margin: 8px 0; }
.report th, .report td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.danger summary { color: var(--bad); cursor: pointer; margin-top: 8px; }
.danger-btn { border-color: var(--bad); color: var(--bad); }

a.btn { text-decoration: none; display: inline-block; text-align: center; }
.report tbody th, .report td:nth-child(2) { white-space: nowrap; }
