:root {
  color-scheme: light;
  --bg: hsl(42 28% 97%);
  --fg: hsl(245 15% 12%);
  --card: hsl(0 0% 100%);
  --card-soft: hsl(252 48% 97%);
  --border: hsl(246 10% 84%);
  --border-strong: hsl(250 18% 70%);
  --muted: hsl(245 7% 42%);
  --primary: hsl(255 58% 43%);
  --primary-hover: hsl(255 62% 35%);
  --primary-soft: hsl(252 68% 93%);
  --visited: hsl(252 55% 53%);
  --attempted: hsl(31 83% 39%);
  --solved: hsl(156 56% 29%);
  --danger: hsl(0 65% 42%);
  --quiet: hsl(247 14% 91%);
  --shadow: 0 24px 70px hsl(250 26% 19% / .09);
  --shadow-soft: 0 12px 32px hsl(250 22% 18% / .06);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: hsl(245 12% 7%);
  --fg: hsl(45 20% 96%);
  --card: hsl(244 10% 10%);
  --card-soft: hsl(250 18% 14%);
  --border: hsl(245 7% 22%);
  --border-strong: hsl(250 12% 34%);
  --muted: hsl(245 7% 69%);
  --primary: hsl(252 88% 76%);
  --primary-hover: hsl(252 96% 84%);
  --primary-soft: hsl(252 26% 19%);
  --visited: hsl(252 81% 75%);
  --attempted: hsl(38 90% 65%);
  --solved: hsl(156 55% 57%);
  --danger: hsl(0 78% 72%);
  --quiet: hsl(245 8% 16%);
  --shadow: 0 26px 70px hsl(245 50% 2% / .4);
  --shadow-soft: 0 12px 32px hsl(245 50% 2% / .25);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; background: var(--bg); color: var(--fg); }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  padding-bottom: 3rem;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

:where(a, button, summary, input):focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.progress-main {
  width: min(72rem, calc(100% - 1.25rem));
  margin-inline: auto;
  padding-top: 4.75rem;
}

.progress-hero {
  position: relative;
  padding: 1.35rem 0 1.45rem;
  border-bottom: 1px solid var(--border);
  animation: progress-in .36s cubic-bezier(.22, 1, .36, 1) both;
}
.progress-hero::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  width: min(24vw, 10rem);
  height: 2px;
  background: var(--primary);
  content: "";
}

.eyebrow {
  margin: 0 0 .55rem;
  color: var(--primary);
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .14em;
  line-height: 1.2;
  text-transform: uppercase;
}

.progress-hero h1,
.journey-copy h2,
.section-heading h2,
.empty-state h2,
.progress-error h2 {
  margin: 0;
  font-family: "Crimson Pro", Georgia, serif;
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: .98;
}
.progress-hero h1 { max-width: 11ch; font-size: clamp(3.1rem, 15vw, 6.5rem); }
.progress-subtitle {
  max-width: 34rem;
  margin: .7rem 0 0;
  color: var(--muted);
  font-family: "Crimson Pro", Georgia, serif;
  font-size: clamp(1.15rem, 4.6vw, 1.55rem);
  line-height: 1.25;
}
.return-note {
  display: inline-flex;
  margin: .75rem 0 0;
  align-items: center;
  gap: .45rem;
  color: var(--fg);
  font-size: .78rem;
  font-weight: 800;
}
.return-note::before { color: var(--primary); content: "↳"; }

.progress-error {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid hsl(0 58% 64% / .5);
  border-radius: 14px;
  background: hsl(0 70% 97%);
}
[data-theme="dark"] .progress-error { background: hsl(0 24% 13%); }
.progress-error h2 { font-size: 1.5rem; }
.progress-error p { margin: .35rem 0 0; color: var(--muted); font-size: .84rem; }

.empty-state {
  margin-top: 1rem;
  padding: clamp(1.5rem, 7vw, 3.2rem) 1.15rem;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: radial-gradient(circle at 50% 0, var(--primary-soft), transparent 52%), var(--card);
  box-shadow: var(--shadow);
  text-align: center;
}
.empty-mark {
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 1rem;
  place-items: center;
  border-radius: 13px;
  background: var(--primary-soft);
  color: var(--primary);
}
.empty-mark svg { width: 2.1rem; height: 2.1rem; fill: currentColor; }
.empty-state h2 { font-size: clamp(1.8rem, 7vw, 2.35rem); }
.empty-state p { max-width: 31rem; margin: .7rem auto 0; color: var(--muted); font-size: .9rem; }
.empty-state small { display: block; margin-top: .8rem; color: var(--muted); font-size: .72rem; }

.journey-panel {
  display: grid;
  gap: 1.15rem;
  margin-top: 1rem;
  padding: 1.2rem 0;
  overflow: hidden;
  border-block: 1px solid var(--border-strong);
  background: linear-gradient(90deg, var(--card-soft), transparent 62%);
  animation: progress-in .36s .04s cubic-bezier(.22, 1, .36, 1) both;
}
.journey-copy h2 { max-width: 25rem; font-size: clamp(1.85rem, 7vw, 2.7rem); }
.recorded-streak {
  display: grid;
  width: fit-content;
  gap: .08rem;
  margin: .85rem 0 0;
  padding-left: .65rem;
  border-left: 2px solid var(--primary);
}
.recorded-streak span { color: var(--muted); font-size: .62rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.recorded-streak strong { font-family: "Crimson Pro", Georgia, serif; font-size: 1.03rem; font-weight: 600; }

.primary-button,
.secondary-button,
.danger-button,
.text-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 800;
  line-height: 1.2;
  padding: .72rem 1rem;
}
.primary-button {
  width: 100%;
  margin-top: 1rem;
  border: 1px solid var(--primary);
  background: var(--primary);
  box-shadow: 0 8px 22px hsl(255 58% 36% / .18);
  color: white;
}
[data-theme="dark"] .primary-button { color: hsl(250 25% 10%); }
.primary-button:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.secondary-button { border: 1px solid var(--border); background: var(--card); }
.secondary-button:hover { border-color: var(--primary); color: var(--primary); }
.danger-button { border: 1px solid hsl(0 55% 65% / .7); background: transparent; color: var(--danger); }
.danger-button:hover { border-color: var(--danger); }
.text-button { border: 0; background: transparent; color: var(--muted); }
.text-button:hover { color: var(--fg); }

.metrics {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(6.8rem, .75fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: .55rem;
  margin: 0;
}
.metric {
  display: flex;
  min-width: 0;
  min-height: 4.55rem;
  flex-direction: column;
  justify-content: space-between;
  padding: .65rem .8rem;
  border-left: 1px solid var(--border);
  background: transparent;
}
.metric-primary { grid-row: 1 / 3; }
.metric dt { color: var(--muted); font-size: .63rem; font-weight: 800; letter-spacing: .08em; line-height: 1.25; text-transform: uppercase; }
.metric dd { margin: .32rem 0 0; font-family: "Crimson Pro", Georgia, serif; font-size: 2rem; font-weight: 600; line-height: .9; }
.metric-primary dd { color: var(--primary); font-size: clamp(4rem, 19vw, 5.8rem); }

.progress-section {
  margin-top: 1.95rem;
  padding-top: 1.45rem;
  border-top: 1px solid var(--border);
  animation: progress-in .36s .08s cubic-bezier(.22, 1, .36, 1) both;
}
.section-heading { display: flex; gap: 1rem; align-items: end; justify-content: space-between; margin-bottom: 1rem; }
.section-heading h2 { font-size: clamp(1.8rem, 7vw, 2.6rem); }
.section-heading > a { display: inline-flex; min-height: 44px; align-items: center; color: var(--primary); font-size: .76rem; font-weight: 800; white-space: nowrap; }
.section-heading > a:hover { color: var(--primary-hover); }

.puzzle-list { display: grid; }
#continueList[data-count="1"] { grid-template-columns: minmax(0, 39rem); }
#continueList[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.continue-card {
  display: flex;
  min-width: 0;
  min-height: 8.9rem;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.15rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 9px 24px hsl(250 22% 18% / .045);
}
.continue-card-copy > a,
.recent-row > div > a,
.game-row > div > a {
  font-family: "Crimson Pro", Georgia, serif;
  font-size: 1.18rem;
  font-weight: 600;
  line-height: 1.15;
  text-decoration: underline;
  text-decoration-color: hsl(252 60% 55% / .24);
  text-underline-offset: 4px;
}
.continue-card-copy > a { font-size: 1.35rem; }
.continue-card a:hover,
.recent-row a:hover,
.game-row a:hover { color: var(--primary); text-decoration-color: currentColor; }
.puzzle-meta,
.game-detail,
.game-best { margin: .45rem 0 0; color: var(--muted); font-size: .7rem; line-height: 1.45; }
.continue-card-cta {
  display: inline-flex;
  width: fit-content;
  min-height: 44px;
  align-items: center;
  color: var(--primary);
  font-size: .75rem;
  font-weight: 800;
}
.continue-card-cta:hover { color: var(--primary-hover); }

.map-grid { display: grid; gap: .8rem; }
.map-panel,
.history-panel {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: none;
}
.map-panel { border-top: 3px solid var(--primary); }
.map-panel header,
.subsection-heading { margin-bottom: 1.1rem; }
.map-panel h3,
.subsection-heading h3 {
  margin: 0;
  font-family: "Crimson Pro", Georgia, serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.1;
}
.map-panel header p,
.subsection-heading p { margin: .3rem 0 0; color: var(--muted); font-size: .72rem; }
.insight-list { display: grid; gap: .86rem; }
.insight-row-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; font-size: .72rem; font-weight: 700; }
.insight-row-heading a { text-decoration: underline; text-decoration-color: hsl(252 60% 55% / .28); text-underline-offset: 3px; }
.insight-row-heading a:hover { color: var(--primary); text-decoration-color: currentColor; }
.insight-row-heading > span:last-child { color: var(--muted); font-size: .67rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.insight-track { height: 7px; margin-top: .38rem; overflow: hidden; border-radius: 999px; background: var(--quiet); }
.insight-track > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--visited)); }
.map-panel:nth-child(2) .insight-track > span { background: linear-gradient(90deg, var(--solved), hsl(172 56% 41%)); }
.map-coverage-note { margin: .8rem 0 0; color: var(--muted); font-size: .72rem; }

.history-grid { display: grid; gap: .8rem; }
.recent-row,
.game-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .8rem;
  min-height: 4.6rem;
  align-items: center;
  border-top: 1px solid var(--border);
  padding: .72rem 0;
}
.recent-row:first-child,
.game-row:first-child { border-top: 0; padding-top: 0; }
.recent-row:last-child,
.game-row:last-child { padding-bottom: 0; }
.state-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: .65rem;
  font-weight: 800;
  padding: .28rem .52rem;
  white-space: nowrap;
}
.state-badge[data-state="solved"] { border-color: hsl(156 48% 45% / .55); color: var(--solved); }
.state-badge[data-state="attempted"] { border-color: hsl(32 70% 55% / .6); color: var(--attempted); }
.state-badge[data-state="visited"] { border-color: hsl(250 55% 58% / .55); color: var(--visited); }

.activity-legend { display: flex; flex-wrap: wrap; gap: .35rem .7rem; margin: -.35rem 0 .75rem; color: var(--muted); font-size: .66rem; }
.activity-legend span { display: inline-flex; min-height: 28px; align-items: center; gap: .26rem; }
.activity-legend i { display: grid; width: 1.05rem; height: 1.05rem; place-items: center; border-radius: 4px; font-size: .65rem; font-style: normal; font-weight: 900; }
.activity-legend i[data-state="visited"] { border: 1px solid var(--visited); color: var(--visited); }
.activity-legend i[data-state="attempted"] { border: 1px solid var(--attempted); color: var(--attempted); }
.activity-legend i[data-state="solved"] { border: 1px solid var(--solved); color: var(--solved); }
.activity-chart { width: fit-content; max-width: 100%; margin-inline: auto; overflow-x: auto; padding: 3px; }
.week-labels,
.activity-grid { display: grid; width: max-content; grid-template-columns: repeat(7, 28px); gap: .28rem; }
.week-labels { margin-bottom: .3rem; color: var(--muted); font-size: .58rem; font-weight: 750; text-align: center; }
.activity-day {
  display: grid;
  min-width: 28px;
  min-height: 28px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--quiet);
  color: transparent;
  font-size: .6rem;
  font-weight: 900;
}
.activity-day:is(a, button) {
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-size: .6rem;
  font-weight: 900;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease;
}
.activity-day:is(a, button):hover { z-index: 1; transform: translateY(-2px); box-shadow: 0 5px 12px hsl(250 30% 18% / .15); }
.activity-day[data-state="visited"] { border-color: var(--visited); background: hsl(250 74% 94%); color: var(--visited); }
.activity-day[data-state="attempted"] { border-color: var(--attempted); background: hsl(38 90% 93%); color: var(--attempted); }
.activity-day[data-state="solved"] { border-color: var(--solved); background: hsl(156 54% 91%); color: var(--solved); }
[data-theme="dark"] .activity-day[data-state="visited"] { background: hsl(250 28% 20%); }
[data-theme="dark"] .activity-day[data-state="attempted"] { background: hsl(38 30% 18%); }
[data-theme="dark"] .activity-day[data-state="solved"] { background: hsl(156 28% 17%); }
.activity-day[data-today="true"] { box-shadow: 0 0 0 1px var(--bg), 0 0 0 3px var(--fg); }
.activity-details {
  margin-top: 1rem;
  padding: .85rem;
  border-top: 1px solid var(--border-strong);
  background: var(--card-soft);
}
.activity-details-heading { display: flex; align-items: start; justify-content: space-between; gap: .8rem; }
.activity-details-heading .eyebrow { margin-bottom: .25rem; }
.activity-details-heading h4 { margin: 0; font-family: "Crimson Pro", Georgia, serif; font-size: 1.35rem; font-weight: 600; line-height: 1.05; }
.activity-details-close {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
  color: var(--muted);
  font-size: 1.25rem;
}
.activity-details-list { display: grid; margin-top: .65rem; }
.activity-details-list article { display: flex; min-height: 44px; align-items: center; justify-content: space-between; gap: .7rem; border-top: 1px solid var(--border); }
.activity-details-list article:first-child { border-top: 0; }
.activity-details-list a { font-family: "Crimson Pro", Georgia, serif; font-size: 1rem; font-weight: 600; text-decoration: underline; text-decoration-color: hsl(252 60% 55% / .24); text-underline-offset: 3px; }
.activity-details-list a:hover { color: var(--primary); text-decoration-color: currentColor; }

.games-summary { margin: 0 0 .55rem; color: var(--muted); font-size: .82rem; }
.game-row { padding: .9rem 0; }
.game-best { color: var(--fg); font-weight: 700; }

.data-details {
  margin-top: 2.35rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.data-details summary {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  list-style: none;
}
.data-details summary::-webkit-details-marker { display: none; }
.data-details summary span:first-child { display: grid; gap: .18rem; }
.data-details summary strong { font-family: "Crimson Pro", Georgia, serif; font-size: 1.4rem; font-weight: 600; }
.data-details summary small { color: var(--muted); font-size: .73rem; }
.data-details summary > span:last-child { color: var(--primary); font-size: 1.3rem; transition: transform .18s ease; }
.data-details[open] summary > span:last-child { transform: rotate(45deg); }
.data-body { padding: 0 0 1.35rem; }
.data-body > p { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }
.data-origin { margin-top: .45rem !important; overflow-wrap: anywhere; }
.data-origin strong { color: var(--fg); }
.data-actions { display: grid; gap: .55rem; margin-top: 1rem; }
.import-preview { margin-top: 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: 11px; background: var(--card-soft); }
.import-preview h3 { margin: 0; font-family: "Crimson Pro", Georgia, serif; font-size: 1.3rem; }
.import-preview > p { margin: .35rem 0 0; color: var(--muted); font-size: .8rem; }
.import-preview fieldset { display: grid; gap: .65rem; margin: .85rem 0 0; padding: 0; border: 0; }
.import-preview legend { margin-bottom: .5rem; font-size: .74rem; font-weight: 800; }
.import-preview label { display: grid; grid-template-columns: 1.2rem minmax(0, 1fr); column-gap: .4rem; align-items: start; font-size: .8rem; font-weight: 700; }
.import-preview label small { grid-column: 2; color: var(--muted); font-size: .7rem; font-weight: 500; }
.import-preview input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.preview-actions { display: flex; gap: .4rem; margin-top: .8rem; }
.preview-actions .primary-button { width: auto; margin-top: 0; }
.data-inventory { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.data-inventory strong { font-size: .74rem; }
.data-inventory p { margin: .25rem 0 0; overflow-wrap: anywhere; color: var(--muted); font-size: .72rem; line-height: 1.5; }
.tools-status { min-height: 1.35rem; margin-top: .8rem !important; color: var(--muted); }
.tools-status[data-state="error"] { color: var(--danger); }
.tools-status[data-state="ok"] { color: var(--solved); }

.site-footer-std { margin-top: 2rem; padding-top: 1.4rem; text-align: center; }
.footer-links-std { display: flex; flex-wrap: wrap; justify-content: center; gap: .3rem .65rem; }
.footer-links-std a, .site-footer-std p { color: var(--muted); font-size: .72rem; }
.footer-links-std a:hover { color: var(--fg); }
.footer-links-std span { color: var(--muted); opacity: .5; }
.footer-legal-std { margin-top: .35rem; opacity: .8; }
.site-footer-std p { margin: .65rem 0 0; opacity: .75; }

@keyframes progress-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 600px) {
  .progress-main { width: min(72rem, calc(100% - 2rem)); padding-top: 5.8rem; }
  .progress-error { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .journey-panel { padding: 1.35rem; }
  .primary-button { width: fit-content; }
  #continueList { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
  #continueList[data-count="1"] { grid-template-columns: minmax(0, 39rem); }
  .map-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-panel, .history-panel { padding: 1.25rem; }
  .data-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 820px) {
  .progress-hero { padding: 2.25rem 0 1.9rem; }
  .progress-subtitle { margin-top: .9rem; }
  .journey-panel { grid-template-columns: minmax(0, .9fr) minmax(30rem, 1.1fr); align-items: center; padding: 1.5rem 0; }
  .metrics { min-height: 12.25rem; }
  .metric { padding: 1rem; }
  .metric dd { font-size: 2.35rem; }
  .metric-primary dd { font-size: 6rem; }
  #continueList { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #continueList[data-count="1"] { grid-template-columns: minmax(0, 39rem); }
  #continueList[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-grid, .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .map-panel, .history-panel { padding: 1.4rem; }
  .activity-day { min-height: 28px; }
  .games-section .puzzle-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 2rem; }
  .games-section .game-row:nth-child(2) { border-top: 0; padding-top: 0; }
}

@media (max-width: 380px) {
  .progress-main { width: min(100% - .9rem, 72rem); }
  .journey-panel { padding: .85rem; }
  .metric { padding: .65rem; }
  .metric-primary dd { font-size: 3.45rem; }
  .section-heading { align-items: start; }
  .continue-card { min-height: 9.5rem; }
  .recent-row, .game-row { grid-template-columns: minmax(0, 1fr); gap: .4rem; }
  .state-badge { width: fit-content; }
  .activity-grid, .week-labels { gap: .22rem; }
  .activity-grid, .week-labels { grid-template-columns: repeat(7, 26px); }
  .activity-day { min-width: 26px; min-height: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
