@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 9% 11%, rgba(255, 90, 54, 0.15) 0 72px, transparent 73px),
    radial-gradient(circle at 93% 10%, rgba(255, 201, 64, 0.26) 0 88px, transparent 89px),
    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; }

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

.cq-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);
}

.cq-brand { display: flex; align-items: center; gap: 0.8rem; }
.cq-mark { position: relative; width: 38px; height: 38px; flex: none; }
.cq-mark::before,
.cq-mark::after { content: ''; position: absolute; inset: 0; border: 2px solid var(--ink); }
.cq-mark::before { background: var(--mustard); transform: rotate(-9deg); }
.cq-mark::after { background: var(--coral); clip-path: polygon(50% 8%, 94% 88%, 6% 88%); transform: rotate(8deg) scale(0.8); }

.cq-brand h1,
.cq-title,
.cq-card h2,
.cq-reward h2,
.cq-target-number {
  font-family: var(--f-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.04;
  margin: 0;
}
.cq-brand h1 { font-size: clamp(1.45rem, 4vw, 2rem); }
.cq-brand p,
.cq-kicker {
  margin: 0;
  color: var(--forest);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cq-link,
.cq-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;
}
.cq-link:hover,
.cq-btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard-lg); }
.cq-link:focus-visible,
.cq-btn:focus-visible,
.cq-point:focus-visible,
.cq-option:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
.cq-btn--primary { background: var(--coral); color: var(--ink); }
.cq-btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

.cq-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;
}
.cq-title { font-size: clamp(2.45rem, 6vw, 4.6rem); max-width: 9ch; }
.cq-title span { background-image: linear-gradient(transparent 65%, var(--mustard) 65%); padding: 0 4px; }
.cq-lede {
  color: #444;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  font-weight: 500;
  line-height: 1.65;
  max-width: 56ch;
  margin: 1.25rem 0 0;
}

.cq-map-card {
  position: relative;
  min-height: 220px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(90deg, rgba(26,26,26,0.06) 1px, transparent 1px),
    linear-gradient(rgba(26,26,26,0.06) 1px, transparent 1px),
    var(--canvas-alt);
  background-size: 32px 32px;
  box-shadow: var(--shadow-hard-lg);
  overflow: hidden;
}
.cq-map-card::before {
  content: '';
  position: absolute;
  left: 24px;
  right: 24px;
  top: 50%;
  height: 12px;
  border-top: 4px dotted var(--forest);
  transform: rotate(-12deg);
}
.cq-map-card::after {
  content: '';
  position: absolute;
  width: 118px;
  height: 118px;
  right: 44px;
  top: 36px;
  background: var(--forest);
  border: 2px solid var(--ink);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  box-shadow: var(--shadow-hard);
}
.cq-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);
}

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

.cq-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);
}
.cq-card h2 { font-size: clamp(1.7rem, 4vw, 2.55rem); margin-bottom: 0.75rem; }
.cq-card p { margin: 0; color: #444; font-weight: 500; }

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

.cq-target-card { display: grid; gap: 1rem; align-content: start; }
.cq-target-number {
  display: inline-flex;
  align-self: start;
  width: fit-content;
  background: var(--mustard);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  padding: 0.55rem 0.9rem;
  font-size: clamp(2rem, 5vw, 3.35rem);
}
.cq-rule-card {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--canvas-alt);
  padding: 0.9rem;
}
.cq-mini-label {
  font-size: 0.74rem;
  font-weight: 900;
  color: #555;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.cq-work-card { display: grid; gap: 1rem; min-width: 0; }
.cq-instruction { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; }
.cq-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;
}

.cq-plane-wrap {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 0.45rem 0.55rem;
  align-items: stretch;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.25rem 0.25rem 0.75rem;
  scrollbar-color: var(--forest) var(--canvas-alt);
}
.cq-plane,
.cq-x-labels {
  min-width: calc(var(--cols) * 44px);
}
.cq-plane {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(44px, 1fr));
  grid-template-rows: repeat(var(--rows), 44px);
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(26,26,26,0.11) 1px, transparent 1px),
    linear-gradient(rgba(26,26,26,0.11) 1px, transparent 1px),
    #fffaf0;
  background-size: 44px 44px;
  box-shadow: var(--shadow-hard);
  overflow: hidden;
}
.cq-point {
  position: relative;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-right: 1px solid rgba(26,26,26,0.14);
  border-bottom: 1px solid rgba(26,26,26,0.14);
  background: transparent;
  cursor: pointer;
}
span.cq-point { display: block; cursor: default; }
.cq-point.is-axis { background: rgba(45, 74, 62, 0.08); }
.cq-point > span,
.cq-point::after,
.cq-point::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.cq-point > span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(26,26,26,0.3);
}
.cq-point.is-cursor::before {
  width: 30px;
  height: 30px;
  border: 2px dashed var(--forest);
  border-radius: 50%;
}
.cq-point.is-selected::after,
.cq-point.is-marker::after,
.cq-point.is-correct::after {
  width: 24px;
  height: 24px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 2px 2px 0 rgba(34,32,28,.20);
}
.cq-point.is-marker::after { background: var(--mustard); clip-path: polygon(50% 0, 100% 44%, 76% 100%, 24% 100%, 0 44%); border-radius: 2px; }
.cq-point.is-start::after {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink);
  background: var(--forest);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  box-shadow: 2px 2px 0 rgba(34,32,28,.20);
}
.cq-point.is-start.is-selected::after,
.cq-point.is-start.is-correct::after { background: var(--coral); clip-path: none; border-radius: 50%; }
.cq-point.is-correct::after { background: var(--forest); }
.cq-y-labels,
.cq-x-labels {
  display: grid;
  color: #555;
  font-size: 0.72rem;
  font-weight: 900;
}
.cq-y-labels { grid-template-rows: repeat(var(--rows), 44px); text-align: right; align-items: center; }
.cq-x-labels { grid-template-columns: repeat(var(--cols), minmax(44px, 1fr)); text-align: center; }

.cq-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.6rem;
}
.cq-option {
  min-height: 54px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--canvas-alt);
  box-shadow: var(--shadow-hard);
  font-weight: 900;
  cursor: pointer;
}
.cq-option.is-selected { background: var(--mustard); transform: translate(-2px, -2px); box-shadow: var(--shadow-hard-lg); }

.cq-actions,
.cq-controls { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.cq-feedback,
.cq-success {
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-hard);
}
.cq-feedback { background: #fff7df; }
.cq-success { background: #e0eadf; }
.cq-feedback h3,
.cq-success strong { font-family: var(--f-display); font-size: 1.35rem; margin: 0 0 0.35rem; }

.cq-reward {
  min-height: 68vh;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 1.2rem;
  text-align: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  background: var(--canvas-alt);
  box-shadow: var(--shadow-hard-lg);
  padding: clamp(1.25rem, 5vw, 4rem);
}
.cq-reward h2 { font-size: clamp(2.8rem, 8vw, 5rem); }
.cq-reward p { max-width: 54ch; margin: 0; color: #444; font-weight: 600; line-height: 1.6; }
.cq-reward-map {
  width: min(280px, 68vw);
  aspect-ratio: 1.4;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 72% 34%, var(--mustard) 0 16px, transparent 17px),
    radial-gradient(circle at 38% 62%, var(--coral) 0 18px, transparent 19px),
    linear-gradient(135deg, transparent 0 46%, var(--forest) 47% 53%, transparent 54%),
    #fffaf0;
  box-shadow: var(--shadow-hard-lg);
}

@media (max-width: 820px) {
  .cq-topbar,
  .cq-progress-row { align-items: flex-start; flex-direction: column; }
  .cq-hero,
  .cq-play-grid { grid-template-columns: 1fr; }
  .cq-map-card { min-height: 170px; }
  .cq-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cq-plane-wrap { grid-template-columns: 28px minmax(0, 1fr); }
  .cq-shell { padding: 1rem; }
}

@media (max-width: 460px) {
  .cq-title { font-size: 2.55rem; }
  .cq-link,
  .cq-btn { width: 100%; }
  .cq-actions { width: 100%; }
  .cq-actions > * { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .cq-link:hover,
  .cq-btn:hover,
  .cq-option.is-selected { transform: none; }
}
