*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&display=swap');

:root {
  --pink: #ff8da1;
  --pink-dark: #e07084;
  --pink-light: #ffb8c7;
  --pink-bg: #fff0f3;
  --white: #ffffff;
  --gray: #f5a5b5;
  --shadow: 0 4px 15px rgba(255, 141, 161, 0.3);
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--pink-bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.floating-cats {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-cat {
  position: absolute;
  font-size: 28px;
  opacity: 0.25;
  animation: floatCat linear infinite;
}

.floating-cat:nth-child(1) { left: 5%; top: -5%; animation-duration: 18s; animation-delay: 0s; font-size: 32px; }
.floating-cat:nth-child(2) { left: 88%; top: 10%; animation-duration: 22s; animation-delay: 2s; font-size: 24px; }
.floating-cat:nth-child(3) { left: 15%; top: 70%; animation-duration: 20s; animation-delay: 4s; font-size: 26px; }
.floating-cat:nth-child(4) { left: 75%; top: 60%; animation-duration: 24s; animation-delay: 1s; font-size: 30px; }
.floating-cat:nth-child(5) { left: 40%; top: -8%; animation-duration: 19s; animation-delay: 3s; font-size: 22px; }
.floating-cat:nth-child(6) { left: 60%; top: 80%; animation-duration: 21s; animation-delay: 5s; font-size: 28px; }
.floating-cat:nth-child(7) { left: 92%; top: 40%; animation-duration: 23s; animation-delay: 6s; font-size: 20px; }
.floating-cat:nth-child(8) { left: 30%; top: 90%; animation-duration: 17s; animation-delay: 0s; font-size: 26px; }

@keyframes floatCat {
  0% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(30px) rotate(5deg); }
  50% { transform: translateY(-10px) rotate(-3deg); }
  75% { transform: translateY(20px) rotate(4deg); }
  100% { transform: translateY(-100vh) rotate(0deg); }
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,141,161,0.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255,184,199,0.15) 0%, transparent 50%);
  pointer-events: none;
}

#app {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 24px;
  text-align: center;
  z-index: 1;
}

header { margin-bottom: 20px; }

.bow-icon {
  font-size: 48px;
  animation: bounce 2s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(255,141,161,0.3));
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

h1 {
  font-size: 28px;
  font-weight: 900;
  color: var(--pink-dark);
  letter-spacing: 1px;
  margin-top: 4px;
}

.subtitle {
  font-size: 14px;
  color: var(--pink);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 16px;
}

.stat {
  font-size: 13px;
  font-weight: 700;
  color: var(--pink-dark);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat span {
  display: block;
  font-size: 22px;
  font-weight: 900;
  color: var(--pink);
  margin-top: 2px;
}

.puzzle-container {
  background: var(--pink-light);
  border-radius: 20px;
  padding: 12px;
  box-shadow: var(--shadow), inset 0 2px 4px rgba(255,255,255,0.5);
  position: relative;
  aspect-ratio: 1;
  margin-bottom: 20px;
}

.puzzle-grid {
  display: grid;
  position: relative;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  height: 100%;
}

.tile {
  background: var(--white);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  color: var(--pink-dark);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease;
  box-shadow: 0 2px 8px rgba(255,141,161,0.2);
  user-select: none;
  position: relative;
  border: 2px solid rgba(255,141,161,0.15);
}

.tile:hover:not(.tile-empty) {
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(255,141,161,0.35);
}

.tile:active:not(.tile-empty) {
  transform: scale(0.96);
}

.tile-empty {
  background: rgba(255,141,161,0.08);
  border: 2px dashed rgba(255,141,161,0.2);
  box-shadow: none;
  cursor: default;
}

.puzzle-solved {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.puzzle-solved::after {
  content: '🔀 Shuffle to play again';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 900;
  color: var(--pink-dark);
  background: rgba(255,240,243,0.6);
  border-radius: 16px;
  z-index: 10;
  letter-spacing: 0.5px;
}

.tile .tile-bow {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  opacity: 0.3;
}

.tile-enter {
  animation: tilePop 0.25s ease-out;
}

@keyframes tilePop {
  0% { transform: scale(0.8); opacity: 0.5; }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 50px;
  background: var(--white);
  color: var(--pink-dark);
  font-family: 'Nunito', sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  letter-spacing: 0.5px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255,141,161,0.35);
}

.btn:active {
  transform: translateY(0);
}

.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,240,243,0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.4s ease;
}

.win-overlay.hidden { display: none; }

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

.win-card {
  background: var(--white);
  border-radius: 24px;
  padding: 40px 36px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(255,141,161,0.3);
  animation: scaleIn 0.4s ease;
  max-width: 320px;
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.win-bow { font-size: 56px; margin-bottom: 8px; }

.win-card h2 {
  font-size: 22px;
  color: var(--pink-dark);
  margin-bottom: 8px;
}

.win-card p {
  font-size: 15px;
  color: var(--pink);
  margin-bottom: 20px;
  font-weight: 700;
}

.btn-win {
  background: var(--pink);
  color: white;
  padding: 12px 36px;
  font-size: 16px;
}

.btn-win:hover {
  background: var(--pink-dark);
}

.btn-plain {
  background: transparent;
  color: var(--pink);
  box-shadow: none;
  margin-top: 4px;
  font-size: 13px;
}

.btn-plain:hover {
  background: rgba(255,141,161,0.08);
  box-shadow: none;
  transform: none;
}

.leaderboard {
  margin-top: 20px;
  background: var(--white);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.leaderboard h3 {
  font-size: 14px;
  color: var(--pink-dark);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.leaderboard ol {
  list-style: none;
  text-align: left;
}

.leaderboard li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--pink-bg);
}

.leaderboard li:last-child { border-bottom: none; }

.lb-top1 {
  background: linear-gradient(135deg, #fff5f7 0%, #ffe0e8 100%);
  border-radius: 12px;
  padding: 10px 6px !important;
  border: 2px solid rgba(255,141,161,0.3);
  box-shadow: 0 2px 12px rgba(255,141,161,0.2);
  position: relative;
  font-size: 15px;
}

.lb-top1::after {
  content: '👑';
  position: absolute;
  top: -12px;
  right: -6px;
  font-size: 20px;
  animation: bounce 1.5s ease-in-out infinite;
}

.lb-top1 .lb-rank { font-size: 22px; }
.lb-top1 .lb-name { color: #d4596b; font-size: 15px; }
.lb-top1 .lb-score { color: #e07084; }

.lb-top2 {
  background: linear-gradient(135deg, #f5f0ff 0%, #e8dfff 100%);
  border-radius: 10px;
  padding: 8px 6px !important;
  border: 1.5px solid rgba(180,140,255,0.2);
  position: relative;
}

.lb-top2::after {
  content: '💜';
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 14px;
}

.lb-top2 .lb-rank { font-size: 18px; }
.lb-top2 .lb-name { color: #7c5cbf; }
.lb-top2 .lb-score { color: #9370db; }

.lb-top3 {
  background: linear-gradient(135deg, #fff8f0 0%, #ffe8d0 100%);
  border-radius: 10px;
  padding: 8px 6px !important;
  border: 1.5px solid rgba(255,180,100,0.2);
  position: relative;
}

.lb-top3::after {
  content: '⭐';
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 14px;
}

.lb-top3 .lb-rank { font-size: 18px; }
.lb-top3 .lb-name { color: #b85a2a; }
.lb-top3 .lb-score { color: #d4793e; }

.lb-empty {
  color: var(--pink);
  font-weight: 700;
  justify-content: center;
  font-size: 13px;
}

.lb-rank { font-size: 16px; width: 28px; flex-shrink: 0; text-align: center; }

.lb-name {
  color: var(--pink-dark);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  color: var(--pink);
  font-size: 12px;
  flex-shrink: 0;
}

.name-input-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}

.name-input-row input {
  font-family: 'Nunito', sans-serif;
  padding: 8px 14px;
  border: 2px solid var(--pink-light);
  border-radius: 50px;
  font-size: 14px;
  color: var(--pink-dark);
  background: var(--pink-bg);
  outline: none;
  width: 140px;
}

.name-input-row input:focus {
  border-color: var(--pink);
}

.name-input-row .btn {
  padding: 8px 18px;
  font-size: 13px;
}