:root {
  --paper: #f7f4ef;
  --surface: #fffdf9;
  --ink: #171515;
  --muted: #6f6a67;
  --line: #d9d3cc;
  --burgundy: #8f2634;
  --burgundy-dark: #6f1825;
  --rose: #f1dfe1;
  --education: #366b5b;
  --social: #765172;
  --health: #3f6676;
  --public: #8a6427;
  --shadow: 0 18px 55px rgba(48, 37, 34, .09);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", Arial, sans-serif;
}

button { font: inherit; }

button:focus-visible,
a:focus-visible,
.category:focus-visible {
  outline: 3px solid rgba(143, 38, 52, .35);
  outline-offset: 3px;
}

.activity-shell {
  width: min(1380px, calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0 64px;
}

.activity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--burgundy);
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.preview-label,
.eyebrow {
  color: var(--burgundy);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.activity-intro {
  max-width: 760px;
  margin: 48px auto 38px;
  text-align: center;
}

.eyebrow { margin: 0 0 13px; }

.activity-intro h1 {
  margin: 0;
  font-size: clamp(42px, 6vw, 72px);
  line-height: .98;
  letter-spacing: -.055em;
}

.lead {
  margin: 20px auto;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.55;
}

.text-button {
  padding: 9px 0 4px;
  border: 0;
  border-bottom: 1px solid #aaa09b;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.instructions {
  width: min(560px, 100%);
  margin: 20px auto 0;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--burgundy);
  background: var(--surface);
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.instructions p { margin: 0; }
.instructions p + p { margin-top: 6px; }

.game {
  padding: clamp(20px, 3vw, 38px);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.game-toolbar {
  min-height: 42px;
  display: grid;
  grid-template-columns: 1fr minmax(260px, auto) 1fr;
  align-items: center;
  gap: 20px;
  margin-bottom: 25px;
}

.progress {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.status.is-error { color: var(--burgundy); }
.status.is-success { color: var(--education); }

.toolbar-actions {
  justify-self: end;
  display: flex;
  gap: 8px;
}

.reset-button,
.check-button {
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.reset-button:hover { border-color: #a69b95; }

.check-button {
  border-color: var(--burgundy);
  background: var(--burgundy);
  color: #fff;
}

.check-button:hover:not(:disabled) { background: var(--burgundy-dark); }

.check-button:disabled {
  border-color: var(--line);
  background: #e7e2dc;
  color: #99918b;
  cursor: not-allowed;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.category {
  position: relative;
  min-height: 190px;
  padding: 22px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto 1fr;
  align-content: start;
  gap: 11px 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 4px solid currentColor;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.category:hover,
.category.is-dragover {
  transform: translateY(-2px);
  border-color: currentColor;
  box-shadow: 0 12px 25px rgba(35, 29, 27, .08);
}

.category-education { color: var(--education); }
.category-social { color: var(--social); }
.category-health { color: var(--health); }
.category-public { color: var(--public); }

.category-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  grid-row: 1 / 3;
  border-radius: 50%;
  background: currentColor;
  color: #fff;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
}

.category-title {
  align-self: center;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.category-count {
  align-self: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  font-weight: 600;
}

.category-hint {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 11px;
  font-style: italic;
}

.matched-list {
  grid-column: 1 / -1;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 5px;
}

.placed-card {
  width: 100%;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 8px 1fr;
  align-items: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.35;
  text-align: left;
  cursor: grab;
}

.placed-card::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: 4px;
  border-radius: 50%;
  background: #aaa29c;
}

.placed-card.is-selected { border-color: var(--burgundy); background: var(--rose); }
.placed-card.is-correct { border-color: #79a18e; background: #edf4f0; }
.placed-card.is-correct::before { background: #39705c; }
.placed-card.is-wrong { border-color: #c68189; background: #fae8e9; }
.placed-card.is-wrong::before { background: var(--burgundy); }
.category.has-correct { border-color: #79a18e; }
.category.has-wrong { border-color: #c68189; }

.category-result {
  grid-column: 1 / -1;
  margin-top: 3px;
  font-size: 10px;
  font-weight: 600;
}

.category.is-wrong { animation: nudge .28s ease; }

.cards-section { margin-top: 28px; }

.cards-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}

.cards-heading h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -.02em;
}

.cards-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.card {
  min-height: 72px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 12px 1fr;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  line-height: 1.38;
  cursor: grab;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, opacity .2s ease;
}

.card::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 1px solid #bbb2ad;
  border-radius: 50%;
  background: var(--paper);
}

.card:hover { transform: translateY(-1px); border-color: #a69b95; }

.card.is-selected {
  border-color: var(--burgundy);
  background: var(--rose);
  box-shadow: 0 0 0 2px rgba(143, 38, 52, .12);
}

.card.is-selected::before { background: var(--burgundy); border-color: var(--burgundy); }
.card.is-dragging { opacity: .45; cursor: grabbing; }
.card.is-matched { opacity: 0; transform: scale(.96); pointer-events: none; }

.completion {
  margin-top: 24px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid #b6c7bd;
  border-radius: 10px;
  background: #edf3ef;
  color: #284d40;
}

.completion[hidden] { display: none; }

.completion > span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--education);
  color: #fff;
  font-weight: 700;
}

.completion strong { display: block; }
.completion p { margin: 4px 0 0; font-size: 13px; line-height: 1.45; }

@keyframes nudge {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@media (max-width: 980px) {
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .activity-shell { width: min(100% - 24px, 1380px); padding-top: 14px; }
  .preview-label { display: none; }
  .activity-intro { margin: 38px auto 28px; }
  .activity-intro h1 { font-size: 43px; }
  .game { padding: 15px; border-radius: 13px; }
  .game-toolbar { grid-template-columns: 1fr auto; gap: 9px 12px; }
  .status { grid-column: 1 / -1; grid-row: 2; text-align: left; }
  .toolbar-actions { grid-column: 2; grid-row: 1; }
  .category-grid, .cards-grid { grid-template-columns: 1fr; }
  .category { min-height: 130px; }
  .cards-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .card { min-height: 65px; cursor: pointer; }
}

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