/* 學測自然練習 [touhou_gsatsci]
 * 全部規則只作用在 #tgs（練習本體）與 #tgs-zoom（點圖放大的全螢幕層，掛在 body 底下）。
 * 前半段是「防主題干擾」的重設：主題對 button / img / a / h1 / p / ol 等元素下的樣式，
 * 只要我們沒有明講同一個屬性就會滲進來，所以把會被動到的屬性先在 #tgs 裡講死。 */

/* ---------- 防主題干擾 ---------- */
#tgs, #tgs *, #tgs *::before, #tgs *::after { box-sizing: border-box; }
#tgs * {
  font-family: inherit; letter-spacing: normal; text-transform: none; text-shadow: none;
  word-spacing: normal; text-indent: 0; float: none;
}
#tgs div, #tgs span, #tgs p, #tgs li, #tgs b, #tgs small, #tgs label { line-height: inherit; }
#tgs p, #tgs ol, #tgs ul, #tgs li, #tgs details, #tgs summary, #tgs picture { font-size: inherit; }
#tgs img { max-width: 100%; height: auto; border: 0; border-radius: 0; box-shadow: none; padding: 0; margin: 0; opacity: 1; filter: none; }
#tgs a { text-decoration: underline; text-underline-offset: 2px; box-shadow: none; background: none; border: 0; }
#tgs button, #tgs select {
  text-transform: none; letter-spacing: normal; box-shadow: none; text-shadow: none;
  line-height: 1.3; width: auto; height: auto; margin: 0; outline-offset: 2px;
  background-image: none; transform: none; transition: background-color .15s, border-color .15s;
}
#tgs button:focus-visible, #tgs select:focus-visible, #tgs .qimg:focus-visible { outline: 2px solid #2A5A87; }
#tgs ol, #tgs ul { list-style-position: outside; }
#tgs ol { list-style-type: decimal; }
#tgs ul { list-style-type: disc; }
#tgs details { display: block; }
#tgs summary { display: list-item; }
#tgs svg.i { display: inline-block; vertical-align: middle; max-width: none; }
#tgs .card, #tgs .msg, #tgs .weak, #tgs .progress, #tgs .qimg, #tgs .tgs-loading, #tgs .sol { display: block; }
#tgs .opt, #tgs .chip, #tgs .qlist button { text-align: center; }
#tgs .btn { justify-content: center; text-align: center; }
#tgs h1::before, #tgs h1::after, #tgs h2::before, #tgs h2::after, #tgs h3::before, #tgs h3::after { content: none; }

/* ---------- 版面 ---------- */
#tgs {
  --bg:#F6F1E9; --card:#FFFDF9; --ink:#16233d; --ink2:#4a5468; --line:#E4DACB;
  --brand:#a8705c; --brand-dk:#8F5B48; --brand-soft:#F1E4DC;
  --ok:#2F6B45; --ok-bg:#E9F0EA; --err:#C0392B; --err-bg:#F8E9E5;
  --info:#2A5A87; --info-bg:#E8EEF3; --warn:#8A6100; --warn-bg:#F3ECDD;
  font-family: "Noto Sans TC", system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink); background: var(--bg);
  line-height: 1.65; font-size: 16px; font-weight: 400; text-align: left; -webkit-text-size-adjust: 100%;
  max-width: 760px; width: 100%; margin: 0 auto; padding: 20px 16px 48px; border-radius: 16px;
  min-height: 360px;
}
#tgs .tgs-loading { color: var(--ink2); padding: 40px 0; text-align: center; }
#tgs h1, #tgs h2, #tgs h3 { font-family: "Noto Serif TC", "Songti TC", serif; color: var(--ink); line-height: 1.35; margin: 0; padding: 0; font-weight: 600; border: 0; background: none; }
#tgs h1 { font-size: 26px; } #tgs h2 { font-size: 20px; } #tgs h3 { font-size: 17px; }
#tgs p { margin: .4em 0; padding: 0; color: inherit; }
#tgs .muted { color: var(--ink2); font-size: 14px; }
#tgs .card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin: 14px 0; }
#tgs .btn { appearance: none; -webkit-appearance: none; border: 1.5px solid var(--brand); background: var(--brand); color: #fff; font: inherit; font-size: 16px; font-weight: 500;
  border-radius: 10px; padding: 11px 18px; min-height: 46px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
#tgs .btn:hover, #tgs .btn:focus { background: var(--brand-dk); border-color: var(--brand-dk); color: #fff; }
#tgs .btn.ghost { background: transparent; color: var(--brand-dk); }
#tgs .btn.ghost:hover, #tgs .btn.ghost:focus { background: var(--brand-soft); color: var(--brand-dk); }
#tgs .btn.small { min-height: 38px; padding: 7px 13px; font-size: 15px; }
#tgs .btn[disabled] { opacity: .45; cursor: default; }
#tgs .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
#tgs .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
#tgs .chip { appearance: none; -webkit-appearance: none; border: 1.5px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 15px; font-weight: 400; cursor: pointer; min-height: 42px; }
#tgs .chip:hover, #tgs .chip:focus { border-color: var(--brand); background: #fff; color: var(--ink); }
#tgs .chip b { color: var(--brand-dk); font-weight: 500; margin-left: 4px; }
#tgs .chip.on, #tgs .chip.on:hover, #tgs .chip.on:focus { border-color: var(--brand); background: var(--brand); color: #fff; }
#tgs .chip.on b { color: #fff; }
#tgs select { appearance: auto; -webkit-appearance: menulist; font: inherit; font-size: 16px; padding: 10px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); max-width: 100%; min-height: 46px; }
#tgs svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* 題目 */
#tgs .qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
#tgs .progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 6px 0 12px; }
#tgs .progress i { display: block; height: 100%; background: var(--brand); }
#tgs .qimg { display: block; margin: 0 -8px; cursor: zoom-in; position: relative; }
#tgs .qimg img { display: block; width: 100%; height: auto; background: #fff; border-radius: 8px; min-height: 40px; }
#tgs .qimg .zoomtip { display: flex; justify-content: flex-end; gap: 4px; align-items: center; color: var(--ink2); font-size: 13px; margin-top: 4px; }
#tgs .qimg .zoomtip svg { width: 14px; height: 14px; }
#tgs details.passage { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; margin: 0 0 12px; background: #fff; }
#tgs details.passage summary { cursor: pointer; color: var(--brand-dk); font-weight: 500; }
#tgs .opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
#tgs .opt { appearance: none; -webkit-appearance: none; font: inherit; font-size: 20px; font-weight: 700; min-height: 56px; padding: 0 4px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }
#tgs .opt:hover:not([disabled]), #tgs .opt:focus:not([disabled]) { border-color: var(--brand); background: #fff; color: var(--ink); }
#tgs .opt.pick-wrong, #tgs .opt.pick-wrong:hover, #tgs .opt.pick-wrong:focus { border-color: var(--err); background: var(--err-bg); color: var(--err); }
#tgs .opt.pick-right, #tgs .opt.pick-right:hover, #tgs .opt.pick-right:focus { border-color: var(--ok); background: var(--ok-bg); color: var(--ok); }
#tgs .opt.is-answer { border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--ok); }
#tgs .opt[disabled] { cursor: default; opacity: 1; }
#tgs .msg { border-left: 4px solid var(--info); background: var(--info-bg); padding: 10px 12px; border-radius: 6px; margin-top: 12px; color: var(--ink); }
#tgs .msg.ok { border-color: var(--ok); background: var(--ok-bg); }
#tgs .msg.err { border-color: var(--err); background: var(--err-bg); }
#tgs .msg.warn { border-color: var(--warn); background: var(--warn-bg); }
#tgs .msg .t { font-weight: 700; display: flex; gap: 6px; align-items: center; }
#tgs .msg .t svg { width: 18px; height: 18px; }
#tgs .sol ol { margin: 6px 0 0; padding: 0 0 0 1.4em; }
#tgs .sol ul { margin: 4px 0; padding: 0 0 0 1.3em; }
#tgs .sol li { margin: 3px 0; padding: 0; }
#tgs .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#tgs .tag { font-size: 13px; border-radius: 6px; padding: 2px 8px; background: var(--brand-soft); color: var(--brand-dk); }
#tgs .tag.navy { background: #E6E9EF; color: var(--ink); }
#tgs .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
#tgs .lk { color: var(--brand-dk); font-weight: 500; }
#tgs .lk:hover { color: var(--ink); }

/* 結果 */
#tgs .score { font-family: "Noto Serif TC", "Songti TC", serif; font-size: 44px; font-weight: 600; color: var(--ink); line-height: 1; }
#tgs .score small { font-size: 20px; color: var(--ink2); }
#tgs .meter { display: grid; grid-template-columns: 6.5em 1fr 4.2em; gap: 10px; align-items: center; margin: 8px 0; font-size: 15px; }
#tgs .meter .bar { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; display: block; }
#tgs .meter .bar i { display: block; height: 100%; background: var(--ink); }
#tgs .meter .bar i.low { background: var(--brand); }
#tgs .meter .v { text-align: right; font-variant-numeric: tabular-nums; }
#tgs .weak { border-left: 4px solid var(--brand); padding: 8px 12px; margin: 10px 0; background: var(--brand-soft); border-radius: 6px; }
#tgs .weak a { color: var(--brand-dk); font-weight: 500; }
#tgs .qlist { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 10px; }
#tgs .qlist button { appearance: none; -webkit-appearance: none; font: inherit; font-size: 14px; min-height: 44px; padding: 0 2px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; color: var(--ink); }
#tgs .qlist button.r, #tgs .qlist button.r:hover, #tgs .qlist button.r:focus { border-color: var(--ok); color: var(--ok); background: #fff; }
#tgs .qlist button.w, #tgs .qlist button.w:hover, #tgs .qlist button.w:focus { border-color: var(--err); color: var(--err); background: #fff; }

/* 點圖放大（掛在 body 底下，避免祖先元素的 transform 讓 position:fixed 失效） */
#tgs-zoom { position: fixed; inset: 0; background: rgba(22,35,61,.92); z-index: 999999; display: none; overflow: auto; -webkit-overflow-scrolling: touch; }
#tgs-zoom.on { display: block; }
#tgs-zoom img { display: block; background: #fff; margin: 56px auto 24px; max-width: none; height: auto; border: 0; border-radius: 0; box-shadow: none; padding: 0; }
#tgs-zoom button { appearance: none; -webkit-appearance: none; position: fixed; top: 10px; right: 10px; font: 16px/1.3 "Noto Sans TC", system-ui, sans-serif; text-transform: none; letter-spacing: normal;
  border: 0; border-radius: 10px; padding: 9px 14px; margin: 0; min-height: 0; width: auto; background: #fff; color: #16233d; cursor: pointer; box-shadow: none; }
#tgs-zoom button:hover, #tgs-zoom button:focus { background: #F1E4DC; color: #16233d; }
#tgs-zoom .z { position: fixed; top: 10px; left: 10px; display: flex; gap: 8px; }
#tgs-zoom .z button { position: static; }
body.tgs-noscroll { overflow: hidden; }

/* 手機上網站右下角有小助教浮動鈕（約 100px 高），底部多留白，最後一排按鈕與 LINE 連結才不會被蓋住 */
@media (max-width: 520px) {
  #tgs { padding: 14px 12px 104px; border-radius: 12px; }
  #tgs h1 { font-size: 23px; }
  #tgs .card { padding: 14px 12px; }
  #tgs .qimg { margin: 0 -6px; }
  #tgs .opts { gap: 8px; }
}

/* ---------- 學測自然：多選、非選、題組 ---------- */
#tgs .opts.n4 { grid-template-columns: repeat(4, 1fr); }
#tgs .opts.n5 { grid-template-columns: repeat(5, 1fr); }
#tgs .opts.n6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 520px) { #tgs .opts.n6 { grid-template-columns: repeat(3, 1fr); } #tgs .opt { font-size: 18px; } }
#tgs .opt.sel, #tgs .opt.sel:hover, #tgs .opt.sel:focus { border-color: var(--info); background: var(--info-bg); color: var(--info); }
#tgs .opt.miss { border-color: var(--ok); border-style: dashed; color: var(--ok); }
#tgs .qtype { display: inline-block; font-size: 13px; border-radius: 6px; padding: 1px 8px; margin-left: 6px; background: var(--brand-soft); color: var(--brand-dk); vertical-align: 1px; }
#tgs .qtype.multi { background: var(--info-bg); color: var(--info); }
#tgs .qtype.non { background: var(--warn-bg); color: var(--warn); }
#tgs .note { font-size: 14px; color: var(--ink2); margin-top: 10px; }
#tgs .nc { border-left: 4px solid var(--warn); background: var(--warn-bg); padding: 10px 12px; border-radius: 6px; margin-top: 12px; }
#tgs .nc ul { margin: 6px 0 0; padding: 0 0 0 1.3em; }
#tgs .selfcheck { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
#tgs .credit { font-size: 13px; color: var(--ink2); margin: 2px 0 8px; }
#tgs .chips + .chips { margin-top: 6px; }
#tgs .subj-label { font-size: 14px; color: var(--ink2); margin: 12px 0 0; }
