:root {
  --ink: #20213b;
  --pink: #ee628c;
  --violet: #6047a5;
  --gem-0: #57dcff;
  --gem-1: #ff78b5;
  --gem-2: #ffe16b;
  --gem-3: #70ea91;
  --gem-4: #ba8dff;
  --gem-5: #ff9470;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 15% 15%, #ffd0e2, transparent 28%),
    radial-gradient(circle at 90% 90%, #b9dfef, transparent 34%), #f8f4ff;
  color: var(--ink);
  font-family: "Space Grotesk", sans-serif;
}
.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
}
.back {
  position: fixed;
  top: 22px;
  left: 24px;
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
.game-shell {
  width: min(570px, 100%);
  padding: 28px;
  background: #fffcffcc;
  border: 1px solid #fff;
  border-radius: 28px;
  box-shadow: 0 25px 65px #40295924;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
}
.eyebrow {
  margin: 0;
  color: var(--pink);
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
}
h1 {
  font: 800 37px/1 "Baloo 2";
  margin: 3px 0;
}
.score-box {
  padding: 8px 14px;
  text-align: center;
  border-radius: 12px;
  background: var(--violet);
  color: #ddd7f5;
  font-size: 10px;
  letter-spacing: 1px;
}
.score-box strong {
  display: block;
  color: #fff;
  font-size: 22px;
  letter-spacing: 0;
}
.guide {
  font-size: 13px;
  line-height: 1.5;
  color: #706c80;
  margin: 16px 0;
}
.guide b {
  color: var(--pink);
}
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  padding: 9px;
  background: #3a3268;
  border-radius: 18px;
  aspect-ratio: 1;
  touch-action: none;
}
.gem {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(145deg, #6c5baa, #3b3268);
  box-shadow:
    inset 0 2px #ffffff3b,
    0 3px 0 #211c4b;
  color: #fff;
  font-size: clamp(20px, 6vw, 38px);
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 0.16s,
    filter 0.16s,
    opacity 0.16s;
}
.gem::before {
  content: "";
  position: absolute;
  inset: 17%;
  border-radius: 16%;
  background: linear-gradient(145deg, #ffffffc7 0 14%, var(--core) 21% 63%, var(--core-shadow) 100%);
  clip-path: var(--shape);
  filter: drop-shadow(0 2px 1px #0003);
  opacity: 0.96;
}
.gem::after {
  position: absolute;
  top: 24%;
  left: 28%;
  width: 22%;
  height: 14%;
  content: "";
  border-radius: 50%;
  background: #fff;
  transform: rotate(-28deg);
  box-shadow: 10px 12px 0 -4px #ffffff88;
}
.gem:hover {
  filter: brightness(1.15);
}
.gem.selected {
  outline: 3px solid #fff;
  transform: scale(0.9);
  filter: brightness(1.35);
}
.gem.dragging {
  transform: scale(1.13);
  filter: brightness(1.28);
  z-index: 2;
}
.gem.type-0 { --shape:polygon(50% 0,100% 28%,82% 88%,50% 100%,18% 88%,0 28%); --core:#49dbff; --core-shadow:#0878cf; background:linear-gradient(145deg,#73edff,#2186d5); box-shadow:inset 0 2px #fff9,0 3px 0 #15568d,0 0 14px #56ddff88; }
.gem.type-1 { --shape:polygon(50% 0,94% 30%,76% 100%,24% 100%,6% 30%); --core:#ff6db2; --core-shadow:#bd1e69; background:linear-gradient(145deg,#ff8ec2,#cf3f82); box-shadow:inset 0 2px #fff9,0 3px 0 #8b2453,0 0 14px #ff7fb488; }
.gem.type-2 { --shape:polygon(25% 0,75% 0,100% 25%,100% 75%,75% 100%,25% 100%,0 75%,0 25%); --core:#ffe65f; --core-shadow:#dc9410; background:linear-gradient(145deg,#ffe879,#eaaa1b); box-shadow:inset 0 2px #fff9,0 3px 0 #a36d0e,0 0 14px #ffd95d88; }
.gem.type-3 { --shape:circle(50% at 50% 50%); --core:#7cea83; --core-shadow:#269d55; background:linear-gradient(145deg,#94f18c,#38a95e); box-shadow:inset 0 2px #fff9,0 3px 0 #23723d,0 0 14px #83f89388; }
.gem.type-4 { --shape:polygon(50% 0,100% 88%,78% 100%,22% 100%,0 88%); --core:#bd85ff; --core-shadow:#6739bd; background:linear-gradient(145deg,#c79afb,#7548c8); box-shadow:inset 0 2px #fff9,0 3px 0 #4a278e,0 0 14px #bc8cff88; }
.gem.type-5 { --shape:polygon(50% 0,61% 32%,96% 25%,72% 52%,84% 90%,50% 70%,16% 90%,28% 52%,4% 25%,39% 32%); --core:#ff8566; --core-shadow:#cf392b; background:linear-gradient(145deg,#ff9872,#df4c37); box-shadow:inset 0 2px #fff9,0 3px 0 #9b3025,0 0 14px #ff8d7188; }
.swap-ghost {
  position: absolute !important;
  margin: 0;
  pointer-events: none;
  transition: transform 260ms cubic-bezier(.22,.9,.3,1.12);
  will-change: transform;
}
.gem.match {
  animation: burst 0.25s ease-out forwards;
}
@keyframes burst {
  to {
    transform: scale(0);
    opacity: 0;
  }
}
.spark {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--spark);
  box-shadow: 0 0 7px var(--spark);
  pointer-events: none;
  z-index: 5;
  animation: spark 0.48s ease-out forwards;
}
@keyframes spark {
  to {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 18px;
  font-size: 12px;
  color: #766e86;
}
.footer button {
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  background: var(--pink);
  color: #fff;
  font: 700 12px "Space Grotesk";
  cursor: pointer;
}
@media (max-width: 600px) {
  .page {
    padding: 18px 12px;
  }
  .back {
    position: static;
    justify-self: start;
    margin-bottom: 14px;
  }
  .game-shell {
    padding: 22px 13px;
  }
  h1 {
    font-size: 30px;
  }
  .board {
    gap: 4px;
    padding: 7px;
  }
  .gem {
    border-radius: 8px;
  }
  .guide {
    margin: 13px 0;
  }
}
