/* =========================================================
   KiSS SCiENCE 科學大富翁 — 手機版樣式
   色票、尺寸皆取自 Figma（375 寬設計稿）
   ========================================================= */
:root {
  --blue: #3667AA;        /* 按鈕 / 標題 / 選取 */
  --blue-light: #477ED9;  /* Header 漸層起點、Loading 文字 */
  --blue-link: #2B76D1;   /* 官網連結 / 解鎖後滑軌 */
  --sky: #82D1FC;
  --yellow: #FFF42E;
  --pink: #FF85C6;
  --pink-card: #FFEBEB;   /* 題目卡 */
  --green-card: #DAF2DA;  /* 答對 */
  --red-card: #FFB3B3;    /* 答錯 */
  --red: #E60012;
  --gray: #CCCCCC;
  --ink: #171717;
  --navy: #21244F;        /* 選項文字 */
  --ground: #A7A9BC;      /* 首頁插圖底部灰 */
  --radius: 8px;
  --shadow: 0 2px 6px rgba(0, 0, 0, .14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #fff;
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

/* 手機版頁面：寬螢幕時置中成 430px 直欄 */
body { background: #2f3142; }
#app {
  position: relative;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  background: #fff;
  overflow-x: hidden;
}

button { font-family: inherit; }

/* ---------- 共用按鈕 ---------- */
.btn {
  display: inline-block;
  border: 0;
  border-radius: 24px;
  height: 48px;
  padding: 0 24px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .04em;
  color: #fff;
  background: var(--blue);
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  transition: opacity .15s, background .15s;
}
.btn:active { opacity: .85; }
.btn:disabled { background: var(--gray); box-shadow: none; cursor: default; }

/* =========================================================
   待機（首頁）
   ========================================================= */
.screen-idle {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ground) url("../assets/hero.png") no-repeat center center;
  background-size: cover;   /* 任何高寬比都填滿，多餘部分裁掉邊緣 */
}
.hero-logo {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 240px;
  height: auto;
}
.btn-join {
  position: absolute;
  left: 50%;
  bottom: 32px;
  bottom: calc(32px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: 164px;
  padding: 0;
}

/* =========================================================
   問答
   ========================================================= */
.screen-quiz {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #fff url("../assets/wave_top.svg") no-repeat top center;
  background-size: 100% auto;
}
/* 底部粉紅波浪：固定在視窗底、置於內容下方 */
.screen-quiz::after {
  content: "";
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 100%;
  max-width: 430px;
  transform: translateX(-50%);
  height: 40vw;
  max-height: 150px;
  background: url("../assets/wave_bottom.svg") no-repeat bottom center;
  background-size: 100% auto;
  pointer-events: none;
  z-index: 0;
}

.quiz-header {
  position: relative;
  z-index: 1;
  height: 76px;
  padding: 15px 16px 0 21px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.quiz-logo { width: 140px; height: 61px; flex: none; }

/* 進度點：答對數（最多 6 顆） */
.progress {
  flex: 1;
  display: flex;
  align-items: center;
  margin-top: 6px;
  min-width: 0;
}
.progress .dot {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--gray);
  border: 2px solid #fff;
}
.progress .dot.on { background: var(--yellow); }
.progress .line { flex: 1; height: 2px; background: #fff; }

.quiz-body {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 17px 40px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
}

.question-card {
  background: var(--pink-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 8px;           /* 左右與選項相同，文字左緣才會對齊 */
  min-height: 144px;
  font-size: 16px;
  line-height: 23px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;     /* 垂直置中 */
  text-align: left;            /* 靠左，與選項一致 */
}
/* 題目標題：縣市＋場域編號＋機構全名，例「南投H06　財團法人…」 */
.question-tag {
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.45;
  white-space: pre-line;
  text-wrap: balance;
  margin-bottom: 6px;
}
.question-text { white-space: pre-line; text-wrap: balance; }

/* 首頁：網址沒有場次代碼時，取代「參與作答」按鈕 */
.no-session {
  position: absolute;
  left: 0; right: 0;
  bottom: 48px;
  margin: 0;
  padding: 0 24px;
  text-align: center;
  font-size: 16px;
  line-height: 1.6;
  font-weight: 700;
  color: var(--blue);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.option {
  background: #fff;
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  min-height: 96px;
  text-align: left;
  font-size: 16px;
  line-height: 20px;
  color: var(--navy);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.option.selected { background: var(--blue); color: #fff; }
.option.correct  { background: var(--green-card); color: var(--navy); }
.option.wrong    { background: var(--red-card);   color: var(--navy); }
.options.locked .option { cursor: default; }

.btn-submit {
  align-self: center;
  width: 160px;
  padding: 0;
}
/* 內容短時把按鈕推到底部；內容長時自然接在選項之後（至少留 18px） */
.quiz-body .spacer { flex: 1; min-height: 18px; }

/* =========================================================
   彈窗
   ========================================================= */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 8px;
}
.card {
  position: relative;
  width: 100%;
  max-width: 359px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  text-align: center;
}
.card-wait { max-width: 338px; padding: 16px 16px 16px; }
.card-answer { padding: 16px 16px 16px; }
.card-loading { padding: 16px; }
.card-win { padding: 40px 16px 24px; }
.card-end { padding: 40px 16px 32px; }
.card-redeem { padding: 32px 16px 32px; }

.card-title-sm { margin: 0 0 8px; font-size: 18px; line-height: 24px; font-weight: 700; color: var(--blue); }
.card-title    { margin: 0 0 16px; font-size: 24px; line-height: 34px; font-weight: 700; color: var(--blue); }
.card-title-lg { margin: 0 0 24px; font-size: 28px; line-height: 40px; font-weight: 700; color: var(--blue); }

.card-text {
  margin: 0;
  font-size: 16px;
  line-height: 22px;
  color: var(--ink);
  text-align: left;
}
.card-text strong { font-weight: 700; }
.card-text-lg {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 24px;
  color: var(--ink);
  text-align: left;
  display: inline-block;
}
.card-end .card-text-lg { display: block; width: 240px; margin-left: auto; margin-right: auto; }

.answer-text {
  margin: 0;
  font-size: 16px;
  line-height: 22px;
  color: var(--ink);
  text-align: left;
}

/* Loading 火車 + 進度條 */
.loading { display: flex; flex-direction: column; align-items: center; }
.train { width: 168px; height: 84px; margin: 8px 0 12px; }
.loading-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--blue-light);
  margin-bottom: 12px;
}
.loading-bar {
  width: 238px;
  height: 22px;
  border-radius: 11px;
  border: 2px solid var(--blue-light);
  background: rgba(255, 133, 198, .1);
  padding: 3px;
  overflow: hidden;
}
.loading-bar span {
  display: block;
  height: 12px;
  width: 50%;
  border-radius: 6px;
  background: var(--pink);
  animation: fill 2s ease-in-out infinite;
}
@keyframes fill {
  0%   { width: 8%; }
  70%  { width: 100%; }
  100% { width: 100%; }
}

/* 注意標籤 */
.notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 19px;
  color: var(--red);
  font-weight: 500;
}
.notice-tag {
  display: inline-block;
  padding: 1px 8px 0;
  border: 1px solid var(--red);
  font-size: 12px;
  line-height: 17px;
  font-weight: 700;
}

.btn-staff { width: 152px; padding: 0; margin-top: 24px; font-size: 16px; }

/* 官網連結 */
.site-link {
  display: inline-block;
  font-size: 22px;
  font-weight: 700;
  color: var(--blue-link);
  text-decoration: underline;
  text-underline-offset: 4px;
  letter-spacing: .02em;
}

/* 兌換：關閉鈕 */
.close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 24px;
  height: 24px;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}
.close::before, .close::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 20px; height: 2px;
  background: var(--blue);
  transform: translate(-50%, -50%) rotate(45deg);
}
.close::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* 兌換：滑動解鎖 */
.slider {
  position: relative;
  width: 238px;
  height: 38px;
  margin: 8px auto 40px;
  border-radius: 19px;
  background: var(--gray);
  border: 1px solid #eee;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
.slider-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 64px;
  font-size: 18px;
  color: #333;
  transition: padding .2s, color .2s;
}
.slider.unlocked { background: var(--blue-link); }
.slider.unlocked .slider-label { padding-left: 0; padding-right: 64px; color: #fff; }
.slider-knob {
  position: absolute;
  top: 0;
  left: 0;
  width: 64px;
  height: 36px;
  border-radius: 18px;
  background: var(--blue);
  display: flex;
  align-items: center;
  padding-left: 12px;
  gap: 6px;
  cursor: grab;
  will-change: transform;
}
.slider-knob .grip {
  width: 14px;
  height: 12px;
  background: repeating-linear-gradient(90deg, #fff 0 2px, transparent 2px 6px);
}
.slider-knob .ball {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  margin-left: auto;
  margin-right: 2px;
}
.btn-redeem { width: 240px; padding: 0; }

/* =========================================================
   Toast
   ========================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(33, 36, 79, .92);
  color: #fff;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 20px;
  white-space: nowrap;
}

/* =========================================================
   開發用：主持人模擬面板
   ========================================================= */
.dev-panel {
  position: fixed;
  right: 8px;
  top: 8px;
  z-index: 200;
  font-size: 12px;
}
.dev-toggle {
  background: #21244F;
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 12px;
  opacity: .8;
}
.dev-body {
  margin-top: 6px;
  background: rgba(33, 36, 79, .95);
  color: #fff;
  padding: 8px;
  border-radius: 8px;
  width: 220px;
}
.dev-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.dev-row button {
  border: 0;
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--blue-light);
  color: #fff;
  font-size: 12px;
}
.dev-row input { width: 48px; font-size: 12px; }
.dev-status { opacity: .8; line-height: 1.5; }
