:root {
  color-scheme: light;
  --bg: #F5F3EE;
  --surface: #FCFBF8;
  --surface-2: #EDE9DF;
  --text: #16171A;
  --muted: #6C675D;
  --border: #D8D2C5;
  --border-strong: #16171A;
  --accent: #B23A2A;
  --accent-ink: #1F2326;
  --ok: #2F6B4F;
  --warn: #C48A1B;
  --warn-ink: #8A5C00;
  --danger: #B23A2A;
  --shadow: 0 1px 0 rgba(22, 23, 26, 0.04), 0 4px 14px rgba(22, 23, 26, 0.06);
  --radius: 10px;
  --font-display: Georgia, 'Times New Roman', 'PT Serif', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16171A;
  --surface: #1D1F22;
  --surface-2: #24262A;
  --text: #F2F0EA;
  --muted: #9B968C;
  --border: #34363B;
  --border-strong: #F2F0EA;
  --accent: #D85A43;
  --accent-ink: #F2F0EA;
  --ok: #4E9C77;
  --warn: #D9A13B;
  --warn-ink: #E0AD4A;
  --danger: #E05A44;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 6px 18px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus { top: 12px; }

.notice {
  margin: 20px auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

#app:focus,
.step-text:focus,
.result-title:focus { outline: none; }

.brand:focus-visible,
.theme-toggle:focus-visible,
.btn:focus-visible,
.choice:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  transition: background 0.25s ease, color 0.25s ease;
}

.shell {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--accent-ink);
  color: var(--bg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  border-radius: 6px;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  min-height: 38px;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--text);
  color: var(--bg);
}

/* ---------- Hero ---------- */
.hero {
  padding: 40px 0 30px;
}

.hero-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(30px, 6vw, 48px);
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}

.hero-sub {
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
  margin: 0;
}

.streak {
  display: inline-block;
  margin: 14px 0 0;
  padding: 5px 12px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

/* ---------- Daily ---------- */
.daily {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0 26px;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.daily-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.daily-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.daily-sub {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 15px;
}

.daily .btn { margin-top: 6px; }

/* ---------- Cards grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 18px;
  padding: 8px 0 40px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-index {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.card-title {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}

.card-tagline {
  color: var(--muted);
  font-size: 14.5px;
  margin: 0;
  flex: 1;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.chip b { font-weight: 700; }

.chip-progress {
  color: var(--accent);
  border-color: var(--accent);
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* ---------- Buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  padding: 11px 20px;
  border-radius: 7px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease, background 0.15s ease;
}

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

.btn:disabled {
  cursor: default;
  opacity: 0.55;
}

.btn:disabled:hover,
.btn:disabled:active {
  opacity: 0.55;
  transform: none;
}

.btn.is-error,
.btn.is-error:hover {
  border-color: var(--danger);
  color: var(--danger);
  opacity: 1;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
  opacity: 1;
}

/* ---------- Test view ---------- */
.view-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 26px 0 14px;
  flex-wrap: wrap;
}

.view-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 4vw, 30px);
  letter-spacing: -0.01em;
  margin: 0;
}

.step-counter {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- Resource bars ---------- */
.resources {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 6px 0 20px;
}

.resource {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.resource-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.resource-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.resource-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.resource-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.resource-fill {
  height: 100%;
  width: 0;
  background: var(--ok);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s ease;
}

.resource.warn .resource-fill { background: var(--warn); }
.resource.warn .resource-value { color: var(--warn-ink); }

.resource.danger .resource-fill { background: var(--danger); }
.resource.danger .resource-value { color: var(--danger); }

.resource.changed {
  animation: resourcePulse 0.55s ease;
}

@keyframes resourcePulse {
  0% { border-color: var(--accent); }
  100% { border-color: var(--border); }
}

/* ---------- Step card ---------- */
.step-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  max-width: 720px;
}

.step-text {
  font-family: var(--font-display);
  font-size: clamp(20px, 3.4vw, 26px);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 22px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.4;
  cursor: pointer;
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.08s ease, outline-color 0.15s ease;
}

.choice:not(:disabled):hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.choice:not(:disabled):active {
  transform: translateY(1px);
  outline-color: var(--accent);
}

.choice:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  border-style: dashed;
  animation: blockedFade 0.4s ease;
}

@keyframes blockedFade {
  from { opacity: 0.25; }
  to { opacity: 0.55; }
}

.choice-reason {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}

/* ---------- Final / Fail ---------- */
.result-plate {
  background: var(--accent-ink);
  color: var(--bg);
  border-radius: var(--radius);
  padding: 28px;
  margin: 26px 0 20px;
  box-shadow: var(--shadow);
}

.result-plate.danger-plate { background: var(--danger); }

.result-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.75;
  margin: 0 0 10px;
}

.result-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}

.result-text {
  margin: 0;
  opacity: 0.9;
  max-width: 640px;
  font-size: 16px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -0.01em;
  margin: 26px 0 12px;
}

/* ---------- Breakdown ---------- */
.breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 720px;
}

.breakdown-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.breakdown-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.breakdown-step {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  text-transform: uppercase;
  white-space: nowrap;
}

.breakdown-choice {
  font-weight: 700;
  font-size: 15px;
}

.breakdown-note {
  color: var(--muted);
  font-size: 14px;
  margin: 6px 0 0;
}

.breakdown-delta {
  display: inline-block;
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
}

/* ---------- Challenge & collection ---------- */
.challenge-note {
  margin: 0 0 18px;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 600;
}

.challenge-result {
  margin: 14px 0 0;
  font-size: 15px;
  font-weight: 700;
  opacity: 0.95;
}

.collection-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.collection-note b { color: var(--text); }

/* ---------- Share row ---------- */
.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 6px;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s ease;
}

.share-btn:hover { background: var(--surface-2); }

.subscribe {
  margin: 6px 0 22px;
  color: var(--muted);
  font-size: 14px;
}

.subscribe a {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.subscribe a:hover { border-bottom-color: var(--text); }

/* ---------- Result actions ---------- */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 26px 0 40px;
}

.btn.copied {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 34px;
  margin-top: 10px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-nav a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.footer-nav a:hover {
  color: var(--text);
  border-bottom-color: var(--border);
}

/* ---------- Landing pages ---------- */
.landing { padding-bottom: 40px; }

.breadcrumbs {
  padding: 20px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.breadcrumbs a:hover { color: var(--text); }

.breadcrumbs .current { color: var(--text); }

.landing-hero { padding: 26px 0 8px; }

.cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 20px 0 8px;
}

.cta-note {
  color: var(--muted);
  font-size: 13px;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin: 24px 0 8px;
}

.landing-card { gap: 10px; }

.stakes {
  margin: 0;
  padding-left: 18px;
}

.stakes li { margin: 0 0 6px; }

.landing-text {
  max-width: 720px;
  margin: 24px 0 0;
}

.landing-text p { margin: 0 0 14px; }

.landing-text h2 {
  margin: 30px 0 10px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: -0.01em;
}

.how-list {
  margin: 0;
  padding-left: 20px;
}

.how-list li { margin: 0 0 8px; }

.test-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin: 12px 0 0;
}

.test-link {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.test-link:hover { background: var(--surface-2); }

.test-link b {
  display: block;
  margin-bottom: 4px;
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.2;
}

.test-link span {
  color: var(--muted);
  font-size: 13px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .resources { grid-template-columns: 1fr; gap: 10px; }
  .step-card { padding: 20px; }
  .result-plate { padding: 22px; }
  .card-actions { flex-direction: column; }
  .card-actions .btn { width: 100%; }
  .header-actions { gap: 6px; }
  .header-actions .theme-toggle { min-height: 40px; padding: 6px 9px; font-size: 12px; }
  .daily { padding: 18px; }
  .daily .btn { width: 100%; }
  .share-row .share-btn { flex: 1 1 auto; }
  .breadcrumbs { padding-top: 14px; }
}

@media (max-width: 360px) {
  .brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .resource.changed,
  .choice:disabled {
    animation: none;
  }
  .resource-fill,
  .choice {
    transition: none;
  }
}
