/* Sing-Along Puzzles — Mignuti Kids
 * Shared Banana Berry palette.
 */

:root {
  --color-cream: #fff8e7;
  --color-sky: #4ecdc4;
  --color-banana: #ffd93d;
  --color-berry: #de1c56;
  --color-ink: #2c2c2c;
  --color-leaf: #4aa84f;
  --radius: 18px;
  --shadow-card: 0 8px 24px rgba(44, 44, 44, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: linear-gradient(180deg, #bfefeb 0%, var(--color-cream) 65%);
  color: var(--color-ink);
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px
    max(16px, env(safe-area-inset-bottom)) 16px;
}

.view {
  max-width: 720px;
  margin: 0 auto;
}

.view.hidden {
  display: none;
}

/* Header */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
  position: relative;
}

.header--game {
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

.title {
  font-size: clamp(26px, 6vw, 38px);
  color: var(--color-berry);
  margin: 0 0 4px;
  font-weight: 900;
  letter-spacing: 0.01em;
  width: 100%;
}

.title--game {
  text-align: center;
  flex: 1;
  font-size: clamp(20px, 5vw, 28px);
  width: auto;
  margin: 0;
}

.sub {
  width: 100%;
  margin: 0 0 12px;
  font-size: clamp(14px, 3.4vw, 18px);
  opacity: 0.8;
}

.header-actions {
  position: absolute;
  right: 0;
  top: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 120ms ease;
}

.icon-btn:active {
  transform: scale(0.94);
}

.icon-btn:focus-visible {
  outline: 3px solid var(--color-berry);
  outline-offset: 3px;
}

.icon {
  width: 20px;
  height: 20px;
  display: inline-block;
  background: var(--color-ink);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.icon-sound-off {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 10v4h4l5 4V6L7 10H3zm13.59 2L14 9.41 15.41 8 18 10.59 20.59 8 22 9.41 19.41 12 22 14.59 20.59 16 18 13.41 15.41 16 14 14.59 16.59 12z'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 10v4h4l5 4V6L7 10H3zm13.59 2L14 9.41 15.41 8 18 10.59 20.59 8 22 9.41 19.41 12 22 14.59 20.59 16 18 13.41 15.41 16 14 14.59 16.59 12z'/></svg>");
}

.icon-sound-on {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 10v4h4l5 4V6L7 10H3zm11 0.5A3.5 3.5 0 0 1 17.5 14a3.5 3.5 0 0 1-3.5 3.5v-7zm0-4.5a8 8 0 0 1 8 8 8 8 0 0 1-8 8v-2a6 6 0 0 0 6-6 6 6 0 0 0-6-6V6z'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M3 10v4h4l5 4V6L7 10H3zm11 0.5A3.5 3.5 0 0 1 17.5 14a3.5 3.5 0 0 1-3.5 3.5v-7zm0-4.5a8 8 0 0 1 8 8 8 8 0 0 1-8 8v-2a6 6 0 0 0 6-6 6 6 0 0 0-6-6V6z'/></svg>");
}

/* Screen-reader-only helper */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Easy / Harder toggle on the picker */
.size-toggle {
  border: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.size-toggle__opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--color-banana);
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  min-height: 44px;
  color: var(--color-ink);
  transition:
    background 120ms ease,
    color 120ms ease,
    border-color 120ms ease;
}

.size-toggle__opt input {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--color-berry);
  border-radius: 50%;
  margin: 0;
  display: inline-block;
  position: relative;
  cursor: pointer;
  background: #fff;
}

.size-toggle__opt input:checked {
  background: var(--color-berry);
  box-shadow: inset 0 0 0 3px #fff;
}

.size-toggle__opt:has(input:checked) {
  background: var(--color-berry);
  color: #fff;
  border-color: var(--color-berry);
}

.size-toggle__opt:focus-within {
  outline: 3px solid var(--color-banana);
  outline-offset: 3px;
}

.solved-moves {
  margin: 0 0 16px;
  font-weight: 700;
  font-size: 15px;
  color: var(--color-ink);
  opacity: 0.85;
}

/* Star rating strip on the solved overlay. */
.stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 0 4px;
  font-size: clamp(34px, 8vw, 46px);
  line-height: 1;
}

.stars .star {
  color: rgba(44, 44, 44, 0.18);
  transform: scale(0.6);
  opacity: 0.4;
  transition:
    transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 200ms ease,
    color 200ms ease;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.stars .star.is-on {
  color: #ffbf00;
  opacity: 1;
}

.stars .star.is-on.is-animate {
  transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .stars .star {
    transition: none;
    transform: scale(1);
  }
}

.solved-bonus {
  margin: 4px 0 10px;
  font-weight: 900;
  font-size: clamp(14px, 3.5vw, 18px);
  color: #b8882a;
  letter-spacing: 0.04em;
  min-height: 1.2em;
}

/* Puzzle picker grid */
.puzzle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.puzzle-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 4px solid var(--color-banana);
  border-radius: 22px;
  background: #fff;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 120ms ease;
}

.puzzle-card:active {
  transform: scale(0.97);
}

.puzzle-card:focus-visible {
  outline: 3px solid var(--color-berry);
  outline-offset: 3px;
}

.puzzle-card svg {
  display: block;
  width: 100%;
  height: 100%;
}

.puzzle-card__label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 8px;
  background: rgba(44, 44, 44, 0.75);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.puzzle-card__badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-berry);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.puzzle-card__art {
  display: block;
  width: 100%;
  height: 100%;
}

/* Today's Pick highlight — yellow ring so it reads first. */
.puzzle-card--daily {
  border-color: #ffbf00;
  box-shadow:
    var(--shadow-card),
    0 0 0 3px rgba(255, 191, 0, 0.35);
}

.puzzle-card__daily-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffbf00;
  color: var(--color-ink);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.puzzle-card__stars {
  position: absolute;
  bottom: 32px;
  left: 0;
  right: 0;
  text-align: center;
  color: #ffbf00;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.progress {
  margin-top: 18px;
  text-align: center;
  font-size: 14px;
  opacity: 0.8;
}

/* Game view */
.board-wrap {
  display: grid;
  place-items: center;
  margin: 10px 0;
}

.board {
  width: min(92vw, 420px);
  aspect-ratio: 1 / 1;
  position: relative;
  background: #fff;
  border: 4px solid var(--color-banana);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
  touch-action: manipulation;
  outline: none;
}

.board:focus-visible {
  box-shadow:
    var(--shadow-card),
    0 0 0 3px var(--color-berry);
}

.tile {
  position: absolute;
  border: none;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  transition:
    left 160ms ease,
    top 160ms ease,
    transform 100ms ease;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6),
    0 1px 2px rgba(0, 0, 0, 0.1);
}

.tile:active {
  transform: scale(0.97);
}

.tile.is-selected {
  box-shadow: inset 0 0 0 3px var(--color-berry),
    0 2px 6px rgba(0, 0, 0, 0.18);
  z-index: 2;
}

/* Hint pulse — shown after idle to nudge the child toward a good move. */
.tile.is-hint {
  animation: tile-hint-pulse 900ms ease-in-out 3;
  z-index: 3;
}
@keyframes tile-hint-pulse {
  0%,
  100% {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6),
      0 1px 2px rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow: inset 0 0 0 3px #ffbf00,
      0 0 0 4px rgba(255, 191, 0, 0.4),
      0 1px 2px rgba(0, 0, 0, 0.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Replace the pulse with a solid outline so SR + motion-sensitive kids
     still get the hint without animation. */
  .tile.is-hint {
    animation: none;
    box-shadow: inset 0 0 0 3px #ffbf00,
      0 0 0 3px rgba(255, 191, 0, 0.5),
      0 1px 2px rgba(0, 0, 0, 0.1);
  }
}

.tile svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .tile {
    transition: none;
  }
}

.game-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 0 4px;
}

.move-count {
  font-weight: 700;
  opacity: 0.8;
}

.ghost-btn {
  border: 2px solid var(--color-berry);
  background: #fff;
  color: var(--color-berry);
  font-weight: 800;
  font-size: 15px;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 44px;
  transition: transform 100ms ease;
}

.ghost-btn--small {
  font-size: 13px;
  padding: 8px 12px;
  min-height: 40px;
}

.ghost-btn:active {
  transform: scale(0.97);
}

.ghost-btn:focus-visible {
  outline: 3px solid var(--color-banana);
  outline-offset: 3px;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(44, 44, 44, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 20px;
  pointer-events: auto;
  animation: fadeIn 180ms ease both;
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  background: var(--color-cream);
  border: 4px solid var(--color-banana);
  border-radius: 28px;
  padding: clamp(20px, 5vw, 36px) clamp(22px, 6vw, 42px);
  text-align: center;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.overlay-title {
  margin: 0 0 10px;
  font-size: clamp(26px, 6.5vw, 40px);
  color: var(--color-berry);
  font-weight: 900;
}

.overlay-sub {
  margin: 0 0 18px;
  font-size: clamp(18px, 4vw, 22px);
  color: var(--color-ink);
  line-height: 1.4;
  font-weight: 700;
  animation: bob 900ms ease-in-out infinite alternate;
}

.overlay-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.big-btn {
  display: inline-block;
  min-width: 160px;
  min-height: 52px;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  background: var(--color-berry);
  color: #fff;
  font-weight: 800;
  font-size: clamp(16px, 4vw, 20px);
  cursor: pointer;
  box-shadow: 0 6px 0 #9a1540;
  transition:
    transform 100ms ease,
    box-shadow 100ms ease;
}

.big-btn:hover {
  transform: translateY(-1px);
}

.big-btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #9a1540;
}

.big-btn:focus-visible {
  outline: 3px solid var(--color-banana);
  outline-offset: 4px;
}

.big-btn--ghost {
  background: #fff;
  color: var(--color-berry);
  box-shadow: 0 4px 0 rgba(44, 44, 44, 0.15);
}

.big-btn--ghost:active {
  box-shadow: 0 2px 0 rgba(44, 44, 44, 0.15);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes bob {
  from {
    transform: translateY(-2px);
  }
  to {
    transform: translateY(2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay {
    animation: none;
  }
  .overlay-sub {
    animation: none;
  }
  .big-btn {
    transition: none;
  }
}
