/* Family Math 2.0 shared visual system: tokens, controls, shell, cards. Games add their own game.css on top. */
:root {
  --fm-ink: #1f2740; --fm-muted: #5d6683; --fm-paper: #fff; --fm-mist: #f1f4fb; --fm-line: #c9d0e4;
  --fm-accent: #1FA6A2; --fm-navy: #17324D; --fm-paper: #F7F4EC;
  --fm-mint: #1d9a6c; --fm-mint-soft: #dff5ec; --fm-coral: #c4452e; --fm-coral-soft: #fde5df;
  --fm-gold: #d99a12; --fm-gold-soft: #fbefcf; --fm-sky: #2a7bd6; --fm-sky-soft: #dcebfb;
  --fm-radius: 16px; --fm-shadow: 0 8px 24px rgba(31, 39, 64, 0.1); --fm-focus: 0 0 0 3px #fff, 0 0 0 6px #1f2740;
  --fm-font: "Atkinson Hyperlegible", "Nunito", system-ui, sans-serif;
}
.fm2-page { margin: 0; background: var(--fm-mist); color: var(--fm-ink); font-family: var(--fm-font); font-size: 18px; line-height: 1.5; }
.fm2-page *, .fm2-page *::before, .fm2-page *::after { box-sizing: border-box; }
.fm2-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fm2-wrap { width: min(1120px, 100% - 32px); margin: 0 auto; padding: 16px 0 96px; } /* the Save/Resume pill floats bottom-right: always leave room to scroll content clear of it */
.fm2-eyebrow { margin: 0; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: var(--fm-accent); }
.fm2-card { background: var(--fm-paper); border: 1px solid var(--fm-line); border-radius: var(--fm-radius); padding: 20px; box-shadow: var(--fm-shadow); }

.fm2-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; min-width: 48px; padding: 8px 18px; border: 2px solid var(--fm-navy); border-radius: 999px; background: var(--fm-paper); color: var(--fm-navy); font: 800 1rem/1.2 var(--fm-font); cursor: pointer; text-decoration: none; touch-action: manipulation; }
.fm2-btn:hover { background: var(--fm-paper); }
.fm2-btn:focus-visible, .fm2-page a:focus-visible, .fm2-page select:focus-visible, .fm2-page input:focus-visible, .fm2-page [tabindex]:focus-visible { outline: none; box-shadow: var(--fm-focus); }
.fm2-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.fm2-btn-primary { background: var(--fm-navy); color: #fff; }
.fm2-btn-primary:hover { background: var(--fm-accent); }
.fm2-btn-quiet { border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 3px; }

.fm2-shell { display: grid; gap: 14px; }
.fm2-shell[hidden], .fm2-finish[hidden], .fm2-turn[hidden], .fm2-hintbox[hidden], .fm2-explain[hidden], .fm2-btn[hidden] { display: none; }
.fm2-shell-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.fm2-shell-title { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 240px; }
.fm2-shell-title h1 { margin: 0; font-size: clamp(1.3rem, 4vw, 1.8rem); line-height: 1.1; }
.fm2-shell-title p { margin: 2px 0 0; color: var(--fm-muted); font-size: 0.95rem; }
.fm2-shell-icon { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--fm-paper); }
.fm2-shell-icon svg { width: 36px; height: 36px; }
.fm2-shell-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.fm2-progress-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.fm2-dots { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; }
.fm2-dot { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--fm-line); background: var(--fm-paper); font-weight: 800; font-size: 0.9rem; }
.fm2-dot-current { border-color: var(--fm-accent); background: var(--fm-paper); }
.fm2-dot-done { border-color: var(--fm-mint); background: var(--fm-mint-soft); color: #0f5e42; }
.fm2-dot-shown { border-color: var(--fm-gold); background: var(--fm-gold-soft); }
.fm2-round-label { margin: 0; color: var(--fm-muted); font-weight: 700; }
.fm2-turn { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; border-radius: 12px; background: var(--fm-sky-soft); }
.fm2-role { padding: 2px 12px; border-radius: 999px; background: var(--fm-paper); border: 2px solid var(--fm-sky); }
.fm2-role-caregiver { border-color: var(--fm-gold); }
.fm2-play { background: var(--fm-paper); border: 1px solid var(--fm-line); border-radius: var(--fm-radius); padding: clamp(14px, 3vw, 24px); box-shadow: var(--fm-shadow); display: grid; gap: 14px; }
.fm2-prompt { margin: 0; font-size: clamp(1.25rem, 3.6vw, 1.75rem); line-height: 1.25; }
.fm2-page .fm2-prompt:focus, .fm2-page .fm2-prompt:focus-visible, .fm2-page .fm2-finish-card h1:focus-visible { outline: none; box-shadow: none; }
.fm2-stage { min-width: 0; overflow-x: auto; }
.fm2-hintbox, .fm2-explain { padding: 12px 14px; border-radius: 12px; background: var(--fm-gold-soft); border-left: 6px solid var(--fm-gold); }
.fm2-explain { background: var(--fm-sky-soft); border-left-color: var(--fm-sky); }
.fm2-feedback { min-height: 1.5em; display: flex; gap: 8px; align-items: flex-start; font-weight: 700; }
.fm2-feedback:empty { display: none; }
.fm2-feedback-icon { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 0.85rem; }
.fm2-feedback-good .fm2-feedback-icon { background: var(--fm-mint); }
.fm2-feedback-try .fm2-feedback-icon { background: var(--fm-coral); }
.fm2-feedback-info .fm2-feedback-icon { background: var(--fm-sky); }
.fm2-toolbar { display: flex; flex-wrap: wrap; gap: 10px; }
.fm2-dialog { max-width: min(560px, calc(100vw - 32px)); border: 3px solid var(--fm-navy); border-radius: var(--fm-radius); padding: 22px; color: var(--fm-ink); }
.fm2-dialog::backdrop { background: rgba(31, 39, 64, 0.5); }
.fm2-finish-card { max-width: 560px; margin: 24px auto; padding: 28px; text-align: center; background: var(--fm-paper); border: 1px solid var(--fm-line); border-radius: var(--fm-radius); box-shadow: var(--fm-shadow); }
.fm2-finish-card h1 { margin: 6px 0; }
.fm2-finish-card h1:focus { outline: none; }
.fm2-stars { margin: 0; font-size: 2.6rem; color: var(--fm-gold); letter-spacing: 0.1em; }
.fm2-finish-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.fm2-art { display: block; max-width: 100%; height: auto; }

/* On phones the action bar stays in view; the shell publishes its height so the Save/Resume pill rides above it. */
@media (max-width: 640px) {
  .fm2-toolbar { position: sticky; bottom: 0; z-index: 20; gap: 2px 6px; margin: 0 -16px; padding: 8px 16px; background: var(--fm-paper); border-top: 1px solid var(--fm-line); box-shadow: 0 -6px 16px rgba(31, 39, 64, 0.08); }
  .fm2-page .fm2-toolbar .fm2-btn { flex: 0 1 auto; min-height: 44px; padding: 4px 12px; font-size: 0.92rem; }
}
/* The Save/Resume pill is fixed to the viewport. The offset keeps it above the action bar; the stage reserves a band
   at its foot on phones so the pill never sits on a control when the page is scrolled to any position. */
body.fm2-page #nsr-root { bottom: calc(var(--fm-toolbar-h, 0px) + 12px); }
/* On phones the pill stops floating over the page: it sits in the document flow above the activity, so it can never
   cover a control whatever the scroll position. */
@media (max-width: 640px) {
  body.fm2-page #nsr-root { position: static; align-items: stretch; margin: 8px 0; }
  body.fm2-page #nsr-root > * { align-self: flex-end; }
}

@media (max-width: 520px) {
  .fm2-page { font-size: 17px; }
  .fm2-btn { flex: 1 1 auto; }
  .fm2-shell-actions { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .fm2-page *, .fm2-page *::before, .fm2-page *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* A skip link is the one .fm2-sr element a keyboard can land on: show it while it has focus. */
.fm2-sr:focus-visible { position: fixed; top: 8px; left: 8px; z-index: 100; width: auto; height: auto; padding: 8px 14px; overflow: visible; clip: auto; white-space: normal; background: var(--fm-paper); color: var(--fm-ink); border-radius: 8px; box-shadow: var(--fm-focus); }
