:root {
  --pink: #ff5d8f;
  --purple: #9b7bff;
  --blue: #3fa9f5;
  --green: #5fd35f;
  --yellow: #ffd23d;
  --orange: #ff9f43;
  --ink: #3a2c5a;
  --panel: #fffdf7;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Baloo 2", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #e6fff0 0%, #fde9ff 50%, #fff7e6 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

.topbar {
  position: relative;
  z-index: 10;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 10px rgba(120, 80, 160, 0.15);
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.topbar::-webkit-scrollbar {
  display: none;
}

.topbar > * {
  flex: 0 0 auto;
}

.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 900;
  text-decoration: none;
}

.site-logo-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: var(--green);
  color: #fff;
  box-shadow: 3px 3px 0 rgba(58, 44, 90, 0.28);
  font-size: 0.72rem;
  letter-spacing: 0;
}

.logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  max-width: min(38vw, 340px);
  overflow: hidden;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--purple));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
  pointer-events: none;
}

.topbar-spacer {
  flex: 1 1 auto;
  min-width: clamp(80px, 20vw, 200px);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border-radius: 999px;
  padding: 4px 11px;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(120, 80, 160, 0.18);
}

.chip b {
  color: var(--purple);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.15rem;
  background: #fff;
  box-shadow: 0 3px 8px rgba(120, 80, 160, 0.22);
  display: grid;
  place-items: center;
  transition: transform 0.1s;
}

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

.btn {
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.08s, box-shadow 0.08s;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.btn.green {
  background: var(--green);
}

.btn.blue {
  background: var(--blue);
}

.btn.orange {
  background: var(--orange);
}

.progress-wrap {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  height: 10px;
  background: rgba(255, 255, 255, 0.6);
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  transition: width 0.35s ease;
}

.game-area {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.holes-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 16px;
  flex: 1 1 auto;
  min-height: 0;
}

.shape-hole {
  width: min(22vmin, 120px);
  height: min(22vmin, 120px);
  position: relative;
}

.hole-outline {
  width: 100%;
  height: 100%;
  border: 4px dashed #bbb;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.4);
  display: grid;
  place-items: center;
  transition: border-color 0.2s, background 0.2s;
}

.hole-outline.active-hover {
  border-color: var(--green);
  background: rgba(95, 211, 95, 0.15);
}

.shapes-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  box-shadow: 0 -3px 14px rgba(120, 80, 160, 0.18);
  flex: 0 0 auto;
}

.shape-piece {
  width: min(18vmin, 100px);
  height: min(18vmin, 100px);
  position: relative;
  cursor: grab;
  touch-action: none;
  transition: transform 0.12s;
  filter: drop-shadow(0 3px 4px rgba(58, 44, 90, 0.18));
}

.shape-piece:active {
  transform: scale(1.05);
}

.shape-piece.dragging {
  position: fixed;
  z-index: 9999;
  cursor: grabbing;
  transform: scale(1.08);
  filter: drop-shadow(0 10px 12px rgba(58, 44, 90, 0.24));
  pointer-events: none;
}

.shape-piece.shaking {
  animation: shapeshake 0.5s ease;
}

@keyframes shapeshake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-12px);
  }
  40% {
    transform: translateX(12px);
  }
  60% {
    transform: translateX(-8px);
  }
  80% {
    transform: translateX(8px);
  }
}

.shape-piece.matched {
  cursor: default;
  opacity: 0.6;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(58, 44, 90, 0.12));
  animation: matchpop 0.4s ease;
}

@keyframes matchpop {
  0% {
    transform: scale(1.3);
  }
  60% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 0.4;
  }
}

.prompt {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  padding: 6px 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.6);
  flex: 0 0 auto;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(60, 44, 90, 0.55);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.overlay.open {
  display: flex;
}

.modal {
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  width: min(90vw, 480px);
  text-align: center;
  box-shadow: 0 20px 60px rgba(60, 44, 90, 0.4);
  animation: popin 0.25s ease;
}

@keyframes popin {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}

.modal .trophy {
  font-size: 4.6rem;
  animation: bounce 0.8s ease infinite alternate;
}

@keyframes bounce {
  to {
    transform: translateY(-14px);
  }
}

.modal h2 {
  margin: 0 0 4px;
  font-size: 1.8rem;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

#confetti {
  position: fixed;
  inset: 0;
  z-index: 95;
  pointer-events: none;
}

@media (max-width: 500px) {
  .shape-hole {
    width: min(26vmin, 100px);
    height: min(26vmin, 100px);
  }
  .shape-piece {
    width: min(22vmin, 80px);
    height: min(22vmin, 80px);
  }
  .prompt {
    font-size: 1.1rem;
  }
}
