/* Factor Bugs (js/arcade/factorbugs.js). Every class starts with .fbg- */

.fbg-wrap { display: grid; gap: 8px; width: min(100%, 560px); margin: 0 auto; padding-bottom: 14px; }

/* ---------- HUD: the bug she is on, the stars she can win, the score ---------- */
.fbg-hud { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 14px; font: 700 14px var(--font-ui); color: var(--muted); }
.fbg-hud b { color: var(--ink); font-size: 19px; }
.fbg-stars { display: inline-flex; gap: 3px; }
.fbg-star {
  --f: 0%; width: 24px; height: 24px;
  clip-path: polygon(50% 2%, 62% 36%, 98% 37%, 69% 59%, 80% 94%, 50% 73%, 20% 94%, 31% 59%, 2% 37%, 38% 36%);
  background: linear-gradient(90deg, var(--sun) var(--f), var(--tile-shadow) var(--f));
}
.fbg-star.fbg-half { --f: 50%; }
.fbg-star.fbg-full { --f: 100%; animation: fbg-pop 0.45s; }
@keyframes fbg-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.25); } 100% { transform: none; } }

/* ---------- the question ---------- */
.fbg-goal { margin: 0; padding: 6px 12px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-soft); text-align: center; font: 700 19px/1.3 var(--font-read); color: var(--ink); }
.fbg-goal b { font: 900 26px/1 var(--font-ui); color: var(--grape-d); }

/* ---------- the bug ---------- */
.fbg-bugs { display: grid; gap: 4px; padding: 8px 6px 4px; border-radius: var(--radius); background: color-mix(in srgb, var(--lime) 22%, white); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--lime) 55%, white); }
.fbg-bug { display: block; width: 100%; height: auto; overflow: visible; }
.fbg-body { fill: var(--rose); stroke: var(--rose-d); stroke-width: 3; }
.fbg-spot { fill: var(--rose-d); opacity: 0.55; }
.fbg-head { fill: var(--grape); stroke: var(--grape-d); stroke-width: 3; }
.fbg-eye { fill: var(--card); }
.fbg-pupil { fill: var(--ink); }
.fbg-smile, .fbg-feeler { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.fbg-smile { stroke: var(--card); }
.fbg-tip { fill: var(--sun); stroke: var(--sun-d); stroke-width: 1.5; }
.fbg-num { font: 900 40px var(--font-ui); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.fbg-leg { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.fbg-label { font: 800 13px var(--font-ui); fill: var(--ink); text-anchor: middle; }
.fbg-hit { fill: var(--green-d); font-size: 16px; font-weight: 900; }
.fbg-thumb { fill: color-mix(in srgb, var(--sky) 55%, white); stroke: var(--sky-d); stroke-width: 1.2; }
.fbg-thumb-line { stroke: var(--sky-d); stroke-width: 0.6; opacity: 0.7; }
.fbg-pair.fbg-new { animation: fbg-grow 0.45s ease-out; transform-origin: 50% 40%; transform-box: view-box; }
@keyframes fbg-grow { 0% { transform: scaleY(0.2); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ---------- the rectangle she is building ---------- */
.fbg-build { border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow-soft); padding: 4px; }
.fbg-grid { display: block; width: 100%; height: auto; max-height: 150px; }
.fbg-cell { fill: var(--sky); }
.fbg-cell.fbg-over { fill: var(--sun); stroke: var(--sun-d); stroke-width: 1; }

.fbg-msg { min-height: 48px; margin: 0; display: grid; place-items: center; text-align: center; font: 700 16px/1.35 var(--font-read); color: var(--ink); }
.fbg-msg.fbg-yes { color: var(--green-d); }
.fbg-ask { margin: 0; text-align: center; font: 700 15px/1.2 var(--font-read); color: var(--muted); }

/* ---------- the buttons ---------- */
.fbg-chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.fbg-chip {
  min-height: 48px; border: 0; border-radius: 14px; background: var(--card); color: var(--ink); font: 800 22px var(--font-ui);
  box-shadow: 0 4px 0 var(--tile-shadow); cursor: pointer; touch-action: manipulation;
}
.fbg-chip:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--tile-shadow); }
.fbg-chip.fbg-got { background: color-mix(in srgb, var(--green) 30%, white); box-shadow: 0 4px 0 var(--green-d); }
.fbg-done .fbg-chip, .fbg-done .fbg-choice { opacity: 0.5; pointer-events: none; }
.fbg-sort { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fbg-btn { touch-action: manipulation; min-height: 48px; }
.fbg-choice { background: var(--sky); box-shadow: 0 5px 0 var(--sky-d); color: var(--ink); }
.fbg-foot { display: grid; justify-items: center; }
.fbg-foot .fbg-btn { min-width: 220px; }

/* a wrong try: a little shake */
.fbg-no { animation: fbg-no 0.32s; }
@keyframes fbg-no { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* iPad: more room */
@media (min-width: 700px) {
  .fbg-wrap { gap: 12px; }
  .fbg-goal { font-size: 23px; }
  .fbg-goal b { font-size: 32px; }
  .fbg-msg { font-size: 19px; }
  .fbg-chip { min-height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .fbg-star.fbg-full, .fbg-pair.fbg-new, .fbg-no { animation: none; }
}
