@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 8% 14%, rgba(255, 90, 54, 0.14) 0 72px, transparent 73px),
    radial-gradient(circle at 92% 9%, rgba(255, 201, 64, 0.25) 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; }

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

.ff-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);
}
.ff-brand { display: flex; align-items: center; gap: 0.8rem; }
.ff-mark { position: relative; width: 40px; height: 40px; flex: none; }
.ff-mark::before,
.ff-mark::after { content: ''; position: absolute; inset: 0; border: 2px solid var(--ink); }
.ff-mark::before { background: var(--forest); transform: rotate(-10deg); }
.ff-mark::after { background: var(--mustard); transform: rotate(10deg) scale(0.78); clip-path: polygon(50% 5%, 94% 50%, 50% 95%, 6% 50%); }

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

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

.ff-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;
}
.ff-title { font-size: clamp(2.45rem, 6vw, 4.6rem); max-width: 9ch; }
.ff-title span { background-image: linear-gradient(transparent 65%, var(--mustard) 65%); padding: 0 4px; }
.ff-lede { color: #444; font-size: clamp(1rem, 2.2vw, 1.2rem); font-weight: 500; line-height: 1.65; max-width: 58ch; margin: 1.25rem 0 0; }
.ff-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: 34px 34px;
  box-shadow: var(--shadow-hard-lg);
  overflow: hidden;
}
.ff-map-card::before {
  content: '';
  position: absolute;
  left: 26px;
  bottom: 34px;
  width: 190px;
  height: 74px;
  border: 2px solid var(--ink);
  background: var(--forest);
  box-shadow: var(--shadow-hard);
  clip-path: polygon(0 18%, 78% 18%, 100% 50%, 78% 82%, 0 82%);
}
.ff-map-card::after {
  content: 'x → f(x)';
  position: absolute;
  right: 25px;
  top: 44px;
  width: 142px;
  min-height: 94px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  background: var(--canvas);
  box-shadow: var(--shadow-hard);
  color: var(--forest);
  font-family: var(--f-display);
  font-size: 1.65rem;
  font-weight: 800;
  transform: rotate(4deg);
}
.ff-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); }

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

.ff-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); }
.ff-card h2 { font-size: clamp(1.7rem, 4vw, 2.55rem); margin-bottom: 0.75rem; }
.ff-card p { margin: 0; color: #444; font-weight: 500; line-height: 1.55; }
.ff-card strong { color: var(--ink); }
.ff-challenge-card { margin-bottom: 1.5rem; }
.ff-play-grid { display: grid; grid-template-columns: minmax(0, 0.38fr) minmax(0, 0.62fr); gap: clamp(1rem, 3vw, 2rem); align-items: start; }
.ff-target-card { display: grid; gap: 1rem; align-content: start; }
.ff-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(2.2rem, 6vw, 4rem); }
.ff-mini-label { color: #666; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.35rem; }
.ff-count-pill { border: 2px solid var(--ink); border-radius: 999px; background: var(--mustard); padding: 0.4rem 0.65rem; font-size: 0.8rem; font-weight: 900; white-space: nowrap; }
.ff-work-card { display: grid; gap: 1rem; }
.ff-instruction { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }
.ff-instruction p { margin: 0.25rem 0 0; }

.ff-machine,
.ff-balance,
.ff-pair-board {
  border: 2px solid var(--ink);
  background: #fffaf0;
  border-radius: var(--radius-lg);
  padding: clamp(0.75rem, 2.5vw, 1.1rem);
  box-shadow: var(--shadow-hard);
}
.ff-machine {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  font-size: clamp(1.25rem, 4vw, 2rem);
}
.ff-chip,
.ff-rule-plate {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  box-shadow: 3px 3px 0 rgba(34,32,28,.20);
}
.ff-chip--input { background: var(--canvas-alt); }
.ff-chip--output { background: var(--mustard); }
.ff-chip--unknown { background: var(--coral); }
.ff-rule-plate { background: var(--forest); color: var(--canvas); font-size: 0.82em; }
.ff-arrow { color: var(--forest); }
.ff-balance { display: flex; align-items: center; justify-content: center; gap: 0.75rem; font-size: clamp(1.5rem, 5vw, 2.8rem); }
.ff-balance span { border: 2px solid var(--ink); border-radius: var(--radius); background: var(--canvas-alt); padding: 0.35rem 0.7rem; box-shadow: 3px 3px 0 rgba(34,32,28,.20); }
.ff-balance strong { color: var(--forest); }
.ff-pair-board { display: grid; gap: 0.7rem; }
.ff-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.5rem; align-items: center; font-size: clamp(1.15rem, 4vw, 1.8rem); }
.ff-pair span { border: 2px solid var(--ink); border-radius: var(--radius); background: var(--canvas-alt); padding: 0.35rem 0.55rem; text-align: center; }
.ff-pair strong { color: var(--coral); }

.ff-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.75rem; }
.ff-option { min-height: 68px; background: var(--canvas-alt); padding: 0.65rem; font-family: var(--f-display); font-size: clamp(1.25rem, 3vw, 2rem); }
.ff-option span { overflow-wrap: anywhere; }
.ff-option.is-selected { background: var(--mustard); transform: translate(-2px, -2px); box-shadow: var(--shadow-hard-lg); }
.ff-actions { display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: center; }

.ff-feedback,
.ff-success { border: 2px solid var(--ink); border-radius: var(--radius-lg); box-shadow: var(--shadow-hard); padding: 1rem; }
.ff-feedback { background: #fff7dd; }
.ff-success { background: #e1efe5; }
.ff-feedback h3 { margin: 0 0 0.35rem; font-family: var(--f-display); font-size: 1.35rem; }
.ff-feedback p,
.ff-success p { margin: 0; color: #333; font-weight: 600; line-height: 1.55; }
.ff-success strong { display: block; margin-bottom: 0.35rem; font-family: var(--f-display); font-size: 1.35rem; }
.ff-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.ff-compare-panel { border: 2px solid var(--ink); border-radius: var(--radius); background: var(--canvas); padding: 0.8rem; }
.ff-compare-panel p { overflow-wrap: anywhere; }

.ff-reward { min-height: min(720px, calc(100vh - 7rem)); display: grid; place-items: center; align-content: center; gap: 1.25rem; 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, 3rem); }
.ff-reward h2 { font-size: clamp(2.6rem, 8vw, 5.4rem); }
.ff-reward p { max-width: 58ch; margin: 0 auto; color: #444; font-size: 1.1rem; font-weight: 600; line-height: 1.65; }
.ff-reward-machine { position: relative; width: min(280px, 74vw); aspect-ratio: 1.65; border: 2px solid var(--ink); border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--forest) 0 38%, var(--mustard) 38% 62%, var(--coral) 62%); box-shadow: var(--shadow-hard-lg); transform: rotate(-3deg); }
.ff-reward-machine::after { content: 'f(x)'; position: absolute; inset: 28% 25%; display: grid; place-items: center; border: 2px solid var(--ink); background: var(--canvas); color: var(--forest); font-family: var(--f-display); font-size: 2rem; font-weight: 800; box-shadow: var(--shadow-hard); }

@media (max-width: 860px) {
  .ff-topbar,
  .ff-hero,
  .ff-play-grid { grid-template-columns: 1fr; }
  .ff-topbar { align-items: flex-start; }
  .ff-map-card { min-height: 170px; }
  .ff-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .ff-shell { padding: 0.8rem; }
  .ff-topbar { display: grid; gap: 1rem; }
  .ff-link,
  .ff-btn { width: 100%; }
  .ff-title { max-width: 100%; }
  .ff-instruction,
  .ff-progress-row { display: grid; }
  .ff-options,
  .ff-compare { grid-template-columns: 1fr; }
  .ff-machine,
  .ff-balance { justify-content: start; font-size: clamp(1.25rem, 8vw, 2rem); }
  .ff-chip,
  .ff-rule-plate,
  .ff-balance span { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .ff-link:hover,
  .ff-btn:hover,
  .ff-option:hover,
  .ff-option.is-selected { transform: none; }
}
