/* 每日經文 — 溫暖紙質 × 現代極簡 */
:root {
  --bg: #faf6ee;
  --card: #fffdf7;
  --ink: #2d2416;
  --ink-soft: #6f6352;
  --line: #e6dcc8;
  --gold: #a87b2d;
  --gold-soft: #f3e8d2;
  --green: #4a7c46;
  --green-bg: #e4efe0;
  --yellow: #b98f1e;
  --yellow-bg: #f7edd0;
  --gray-bg: #efeade;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(90, 70, 30, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171310;
    --card: #211c16;
    --ink: #ece2d0;
    --ink-soft: #a2947c;
    --line: #3a3226;
    --gold: #d3a856;
    --gold-soft: #33291a;
    --green: #8fbf87;
    --green-bg: #263822;
    --yellow: #d8b34a;
    --yellow-bg: #3a2f14;
    --gray-bg: #2a251d;
    --shadow: 0 2px 10px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { height: 100%; }
body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg); color: var(--ink);
  max-width: 520px; margin: 0 auto; padding: 0 14px 40px;
  min-height: 100%;
}
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px;
}
h1 { font-size: 1.15rem; letter-spacing: .12em; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.day-tag { font-size: .75rem; color: var(--gold); font-weight: 600; letter-spacing: .05em; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-soft); font-size: .95rem; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.93); }

.pet-strip {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 14px; margin-bottom: 12px; cursor: pointer;
}
.pet-strip svg { width: 58px; height: 50px; flex-shrink: 0; }
.pet-strip.happy svg { animation: hop 1.2s ease infinite; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px) rotate(-2deg); } 55% { transform: translateY(0); } }
.pet-info { flex: 1; min-width: 0; }
.pet-name { font-size: .85rem; font-weight: 700; display: flex; align-items: baseline; gap: 6px; }
.pet-stage { font-size: .7rem; color: var(--gold); font-weight: 600; }
.pet-mood { font-size: .76rem; color: var(--ink-soft); margin-top: 2px; }
.pet-bar { height: 6px; background: var(--gray-bg); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.pet-bar > div { height: 100%; background: var(--green); border-radius: 99px; transition: width .5s ease; }

.verse-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 20px 16px; margin-bottom: 14px; position: relative;
}
.verse-card::before {
  content: "“"; position: absolute; top: 2px; left: 12px;
  font-family: Georgia, serif; font-size: 2.6rem; color: var(--gold); opacity: .45; line-height: 1;
}
.verse-text {
  font-family: "Noto Serif TC", "PMingLiU", Georgia, serif;
  font-size: 1.22rem; line-height: 1.9; letter-spacing: .04em; min-height: 3.6em;
}
.verse-text .mask { color: var(--gold); letter-spacing: .1em; }
.hints { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.hint-chip {
  font-size: .78rem; padding: 4px 10px; border-radius: 999px;
  background: var(--gold-soft); color: var(--gold); border: 1px solid transparent;
  animation: pop .25s ease;
}
.hint-chip.locked { background: transparent; border: 1px dashed var(--line); color: var(--ink-soft); opacity: .55; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.guesses { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.guess-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 14px; min-height: 44px; font-size: .95rem;
}
.guess-row.empty { border-style: dashed; opacity: .45; }
.guess-row .g-num { font-size: .75rem; color: var(--ink-soft); width: 1.2em; }
.guess-row .g-book { flex: 1; font-weight: 600; }
.guess-row .g-fb { display: flex; gap: 6px; align-items: center; font-size: .85rem; }
.guess-row.correct { background: var(--green-bg); border-color: var(--green); }
.guess-row.close { background: var(--yellow-bg); border-color: var(--yellow); }
.fb-dir { color: var(--ink-soft); font-size: .8rem; }

.picker input {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 1rem; margin-bottom: 10px;
}
.picker input:focus { outline: 2px solid var(--gold); border-color: transparent; }
.bk-group-label { font-size: .74rem; color: var(--ink-soft); letter-spacing: .15em; margin: 10px 2px 6px; }
.bk-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.bk-chip {
  padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: .85rem; cursor: pointer;
}
.bk-chip:hover { border-color: var(--gold); }
.bk-chip.selected { background: var(--gold); color: #fff; border-color: var(--gold); font-weight: 700; }
.bk-chip.used { opacity: .3; text-decoration: line-through; pointer-events: none; }
.bk-chip.hidden { display: none; }
#guess-btn {
  width: 100%; margin-top: 14px; padding: 13px; border: none; border-radius: 12px;
  background: var(--gold); color: #fff; font-size: 1.05rem; font-weight: 700;
  letter-spacing: .2em; cursor: pointer; box-shadow: var(--shadow);
}
#guess-btn:disabled { opacity: .35; cursor: default; }
#guess-btn:not(:disabled):active { transform: scale(.98); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 14, 5, .55);
  display: grid; place-items: center; z-index: 50; padding: 18px;
}
/* 關鍵：author 的 display 會蓋掉 hidden 屬性，必須明確補回 */
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--card); color: var(--ink); border-radius: 18px; position: relative;
  max-width: 440px; width: 100%; max-height: 82vh; overflow-y: auto;
  padding: 26px 22px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
  animation: rise .22s ease;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-close {
  position: absolute; top: 12px; right: 12px; border: none; background: none;
  color: var(--ink-soft); font-size: 1.1rem; cursor: pointer; padding: 6px;
}
.modal h2 { font-size: 1.1rem; letter-spacing: .1em; margin-bottom: 14px; }
.modal p { font-size: .92rem; line-height: 1.75; color: var(--ink-soft); margin-bottom: 10px; }
.modal .verse-full {
  font-family: "Noto Serif TC", Georgia, serif; font-size: 1.05rem; line-height: 1.9;
  color: var(--ink); background: var(--gold-soft); border-radius: 10px; padding: 14px 16px; margin: 12px 0;
}
.modal .ref { text-align: right; color: var(--gold); font-weight: 700; margin-top: 6px; font-size: .9rem; }
.legend { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: .88rem; }
.legend span { display: inline-block; }
.stats-grid { display: flex; justify-content: space-around; text-align: center; margin: 16px 0; }
.stats-grid .num { font-size: 1.7rem; font-weight: 800; color: var(--gold); }
.stats-grid .lbl { font-size: .72rem; color: var(--ink-soft); }
.dist-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: .8rem; }
.dist-bar { height: 18px; background: var(--gold); border-radius: 4px; color: #fff; font-size: .72rem; display: flex; align-items: center; justify-content: flex-end; padding: 0 6px; min-width: 20px; }
.share-btn {
  width: 100%; margin-top: 14px; padding: 12px; border: none; border-radius: 12px;
  background: var(--green); color: #fff; font-size: 1rem; font-weight: 700; letter-spacing: .15em; cursor: pointer;
}
.countdown { text-align: center; color: var(--ink-soft); font-size: .85rem; margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 999px;
  font-size: .9rem; z-index: 99; animation: pop .2s ease; white-space: nowrap;
}
@media (min-width: 521px) { body { padding-top: 6px; } }
