:root {
  --tens:  #2f6fd0;
  --ones:  #d97316;
  --ink:   #3f5b6b;
  --card:  #ffffff;
  --muted: #93a7b4;
  --shadow: 0 10px 28px rgba(60, 110, 80, .2);
  --radius: 22px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Nunito, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #bfe6ff 0%, #e4f5ff 52%, #f3fbe8 100%);
  background-attachment: fixed;
}

/* ---- meadow scenery ------------------------------------------------ */
.meadow { position: fixed; inset: 0; overflow: hidden; z-index: 0; }
.sun {
  position: absolute; top: -40px; right: -30px; width: 150px; height: 150px;
  border-radius: 50%; background: #ffe27a; box-shadow: 0 0 70px rgba(255, 213, 74, .8);
}
.cloud { position: absolute; background: rgba(255, 255, 255, .9); border-radius: 999px; }
.cloud::before {
  content: ""; position: absolute; top: -50%; left: 22%;
  width: 60%; height: 200%; background: inherit; border-radius: 50%;
}
.cloud-1 { top: 12%; left: 8%;  width: 130px; height: 40px; animation: drift 70s linear infinite; }
.cloud-2 { top: 26%; right: 12%; width: 95px;  height: 30px; animation: drift 95s linear infinite reverse; }
@keyframes drift { from { transform: translateX(-15vw); } to { transform: translateX(115vw); } }

.hill { position: absolute; left: 50%; border-radius: 50% 50% 0 0; transform: translateX(-50%); }
.hill-back  { bottom: -120px; width: 150vw; height: 300px; background: #a8d982; }
.hill-front { bottom: -160px; width: 190vw; height: 320px; background: #8ccb6b; }

@media (prefers-reduced-motion: reduce) {
  .cloud { animation: none; }
}

/* ---- layout -------------------------------------------------------- */
.app {
  position: relative; z-index: 1;
  max-width: 480px; margin: 0 auto;
  padding: 16px 16px 32px;
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .92); border-radius: 999px;
  padding: 6px 12px; font-weight: 800; font-size: 14px; box-shadow: 0 2px 8px rgba(70, 120, 90, .18);
}
.pill .stars { color: var(--ones); }

.pips { display: flex; gap: 5px; justify-content: center; margin-bottom: 18px; }
.pip { width: 20px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .8); }
.pip.done { background: #5aa845; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 26px 16px; box-shadow: var(--shadow);
}

/* ---- the problem --------------------------------------------------- */
.problem {
  display: flex; align-items: flex-start; justify-content: center;
  gap: 2px; font-size: clamp(30px, 9vw, 42px); font-weight: 800; line-height: 1;
}
.digit { display: inline-flex; flex-direction: column; align-items: center; }
.digit .place { font-size: 9px; letter-spacing: .5px; margin-top: 6px; font-weight: 800; }
.tens { color: var(--tens); }
.ones { color: var(--ones); }
.tens .place { color: #8fabd8; }
.ones .place { color: #e3b280; }
.op { color: #c2cbd9; margin: 0 8px; }

.answer {
  display: inline-block; min-width: 84px; text-align: center;
  background: #eef2f9; border-radius: 12px; padding: 0 10px; color: #5a6b85;
}
.answer.wrong { animation: shake .35s; background: #ffe8e0; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* ---- teaching breakdown -------------------------------------------- */
.breakdown { margin-top: 18px; font-size: 17px; font-weight: 700; }
.breakdown table { margin: 0 auto; border-collapse: collapse; }
.breakdown td { padding: 3px 7px; }
.breakdown .label { font-size: 10px; letter-spacing: .5px; }
.breakdown .total td { border-top: 3px solid #dfe7ef; font-size: 21px; }

/* ---- number pad ---------------------------------------------------- */
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px; }
.key {
  font-family: inherit; font-size: 26px; font-weight: 800; color: var(--ink);
  background: #fff; border: none; border-radius: 16px; padding: 16px 0;
  box-shadow: 0 4px 0 #d8e6dc; cursor: pointer;
  min-height: 60px;                      /* large enough for a six-year-old */
  -webkit-tap-highlight-color: transparent;
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 #d8e6dc; }
.key.wide { font-size: 20px; }
.key.go { background: #5aa845; color: #fff; box-shadow: 0 4px 0 #3f8231; }

/* On the digit pad specifically (PIN entry / gameplay), give the delete key
   real extra width — easier for a six-year-old thumb to hit — and let the
   Go button, now alone on the row below it, fill the full row instead of
   being stranded at a third of the width. The complete screen's own
   Switch/Play-again pad is a plain .pad (not .pad-digits) and keeps its
   even two-column layout untouched. */
.pad-digits .key.wide { grid-column: span 2; }
.pad-digits .key.go { grid-column: 1 / -1; }

/* ---- family code (parent-facing text entry) ------------------------- */
.code-input {
  display: block; width: 100%; box-sizing: border-box;
  font-family: inherit; font-size: 22px; font-weight: 800; letter-spacing: .5px;
  color: var(--ink); text-align: center;
  background: #eef2f9; border: 2px solid transparent; border-radius: 12px;
  padding: 16px 12px; margin-bottom: 12px;
  -webkit-appearance: none; appearance: none;
}
.code-input::placeholder { color: var(--muted); font-weight: 700; letter-spacing: normal; }
.code-input:focus { outline: none; border-color: var(--tens); background: #fff; }
.code-submit { display: block; width: 100%; }

/* ---- profile cards ------------------------------------------------- */
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; }
.profile-card {
  background: #fff; border: none; border-radius: var(--radius); padding: 20px 12px;
  font-family: inherit; cursor: pointer; box-shadow: var(--shadow); text-align: center;
}
.profile-card .avatar { font-size: 42px; }
.profile-card .name { font-weight: 800; font-size: 17px; margin-top: 6px; }

h1 { font-size: 22px; text-align: center; margin: 6px 0 18px; }
.hint { text-align: center; color: var(--muted); font-size: 14px; margin-top: 10px; }
.error { text-align: center; color: #c0392b; font-weight: 700; margin-top: 10px; min-height: 20px; }
.celebrate { text-align: center; font-size: 46px; margin-bottom: 8px; }
.big-score { text-align: center; font-size: 40px; font-weight: 800; color: var(--ones); }
