/* Base and components for the newer games. Older games carry the same base
   inline. Load this before tool.css, which adds the shared theme and chrome. */
:root{--ink:#243e36;--r1:#C93A45;--r2:#EE8B3A;--r3:#F2C53D;--r4:#2F8553;--r5:#5BB8D6;--r6:#3D5FC4;--r7:#7E52BA;--r8:#B8437C;
  --rainbow-v:linear-gradient(180deg,var(--r1),var(--r2),var(--r3),var(--r4),var(--r5),var(--r6),var(--r7),var(--r8))}
*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{margin:0}
main{margin:0 auto}
body{font-family:var(--sb-round,Fredoka,system-ui,sans-serif);-webkit-tap-highlight-color:transparent}
h1{text-align:center}
.lead{text-align:center}
h2{display:flex;align-items:center;gap:10px;margin:0 0 10px}
h2::before{content:"";flex:none;border-radius:6px;background:var(--rainbow-v)}
.hint{margin:0 0 12px}
.card{padding:18px}
.btn{font:inherit;font-size:1.15rem;font-weight:600;border:0;border-radius:999px;padding:13px 22px;cursor:pointer;transition:transform .12s}
.btn:active{transform:translateY(3px)}
.actions{display:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin-top:16px}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.confetti{position:fixed;top:-10px;width:10px;height:14px;border-radius:2px;pointer-events:none;z-index:9;animation:fall linear forwards}
@keyframes fall{to{transform:translateY(105vh) rotate(720deg);opacity:.8}}
@keyframes pop{from{transform:scale(0)}to{transform:scale(1)}}
@keyframes shake{25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
@keyframes ring{from{box-shadow:0 0 0 0 rgba(36,84,71,.35)}to{box-shadow:0 0 0 18px rgba(36,84,71,0)}}

/* Segmented control for modes. Same look as the drawing modes. */
.seg{display:flex;gap:4px;width:fit-content;max-width:100%;margin:0 auto 12px;padding:5px;border-radius:999px;background:#efeadb}
.seg button{display:inline-flex;align-items:center;gap:9px;min-height:50px;padding:6px 18px 6px 7px;border:0;border-radius:999px;background:transparent;color:var(--muted);font:inherit;font-size:1.05rem;font-weight:600;cursor:pointer}
.seg button[aria-pressed="true"]{background:#fff;color:var(--ink);box-shadow:inset 0 0 0 2px var(--ink),0 2px 0 #d9d4c3}
.seg-ico{display:grid;place-items:center;min-width:36px;height:36px;padding:0 6px;border-radius:10px;background:#fff;border:2px solid var(--line);font-size:.95rem;font-weight:700;color:var(--ink)}

/* Difficulty: two small pills and an optional automatic step up. */
.level{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px 14px;margin:0 0 16px;font-size:15px;color:var(--muted)}
.level-pills{display:flex;gap:4px}
.level-pills button{min-height:40px;padding:0 14px;border:1px solid var(--line);border-radius:999px;background:var(--card);color:var(--ink);font:inherit;font-size:15px;font-weight:600;cursor:pointer}
.level-pills button[aria-pressed="true"]{background:var(--green);border-color:var(--green);color:#fff}
.level label{display:inline-flex;align-items:center;gap:8px;min-height:40px;cursor:pointer}
.level input{width:20px;height:20px;accent-color:var(--green)}

/* Prompt: a big replay button and one short instruction. */
.prompt{display:flex;align-items:center;gap:16px;margin-bottom:18px}
.replay{flex:none;display:grid;place-items:center;width:76px;height:76px;border:0;border-radius:50%;background:var(--green);color:#fff;cursor:pointer;box-shadow:0 4px 0 #173a30}
.replay svg{width:36px;height:36px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.replay.playing{animation:ring 1s ease-out infinite}
.prompt-text{margin:0;font-size:1.25rem;font-weight:600;line-height:1.35}

/* Answer tiles: letters, numbers or pictures. JS sets --c and --t like the letter grids. */
.choices{display:grid;grid-template-columns:repeat(var(--cols,3),minmax(0,1fr));gap:12px;max-width:480px;margin-inline:auto}
.choices[data-count="4"]{--cols:4}
.choices[data-count="5"],.choices[data-count="6"]{--cols:3}
.choices.numbers{--cols:5;gap:10px}
.choice{position:relative;display:grid;place-items:center;aspect-ratio:1;min-height:64px;border:4px solid var(--c,var(--line));border-radius:22px;background:#fff;color:var(--ink);font:inherit;font-size:clamp(2.2rem,9vw,3.4rem);font-weight:700;line-height:1;cursor:pointer;box-shadow:0 4px 0 rgba(36,62,54,.16);transition:transform .12s,opacity .2s}
.choices.numbers .choice{border-radius:18px;font-size:clamp(1.5rem,6vw,2.1rem)}
.choice.picture{font-size:clamp(2.6rem,11vw,4.6rem)}
.choice:active{transform:translateY(2px)}
.choice.is-right{background:var(--c,var(--r4));color:var(--t,#fff);border-color:#fff;box-shadow:0 0 0 3px var(--ink);animation:pop .35s cubic-bezier(.2,1.5,.4,1)}
.choice.is-wrong{opacity:.45;animation:shake .35s}
.choice.is-answer{box-shadow:0 0 0 4px var(--r3),0 0 0 8px rgba(242,197,61,.35)}
.choice.is-right::after,.choice.is-answer::after{content:"✓";position:absolute;top:-10px;right:-10px;display:grid;place-items:center;width:30px;height:30px;border-radius:50%;background:var(--r4);color:#fff;font-size:17px;box-shadow:0 0 0 3px #fff}
.choice:disabled{cursor:default}
.feedback{min-height:1.6em;margin:16px 0 0;text-align:center;font-size:1.2rem;font-weight:600}
.round{display:flex;justify-content:center;gap:8px;margin-top:12px}
.round i{width:12px;height:12px;border-radius:50%;background:#e3dccb}
.round i.done{background:var(--r4)}

/* Ten-frame: two rows of five, the classic counting frame. */
.tenframe{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px;width:min(100%,420px);margin:0 auto;padding:8px;border:3px solid var(--ink);border-radius:16px;background:#fffdf6}
.tenframe .cell{min-width:0;display:grid;place-items:center;aspect-ratio:1;border:2px dashed #d6d0bf;border-radius:10px}
.obj{position:relative;display:grid;place-items:center;width:78%;aspect-ratio:1;padding:0;border:0;border-radius:50%;background:var(--c,var(--r1));box-shadow:inset 0 -5px 0 rgba(0,0,0,.18);font:inherit;cursor:pointer;animation:pop .3s cubic-bezier(.2,1.4,.4,1) both}
.obj.star{border-radius:0;box-shadow:none;clip-path:polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)}
.obj b{display:grid;place-items:center;width:62%;aspect-ratio:1;border-radius:50%;background:#fff;color:var(--ink);font-size:clamp(.9rem,3.6vw,1.2rem);transform:scale(0);transition:transform .2s cubic-bezier(.2,1.5,.4,1)}
.obj.counted b{transform:scale(1)}
.obj.counted{outline:3px solid var(--ink);outline-offset:2px}
.obj.star.counted{outline:0}
/* Stars are for groups that are not counted one by one. Numbers need round objects. */
.obj.star b{display:none}
.count-total{margin:14px 0 6px;text-align:center;font-size:1.15rem;font-weight:600}

/* Compare: two frames, each one big answer button, and "same" below. */
.compare{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:14px}
.side{min-width:0;display:grid;gap:10px;padding:10px;border:3px solid transparent;border-radius:20px;background:#f6f2e7;color:var(--ink);font:inherit;font-weight:600;cursor:pointer;transition:border-color .15s,transform .12s}
.side .tenframe{width:100%;padding:5px;gap:4px;border-width:2px}
.side .obj{cursor:inherit}
.side:hover{border-color:#d6d0bf}
.side.is-right{border-color:var(--r4);background:#e2efdf}
.side.is-wrong{opacity:.5;animation:shake .35s}
.side.is-answer{border-color:var(--r3)}
.same{display:block;margin:14px auto 0}
/* The "Same" answer takes the same states as the groups. Three classes beat tool.css. */
.btn.quiet.same.is-right{background:var(--r4);color:#fff;box-shadow:inset 0 0 0 2px var(--r4),0 4px 0 #1f5f3a;animation:pop .35s cubic-bezier(.2,1.5,.4,1)}
.btn.quiet.same.is-answer{box-shadow:inset 0 0 0 2px var(--ink),0 0 0 4px var(--r3),0 0 0 8px rgba(242,197,61,.35)}
.btn.quiet.same.is-wrong{opacity:.5;animation:shake .35s}

@media(max-width:480px){
  .seg{width:100%;border-radius:20px}
  .seg button{flex:1 1 0;flex-direction:column;justify-content:center;gap:4px;padding:8px 4px;border-radius:16px;font-size:.95rem;line-height:1.1}
  .prompt{gap:12px}
  .replay{width:64px;height:64px}
  .replay svg{width:30px;height:30px}
  .prompt-text{font-size:1.1rem}
  .choices{gap:10px}
  .choices.numbers{gap:8px}
  .compare{gap:10px}
  .side{padding:6px}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}}
