/* Division 1, 2 and 3: practice with equal groups and arrays */
: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;
  --bean: #E8742A; --group: #EAF6FC; --group-line: #7FB8D6;
  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;
}
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; }
.sub { display: block; font-size: 1rem; font-weight: 700; color: var(--soft-ink); }
.tools { display: flex; gap: 8px; align-items: center; }
.streak { font-weight: 700; font-size: 1.05rem; }
.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: 5px; margin-bottom: 14px; }
.track span { width: 13px; height: 13px; border-radius: 50%; background: var(--dot); }
.track span.done { background: var(--leaf); }
.track span.retry { background: var(--sun); }
.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; }

/* the fact: 35 ÷ 5 = [ ] */
.fact { display: flex; align-items: center; justify-content: center; gap: .3em; font-weight: 700; font-size: clamp(2.6rem, 11vw, 4.4rem); line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fact .op { color: var(--soft-ink); }
.slot { display: inline-grid; place-items: center; min-width: 1.5em; height: 1.4em; padding: 0 .15em; 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); }

/* keypad */
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; margin: 14px auto 0; }
.keypad button { font: inherit; font-weight: 700; font-size: 1.7rem; min-height: 54px; background: var(--btn); color: var(--ink); border: 3px solid var(--btn-border); border-radius: 16px; cursor: pointer; touch-action: manipulation; }
.keypad button.check { background: var(--grape); color: var(--grape-ink); border-color: var(--grape); font-size: 1.3rem; }
.keypad button.del { font-size: 1.4rem; }
.keypad button:disabled { opacity: .45; cursor: default; }

/* help */
.help { margin-top: 16px; padding: 12px; border-radius: 20px; border: 3px dashed var(--sun); }
.htitle { margin: 0 0 8px; text-align: center; font-weight: 700; font-size: clamp(1.1rem, 4vw, 1.3rem); }
.ways { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.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; }
.hlines { margin: 10px 0 0; padding-left: 1.2em; font-size: clamp(1rem, 3.6vw, 1.12rem); line-height: 1.4; }
.hlines li { margin-bottom: 4px; }

/* equal groups: each group is a circle of beans with the running count under it */
.groups { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.grp { display: grid; justify-items: center; gap: 2px; opacity: .25; transition: opacity .25s, transform .25s; }
.grp.on { opacity: 1; }
.grp.say { transform: scale(1.08); }
.gdots { display: grid; gap: 3px; padding: 7px; border-radius: 16px; background: var(--group); border: 2px solid var(--group-line); }
.gdots.c2 { grid-template-columns: repeat(2, 12px); }
.gdots.c3 { grid-template-columns: repeat(3, 12px); }
.gdots.c4 { grid-template-columns: repeat(4, 12px); }
.gdots.c5 { grid-template-columns: repeat(5, 12px); }
.gdots i { width: 12px; height: 12px; border-radius: 50%; background: var(--bean); }
.gcount { font-weight: 700; font-size: 1rem; }
.grp.say .gcount, .arow.say .acount { color: var(--grape); }

/* array: one row per group, running count at the end of each row */
.arr { display: grid; gap: 4px; justify-items: start; }
.arow { display: flex; align-items: center; gap: 10px; opacity: .25; transition: opacity .25s; }
.arow.on { opacity: 1; }
.adots { display: flex; gap: 4px; padding: 3px 6px; border-radius: 999px; }
.arow.say .adots { background: var(--sun-bg); }
.adots i { width: 15px; height: 15px; border-radius: 50%; background: var(--bean); }
.acount { font-weight: 700; min-width: 2ch; }

.feedback { min-height: 1.6em; margin-top: 12px; text-align: center; font-size: clamp(1.1rem, 4vw, 1.35rem); }
.feedback.good { color: var(--leaf); font-weight: 700; }
.feedback.try { color: var(--berry); }
.next { font: inherit; font-weight: 700; font-size: 1.4rem; display: block; margin: 10px auto 0; background: var(--grape); color: var(--grape-ink); border: none; border-radius: 999px; padding: 12px 36px; cursor: pointer; }
.hidden { display: none !important; }
.end { text-align: center; padding: 30px 10px; }
.end .big { font-size: clamp(3rem, 14vw, 5rem); margin: 0; }
.end p { font-size: 1.4rem; }

@media (max-width: 420px) {
  .gdots i { width: 10px; height: 10px; }
  .gdots.c2 { grid-template-columns: repeat(2, 10px); } .gdots.c3 { grid-template-columns: repeat(3, 10px); }
  .gdots.c4 { grid-template-columns: repeat(4, 10px); } .gdots.c5 { grid-template-columns: repeat(5, 10px); }
  .adots i { width: 12px; height: 12px; }
}

/* laptops: the problem and keypad 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, 1.15fr); column-gap: 24px; align-items: start; grid-auto-flow: row dense; }
  #game > .prompt, #game > .fact, #game > .keypad { grid-column: 1; }
  #help, #feedback, #nextBtn { grid-column: 2; }
  #help { margin-top: 0; grid-row: 1 / span 3; }
  #feedback { grid-row: 4; }
  #nextBtn { grid-row: 5; }
}
@media (min-width: 900px) and (max-height: 760px) {
  .keypad button { min-height: 46px; font-size: 1.5rem; }
  .arr { gap: 1px; }
  .adots { gap: 3px; padding: 2px 6px; }
  .adots i { width: 12px; height: 12px; }
  .hlines { margin-top: 6px; line-height: 1.3; }
  .help { padding: 10px; }
}
