:root {
  --green: #7C9473;
  --green-deep: #5a6e56;
  --brown: #A86F4D;
  --sand: #B5A273;
  --apricot: #E3C9A7;
  --sage: #6E8E82;
  --text: #4A4A43;
  --text-light: #7A7A70;
  --bg: #F5F2E9;
  --white: #FFFDF8;
  --shadow-sm: 0 2px 8px rgba(74, 74, 67, 0.06);
  --shadow-md: 0 4px 16px rgba(74, 74, 67, 0.08);
  --shadow-card: 0 2px 12px rgba(74, 74, 67, 0.07), 0 0 0 1px rgba(74, 74, 67, 0.04);
  --shadow-card-hover: 0 8px 24px rgba(74, 74, 67, 0.12), 0 0 0 1px rgba(168, 111, 77, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, #f9f4e5 0%, var(--bg) 10%, var(--bg) 100%);
  line-height: 1.75;
  min-height: 100vh;
}

/* ─── Header ─── */
.page-header {
  text-align: center;
  padding: 2.5rem 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(74, 74, 67, 0.06);
}

.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--sage);
  margin-bottom: 1.25rem;
  transition: color var(--transition);
}

.back-link:hover { color: var(--green); }

.page-header h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.25rem;
  letter-spacing: 0.04em;
}

/* ─── Filters ─── */
.filters {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 242, 233, 0.94);
  backdrop-filter: blur(8px);
  padding: 0.75rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  border-bottom: 1px solid rgba(74, 74, 67, 0.06);
  justify-content: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 500;
  white-space: nowrap;
}

.filter-btn {
  padding: 0.25rem 0.6rem;
  border: 1px solid rgba(74, 74, 67, 0.15);
  border-radius: 999px;
  background: var(--white);
  font-size: 0.72rem;
  color: var(--text-light);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--sage);
  color: var(--sage);
}

.filter-btn.active {
  background: var(--sage);
  color: var(--white);
  border-color: var(--sage);
}

.random-btn {
  padding: 0.35rem 0.9rem;
  border: 1px dashed rgba(168, 111, 77, 0.4);
  border-radius: 999px;
  background: rgba(168, 111, 77, 0.05);
  font-size: 0.75rem;
  color: var(--brown);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  white-space: nowrap;
  margin-left: 0.25rem;
}

.random-btn:hover {
  background: rgba(168, 111, 77, 0.12);
  border-color: var(--brown);
}

/* ─── Progress ─── */
.progress-bar-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 0;
}

.done-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: var(--white);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(74, 74, 67, 0.06);
}

.done-label {
  font-size: 0.78rem;
  color: var(--text-light);
  font-weight: 500;
  white-space: nowrap;
}

.done-bar {
  flex: 1;
  height: 6px;
  background: rgba(74, 74, 67, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.done-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--apricot), var(--brown));
  border-radius: 999px;
  transition: width 0.4s;
}

.done-text {
  font-size: 0.78rem;
  color: var(--brown);
  font-weight: 600;
  white-space: nowrap;
}

/* ─── Card Grid ─── */
.card-grid {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

/* ─── Mission Card ─── */
.mission-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid rgba(74, 74, 67, 0.06);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}

.mission-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.mission-card.filtered-out {
  display: none;
}

.card-face {
  padding: 1.5rem;
  cursor: pointer;
}

.card-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15em 0.6em;
  border-radius: 999px;
  background: rgba(227, 201, 167, 0.2);
  color: var(--brown);
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.card-num {
  display: block;
  font-size: 0.7rem;
  color: var(--text-light);
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.card-face h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.card-tagline {
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.card-meta {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.card-meta span {
  font-size: 0.7rem;
  color: var(--text-light);
  background: rgba(245, 242, 233, 0.6);
  padding: 0.15em 0.5em;
  border-radius: 4px;
}

.card-expand {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0.5rem;
  border: 1px solid rgba(74, 74, 67, 0.1);
  border-radius: var(--radius-sm);
  background: rgba(245, 242, 233, 0.5);
  font-size: 0.78rem;
  color: var(--text-light);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.card-expand:hover {
  background: rgba(110, 142, 130, 0.08);
  border-color: var(--sage);
  color: var(--sage);
}

/* ─── Card Detail ─── */
.card-detail {
  display: none;
  padding: 0 1.5rem 1.5rem;
  border-top: 1px solid rgba(74, 74, 67, 0.06);
}

.card-detail.open {
  display: block;
}

.detail-section {
  margin-bottom: 1rem;
}

.detail-section h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.detail-section p,
.detail-section li {
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.7;
}

.detail-section ol {
  padding-left: 1.25rem;
}

.detail-section li {
  margin-bottom: 0.3rem;
}

.treasure-list {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: rgba(245, 242, 233, 0.5);
  border-radius: var(--radius-sm);
}

.treasure-list p {
  font-size: 0.8rem;
  line-height: 1.7;
}

/* ─── Buttons in detail ─── */
.btn-print,
.btn-done {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.45rem 1.25rem;
  border: 1px solid rgba(74, 74, 67, 0.15);
  border-radius: 999px;
  background: var(--white);
  font-size: 0.78rem;
  color: var(--text-light);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
  margin-right: 0.5rem;
}

.btn-print:hover {
  border-color: var(--sage);
  color: var(--sage);
  background: rgba(110, 142, 130, 0.05);
}

.btn-done {
  border-color: rgba(124, 148, 115, 0.3);
  color: var(--green);
}

.btn-done:hover {
  background: rgba(124, 148, 115, 0.08);
}

.btn-done.done {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}

/* ─── Footer ─── */
.course-footer {
  text-align: center;
  padding: 3rem 1.5rem 2.5rem;
  border-top: 1px solid rgba(74, 74, 67, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.course-footer p {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.course-footer a {
  font-size: 0.85rem;
  color: var(--text-light);
  transition: color var(--transition);
}

.course-footer a:hover { color: var(--green); }

/* ─── Print styles ─── */
@media print {
  body { background: white; color: black; }
  .page-header, .filters, .progress-bar-section, .course-footer, .btn-done, .card-expand { display: none !important; }
  .mission-card { break-inside: avoid; page-break-inside: avoid; box-shadow: none; border: 1px solid #ccc; margin-bottom: 1rem; }
  .card-detail { display: block !important; }
  .btn-print { display: none !important; }
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .card-grid { grid-template-columns: 1fr; padding: 1rem 1rem 3rem; }
  .filters { padding: 0.6rem 1rem; gap: 0.5rem; }
}

@media (max-width: 480px) {
  .filter-group { width: 100%; justify-content: center; }
  .random-btn { width: 100%; text-align: center; margin-left: 0; margin-top: 0.25rem; }
}

@media print {
  .card-grid { display: block; }
  .mission-card { margin-bottom: 1.5rem; }
}
