:root {
  --ink: #14213d;
  --muted: rgba(20, 33, 61, .68);
  --soft: #f5f7ff;
  --white: #ffffff;
  --purple: #6d4cff;
  --teal: #10b7b0;
  --pink: #ec4899;
  --orange: #f97316;
  --green: #22c55e;
  --red: #ef4444;
  --border: rgba(20, 33, 61, .12);
  --shadow: 0 22px 70px rgba(20, 33, 61, .14);
  --radius: 30px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(109, 76, 255, .22), transparent 30%),
    radial-gradient(circle at 92% 12%, rgba(16, 183, 176, .22), transparent 28%),
    linear-gradient(135deg, #fdfaff 0%, #eef9ff 52%, #fff7ed 100%);
}

button, select { font: inherit; }

.ff-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.ff-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--purple), var(--teal));
  color: #fff;
  font-weight: 950;
  box-shadow: 0 12px 24px rgba(109, 76, 255, .22);
}

.brand strong { display: block; font-size: 1.05rem; }
.brand small { color: var(--muted); font-weight: 800; }

.top-actions, .end-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost-btn, .start-btn {
  border: 0;
  min-height: 48px;
  border-radius: 16px;
  padding: 12px 18px;
  font-weight: 950;
  cursor: pointer;
}

.ghost-btn {
  background: rgba(255, 255, 255, .72);
  color: var(--ink);
  border: 1px solid var(--border);
}

.ghost-btn.dark {
  background: #172033;
  color: #fff;
}

.start-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--purple), var(--teal));
  box-shadow: 0 15px 35px rgba(109, 76, 255, .25);
}

.setup-card, .game-card, .end-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.setup-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 26px;
  padding: clamp(26px, 5vw, 54px);
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 12px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(109, 76, 255, .12);
  color: #5738de;
  font-weight: 950;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: .78rem;
}

.setup-copy h1 {
  margin: 0;
  font-size: clamp(2.35rem, 6vw, 5.3rem);
  line-height: .94;
  letter-spacing: -.07em;
}

.setup-copy p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1.55;
  max-width: 650px;
}

.setup-controls {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 24px;
  background: #fff;
  border: 1px solid var(--border);
}

label {
  display: grid;
  gap: 7px;
  font-weight: 900;
  color: rgba(20, 33, 61, .76);
}

select {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 0 12px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 850;
}

.game-card { padding: clamp(16px, 3vw, 28px); }
.game-card[hidden], .setup-card[hidden], .end-screen[hidden] { display: none !important; }

.score-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--border);
  padding: 14px;
  display: grid;
  gap: 5px;
}

.stat-card span { color: var(--muted); font-weight: 900; }
.stat-card strong { font-size: clamp(1.55rem, 4vw, 2.4rem); line-height: 1; }

.force-meter {
  border-radius: 24px;
  background: #fff;
  border: 1px solid var(--border);
  padding: 14px;
  margin-bottom: 16px;
}

.force-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 950;
  margin-bottom: 10px;
}

.meter-track {
  height: 18px;
  border-radius: 999px;
  background: #e8ebf6;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--purple), var(--teal), var(--green));
  border-radius: inherit;
  transition: width .35s ease;
}

.question-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.question-copy, .target-visual {
  border-radius: 26px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 22px;
}

.question-copy h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 3rem);
  letter-spacing: -.05em;
}

.target-text {
  margin: 14px 0 0;
  font-size: clamp(1.8rem, 5vw, 4.3rem);
  line-height: .96;
  font-weight: 950;
  letter-spacing: -.05em;
  color: var(--purple);
}

.target-visual {
  display: grid;
  place-items: center;
  min-height: 210px;
  background:
    radial-gradient(circle at top right, rgba(109, 76, 255, .16), transparent 34%),
    #fff;
}

.fraction-svg { width: min(100%, 330px); height: auto; display: block; }
.fraction-label { font-size: 42px; font-weight: 950; fill: #14213d; }

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

.option-card {
  min-height: 180px;
  padding: 14px;
  border: 2px solid transparent;
  border-radius: 24px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(20, 33, 61, .08);
  cursor: pointer;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.option-card:hover { transform: translateY(-3px); border-color: rgba(109, 76, 255, .35); }
.option-card.correct { background: rgba(34, 197, 94, .12); border-color: var(--green); }
.option-card.wrong { background: rgba(239, 68, 68, .10); border-color: var(--red); }

.option-label {
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  font-weight: 950;
  letter-spacing: -.03em;
}

.feedback {
  margin-top: 16px;
  min-height: 52px;
  padding: 15px 18px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 950;
  text-align: center;
}

.feedback.good { color: #087c50; background: rgba(34, 197, 94, .12); }
.feedback.bad { color: #b42318; background: rgba(239, 68, 68, .10); }

.end-screen {
  min-height: min(72vh, 720px);
  display: grid;
  place-items: center;
}

.end-card {
  width: min(720px, 100%);
  padding: clamp(24px, 4vw, 44px);
  text-align: center;
}

.end-card h2 {
  margin: 0;
  font-size: clamp(2.1rem, 6vw, 4.4rem);
  letter-spacing: -.06em;
}

.end-card p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.5;
}

.end-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 22px 0;
}

.end-stats div {
  border-radius: 20px;
  padding: 14px;
  background: var(--soft);
}

.end-stats span { display: block; color: var(--muted); font-weight: 900; }
.end-stats strong { display: block; font-size: 1.8rem; margin-top: 4px; }

@media (max-width: 900px) {
  .setup-card, .question-panel { grid-template-columns: 1fr; }
  .score-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .option-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 580px) {
  .ff-shell { width: min(100% - 18px, 1180px); padding-top: 12px; }
  .ff-topbar { align-items: flex-start; }
  .top-actions { flex-direction: column; }
  .ghost-btn, .start-btn { min-height: 44px; padding: 10px 13px; }
  .setup-card { border-radius: 24px; padding: 20px; }
  .option-card { min-height: 148px; }
  .end-stats { grid-template-columns: 1fr; }
}
