* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f1b3d;
  --panel: #1a2a56;
  --accent: #ffd24a;
  --accent2: #4ac2ff;
  --text: #f2f5ff;
  --muted: #9db0d8;
  --green: #3ddc84;
  --red: #ff6b6b;
}
body {
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: linear-gradient(160deg, var(--bg), #16244d 60%, #1d1b3f);
  color: var(--text);
  min-height: 100vh;
}
.container { max-width: 520px; margin: 0 auto; padding: 20px 16px 48px; }
.loading { text-align: center; padding-top: 40vh; color: var(--muted); }

.hero { text-align: center; padding: 48px 0 28px; }
.hero h1 {
  font-size: 44px; letter-spacing: 6px;
  background: linear-gradient(90deg, var(--accent), #ff9c4a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { color: var(--muted); margin-top: 10px; }
.hero.small { padding: 24px 0 16px; }
.hero.small h1 { font-size: 30px; }

.btn {
  display: inline-block; border: none; border-radius: 14px; cursor: pointer;
  font-size: 18px; font-family: inherit; padding: 14px 22px;
  background: var(--accent); color: #333; font-weight: 700;
  transition: transform .08s;
}
.btn:active { transform: scale(.96); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--muted); }
.btn.yes { background: var(--green); color: #0b3320; }
.btn.no { background: var(--red); color: #fff; }
.btn:disabled { opacity: .85; cursor: default; }

.stage-btns, .menu-btns { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.btn.stage { padding: 22px; font-size: 22px; line-height: 1.5; }
.btn.stage span { font-size: 14px; font-weight: 400; }
.btn.main { padding: 20px; font-size: 20px; background: var(--panel); color: var(--text); border: 1px solid #2e4380; }
.menu-btns .ghost { align-self: center; margin-top: 8px; font-size: 14px; padding: 10px 18px; }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar .back { background: none; border: none; color: var(--accent2); font-size: 26px; cursor: pointer; }
.topbar h2 { font-size: 20px; font-weight: 600; }

.flash-progress { text-align: center; color: var(--muted); margin-bottom: 14px; font-size: 14px; }
.flash-card {
  background: var(--panel); border: 1px solid #2e4380; border-radius: 20px;
  min-height: 300px; display: flex; align-items: center; justify-content: center;
  padding: 28px; cursor: pointer; text-align: center;
}
.flash-word { font-size: 42px; font-weight: 800; color: var(--accent); word-break: break-word; }
.flash-word.small { font-size: 28px; }
.flash-hint { color: var(--muted); margin-top: 16px; font-size: 14px; }
.flash-pos { color: var(--accent2); margin: 8px 0 4px; font-style: italic; }
.flash-zh { font-size: 26px; margin: 10px 0 16px; }
.flash-ex { font-size: 16px; line-height: 1.7; color: var(--text); }
.flash-ex .ex-zh { color: var(--muted); font-size: 14px; }
.flash-btns { display: flex; gap: 14px; margin-top: 18px; }
.flash-btns .btn { flex: 1; padding: 18px; font-size: 20px; }
.hidden { display: none !important; }

.quiz-prompt {
  background: var(--panel); border: 1px solid #2e4380; border-radius: 16px;
  padding: 26px 20px; text-align: center; font-size: 26px; font-weight: 700;
  line-height: 1.6;
}
.quiz-sub { text-align: center; color: var(--muted); margin: 12px 0 18px; font-size: 14px; }
.quiz-opts { display: flex; flex-direction: column; gap: 12px; }
.btn.opt { background: #223668; color: var(--text); text-align: center; font-weight: 500; }
.btn.opt.right { background: var(--green); color: #0b3320; font-weight: 800; }
.btn.opt.wrong { background: var(--red); color: #fff; }

.card-done { text-align: center; padding: 60px 0; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.card-done .big { font-size: 64px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.stat-tile { background: var(--panel); border: 1px solid #2e4380; border-radius: 16px; padding: 18px; text-align: center; }
.stat-num { font-size: 34px; font-weight: 800; color: var(--accent); }
.stat-cap { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-bar-label { font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
.stat-bar { position: relative; background: #223668; border-radius: 10px; height: 22px; overflow: hidden; }
.stat-bar-fill { background: linear-gradient(90deg, var(--accent2), var(--green)); height: 100%; border-radius: 10px; }
.stat-bar span { position: absolute; right: 8px; top: 0; line-height: 22px; font-size: 12px; }
.stat-note { color: var(--muted); font-size: 13px; margin: 16px 0 24px; }
.io-box { display: flex; flex-wrap: wrap; gap: 10px; }
.io-box textarea {
  width: 100%; min-height: 80px; border-radius: 10px; border: 1px solid #2e4380;
  background: #101c3e; color: var(--text); padding: 10px; font-size: 12px; font-family: monospace;
}

/* ── 文學家對戰 ── */
.bt-pick { display: grid; gap: 14px; margin-top: 20px; }
.bt-oppgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.bt-oppcard {
  background: var(--panel); border: 1px solid #2e4380; border-radius: 16px;
  padding: 16px 10px; text-align: center; cursor: pointer; color: var(--text);
  transition: transform .08s, border-color .15s;
}
.bt-oppcard:active { transform: scale(.96); }
.bt-oppcard:hover { border-color: var(--accent); }
.bt-face { font-size: 40px; }
.bt-face.big { font-size: 54px; }
.bt-name { font-weight: 700; margin-top: 4px; }
.bt-tier { font-size: 11px; padding: 1px 8px; border-radius: 8px; margin-left: 6px; }
.t-入門 { background: #1f5c3a; color: #b7f5cf; }
.t-進階 { background: #4a4416; color: var(--accent); }
.t-高手 { background: #5a2a14; color: #ffb98a; }
.t-宗師 { background: #4a1f5c; color: #e5b7f5; }

.bt-arena { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 16px; }
.bt-arena .bt-side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bt-arena .foe { order: 0; }
.bt-arena .me { order: 2; }
.bt-arena .bt-log { order: 1; }
.bt-hp {
  width: 100%; height: 20px; border-radius: 10px; background: #101c3e;
  border: 1px solid #2e4380; position: relative; overflow: hidden;
}
.bt-hp-fill { height: 100%; background: linear-gradient(90deg, var(--green), #7bffb0); transition: width .4s; }
.bt-hp.low .bt-hp-fill { background: linear-gradient(90deg, var(--red), #ff9c8a); }
.bt-hp span { position: absolute; right: 8px; top: 1px; font-size: 12px; font-weight: 700; }
.bt-hp.active { box-shadow: 0 0 0 2px var(--accent); }
.bt-log {
  text-align: center; font-size: 14px; color: var(--accent); min-height: 20px;
  padding: 6px 4px; font-weight: 600;
}
.bt-turn { text-align: center; font-weight: 700; color: var(--accent2); margin-bottom: 10px; }
.bt-q .quiz-prompt { margin-top: 4px; }
.bt-quote { color: var(--muted); font-style: italic; margin: 12px 0; padding: 0 12px; }
.bt-portrait {
  width: 66px; height: 66px; border-radius: 14px; object-fit: cover;
  border: 1px solid #2e4380; background: #101c3e;
}
.bt-portrait.big { width: 104px; height: 104px; border-radius: 18px; }
.bt-face-emoji { font-size: 40px; }
.bt-face-emoji.big { font-size: 54px; }
