:root {
  --header: rgb(32, 178, 170);
  --header-dark: rgb(22, 148, 142);
  --cell: rgb(224, 255, 255);
  --ink: rgb(0, 0, 0);
  --paper: #f4fbfb;
  --muted: #3d5a5a;
  --ok: #0a7a4b;
  --bad: #c62828;
  --warn: #b26a00;
  --line: rgba(32, 178, 170, 0.35);
  --shadow: 0 12px 40px rgba(16, 80, 78, 0.12);
  --radius: 14px;
  --font: "IBM Plex Sans TC", "Noto Sans TC", "PingFang HK", "Hiragino Sans CNS", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(32, 178, 170, 0.22), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(224, 255, 255, 0.9), transparent 45%),
    linear-gradient(180deg, #e8fafa 0%, var(--paper) 40%, #dff6f5 100%);
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

/* —— Screens —— */
.screen {
  min-height: 100vh;
  padding: 24px 16px 48px;
}

.wrap {
  width: min(920px, 100%);
  margin: 0 auto;
}

.brand-bar {
  background: var(--header);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  justify-content: space-between;
}

.brand-bar h1 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.7rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-bar .tag {
  margin: 0;
  opacity: 0.92;
  font-size: 0.92rem;
}

.brand-bar a.up {
  color: #fff;
  font-size: 0.92rem;
  opacity: 0.92;
}

.panel {
  margin-top: 18px;
  background: var(--cell);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.2rem;
  color: var(--header-dark);
}

.rules {
  margin: 0;
  padding-left: 1.2em;
  line-height: 1.7;
  color: var(--muted);
}

.rules strong {
  color: var(--ink);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 8px;
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 1.35rem;
  color: var(--header-dark);
}

.stat span {
  font-size: 0.85rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

a.btn {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--header);
  color: #fff;
  box-shadow: 0 8px 20px rgba(32, 178, 170, 0.35);
}

.btn-primary:hover {
  background: var(--header-dark);
}

.btn-ghost {
  background: #fff;
  color: var(--header-dark);
  border: 1.5px solid var(--header);
}

.btn-danger {
  background: var(--bad);
  color: #fff;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bank-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--header-dark);
}

.bank-select {
  width: 100%;
  max-width: 420px;
  appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2314948e' d='M6 8L0 0h12z'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1.5px solid var(--header);
  border-radius: 12px;
  padding: 12px 40px 12px 14px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}

.bank-select:focus {
  outline: 2px solid var(--header);
  outline-offset: 2px;
}

.note {
  margin-top: 14px;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
}

.disclaimer {
  margin-top: 22px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
}

.disclaimer strong {
  display: block;
  margin-bottom: 8px;
}

.disclaimer p {
  margin: 0 0 0.55rem;
}

.disclaimer p:last-child {
  margin-bottom: 0;
}

/* —— Exam chrome —— */
.exam-top {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(224, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}

.exam-top-inner {
  width: min(1100px, 100%);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--header-dark);
  background: #fff;
  border: 1.5px solid var(--header);
  border-radius: 999px;
  padding: 6px 14px;
  min-width: 7.5rem;
  text-align: center;
}

.timer.warn {
  color: var(--warn);
  border-color: var(--warn);
}

.timer.danger {
  color: var(--bad);
  border-color: var(--bad);
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  50% { opacity: 0.65; }
}

.progress-bits {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.pill {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}

.pill.ok { border-color: var(--ok); color: var(--ok); }
.pill.bad { border-color: var(--bad); color: var(--bad); }

.exam-body {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 18px 16px 40px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 860px) {
  .exam-body {
    grid-template-columns: 1fr;
  }
  .question-card {
    order: -1;
  }
  .nav-panel {
    position: static;
  }
  .stats {
    grid-template-columns: 1fr;
  }
}

.nav-panel {
  background: var(--cell);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  position: sticky;
  top: 72px;
}

.nav-panel h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--header-dark);
}

.q-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.q-dot {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  aspect-ratio: 1;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
}

.q-dot.current {
  outline: 2px solid var(--header);
  outline-offset: 1px;
}

.q-dot.answered {
  background: var(--header);
  color: #fff;
  border-color: var(--header);
}

.q-dot.flagged {
  box-shadow: inset 0 0 0 2px var(--warn);
}

.q-dot.correct {
  background: var(--ok);
  color: #fff;
  border-color: var(--ok);
}

.q-dot.wrong {
  background: var(--bad);
  color: #fff;
  border-color: var(--bad);
}

.legend {
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}

.question-card {
  background: var(--cell);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 420px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.badge {
  background: var(--header);
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge.alt {
  background: #fff;
  color: var(--header-dark);
  border: 1px solid var(--header);
}

.q-title {
  margin: 0 0 16px;
  font-size: clamp(1.05rem, 2.4vw, 1.25rem);
  line-height: 1.55;
  font-weight: 600;
}

.q-image {
  display: block;
  max-width: min(280px, 100%);
  max-height: 220px;
  width: auto;
  height: auto;
  margin: 0 0 16px;
  background: #fff;
  border-radius: 8px;
}

.choices {
  display: grid;
  gap: 10px;
}

.choice {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.choice:hover {
  border-color: var(--header);
}

.choice.selected {
  border-color: var(--header);
  background: rgba(32, 178, 170, 0.12);
  box-shadow: inset 0 0 0 1px var(--header);
}

.choice.reveal-correct {
  border-color: var(--ok);
  background: rgba(10, 122, 75, 0.1);
}

.choice.reveal-wrong {
  border-color: var(--bad);
  background: rgba(198, 40, 40, 0.08);
}

.choice-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--header);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.choice.selected .choice-letter,
.choice.reveal-correct .choice-letter {
  background: var(--header-dark);
}

.choice.reveal-wrong .choice-letter {
  background: var(--bad);
}

.choice-text {
  line-height: 1.5;
  padding-top: 3px;
}

.explain {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff;
  border-left: 4px solid var(--header);
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
}

.nav-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  justify-content: space-between;
}

.nav-btns .left,
.nav-btns .right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* —— Result —— */
.result-hero {
  text-align: center;
  padding: 8px 0 4px;
}

.result-hero .verdict {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  margin: 8px 0;
}

.verdict.pass { color: var(--ok); }
.verdict.fail { color: var(--bad); }

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

@media (max-width: 640px) {
  .score-grid {
    grid-template-columns: 1fr;
  }
}

.score-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.score-card h3 {
  margin: 0 0 6px;
  color: var(--header-dark);
}

.score-card .big {
  font-size: 2rem;
  font-weight: 800;
  margin: 4px 0;
}

.review-list {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.review-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.review-item.wrong {
  border-color: rgba(198, 40, 40, 0.45);
}

.review-item h4 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.review-item p {
  margin: 4px 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 40, 40, 0.45);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 16px;
}

.modal {
  width: min(420px, 100%);
  background: var(--cell);
  border-radius: var(--radius);
  padding: 22px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal h3 {
  margin: 0 0 8px;
  color: var(--header-dark);
}

.modal p {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.55;
}
