/* ============================================================
   Sparkle Pop — game-only styles (linked from games/sparkle-pop.html)
   Uses site tokens from styles.css
   ============================================================ */

.sparkle-game {
  position: relative;
  overflow: visible;
  padding-bottom: 20px;
}

.sparkle-help {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.35;
  text-align: center;
}

/* ---- HUD ---- */
.sparkle-hud {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  margin-bottom: 7px;
}

.sparkle-stat,
.sparkle-goals {
  min-height: 48px;
  background: var(--bg-window);
  border: 2px solid var(--border);
  box-shadow: 2px 2px 0 var(--shadow);
}

.sparkle-stat {
  min-width: 70px;
  padding: 6px 9px;
  text-align: center;
}

.sparkle-stat-label,
.sparkle-goals-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
}

.sparkle-stat-value {
  color: var(--text-dark);
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
}

.sparkle-goals {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 8px;
}

.sparkle-goals-label {
  margin: 0 2px 0 0;
}

.sparkle-goal {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-width: 49px;
  padding: 3px 5px;
  background: linear-gradient(180deg, #fff 0%, var(--pink-soft) 100%);
  border: 1px solid var(--border);
  color: var(--text-dark);
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  white-space: nowrap;
}

.sparkle-goal-icon {
  font-family: sans-serif;
  font-size: 18px;
  line-height: 1;
}

.sparkle-goal.is-done {
  background: linear-gradient(180deg, #f6fff9 0%, var(--mint) 100%);
  opacity: 0.78;
}

.sparkle-goal.is-done .sparkle-goal-count {
  color: #39735f;
}

.sparkle-status {
  min-height: 20px;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.2;
  text-align: center;
}

/* ---- board shell: keep overflow visible so last-row tiles/shadows aren't clipped ---- */
.sparkle-board-shell {
  display: flex;
  width: 100%;
  max-width: 568px;
  margin: 0 auto 13px;
  padding: 7px 7px 11px;
  overflow: visible;
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 255, 255, 0.9) 0 2px, transparent 3px),
    linear-gradient(145deg, rgba(255, 214, 234, 0.78), rgba(203, 182, 240, 0.72));
  border: 2px solid var(--border);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.75), 3px 3px 0 var(--shadow);
}

.sparkle-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 5px;
  width: 100%;
  height: auto;
  padding: 0 0 2px;
  overflow: visible;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.sparkle-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  padding: 0;
  overflow: visible;
  cursor: pointer;
  color: inherit;
  background: linear-gradient(145deg, #fff 5%, var(--cream) 58%, #f9e8f4 100%);
  border: 2px solid rgba(155, 77, 138, 0.72);
  border-radius: 9px;
  box-shadow: inset 1px 1px 0 #fff, 2px 2px 0 rgba(155, 77, 138, 0.32);
  font: inherit;
  line-height: 1;
  transition: transform 0.13s ease, filter 0.13s ease, background 0.13s ease;
  -webkit-tap-highlight-color: transparent;
}

.sparkle-tile.is-swapping {
  z-index: 5;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.22, 0.8, 0.32, 1);
}

.sparkle-board.is-busy .sparkle-tile:hover {
  transform: none;
  filter: none;
}

.sparkle-tile:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

.sparkle-tile:focus-visible {
  outline: 2px dashed var(--pink-deep);
  outline-offset: 2px;
  z-index: 2;
}

.sparkle-tile.is-selected {
  z-index: 2;
  background: linear-gradient(145deg, #fff 0%, var(--yellow-soft) 100%);
  border-color: var(--pink-deep);
  box-shadow: 0 0 0 2px rgba(247, 168, 208, 0.52), 2px 2px 0 var(--pink-deep);
  transform: translateY(-2px) scale(1.035);
}

.sparkle-tile-emoji {
  display: block;
  font-family: sans-serif;
  font-size: clamp(21px, 5.4vw, 36px);
  line-height: 1;
  filter: drop-shadow(1px 2px 0 rgba(155, 77, 138, 0.18));
  pointer-events: none;
}

.sparkle-tile.is-power {
  color: #7b45ad;
  background: radial-gradient(circle, #fff 0 14%, #fff4ad 16% 30%, #e6c8ff 52%, #f6a8d3 100%);
  border-color: #8651b1;
  box-shadow: 0 0 9px rgba(217, 128, 255, 0.8), inset 1px 1px 0 #fff, 2px 2px 0 #8f62b4;
  animation: sparkle-pulse 1.25s ease-in-out infinite alternate;
}

.sparkle-tile.is-power::after {
  content: "✦";
  position: absolute;
  top: 3px;
  right: 4px;
  color: #fff;
  font-size: 9px;
  text-shadow: 0 0 3px #9a51c8;
}

.sparkle-tile.is-super {
  background: radial-gradient(circle, #fff 0 12%, #ffe985 14% 27%, #ff9dd1 46%, #b89cff 68%, #7e5ac8 100%);
  border-color: #69349b;
  box-shadow: 0 0 12px rgba(232, 123, 184, 0.95), inset 1px 1px 0 #fff, 2px 2px 0 #7443a0;
  animation: super-pop 0.7s ease-in-out infinite alternate;
}

.sparkle-tile.is-power .sparkle-tile-emoji,
.sparkle-tile.is-super .sparkle-tile-emoji {
  font-size: clamp(20px, 5vw, 33px);
}

/* Lightning faces the line it will clear: upright = column, on its side = row */
.sparkle-tile.is-power.is-dir-h .sparkle-tile-emoji {
  transform: rotate(90deg) scaleX(1.15);
}

.sparkle-tile.is-power.is-dir-v .sparkle-tile-emoji {
  transform: rotate(0deg);
}

.sparkle-tile.is-clearing {
  animation: tile-clear 0.24s ease forwards;
  pointer-events: none;
}

.sparkle-tile.is-invalid {
  animation: invalid-bounce 0.3s ease;
}

.sparkle-tile.is-empty {
  visibility: hidden;
  pointer-events: none;
  box-shadow: none;
  border-color: transparent;
  background: transparent;
}

.sparkle-board.is-busy .sparkle-tile {
  cursor: wait;
}

.sparkle-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.sparkle-actions .btn {
  display: inline-block;
  margin-top: 0;
  text-decoration: none;
}

.sparkle-back-btn {
  font-size: 8px !important;
}

.sparkle-win {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(243, 238, 252, 0.86);
}

.sparkle-win[hidden] {
  display: none !important;
}

.sparkle-win-inner {
  width: 100%;
  max-width: 330px;
  padding: 20px 16px;
  text-align: center;
  background: var(--bg-window);
  border: 2px solid var(--border);
  box-shadow: 4px 4px 0 var(--shadow);
}

.sparkle-win-title {
  margin: 0 0 11px;
  color: var(--text-dark);
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
}

.sparkle-win-msg {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 19px;
  line-height: 1.35;
}

@keyframes sparkle-pulse {
  from { filter: brightness(1); transform: scale(0.98); }
  to { filter: brightness(1.1); transform: scale(1.03); }
}

@keyframes super-pop {
  from { filter: hue-rotate(-8deg) brightness(1); transform: rotate(-2deg) scale(0.98); }
  to { filter: hue-rotate(10deg) brightness(1.12); transform: rotate(2deg) scale(1.04); }
}

@keyframes tile-clear {
  0% { opacity: 1; transform: scale(1); }
  55% { opacity: 0.85; transform: scale(1.14) rotate(5deg); }
  100% { opacity: 0; transform: scale(0.25) rotate(-10deg); }
}

@keyframes invalid-bounce {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px) rotate(-2deg); }
  60% { transform: translateX(4px) rotate(2deg); }
}

@media (max-width: 560px) {
  .sparkle-board-shell { padding: 5px 5px 9px; }
  .sparkle-board { gap: 3px; }
  .sparkle-tile {
    border-width: 1px;
    border-radius: 6px;
    box-shadow: inset 1px 1px 0 #fff, 1px 1px 0 rgba(155, 77, 138, 0.34);
  }
  .sparkle-goals { order: 3; flex-basis: 100%; }
}

@media (max-width: 380px) {
  .sparkle-game { padding-left: 7px; padding-right: 7px; }
  .sparkle-help { font-size: 16px; }
  .sparkle-board { gap: 2px; }
  .sparkle-board-shell { padding: 4px 4px 7px; }
  .sparkle-tile { border-radius: 4px; }
  .sparkle-tile-emoji { font-size: clamp(18px, 7vw, 25px); }
  .sparkle-goal { min-width: 46px; padding: 3px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .sparkle-tile,
  .sparkle-tile.is-power,
  .sparkle-tile.is-super,
  .sparkle-tile.is-clearing,
  .sparkle-tile.is-invalid {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition: none;
  }
}

/* Site chrome otherwise clips the last tile row + shadows */
.os-body.sparkle-game {
  overflow: visible;
  padding-bottom: 20px;
}
