/* ==========================================================================
   HelloHiDear — Sports & Movement shared chrome
   --------------------------------------------------------------------------
   Same UI architecture as the Hurdles Rhythm game (top bar, canvas stage,
   bottom action bar, start/pause/results overlays), generalized so all 17
   Sports & Movement games share one consistent look. Every class is
   prefixed "sm-" so it can never collide with the rest of the platform or
   with any individual game's own style.css. Loaded only by these games'
   own HTML pages — no global CSS anywhere else is touched.
   ========================================================================== */

:root {
  --sm-purple: hsl(263 70% 55%);
  --sm-purple-dark: hsl(263 80% 45%);
  --sm-orange: hsl(35 90% 60%);
  --sm-orange-dark: hsl(28 88% 52%);
  --sm-cyan: hsl(185 85% 55%);
  --sm-pink: hsl(340 80% 65%);
  --sm-green: hsl(142 66% 45%);
  --sm-gold: hsl(45 95% 55%);
  --sm-ink: hsl(225 15% 15%);
  --sm-ink-soft: hsl(225 10% 45%);
  --sm-bg: hsl(240 100% 99%);
  --sm-card: hsl(0 0% 100%);
  --sm-radius: 1.5rem;
  --sm-shadow-soft: 0 4px 15px -2px hsl(225 15% 15% / 0.10);
  --sm-shadow-pop: 0 14px 40px -8px hsl(263 70% 35% / 0.35);
  --sm-font: "Fredoka", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
  /* Per-game accent, overridden in each game's own style.css. */
  --sm-accent: var(--sm-purple);
  --sm-accent-dark: var(--sm-purple-dark);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sm-font);
  background: var(--sm-bg);
  color: var(--sm-ink);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.sm-root { display: flex; flex-direction: column; height: 100dvh; max-height: 100dvh; }

.sm-topbar {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.9rem; background: var(--sm-card);
  box-shadow: var(--sm-shadow-soft); z-index: 5;
}
.sm-progress {
  flex: 1; height: 1.4rem; min-width: 4rem;
  background: hsl(240 20% 93%); border-radius: 999px; overflow: hidden; position: relative;
}
.sm-progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--sm-cyan), var(--sm-accent));
  transition: width 0.35s ease;
}
.sm-starcount {
  display: flex; align-items: center; gap: 0.3rem; font-weight: 700; font-size: 1.25rem;
  background: hsl(45 95% 55% / 0.18); border-radius: 999px; padding: 0.25rem 0.85rem;
  min-width: 4.5rem; justify-content: center;
}
.sm-iconbtn {
  width: 3.25rem; height: 3.25rem; min-width: 3.25rem; border: none; border-radius: 1rem;
  background: hsl(263 70% 55% / 0.12); color: var(--sm-accent-dark); font-size: 1.4rem;
  line-height: 1; cursor: pointer; display: grid; place-items: center;
  transition: transform 0.15s ease, background 0.2s ease;
}
.sm-iconbtn:hover { background: hsl(263 70% 55% / 0.22); }
.sm-iconbtn:active { transform: scale(0.9); }
.sm-iconbtn:focus-visible, .sm-btn:focus-visible, .sm-agebtn:focus-visible, .sm-check:focus-visible input {
  outline: 4px solid var(--sm-cyan); outline-offset: 2px;
}

.sm-stage { position: relative; flex: 1; min-height: 0; background: hsl(197 90% 84%); }
.sm-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: pointer; }

.sm-feedback {
  position: absolute; left: 50%; top: 18%; translate: -50% 0;
  padding: 0.55rem 1.4rem; border-radius: 999px; background: var(--sm-card);
  box-shadow: var(--sm-shadow-pop); font-size: clamp(1.1rem, 3.4vw, 1.6rem); font-weight: 700;
  color: var(--sm-accent-dark); white-space: nowrap; opacity: 0; pointer-events: none; z-index: 4;
}
.sm-feedback.sm-show { animation: sm-feedback-pop 1.1s ease-out forwards; }
.sm-feedback.sm-miss { color: var(--sm-orange-dark); }
@keyframes sm-feedback-pop {
  0% { opacity: 0; transform: scale(0.4) translateY(14px); }
  18% { opacity: 1; transform: scale(1.12) translateY(0); }
  30% { transform: scale(1); }
  75% { opacity: 1; transform: scale(1) translateY(-6px); }
  100% { opacity: 0; transform: scale(0.92) translateY(-22px); }
}

.sm-countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: clamp(3.5rem, 16vw, 7rem); font-weight: 700; color: var(--sm-card);
  text-shadow: 0 6px 0 hsl(263 80% 45% / 0.45); pointer-events: none; z-index: 4;
}
.sm-countdown span { display: inline-block; animation: sm-count-beat 0.5s ease-out; }
@keyframes sm-count-beat {
  0% { transform: scale(1.7); opacity: 0; } 60% { transform: scale(0.95); opacity: 1; } 100% { transform: scale(1); }
}

.sm-bottombar {
  display: flex; flex-direction: column; align-items: center; gap: 0.45rem;
  padding: 0.55rem 1rem calc(0.8rem + env(safe-area-inset-bottom));
  background: var(--sm-card); box-shadow: 0 -6px 20px -8px hsl(225 15% 15% / 0.15); z-index: 5;
}
.sm-tip {
  margin: 0; font-size: clamp(0.88rem, 2.5vw, 1.02rem); font-weight: 500;
  color: var(--sm-ink-soft); text-align: center; min-height: 1.3em;
}
.sm-actionbtn {
  width: min(100%, 30rem); min-height: 5.5rem; border: none; border-radius: var(--sm-radius);
  background: linear-gradient(135deg, var(--sm-orange), var(--sm-orange-dark)); color: #fff;
  font-family: inherit; font-size: clamp(1.4rem, 5.6vw, 2rem); font-weight: 700; letter-spacing: 0.05em;
  cursor: pointer; box-shadow: 0 8px 0 hsl(28 80% 40%), var(--sm-shadow-soft);
  transition: transform 0.08s ease, box-shadow 0.08s ease; touch-action: manipulation;
}
.sm-actionbtn:active, .sm-actionbtn.sm-pressed {
  transform: translateY(6px); box-shadow: 0 2px 0 hsl(28 80% 40%), var(--sm-shadow-soft);
}
.sm-actionbtn:disabled { opacity: 0.5; cursor: default; box-shadow: none; transform: none; }

.sm-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: hsl(255 60% 30% / 0.45); backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px); z-index: 10; overflow-y: auto;
}
.sm-overlay[hidden] { display: none; }
.sm-card {
  width: min(100%, 30rem); max-height: 100%; overflow-y: auto; background: var(--sm-card);
  border-radius: var(--sm-radius); box-shadow: var(--sm-shadow-pop); padding: 1.4rem 1.5rem 1.6rem;
  text-align: center; animation: sm-card-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes sm-card-in {
  from { transform: scale(0.7) translateY(30px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; }
}
.sm-title {
  margin: 0 0 0.1rem; font-size: clamp(1.8rem, 6.5vw, 2.4rem); font-weight: 700;
  background: linear-gradient(135deg, var(--sm-accent), var(--sm-pink));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sm-subtitle { margin: 0 0 1rem; font-size: 1.02rem; font-weight: 500; color: var(--sm-ink-soft); }
.sm-heading { margin: 1.1rem 0 0.5rem; font-size: 1.05rem; font-weight: 700; color: var(--sm-ink); }

.sm-mascot-preview { width: 8.5rem; height: 8.5rem; margin: 0 auto; display: block; }
.sm-mascot-name { margin: 0.2rem 0 0; font-weight: 700; font-size: 1.1rem; color: var(--sm-accent-dark); }
.sm-shuffle {
  margin-top: 0.35rem; border: none; background: hsl(185 85% 55% / 0.16); color: hsl(190 80% 30%);
  font-family: inherit; font-weight: 700; font-size: 0.98rem; border-radius: 999px; padding: 0.5rem 1.1rem;
  min-height: 2.8rem; cursor: pointer; transition: transform 0.15s ease;
}
.sm-shuffle:active { transform: scale(0.93); }

.sm-agegroup { display: flex; gap: 0.6rem; justify-content: center; }
.sm-agebtn {
  flex: 1; max-width: 8.5rem; min-height: 4.25rem; border: 3px solid hsl(240 20% 90%);
  border-radius: 1.1rem; background: var(--sm-card); font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}
.sm-agebtn:active { transform: scale(0.94); }
.sm-agebtn .sm-age-emoji { font-size: 1.4rem; }
.sm-agebtn .sm-age-label { font-weight: 700; font-size: 1rem; color: var(--sm-ink); }
.sm-agebtn[aria-pressed="true"] {
  border-color: var(--sm-accent); background: hsl(263 70% 55% / 0.10); transform: scale(1.04);
}

.sm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%;
  min-height: 4rem; margin-top: 0.9rem; border: none; border-radius: 1.2rem; font-family: inherit;
  font-size: 1.3rem; font-weight: 700; cursor: pointer; transition: transform 0.12s ease, filter 0.2s ease;
  text-decoration: none;
}
.sm-btn:hover { filter: brightness(1.06); }
.sm-btn:active { transform: scale(0.95); }
.sm-btn-primary {
  background: linear-gradient(135deg, var(--sm-accent), hsl(285 85% 60%)); color: #fff;
  box-shadow: 0 6px 0 var(--sm-accent-dark), var(--sm-shadow-soft);
}
.sm-btn-primary:active { box-shadow: 0 2px 0 var(--sm-accent-dark); transform: translateY(4px) scale(0.98); }
.sm-btn-secondary { background: hsl(263 70% 55% / 0.10); color: var(--sm-accent-dark); }

.sm-settings { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 1rem; text-align: left; }
.sm-check {
  display: flex; align-items: center; gap: 0.7rem; font-size: 1rem; font-weight: 500;
  color: var(--sm-ink-soft); padding: 0.45rem 0.4rem; border-radius: 0.8rem; cursor: pointer; min-height: 3rem;
}
.sm-check:hover { background: hsl(240 20% 96%); }
.sm-check input { width: 1.6rem; height: 1.6rem; accent-color: var(--sm-accent); cursor: pointer; flex-shrink: 0; }

.sm-medal {
  width: 6.2rem; height: 6.2rem; margin: 0.4rem auto 0.2rem; border-radius: 50%; display: grid;
  place-items: center; font-size: 2.9rem; animation: sm-medal-spin 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: inset 0 -6px 0 hsl(0 0% 0% / 0.12), var(--sm-shadow-soft);
}
@keyframes sm-medal-spin {
  from { transform: rotateY(180deg) scale(0.3); opacity: 0; } to { transform: rotateY(0) scale(1); opacity: 1; }
}
.sm-medal-gold { background: linear-gradient(160deg, hsl(48 100% 67%), hsl(40 95% 50%)); }
.sm-medal-silver { background: linear-gradient(160deg, hsl(220 15% 88%), hsl(220 10% 68%)); }
.sm-medal-bronze { background: linear-gradient(160deg, hsl(28 60% 62%), hsl(25 55% 45%)); }
.sm-medal-label { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--sm-ink); }
.sm-result-stars { font-size: 1.5rem; font-weight: 700; margin: 0.5rem 0 0; color: var(--sm-ink); }
.sm-result-best { margin: 0.15rem 0 0; font-size: 0.98rem; color: var(--sm-ink-soft); font-weight: 500; }

.sm-badges { display: flex; flex-wrap: wrap; gap: 0.45rem; justify-content: center; margin: 0.6rem 0 0; padding: 0; list-style: none; }
.sm-badge {
  display: inline-flex; align-items: center; gap: 0.35rem; background: hsl(45 95% 55% / 0.16);
  border-radius: 999px; padding: 0.35rem 0.85rem; font-size: 0.92rem; font-weight: 700; color: hsl(30 70% 32%);
  animation: sm-card-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
.sm-badge:nth-child(2) { animation-delay: 0.12s; }
.sm-badge:nth-child(3) { animation-delay: 0.24s; }
.sm-badge:nth-child(4) { animation-delay: 0.36s; }

.sm-parent-tip {
  margin: 1rem 0 0; padding: 0.8rem 1rem; border-radius: 1rem; background: hsl(185 85% 55% / 0.12);
  color: hsl(195 60% 26%); font-size: 0.92rem; font-weight: 500; text-align: left;
}
.sm-parent-tip strong { display: block; margin-bottom: 0.15rem; }

/* ---- Shared answer-choice buttons (Jump Rope, Baseball, Archery, Bowling…) --
   Real <button> elements (not canvas hit-testing) so Tab/Enter and
   screen readers work natively; positioned as an overlay row above the
   bottom bar, shown only while a question is active. */
.sm-choices {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 0.6rem;
  justify-content: center; flex-wrap: wrap; padding: 0.7rem 0.8rem 0.6rem; z-index: 6;
  background: linear-gradient(0deg, hsl(0 0% 100% / 0.92), hsl(0 0% 100% / 0.55) 80%, transparent);
}
.sm-choices[hidden] { display: none; }
.sm-choice-btn {
  min-width: 4.4rem; min-height: 4.4rem; padding: 0.5rem 1rem; border: none; border-radius: 1.1rem;
  background: var(--sm-card); color: var(--sm-ink); font-family: inherit; font-size: 1.6rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 6px 0 hsl(240 20% 80%), var(--sm-shadow-soft);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.sm-choice-btn:hover { background: hsl(263 70% 55% / 0.08); }
.sm-choice-btn:active, .sm-choice-btn.sm-pressed { transform: translateY(5px); box-shadow: 0 1px 0 hsl(240 20% 80%), var(--sm-shadow-soft); }
.sm-choice-btn:focus-visible { outline: 4px solid var(--sm-cyan); outline-offset: 2px; }
.sm-choice-btn.sm-correct { background: hsl(142 66% 45%); color: #fff; box-shadow: 0 6px 0 hsl(142 66% 32%); }
.sm-choice-btn.sm-wrong { background: hsl(0 70% 65%); color: #fff; box-shadow: 0 6px 0 hsl(0 70% 45%); }
.sm-choice-btn.sm-selected { background: var(--sm-accent); color: #fff; box-shadow: 0 6px 0 var(--sm-accent-dark); transform: translateY(2px); }

.sm-visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- Compact start card on small phones ---- */
@media (max-width: 480px), (max-height: 760px) {
  .sm-card { padding: 1rem 1.1rem 1.1rem; }
  .sm-title { font-size: 1.6rem; }
  .sm-subtitle { font-size: 0.92rem; margin-bottom: 0.5rem; }
  .sm-mascot-preview { width: 5.5rem; height: 5.5rem; }
  .sm-mascot-name { font-size: 1rem; margin-top: 0; }
  .sm-shuffle { margin-top: 0.2rem; padding: 0.4rem 1rem; min-height: 2.5rem; font-size: 0.9rem; }
  .sm-heading { margin: 0.6rem 0 0.35rem; font-size: 0.96rem; }
  .sm-agebtn { min-height: 4rem; }
  .sm-agebtn .sm-age-emoji { font-size: 1.15rem; }
  .sm-btn { min-height: 4rem; margin-top: 0.6rem; font-size: 1.15rem; }
  .sm-settings { margin-top: 0.45rem; gap: 0.1rem; }
  .sm-check { min-height: 2.5rem; padding: 0.2rem 0.4rem; font-size: 0.9rem; }
}
@media (max-height: 480px) {
  .sm-actionbtn { min-height: 4rem; font-size: 1.3rem; }
  .sm-tip { display: none; }
  .sm-bottombar { padding-top: 0.35rem; }
  .sm-card { padding: 1rem 1.1rem 1.2rem; }
  .sm-mascot-preview { width: 5.2rem; height: 5.2rem; }
  .sm-title { font-size: 1.5rem; }
}
@media (max-width: 420px) {
  .sm-topbar { gap: 0.5rem; padding: 0.5rem 0.6rem; }
  .sm-starcount { font-size: 1rem; min-width: 3.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sm-card, .sm-medal, .sm-badge, .sm-countdown span { animation: none; }
  .sm-feedback.sm-show { animation: sm-feedback-fade 1.1s ease forwards; }
}
.sm-root.sm-reduced-motion .sm-card,
.sm-root.sm-reduced-motion .sm-medal,
.sm-root.sm-reduced-motion .sm-badge,
.sm-root.sm-reduced-motion .sm-countdown span { animation: none; }
.sm-root.sm-reduced-motion .sm-feedback.sm-show { animation: sm-feedback-fade 1.1s ease forwards; }
@keyframes sm-feedback-fade {
  0% { opacity: 0; } 15% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; }
}
