@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,800&family=DM+Sans:wght@400;500;700;800&display=swap');

:root {
  --canvas: #F5F1E7;
  --canvas-alt: #EFE9DB;
  --ink: #22201C;
  --forest: #2E5141;
  --forest-light: #3C5C4E;
  --coral: #C8512E;
  --mustard: #F0C24B;
  --rule: #D6D1C4;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow-hard: 3px 3px 0 0 rgba(34,32,28,.20);
  --shadow-hard-lg: 4px 4px 0 0 rgba(34,32,28,.14);
  --f-display: 'Bricolage Grotesque', sans-serif;
  --f-body: 'DM Sans', sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100vh;
  margin: 0;
  font-family: var(--f-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 12%, rgba(255, 90, 54, 0.13) 0 72px, transparent 73px),
    radial-gradient(circle at 92% 8%, rgba(255, 201, 64, 0.22) 0 84px, transparent 85px),
    linear-gradient(90deg, rgba(26, 26, 26, 0.035) 1px, transparent 1px),
    linear-gradient(var(--canvas), var(--canvas));
  background-size: auto, auto, 48px 48px, auto;
}
button { font: inherit; }
a { color: inherit; }

.mp-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2.75rem);
}

.mp-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--ink);
  margin-bottom: clamp(1.25rem, 3vw, 2.5rem);
}

.mp-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.mp-mark {
  position: relative;
  width: 38px;
  height: 38px;
  flex: none;
}
.mp-mark::before,
.mp-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--ink);
}
.mp-mark::before { background: var(--mustard); transform: rotate(-13deg); }
.mp-mark::after { background: var(--coral); border-radius: 50%; transform: rotate(15deg) scale(0.82); opacity: 0.88; }

.mp-brand h1,
.mp-title,
.mp-card h2,
.mp-reward h2,
.mp-fraction {
  font-family: var(--f-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.04;
  margin: 0;
}

.mp-brand h1 { font-size: clamp(1.45rem, 4vw, 2rem); }
.mp-brand p,
.mp-kicker {
  margin: 0;
  color: var(--forest);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.mp-link,
.mp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--ink);
  font-weight: 800;
  line-height: 1;
  min-height: 44px;
  padding: 0.78rem 1rem;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-hard);
  transition: 0.15s ease-in-out;
}
.mp-link:hover,
.mp-btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard-lg); }
.mp-link:focus-visible,
.mp-btn:focus-visible,
.mp-tile:focus-visible,
.mp-option:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
.mp-btn--primary { background: var(--coral); color: var(--ink); }
.mp-btn--forest { background: var(--forest); color: var(--canvas); }
.mp-btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.mp-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.42fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: stretch;
  margin-bottom: 1.5rem;
}

.mp-title {
  font-size: clamp(2.45rem, 6vw, 4.6rem);
  max-width: 8.5ch;
}
.mp-title span { background-image: linear-gradient(transparent 65%, var(--mustard) 65%); padding: 0 4px; }
.mp-lede {
  color: #444;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  font-weight: 500;
  line-height: 1.65;
  max-width: 54ch;
  margin: 1.25rem 0 0;
}

.mp-map-card {
  position: relative;
  min-height: 220px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--canvas-alt);
  box-shadow: var(--shadow-hard-lg);
  overflow: hidden;
}
.mp-map-card::before {
  content: '';
  position: absolute;
  inset: 18px;
  background:
    linear-gradient(90deg, rgba(26, 26, 26, 0.12) 1px, transparent 1px),
    linear-gradient(180deg, rgba(26, 26, 26, 0.12) 1px, transparent 1px);
  background-size: 36px 36px;
}
.mp-map-card::after {
  content: '';
  position: absolute;
  width: 138px;
  height: 138px;
  right: 32px;
  top: 32px;
  background: var(--forest);
  border: 2px solid var(--ink);
  border-radius: 50% 42% 48% 44%;
  box-shadow: var(--shadow-hard);
}
.mp-route {
  position: absolute;
  left: 34px;
  bottom: 40px;
  width: 70%;
  height: 5px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 18px, transparent 18px 30px);
  transform: rotate(-11deg);
  z-index: 1;
}
.mp-stamp {
  position: absolute;
  right: 28px;
  bottom: 26px;
  z-index: 2;
  background: var(--mustard);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-hard);
  padding: 0.45rem 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  transform: rotate(-5deg);
}

.mp-progress-wrap {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}
.mp-progress-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.mp-progress {
  height: 18px;
  border: 2px solid var(--ink);
  background: var(--canvas-alt);
  border-radius: 999px;
  overflow: hidden;
}
.mp-progress span {
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  background: linear-gradient(90deg, var(--coral), var(--mustard));
}

.mp-card {
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--canvas);
  box-shadow: var(--shadow-hard-lg);
  padding: clamp(1rem, 3vw, 2rem);
}
.mp-card h2 { font-size: clamp(1.7rem, 4vw, 2.55rem); margin-bottom: 0.75rem; }
.mp-card p { margin: 0; color: #444; font-weight: 500; }

.mp-play-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.38fr) minmax(0, 0.62fr);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: start;
}

.mp-target-card {
  display: grid;
  gap: 1rem;
  align-content: start;
}
.mp-fraction {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  align-self: start;
  width: fit-content;
  font-size: clamp(2.2rem, 7vw, 4rem);
  line-height: 0.92;
  background: var(--mustard);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.65rem 0.95rem;
  box-shadow: var(--shadow-hard);
}
.mp-fraction i {
  width: 100%;
  border-top: 4px solid var(--ink);
  margin: 0.18rem 0;
}

.mp-reference-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}
.mp-mini-label {
  font-size: 0.74rem;
  font-weight: 900;
  color: #555;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.mp-work-card { display: grid; gap: 1rem; }
.mp-instruction {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.mp-count-pill {
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--canvas-alt);
  padding: 0.35rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 900;
}

.mp-mosaic {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 4px;
  background: var(--ink);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  padding: 4px;
  width: min(100%, var(--model-w, 430px));
  margin: 0 auto;
  box-shadow: var(--shadow-hard);
}
.mp-mosaic--small { --model-w: 170px; gap: 2px; border-width: 2px; padding: 2px; box-shadow: none; }
.mp-tile {
  min-width: 0;
  aspect-ratio: 1;
  border: 0;
  background: var(--canvas-alt);
  cursor: pointer;
  position: relative;
}
.mp-tile[aria-pressed='true'],
.mp-tile.is-shaded {
  background:
    linear-gradient(135deg, rgba(255, 201, 64, 0.34) 0 24%, transparent 24% 50%, rgba(255, 201, 64, 0.34) 50% 74%, transparent 74%),
    var(--forest);
}
.mp-mosaic--small .mp-tile { cursor: default; }
.mp-tile:disabled { cursor: default; }
.mp-tile:not(:disabled):hover { filter: brightness(0.94); }

.mp-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}
.mp-option {
  display: grid;
  gap: 0.45rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--canvas-alt);
  padding: 0.55rem;
  cursor: pointer;
  box-shadow: var(--shadow-hard);
  min-width: 0;
}
.mp-option.is-selected { background: var(--mustard); transform: translate(-1px, -1px); }
.mp-option-label { font-weight: 900; }
.mp-option-label--hidden {
  visibility: hidden;
}

.mp-actions { display: flex; gap: 0.85rem; flex-wrap: wrap; align-items: center; }
.mp-actions .mp-btn { flex: none; }

.mp-feedback {
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--canvas-alt);
  padding: 1rem;
  box-shadow: var(--shadow-hard);
  display: grid;
  gap: 1rem;
}
.mp-feedback h3 {
  font-family: var(--f-display);
  margin: 0;
  font-size: 1.35rem;
}
.mp-feedback p { margin: 0; color: #444; }
.mp-feedback-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.mp-feedback-panel {
  background: var(--canvas);
  border: 1px solid var(--rule);
  padding: 0.75rem;
  border-radius: var(--radius);
}

.mp-success {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--mustard);
  padding: 1rem;
  box-shadow: var(--shadow-hard);
}
.mp-success strong { display: block; font-family: var(--f-display); font-size: 1.35rem; margin-bottom: 0.25rem; }
.mp-success p { margin: 0; color: var(--ink); }

.mp-reward {
  display: grid;
  gap: 1.35rem;
  max-width: 840px;
  margin: 2rem auto 0;
  text-align: center;
}
.mp-reward h2 { font-size: clamp(2.4rem, 8vw, 5rem); }
.mp-reward p { margin: 0 auto; max-width: 56ch; color: #444; font-size: 1.1rem; font-weight: 500; }
.mp-reward-map {
  min-height: 220px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 30% 48%, var(--forest) 0 72px, transparent 73px),
    radial-gradient(circle at 64% 42%, var(--coral) 0 46px, transparent 47px),
    radial-gradient(circle at 52% 66%, var(--mustard) 0 60px, transparent 61px),
    linear-gradient(90deg, rgba(26, 26, 26, 0.12) 1px, transparent 1px),
    linear-gradient(180deg, var(--canvas-alt), var(--canvas-alt));
  background-size: auto, auto, auto, 34px 34px, auto;
  box-shadow: var(--shadow-hard-lg);
  position: relative;
}
.mp-reward-map::after {
  content: 'PROVINCE CHARTED';
  position: absolute;
  right: 28px;
  bottom: 28px;
  background: var(--mustard);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-hard);
  padding: 0.55rem 0.8rem;
  font-weight: 900;
  transform: rotate(-6deg);
}

@media (max-width: 860px) {
  .mp-hero,
  .mp-play-grid { grid-template-columns: 1fr; }
  .mp-map-card { min-height: 180px; order: -1; }
  .mp-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .mp-shell { padding: 1rem; }
  .mp-topbar { align-items: flex-start; flex-direction: column; }
  .mp-link,
  .mp-actions .mp-btn { width: 100%; }
  .mp-card { padding: 1rem; box-shadow: var(--shadow-hard); }
  .mp-title { font-size: clamp(2.35rem, 14vw, 3.2rem); }
  .mp-reference-row,
  .mp-feedback-grid { grid-template-columns: 1fr; }
  .mp-options { grid-template-columns: 1fr; }
  .mp-mosaic { gap: 3px; padding: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .mp-link:hover,
  .mp-btn:hover,
  .topic-card:hover { transform: none !important; }
}
