/* Add Within 5 (Level 1): doubles pictures, counting on, and lots of celebrating */
:root {
  --sky: #DDF1FA; --card: #FFFFFF; --ink: #1F2A44; --soft-ink: #4A5878;
  --sun: #FFC93C; --sun-bg: #FFF4D2; --grape: #6C4AB6; --grape-ink: #FFFFFF;
  --leaf: #1E7A43; --leaf-bg: #DDF5E6; --berry: #C13560; --berry-bg: #FCE3EA;
  --dot: #B9D7E6; --btn: #FFFFFF; --btn-border: #1F2A44; --pink: #F15BB5;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%; background: var(--sky); color: var(--ink);
  font-family: "Andika", "Century Gothic", "Trebuchet MS", system-ui, sans-serif;
  display: flex; justify-content: center; overflow-x: hidden;
}
main { width: 100%; max-width: 820px; padding: 16px 14px 32px; }
.home-link { display: inline-block; font: inherit; font-weight: 700; color: var(--ink); text-decoration: none; background: var(--btn); border: 2px solid var(--btn-border); border-radius: 999px; padding: 6px 14px; margin-bottom: 10px; min-height: 40px; }
.home-link:focus-visible, button:focus-visible { outline: 4px solid var(--grape); outline-offset: 3px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
h1 { font-size: clamp(1.4rem, 4.5vw, 2rem); margin: 0; }
.tools { display: flex; gap: 8px; align-items: center; }
.streak { font-weight: 700; font-size: 1.1rem; }
.pill { font: inherit; font-size: 1rem; background: var(--btn); color: var(--ink); border: 2px solid var(--btn-border); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.track { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.track span { width: 16px; height: 16px; border-radius: 50%; background: var(--dot); }
.track span.done { background: var(--sun); box-shadow: 0 0 0 2px #E0A800 inset; }
.track span.retry { background: var(--pink); }
.track span.now { outline: 3px solid var(--grape); outline-offset: 1px; }

.card { background: var(--card); border-radius: 26px; padding: 18px 14px 20px; }
.prompt { font-size: clamp(1.15rem, 4.2vw, 1.5rem); text-align: center; margin: 0 0 8px; font-weight: 700; }
.hear { font: inherit; font-size: 1.1rem; background: var(--btn); border: 2px solid var(--btn-border); border-radius: 999px; padding: 2px 10px; cursor: pointer; vertical-align: middle; }

.fact { display: flex; align-items: center; justify-content: center; gap: .3em; font-weight: 700; font-size: clamp(3rem, 13vw, 5rem); line-height: 1.1; white-space: nowrap; }
.fact .op { color: var(--soft-ink); }
.slot { display: inline-grid; place-items: center; min-width: 1.3em; height: 1.3em; border: 4px dashed var(--soft-ink); border-radius: 18px; color: var(--grape); }
.slot.filled { border-style: solid; border-color: var(--leaf); background: var(--leaf-bg); color: var(--leaf); animation: bounceIn .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes bounceIn { from { transform: scale(.4); } to { transform: none; } }

/* answer buttons 1 to 5 */
.nums { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; max-width: 520px; margin: 16px auto 0; }
.num { font: inherit; font-weight: 700; font-size: clamp(2rem, 9vw, 2.8rem); min-height: 72px; background: var(--btn); color: var(--ink); border: 4px solid var(--btn-border); border-radius: 20px; cursor: pointer; touch-action: manipulation; }
.num.right { background: var(--leaf-bg); border-color: var(--leaf); color: var(--leaf); animation: bounceIn .5s cubic-bezier(.3,1.6,.5,1); }
.num.wrong { background: var(--berry-bg); border-color: var(--berry); color: var(--berry); }
.num.hint { box-shadow: 0 0 0 6px var(--sun); border-color: var(--sun); animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 10px rgba(255,201,60,.5); } }
.num:disabled { cursor: default; }

/* help */
.help { margin-top: 16px; padding: 12px; border-radius: 20px; border: 3px dashed var(--sun); text-align: center; }
.htitle { margin: 0 0 6px; font-weight: 700; font-size: clamp(1.15rem, 4.2vw, 1.4rem); }
.hline { margin: 8px 0 0; font-size: clamp(1.05rem, 3.8vw, 1.25rem); line-height: 1.35; }
.ways { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.way { font: inherit; font-weight: 700; font-size: 1rem; background: var(--btn); color: var(--ink); border: 2px solid var(--btn-border); border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.way[aria-pressed="true"] { background: var(--grape); color: var(--grape-ink); border-color: var(--grape); }
.pic { display: flex; justify-content: center; }
.pic-svg { width: min(100%, 300px); height: auto; }
.pic-svg .tag { font: 700 17px "Andika", "Trebuchet MS", sans-serif; fill: var(--grape); }
.pic-svg .part { transition: filter .2s, opacity .2s; }
.pic-svg .part.say { filter: drop-shadow(0 0 6px #FFC93C) drop-shadow(0 0 3px #FFC93C); }

/* counting on: the big number, then the dots to count on */
.counton { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 6px 0; }
.bignum { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; background: var(--grape); color: var(--grape-ink); font-size: 3rem; font-weight: 700; transition: transform .25s; }
.bignum.say { transform: scale(1.15); box-shadow: 0 0 0 6px var(--sun); }
.plus { font-size: 2.6rem; font-weight: 700; color: var(--soft-ink); }
.cdots { display: flex; gap: 12px; }
.cdot { display: grid; justify-items: center; gap: 4px; opacity: .3; transition: opacity .2s, transform .2s; }
.cdot i { width: 44px; height: 44px; border-radius: 50%; background: #FF8A1F; border: 3px solid #B85A0A; }
.cdot b { font-size: 1.6rem; visibility: hidden; color: var(--grape); }
.cdot.on { opacity: 1; }
.cdot.on b { visibility: visible; }
.cdot.say { transform: scale(1.18); }

.feedback { min-height: 1.6em; margin-top: 12px; text-align: center; font-size: clamp(1.15rem, 4.2vw, 1.45rem); }
.feedback.good { color: var(--leaf); font-weight: 700; }
.feedback.try { color: var(--grape); font-weight: 700; }
.next { font: inherit; font-weight: 700; font-size: 1.5rem; display: block; margin: 10px auto 0; background: var(--grape); color: var(--grape-ink); border: none; border-radius: 999px; padding: 12px 40px; cursor: pointer; }
.hidden { display: none !important; }
.end { text-align: center; padding: 26px 10px; }
.end .big { font-size: clamp(3.4rem, 15vw, 5.5rem); margin: 0; animation: wiggle 1s ease-in-out infinite alternate; display: inline-block; }
@keyframes wiggle { from { transform: rotate(-8deg) scale(1); } to { transform: rotate(8deg) scale(1.12); } }
.end h2 { font-size: clamp(1.6rem, 6vw, 2.3rem); margin: 8px 0; }
.end p { font-size: 1.4rem; margin: 6px 0; }
.stars { font-size: clamp(1.6rem, 6vw, 2.2rem); letter-spacing: 2px; }

/* emoji pop on every right answer */
#party { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.pop { position: absolute; line-height: 1; transform: translate(-50%, -50%) scale(0); animation: pop 1.9s cubic-bezier(.2,1.4,.4,1) forwards; }
@keyframes pop {
  0% { transform: translate(-50%, -50%) scale(0) rotate(0); opacity: 1; }
  20% { transform: translate(-50%, -50%) scale(1.25) rotate(calc(var(--r) / 2)); }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1) rotate(var(--r)); opacity: 0; }
}
.cheer { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: clamp(2rem, 8vw, 3.6rem); font-weight: 700; white-space: nowrap; color: #fff; background: linear-gradient(90deg, #EF476F, #F4A300, #06B88A, #118AB2, #9B5DE5); padding: 6px 26px; border-radius: 999px; box-shadow: 0 6px 0 rgba(0,0,0,.15); animation: cheer 1.6s cubic-bezier(.3,1.5,.5,1) forwards; }
@keyframes cheer { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 25% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%); } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 45; }
/* computers with animations turned off (common on school laptops) still get the party: emojis gently fade in and out */
@keyframes calmPop { 0% { opacity: 0; } 15% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes calmCheer { 0% { opacity: 0; } 12% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .pop { transform: translate(-50%, -50%); animation: calmPop 1.9s ease forwards; }
  .cheer { animation: calmCheer 1.7s ease forwards; }
  .end .big { animation: none; }
}

/* laptops: the problem and number buttons on the left, the help picture on the right */
@media (min-width: 900px) {
  main { max-width: 1100px; }
  #game { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 24px; align-items: start; }
  #game > .prompt, #game > .fact, #game > .nums { grid-column: 1; }
  #help { grid-column: 2; grid-row: 1 / span 3; margin-top: 0; }
  #feedback { grid-column: 1 / span 2; grid-row: 4; }
  #nextBtn { grid-column: 1 / span 2; grid-row: 5; }
}
