:root {
  --bg: #f4f9f7;
  --surface: #ffffff;
  --text: #1a2e2a;
  --muted: #5c726c;
  --brand: #0d7a6a;
  --brand-soft: #e6f4f1;
  --accent: #c45c26;
  --ok: #1b7a3d;
  --bad: #b83232;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(13, 122, 106, 0.08);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --tap: 48px;
}

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

html {
  font-size: clamp(15px, 3.5vw, 17px);
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--surface);
  border-bottom: 1px solid rgba(13, 122, 106, 0.12);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar--home {
  background: transparent;
  border-bottom: none;
  padding: max(10px, env(safe-area-inset-top)) 20px 14px;
}

.topbar--home .topbar__nav {
  display: none;
}

.topbar__accent {
  display: none;
  position: relative;
  height: 7px;
  margin: 0 auto;
  max-width: 200px;
  border-radius: 999px;
  overflow: visible;
  background: linear-gradient(
    90deg,
    var(--brand) 0%,
    #3db89a 35%,
    #5ec9b8 65%,
    var(--brand) 100%
  );
  background-size: 220% 100%;
  animation: topbar-accent-flow 5s ease-in-out infinite;
  box-shadow: 0 2px 12px rgba(13, 122, 106, 0.28);
}

.topbar--home .topbar__accent {
  display: block;
}

.topbar__accent-shine {
  position: absolute;
  inset: -2px -40%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 45%,
    transparent 70%
  );
  animation: topbar-accent-shine 3.2s ease-in-out infinite;
  pointer-events: none;
  border-radius: inherit;
}

.topbar__accent-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.85;
  top: 50%;
  margin-top: -3px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  animation: topbar-dot-drift 2.8s ease-in-out infinite;
}

.topbar__accent-dot--a {
  left: 12%;
  animation-delay: 0s;
}

.topbar__accent-dot--b {
  right: 10%;
  animation-delay: 0.7s;
}

.topbar__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

@keyframes topbar-accent-flow {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes topbar-accent-shine {
  0%,
  100% {
    transform: translateX(-30%);
    opacity: 0.2;
  }
  50% {
    transform: translateX(30%);
    opacity: 0.85;
  }
}

@keyframes topbar-dot-drift {
  0%,
  100% {
    transform: translateX(0) scale(1);
    opacity: 0.7;
  }
  50% {
    transform: translateX(6px) scale(1.15);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .topbar__accent,
  .topbar__accent-shine,
  .topbar__accent-dot {
    animation: none;
  }

  .topbar__accent {
    background-position: 50% 50%;
  }
}

.topbar__back {
  width: var(--tap);
  height: var(--tap);
  border: none;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 12px;
  font-size: 1.25rem;
  cursor: pointer;
  flex-shrink: 0;
}

.topbar__back.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

.topbar__spacer {
  width: var(--tap);
  flex-shrink: 0;
}

.main {
  flex: 1;
  padding: 16px 16px max(24px, env(safe-area-inset-bottom));
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card--muted {
  background: var(--brand-soft);
  box-shadow: none;
}

.home-learn-hint {
  margin: 0 0 12px;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
  text-align: center;
}

.home-learn-hint--dim {
  opacity: 0.92;
}

.learn-reset-row {
  margin: 14px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.learn-reset-row__sep {
  margin: 0 0.35em;
  opacity: 0.5;
}

.learn-reset-row__note {
  display: inline;
}

.btn-text {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-text:active {
  opacity: 0.75;
}

.home-hero {
  text-align: center;
  padding: 8px 0 4px;
}

.home-hero h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand);
}

.home-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.grid-actions {
  display: grid;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 12px 18px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text);
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--brand);
  color: #fff;
}

.btn--secondary {
  background: var(--surface);
  color: var(--brand);
  border: 2px solid var(--brand);
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(92, 114, 108, 0.35);
}

.btn--danger {
  background: #fff0f0;
  color: var(--bad);
  border: 1px solid rgba(184, 50, 50, 0.25);
}

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

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(13, 122, 106, 0.25);
  background: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text);
}

.chip.is-on {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.q-meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.q-stem {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 14px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 14px;
  border-radius: 12px;
  border: 2px solid rgba(26, 46, 42, 0.12);
  background: #fff;
  text-align: left;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1.45;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text);
}

.opt:hover {
  border-color: rgba(13, 122, 106, 0.35);
}

.opt.is-selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.opt.is-correct {
  border-color: var(--ok);
  background: #e8f5ec;
}

.opt.is-wrong {
  border-color: var(--bad);
  background: #fdeaea;
}

.opt__key {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(13, 122, 106, 0.15);
  color: var(--brand);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.judge-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.judge-btns .btn {
  min-height: 56px;
  font-size: 1.1rem;
}

.judge-pick {
  border-color: var(--brand) !important;
  background: var(--brand-soft) !important;
  color: var(--brand) !important;
}

.judge-ok {
  border-color: var(--ok) !important;
  background: #e8f5ec !important;
  color: var(--ok) !important;
}

.judge-bad {
  border-color: var(--bad) !important;
  background: #fdeaea !important;
  color: var(--bad) !important;
}

.btn.is-selected {
  border-color: var(--brand) !important;
  background: var(--brand-soft) !important;
  color: var(--brand) !important;
}

.timer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 600;
}

.timer-bar time {
  font-variant-numeric: tabular-nums;
  color: var(--brand);
  font-size: 1.1rem;
}

.timer-bar.is-warn time {
  color: var(--accent);
}

.progress {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.progress__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(13, 122, 106, 0.2);
}

.progress__dot.is-done {
  background: var(--brand);
}

.progress__dot.is-current {
  box-shadow: 0 0 0 2px var(--brand);
}

.score-big {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--brand);
  text-align: center;
  margin: 8px 0;
}

.score-sub {
  text-align: center;
  color: var(--muted);
  margin-bottom: 12px;
}

.table-convert {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-top: 8px;
}

.table-convert th,
.table-convert td {
  border: 1px solid rgba(26, 46, 42, 0.1);
  padding: 8px 10px;
  text-align: left;
}

.table-convert th {
  background: var(--brand-soft);
}

.list-wrong {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-wrong li {
  padding: 12px 0;
  border-bottom: 1px solid rgba(26, 46, 42, 0.08);
}

.list-wrong li:last-child {
  border-bottom: none;
}

.list-wrong small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
  line-height: 1.5;
  word-break: break-word;
}

.empty-hint {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}

.info-list {
  margin: 0;
  padding-left: 1.2rem;
}

.info-list li {
  margin-bottom: 8px;
}

.footer-note {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  margin-top: 20px;
}

.is-hidden {
  display: none !important;
}

body.modal-open {
  overflow: hidden;
  touch-action: none;
}

.modal-host {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.22s ease,
    visibility 0.22s ease;
}

.modal-host.is-open {
  pointer-events: auto;
  opacity: 1;
  visibility: visible;
}

.modal-host__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 46, 42, 0.48);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.modal-host__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  max-height: min(85dvh, 520px);
  overflow: auto;
  background: var(--surface);
  border-radius: 18px;
  padding: 22px 20px 20px;
  box-shadow:
    0 4px 24px rgba(13, 122, 106, 0.12),
    0 24px 48px rgba(0, 0, 0, 0.16);
  transform: translateY(24px) scale(0.97);
  opacity: 0;
  transition:
    transform 0.32s cubic-bezier(0.34, 1.15, 0.64, 1),
    opacity 0.26s ease;
}

.modal-host.is-open .modal-host__panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

@media (min-width: 480px) {
  .modal-host {
    align-items: center;
    padding-bottom: 16px;
  }

  .modal-host__panel {
    border-radius: var(--radius);
  }
}

.modal-host__title {
  margin: 0 0 12px;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.modal-host__body {
  margin: 0;
  font-size: 0.98rem;
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
}

.modal-host__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.modal-host__actions--single {
  grid-template-columns: 1fr;
}

.modal-host__actions .btn {
  min-height: 48px;
}

@media (prefers-reduced-motion: reduce) {
  .modal-host,
  .modal-host__panel {
    transition: none;
  }

  .modal-host.is-open .modal-host__panel {
    transform: none;
  }
}
