/* Ecolympiad — 經濟偵探事務所 樣式 */
:root {
  --navy: #1f2a44;
  --navy-soft: #2c3a5e;
  --gold: #c0894a;
  --gold-light: #e0b878;
  --paper: #f6f1e7;
  --card: #ffffff;
  --text: #232a38;
  --text-soft: #6b7280;
  --melissa: #d65a8a;
  --tryphena: #4f86c6;
  --green: #5b8c5a;
  --red: #c45c5c;
  --shadow: 0 4px 16px rgba(31, 42, 68, 0.10);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", sans-serif;
  background: var(--paper); color: var(--text);
  font-size: 16px; line-height: 1.5;
}
body { max-width: 560px; margin: 0 auto; min-height: 100vh; }
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ===== 底部導覽列 ===== */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  max-width: 560px; margin: 0 auto;
  background: #fff; border-top: 1px solid #e6e0d3;
  box-shadow: 0 -3px 14px rgba(31, 42, 68, 0.08);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav.visible { display: flex; }
.nav-btn {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 4px; border-radius: 12px; color: var(--text-soft);
  transition: background .12s, color .12s;
}
.nav-btn .nav-ico { font-size: 22px; line-height: 1; }
.nav-btn .nav-lbl { font-size: 11px; font-weight: 700; }
.nav-btn.active { color: var(--gold); background: #fbf3e4; }
.nav-btn:active { transform: scale(0.95); }

/* ===== 按鈕 ===== */
.primary-btn {
  background: var(--gold); color: #fff; border: none; border-radius: 14px;
  padding: 14px 22px; font-size: 17px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 0 #9c6b34; transition: transform .08s, box-shadow .08s; width: 100%;
}
.primary-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #9c6b34; }
.primary-btn:disabled { background: #c9cdd6; box-shadow: 0 3px 0 #aeb3bf; cursor: default; }
.ghost-btn { background: none; border: none; color: var(--text-soft); padding: 10px; font-size: 15px; cursor: pointer; width: 100%; }
.hint-btn {
  background: #fff; color: var(--gold); border: 2px solid var(--gold);
  border-radius: 14px; padding: 12px 16px; font-size: 15px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.hint-btn:disabled { opacity: .4; }
.icon-btn { background: none; border: none; font-size: 22px; color: var(--navy); cursor: pointer; padding: 4px 10px; }

/* ===== 選帳號 ===== */
.user-select { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 28px 22px; gap: 14px; }
.brand { text-align: center; margin-bottom: 18px; }
.brand-badge { font-size: 56px; }
.brand h1 { color: var(--navy); font-size: 27px; margin-top: 6px; }
.brand-sub { color: var(--text-soft); font-size: 14px; margin-top: 4px; }
.user-prompt { text-align: center; color: var(--text-soft); margin-bottom: 4px; }
.user-card {
  display: flex; align-items: center; gap: 14px; background: var(--card);
  border: none; border-radius: 18px; padding: 16px 18px; cursor: pointer;
  box-shadow: var(--shadow); text-align: left; width: 100%;
}
.user-card:active { transform: scale(.98); }
.avatar {
  width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 24px; font-weight: 800; flex-shrink: 0;
}
.avatar-melissa { background: var(--melissa); }
.avatar-tryphena { background: var(--tryphena); }
.user-card-name { font-size: 19px; font-weight: 700; }
.user-card-meta { font-size: 13px; color: var(--text-soft); margin-top: 2px; }

.data-tools { text-align: center; margin-top: 10px; font-size: 13px; color: var(--text-soft); }
.link-btn { background: none; border: none; color: var(--text-soft); font-size: 13px; cursor: pointer; padding: 6px 8px; text-decoration: underline; }
.data-tools-dot { opacity: .5; }
.data-textarea {
  width: 100%; height: 110px; border: 1.5px solid #e6e1d6; border-radius: 12px;
  padding: 10px 12px; font-size: 12px; font-family: monospace; resize: none;
  margin-bottom: 12px; color: var(--text); background: #faf7f0; word-break: break-all;
}
.data-textarea:focus { outline: none; border-color: var(--gold); }

/* ===== 頂欄 ===== */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10;
}
.topbar-user { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.topbar-title { font-weight: 700; flex: 1; }
.avatar-mini { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; background: var(--melissa); }
.avatar-tryphena.avatar-mini { background: var(--tryphena); }
.topbar-stats { display: flex; gap: 12px; margin-left: auto; font-size: 14px; }
.stat b { font-size: 15px; }

/* ===== 地圖 ===== */
.map-body, .sublesson-body, .trivia-body { padding: 16px; flex: 1; }
.map-body, .sublesson-body { padding-bottom: 88px; }
.section-title { color: var(--navy); font-size: 18px; margin: 18px 4px 10px; }
.portal-card {
  display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, var(--navy), var(--navy-soft));
  color: #fff; border-radius: 16px; padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow);
}
.portal-card:active { transform: scale(.99); }
.portal-icon { font-size: 30px; }
.portal-title { font-weight: 700; font-size: 16px; }
.portal-sub { font-size: 12px; opacity: .85; }
.portal-arrow { margin-left: auto; font-size: 20px; opacity: .8; }

.stage-card {
  background: var(--card); border-radius: 18px; padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); cursor: pointer; position: relative; transition: transform .1s;
}
.stage-card.locked { opacity: .62; cursor: default; }
.lock-badge { position: absolute; top: 12px; right: 14px; font-size: 12px; color: var(--text-soft); font-weight: 700; }
.stage-header { display: flex; gap: 14px; align-items: flex-start; }
.stage-icon { width: 50px; height: 50px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.stage-num { font-size: 11px; color: var(--text-soft); letter-spacing: .03em; text-transform: uppercase; }
.stage-name { font-size: 18px; font-weight: 800; color: var(--navy); }
.stage-desc { font-size: 13px; color: var(--text-soft); margin-top: 3px; }
.stage-progress { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.stage-progress-bar { flex: 1; height: 8px; background: #ececec; border-radius: 4px; overflow: hidden; }
.stage-progress-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.stage-progress-text { font-size: 12px; color: var(--text-soft); font-weight: 700; }
.stage-roadmap-preview { margin-top: 12px; font-size: 12px; color: var(--text-soft); line-height: 1.6; }
.footer-note { text-align: center; font-size: 11px; color: var(--text-soft); margin: 20px 0 30px; }

/* ===== 子課 ===== */
.stage-hero { background: var(--card); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.stage-hero h2 { color: var(--navy); font-size: 20px; }
.hero-sub { font-size: 13px; color: var(--text-soft); font-weight: 500; }
.stage-hero p { font-size: 14px; color: var(--text-soft); margin-top: 6px; }
.sublesson-card {
  display: flex; align-items: center; gap: 14px; background: var(--card);
  border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer;
}
.sublesson-card:active { transform: scale(.99); }
.sublesson-card.completed { background: #f3f7f3; }
.sublesson-card.in-progress { background: #fbf4e8; border: 1.5px solid var(--gold-light); }
.sublesson-card.in-progress .sublesson-arrow { color: var(--gold); }
.sublesson-num { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
.sublesson-name { font-weight: 700; font-size: 16px; }
.diff-tag { font-size: 11px; font-weight: 700; margin-left: 4px; }
.sublesson-desc { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.sublesson-arrow { margin-left: auto; color: var(--gold); font-size: 18px; }

/* ===== 答題 ===== */
.lesson-topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--paper); position: sticky; top: 0; z-index: 10; }
.lesson-progress-track { flex: 1; height: 12px; background: #e3ddd0; border-radius: 6px; overflow: hidden; }
.lesson-progress-fill { height: 100%; background: var(--gold); border-radius: 6px; transition: width .3s; }
.lesson-hearts { font-size: 15px; font-weight: 700; color: var(--red); white-space: nowrap; }
.lesson-area { flex: 1; padding: 20px 18px; overflow-y: auto; }
.lesson-view { animation: fade .25s; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.intro-text { white-space: pre-line; color: var(--text); font-size: 15px; margin: 12px 0 18px; }
#lesson-intro h2 { color: var(--navy); font-size: 21px; }
.example-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.example-card { background: var(--card); border-radius: 12px; padding: 12px; text-align: center; box-shadow: var(--shadow); }
.example-stim { font-size: 17px; font-weight: 800; color: var(--navy); }
.example-label { font-size: 12px; color: var(--text-soft); margin-top: 4px; }
.intro-note {
  white-space: pre-line; font-size: 14px; line-height: 1.7; color: var(--text);
  background: #fff7ea; border: 1px solid var(--gold); border-left: 4px solid var(--gold);
  border-radius: 12px; padding: 14px 16px; margin: 0 0 20px;
}

.problem-diff { margin-bottom: 12px; }
.diff-badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.problem-prompt { font-size: 18px; font-weight: 700; line-height: 1.55; color: var(--navy); margin-bottom: 14px; white-space: pre-line; }
.problem-stimulus:not(:empty) { background: var(--card); border-radius: 12px; padding: 14px; margin-bottom: 16px; box-shadow: var(--shadow); }
.choice-grid { display: flex; flex-direction: column; gap: 10px; }
.choice-btn {
  background: var(--card); border: 2px solid #e6e1d6; border-radius: 14px; padding: 15px 16px;
  font-size: 16px; text-align: left; cursor: pointer; color: var(--text); transition: border-color .1s, background .1s; line-height: 1.45;
}
.choice-btn:active { transform: scale(.99); }
.choice-btn.selected { border-color: var(--gold); background: #fbf4e8; }
.text-input { width: 100%; padding: 15px 16px; font-size: 18px; border: 2px solid #e6e1d6; border-radius: 14px; outline: none; }
.text-input:focus { border-color: var(--gold); }
.problem-hint { background: #fdf6e6; border-left: 4px solid var(--gold); border-radius: 8px; padding: 12px 14px; margin-top: 16px; font-size: 14px; line-height: 1.7; }
.problem-hint div + div { margin-top: 6px; }

.lesson-footer { display: flex; gap: 12px; padding: 14px 16px; border-top: 1px solid #e6e1d6; background: var(--paper); position: sticky; bottom: 0; }
.lesson-footer .primary-btn { flex: 1; }

.result-emoji { font-size: 50px; text-align: center; }
.result-title { font-size: 22px; font-weight: 800; text-align: center; margin: 6px 0; }
#lesson-result.correct .result-title { color: var(--green); }
#lesson-result.wrong .result-title { color: var(--red); }
.result-detail { text-align: center; color: var(--text-soft); font-size: 15px; margin-bottom: 16px; }
.result-explanation { background: var(--card); border-radius: 14px; padding: 16px; font-size: 14px; line-height: 1.75; white-space: pre-line; box-shadow: var(--shadow); }

.complete-emoji { font-size: 64px; text-align: center; margin-top: 20px; }
#lesson-complete { text-align: center; }
#lesson-complete h2 { color: var(--navy); font-size: 26px; margin: 8px 0 20px; }
.complete-stats { display: flex; justify-content: center; gap: 14px; margin-bottom: 28px; }
.complete-stat { background: var(--card); border-radius: 14px; padding: 16px 14px; min-width: 84px; box-shadow: var(--shadow); }
.complete-num { display: block; font-size: 22px; font-weight: 800; color: var(--gold); }
.complete-label { font-size: 12px; color: var(--text-soft); }

/* ===== 冷知識 ===== */
.zone-hint { font-size: 13px; color: var(--text-soft); margin-bottom: 14px; }
.trivia-zone-card { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer; }
.trivia-zone-card.locked { opacity: .6; }
.trivia-zone-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.trivia-zone-name { font-weight: 700; font-size: 16px; }
.trivia-zone-desc { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.trivia-zone-status { font-size: 12px; color: var(--gold); font-weight: 700; margin-top: 3px; }
.trivia-zone-arrow { margin-left: auto; font-size: 18px; color: var(--gold); }
.trivia-question { font-size: 18px; font-weight: 700; color: var(--navy); line-height: 1.55; margin: 14px 0 18px; }
.trivia-choices { display: flex; flex-direction: column; gap: 10px; }
.trivia-choice { background: var(--card); border: 2px solid #e6e1d6; border-radius: 14px; padding: 14px 16px; font-size: 16px; text-align: left; cursor: pointer; color: var(--text); }
.trivia-choice:active { transform: scale(.99); }
.trivia-choice:disabled { cursor: default; }
.trivia-correct-btn { border-color: var(--green); background: #eef6ee; }
.trivia-wrong-btn { border-color: var(--red); background: #fbeeee; }
.trivia-feedback { margin-top: 18px; }
.trivia-result { font-weight: 800; font-size: 17px; }
.trivia-result.correct { color: var(--green); }
.trivia-result.wrong { color: var(--red); }
.trivia-reward { font-size: 16px; font-weight: 700; margin: 8px 0; }
.trivia-reward-none { color: var(--text-soft); font-weight: 500; font-size: 14px; }
.trivia-fact { background: var(--card); border-radius: 12px; padding: 14px; font-size: 14px; line-height: 1.7; margin: 10px 0 18px; box-shadow: var(--shadow); }

/* ===== modal ===== */
.modal { display: none; position: fixed; inset: 0; background: rgba(31,42,68,.55); z-index: 100; align-items: center; justify-content: center; padding: 24px; }
.modal.active { display: flex; }
.modal-box { background: #fff; border-radius: 20px; padding: 28px 24px; text-align: center; max-width: 360px; width: 100%; }
.modal-emoji { font-size: 48px; }
.modal-box h3 { color: var(--navy); margin: 8px 0; }
.modal-box p { color: var(--text-soft); font-size: 14px; margin-bottom: 18px; }
.modal-box .primary-btn { margin-bottom: 8px; }
#pause-modal .ghost-btn {
  border: 1.5px solid #e6e1d6; border-radius: 14px; color: var(--navy);
  font-weight: 700; padding: 13px; margin-top: 8px; background: #fff;
}
#pause-modal .ghost-btn:active { background: #f6f1e7; }
