@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&display=swap');

:root {
  color-scheme: light;
  --ink: #20241f;
  --muted: #70756d;
  --paper: #f6f3ea;
  --card: #fffdf7;
  --lime: #c9f45d;
  --lime-dark: #9eca33;
  --orange: #ff8b5b;
  --red: #d94d3f;
  --line: #deddd4;
  --shadow: 0 24px 70px rgba(40, 49, 29, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 14%, rgba(201, 244, 93, 0.35) 0 9%, transparent 26%),
    radial-gradient(circle at 91% 90%, rgba(255, 139, 91, 0.18) 0 8%, transparent 28%),
    var(--paper);
  color: var(--ink);
  font-family: Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell {
  width: min(100% - 32px, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 38px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: clamp(30px, 5vh, 52px);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.creator-mark {
  margin-left: auto;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--ink);
  color: var(--lime);
  font-size: 25px;
}

.screen { display: none; animation: arrive 0.4s ease both; }
.screen.is-active { display: block; }

@keyframes arrive {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.results-screen, .complete-screen { max-width: 590px; }
.game-screen, .review-screen { max-width: 760px; margin: 0 auto; }
.eyebrow {
  margin-bottom: 14px;
  color: #5e7629;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: clamp(44px, 9vw, 76px); line-height: 0.98; letter-spacing: -0.065em; }
.lead { max-width: 530px; margin: 22px 0 38px; color: var(--muted); font-size: clamp(17px, 2.5vw, 20px); line-height: 1.55; }

.setup-form { max-width: 520px; }
.field-label, fieldset legend { display: block; margin-bottom: 10px; font-size: 14px; font-weight: 800; }
.number-stepper { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; }
.number-stepper input, .time-input-wrap input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  outline: none;
}
.number-stepper input:focus, .time-input-wrap input:focus, .answer-row input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(201, 244, 93, 0.48); }
.stepper-button { border: 0; border-radius: 16px; background: #e8e6dc; cursor: pointer; font-size: 25px; transition: transform 0.15s, background 0.15s; }
.stepper-button:hover { background: #dcdbd0; }
.stepper-button:active { transform: scale(0.95); }
.field-hint { margin: 7px 0 25px; color: var(--muted); font-size: 12px; }

.timer-settings { margin: 0 0 28px; padding: 0; border: 0; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: block; padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); text-align: center; cursor: pointer; }
.segmented-control input:checked + span { border-color: var(--ink); background: var(--ink); color: white; }
.segmented-control input:focus-visible + span { outline: 3px solid var(--lime-dark); outline-offset: 2px; }
.time-input-wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 12px; padding: 10px 12px 10px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); font-size: 14px; font-weight: 700; }
.time-input-wrap input { width: 90px; padding: 8px; }

.primary-button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 19px 22px;
  border: 0;
  border-radius: 18px;
  background: var(--lime);
  box-shadow: 0 8px 0 var(--lime-dark);
  cursor: pointer;
  font-size: 16px;
  font-weight: 800;
  transition: transform 0.15s, box-shadow 0.15s;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 10px 0 var(--lime-dark); }
.primary-button:active { transform: translateY(5px); box-shadow: 0 3px 0 var(--lime-dark); }
.form-error, .input-error { min-height: 20px; margin: 0 0 8px; color: var(--red); font-size: 13px; font-weight: 700; }

.game-topline { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 14px; }
.game-topline > div { display: flex; flex-direction: column; gap: 3px; }
.game-topline > div:last-child { text-align: right; }
.meta-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.game-topline strong { font-size: 18px; }
.timer-box.is-low strong { color: var(--red); }
.progress-track { height: 7px; margin-bottom: 28px; overflow: hidden; border-radius: 99px; background: #deddd4; }
.progress-track div { width: 0; height: 100%; border-radius: inherit; background: var(--lime-dark); transition: width 0.3s ease; }

.problem-card { padding: clamp(28px, 6vw, 58px); border: 1px solid rgba(32, 36, 31, 0.08); border-radius: 30px; background: var(--card); box-shadow: var(--shadow); text-align: center; }
.round-note { margin: 0 0 20px; color: var(--muted); font-size: 14px; font-weight: 700; }
.problem { font-size: clamp(72px, 18vw, 128px); line-height: 1; white-space: nowrap; }
.answer-form { max-width: 330px; margin: 36px auto 0; text-align: left; }
.answer-form > label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 800; }
.answer-row { display: grid; grid-template-columns: 1fr 64px; gap: 8px; }
.answer-row input { width: 100%; min-width: 0; padding: 14px 18px; border: 2px solid var(--line); border-radius: 16px; background: white; font-size: 25px; font-weight: 800; outline: none; }
.answer-row button { border: 0; border-radius: 16px; background: var(--ink); color: white; cursor: pointer; font-size: 27px; }
.input-error { margin-top: 7px; margin-bottom: -27px; }
.keyboard-hint { margin: 20px 0 0; color: var(--muted); font-size: 12px; text-align: center; }

.results-screen { margin: 0 auto; text-align: center; }
.score-ring { display: grid; width: 146px; height: 146px; place-content: center; margin: 0 auto 32px; border-radius: 50%; background: conic-gradient(var(--lime-dark) 0deg, #deddd4 0deg); box-shadow: inset 0 0 0 13px var(--paper); }
.score-ring strong, .score-ring span { display: block; }
.score-ring strong { font-size: 32px; line-height: 1; }
.score-ring span { margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 700; }
.results-screen h1, .complete-screen h1 { font-size: clamp(42px, 8vw, 66px); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 30px 0 18px; }
.stats-grid div { padding: 19px; border-radius: 18px; background: var(--card); text-align: left; }
.stats-grid span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.stats-grid strong { display: block; margin-top: 3px; font-size: 29px; }
.result-message { min-height: 52px; margin: 18px 0 26px; color: var(--muted); line-height: 1.55; }
.text-button { margin: 25px auto 0; border: 0; background: none; color: var(--muted); cursor: pointer; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }

.review-feedback { min-height: 23px; margin-top: 17px; font-size: 14px; font-weight: 800; }
.review-feedback.is-wrong { color: var(--red); }
.review-feedback.is-right { color: #5a7b14; }
.explanation { margin-top: 18px; padding: 18px; border-radius: 16px; background: #f1f6df; color: #455928; font-size: 14px; line-height: 1.55; text-align: left; }
.explanation strong { display: block; margin-bottom: 5px; color: var(--ink); }

.complete-screen { margin: 0 auto; text-align: center; }
.complete-screen .lead { margin-right: auto; margin-left: auto; }
.celebration { display: grid; width: 120px; height: 120px; place-items: center; margin: 0 auto 32px; border-radius: 36px; background: var(--lime); box-shadow: 12px 12px 0 var(--orange); font-size: 56px; transform: rotate(-5deg); }

[hidden] { display: none !important; }

@media (max-width: 560px) {
  .app-shell { width: min(100% - 24px, 760px); padding-top: 18px; }
  .brand { margin-bottom: 38px; }
  .creator-mark { padding: 6px 9px; font-size: 10px; }
  .problem-card { border-radius: 24px; }
  .problem { font-size: clamp(65px, 23vw, 104px); }
  .keyboard-hint { display: none; }
}

@media (min-width: 800px) {
  .setup-screen {
    display: none;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 430px);
    align-items: center;
    gap: clamp(44px, 7vw, 90px);
  }

  .setup-screen.is-active { display: grid; }
  .setup-intro .lead { margin-bottom: 0; }

  .setup-form {
    padding: 26px;
    border: 1px solid rgba(32, 36, 31, 0.08);
    border-radius: 26px;
    background: rgba(255, 253, 247, 0.82);
    box-shadow: var(--shadow);
  }

  .setup-form .field-hint { margin-bottom: 18px; }
  .setup-form .timer-settings { margin-bottom: 18px; }
}

@media (min-width: 800px) and (max-height: 760px) {
  .app-shell { padding-top: 16px; }
  .brand { margin-bottom: 22px; }
  .setup-screen h1 { font-size: clamp(48px, 6vw, 66px); }
  .setup-intro .lead { margin-top: 16px; }
  .setup-form { padding: 21px 24px; }
  .number-stepper { height: 50px; }
  .segmented-control span { padding: 12px; }
  .primary-button { padding-top: 16px; padding-bottom: 16px; }
}

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