:root {
  color-scheme: light;
  --page: #fffaf0;
  --paper: #fffefa;
  --ink: #40281d;
  --quiet: #715648;
  --line: #e8d8bd;
  --yellow: #ffd24e;
  --light-yellow: #fff1bd;
  --brown: #82571e;
  --green: #256348;
  --red: #8a442e;
  font-family: ui-rounded, "Avenir Next", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  -webkit-tap-highlight-color: transparent;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
:focus-visible, .segments input:focus-visible + span, .levels input:focus-visible + span {
  outline: 3px solid #935116;
  outline-offset: 3px;
}
h1, p { margin: 0; }
.shell {
  max-width: 756px;
  margin-inline: auto;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 15px; }
.brand, .sound { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; }
.brand { border: 0; padding: 0; background: none; font-size: clamp(1.05rem, 4vw, 1.3rem); font-weight: 850; letter-spacing: -.035em; }
.brand img { border-radius: 12px; border: 1px solid #edbd44; }
.sound { padding: 0 12px; background: var(--paper); border: 1px solid var(--line); border-radius: 30px; font-size: .875rem; font-weight: 750; white-space: nowrap; }
.speaker { position: relative; width: 20px; height: 16px; display: inline-block; }
.speaker::before { content: ""; position: absolute; inset: 1px 8px 1px 0; background: currentColor; clip-path: polygon(0 30%, 34% 30%, 100% 0, 100% 100%, 34% 70%, 0 70%); }
.speaker i { position: absolute; right: 0; top: 2px; width: 9px; height: 12px; border-right: 2px solid currentColor; border-radius: 50%; }
.sound[aria-pressed="false"] .speaker i { width: 7px; height: 7px; right: 0; top: 5px; border: 0; border-radius: 0; background: linear-gradient(45deg, transparent 40%, currentColor 41% 59%, transparent 60%), linear-gradient(-45deg, transparent 40%, currentColor 41% 59%, transparent 60%); }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr);
  align-items: center;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: clamp(155px, 34vw, 242px);
  margin-bottom: 14px;
  border: 1px solid #edbb3d;
  border-radius: 26px;
  background: #ffe486;
}
.hero-copy { z-index: 1; padding: clamp(16px, 5vw, 34px); padding-right: 0; }
.hero h1 { font-size: clamp(2rem, 7.5vw, 4.3rem); line-height: .94; font-weight: 950; letter-spacing: -.075em; }
.hero p { margin-top: 10px; font-size: clamp(.875rem, 2.6vw, 1.05rem); font-weight: 650; }
.hero-art { display: grid; place-items: center; position: relative; height: 100%; }
.hero-art::before { content: ""; z-index: -1; position: absolute; width: clamp(150px, 36vw, 260px); aspect-ratio: 1; border-radius: 50%; background: #fff1ae; }
.spark { position: absolute; background: #996126; clip-path: polygon(50% 0, 62% 37%, 100% 50%, 62% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%); }
.spark-one { width: 24px; height: 24px; top: 14%; right: 13%; }
.spark-two { width: 14px; height: 14px; bottom: 19%; right: 12%; }
.spark-three { width: 18px; height: 18px; left: 2%; top: 21%; background: #bb7828; }
.puppy-wrap { width: clamp(116px, 34vw, 229px); }
.puppy { position: relative; aspect-ratio: 1.24; }
.puppy i { position: absolute; display: block; }
.pup-shadow { width: 68%; height: 8%; background: #e4aa4c55; border-radius: 50%; left: 16%; bottom: 5%; }
.ear { width: 26%; height: 58%; top: 25%; background: #cc8b4b; border: 2px solid #663d26; box-shadow: inset 0 -8px #b9753e; }
.ear-left { left: 6%; border-radius: 52% 35% 56% 54%; transform: rotate(24deg); }
.ear-right { right: 6%; border-radius: 35% 52% 54% 56%; transform: rotate(-24deg); }
.face { position: absolute; inset: 16% 21% 22%; border: 2px solid #663d26; background: #fff7dd; box-shadow: inset 0 -6px #f8e3ad; border-radius: 49% 49% 45% 45% / 55% 55% 44% 44%; }
.tuft { top: -8%; left: 44%; width: 19%; height: 18%; border-radius: 70% 34% 43% 33%; border-left: 2px solid #663d26; border-top: 2px solid #663d26; background: #fff7dd; transform: rotate(-15deg); }
.eye { width: 8%; height: 13%; top: 44%; border-radius: 50%; background: #40281d; }
.eye-left { left: 26%; }
.eye-right { right: 26%; }
.cheek { width: 15%; height: 9%; top: 62%; border-radius: 50%; background: #efa58a; }
.cheek-left { left: 12%; }
.cheek-right { right: 12%; }
.nose { top: 56%; left: 44%; width: 12%; height: 10%; background: #40281d; border-radius: 50% 50% 65% 65%; }
.mouth { top: 62%; left: 42%; width: 16%; height: 13%; border-bottom: 2px solid #40281d; border-radius: 50%; }
.bandana { z-index: -1; width: 27%; height: 28%; left: 37%; bottom: 10%; background: #e49942; border: 2px solid #663d26; border-radius: 40% 15% 32% 12%; transform: rotate(25deg); }
.puppy { isolation: isolate; }
.bandana::after { content: ""; position: absolute; width: 37%; aspect-ratio: 1; right: 9%; bottom: 12%; background: #fff6ce; clip-path: polygon(50% 0, 63% 36%, 100% 50%, 63% 63%, 50% 100%, 36% 63%, 0 50%, 36% 36%); }

.setup { background: var(--paper); border: 1px solid var(--line); border-radius: 24px; padding: clamp(13px, 3.3vw, 22px); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 7px; font-size: 1rem; font-weight: 850; }
.levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.levels label, .segments label { position: relative; display: flex; }
.levels input, .segments input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.levels input + span {
  display: flex; align-items: center; gap: clamp(6px, 2vw, 10px);
  width: 100%; min-height: 52px; padding: 6px clamp(5px, 2vw, 11px);
  border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
  cursor: pointer;
}
.levels input:checked + span { background: var(--light-yellow); border-color: #b27a27; }
.levels input:disabled + span { color: var(--quiet); cursor: default; background: #faf5e9; }
.level-number { display: grid; place-items: center; font-weight: 800; width: 25px; height: 25px; flex: none; border-radius: 8px; background: #ffe290; }
.levels input:disabled + span .level-number { background: #eee5d5; }
.level-name { font-weight: 760; font-size: clamp(.82rem, 2.7vw, .98rem); line-height: 1.15; }
.lock { display: inline-block; width: 10px; height: 8px; position: relative; margin-top: 4px; background: currentColor; border-radius: 2px; }
.lock::before { content: ""; position: absolute; left: 2px; top: -5px; width: 6px; height: 7px; border: 1.5px solid currentColor; border-bottom: 0; border-radius: 4px 4px 0 0; }
.options { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: 12px; margin-block: 13px; }
.segments { display: flex; gap: 3px; border: 1px solid var(--line); background: #f9f1df; padding: 3px; border-radius: 12px; }
.segments label { flex: 1 1 auto; }
.segments input + span {
  display: grid; place-items: center; min-width: 0; width: 100%; min-height: 38px; padding: 0 4px;
  border: 1px solid transparent; border-radius: 8px; font-size: clamp(.80rem, 2.7vw, .95rem);
  font-weight: 750; cursor: pointer;
}
.segments input:checked + span { background: var(--paper); border-color: var(--line); box-shadow: 0 1px 2px #6f493213; }
.primary {
  display: block; width: 100%; min-height: 52px; padding: 8px 14px; border: 1px solid #bf8b30;
  border-radius: 14px; background: var(--yellow); color: var(--ink);
  box-shadow: 0 3px 0 #d8a044; font-size: 1.12rem; font-weight: 900;
}
.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #d8a044; }
.primary:disabled { background: #f5ecd9; border-color: var(--line); color: var(--quiet); box-shadow: none; }
.primary.secondary { background: var(--paper); border-color: var(--line); box-shadow: 0 2px 0 var(--line); }

.practice, .finish { max-width: 520px; margin-inline: auto; }
.round-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.round-head h1 { font-size: clamp(1.16rem, 4.2vw, 1.46rem); line-height: 1.17; letter-spacing: -.03em; }
.round-head p { margin-top: 2px; font-size: .875rem; font-weight: 650; color: var(--quiet); }
.text-button { min-height: 44px; border: none; padding: 3px 3px 3px 8px; background: transparent; color: var(--quiet); font-size: .875rem; font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
progress { display: block; width: 100%; height: 8px; appearance: none; border: 0; overflow: hidden; border-radius: 99px; background: #f0e4c9; margin-block: 8px 10px; }
progress::-webkit-progress-bar { background: #f0e4c9; }
progress::-webkit-progress-value { border-radius: 99px; background: #b07821; }
progress::-moz-progress-bar { border-radius: 99px; background: #b07821; }
.problem-card {
  position: relative; overflow: hidden; display: grid; justify-items: center; gap: 6px;
  margin-bottom: 10px; padding: 7px 7px 10px;
  background: var(--light-yellow); border: 1px solid #e7be60; border-radius: 23px;
}
.problem-card .puppy-wrap { width: clamp(57px, 17vw, 87px); }
.problem-card[data-tone="correct"] { background: #e9f5de; border-color: #96bb80; }
.problem-card[data-tone="retry"] { background: #fff0df; border-color: #ebbb9c; }
.equation { display: flex; align-items: center; justify-content: center; gap: .22em; max-width: 100%; white-space: nowrap; font-size: clamp(1.5rem, 8.3vw, 3.5rem); font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.045em; }
.answer { min-width: 1.45em; padding: 0 .12em; text-align: center; border-radius: 11px; background: var(--paper); border: 1px dashed #af7b2d; }
.feedback { min-height: 1.2em; text-align: center; color: var(--quiet); font-weight: 750; font-size: clamp(.88rem, 3.9vw, 1rem); }
[data-tone="correct"] .feedback { color: var(--green); }
[data-tone="retry"] .feedback { color: var(--red); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.keypad button {
  min-height: clamp(44px, 7.3dvh, 66px); border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper); box-shadow: 0 2px 0 #eaddc5; font-size: clamp(1.2rem, 5vw, 1.6rem);
  font-weight: 900; user-select: none;
}
.keypad button:disabled { opacity: .6; }
.keypad button:active:not(:disabled) { background: var(--light-yellow); box-shadow: none; transform: translateY(2px); }
.keypad .zero { grid-column: 1 / 3; }
.keypad .delete { background: #f8f0df; font-size: .9rem; }

.finish { display: grid; gap: 13px; text-align: center; }
.finish-card { display: grid; justify-items: center; gap: 10px; padding: 22px 13px 25px; border-radius: 26px; border: 1px solid #edbb3d; background: #ffe486; }
.finish h1 { font-size: clamp(1.7rem, 7vw, 2.8rem); line-height: 1.02; letter-spacing: -.055em; }
.finish p { font-weight: 700; }
.unlock-message { background: var(--paper); border: 1px solid #e7be60; border-radius: 12px; padding: 8px 12px; }
.finish .text-button { justify-self: center; }
.bouncing .puppy, .finish:not([hidden]) .puppy { animation: bounce .52s ease-out; }
@keyframes bounce { 32% { transform: translateY(-7px) rotate(-6deg); } 65% { transform: translateY(1px) rotate(4deg); } }
@media (min-width: 600px) { .shell { padding-top: max(24px, env(safe-area-inset-top)); } .topbar { margin-bottom: 20px; } .hero { margin-bottom: 18px; } }
@media (max-height: 735px) and (max-width: 500px) {
  .topbar { margin-bottom: 8px; }
  .problem-card .puppy-wrap { width: 52px; }
  .keypad button { min-height: 45px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
