:root {
  --ink: #5b1a6e;
  --muted: #9b3db8;
  --paper: #fff7ff;
  --line: #ff9ad5;
  --select-soft: rgba(255, 105, 180, 0.55);
  --found: #ff1493;
  --found-soft: rgba(255, 215, 0, 0.65);
  --surface: rgba(255, 255, 255, 0.82);
  --shadow: 0 20px 50px rgba(255, 105, 180, 0.35);
  --rainbow: linear-gradient(
    90deg,
    #ff6ec7,
    #ff8c42,
    #ffe66d,
    #7dffb3,
    #6ecbff,
    #c77dff,
    #ff6ec7
  );
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background: #ff9ad5;
  overflow-x: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
}

.rainbow-wash {
  position: absolute;
  inset: -20%;
  background: linear-gradient(
    125deg,
    #ff9ad5 0%,
    #ffd6f0 18%,
    #c9b6ff 36%,
    #9dfff0 54%,
    #ffe66d 72%,
    #ff8fab 88%,
    #ff9ad5 100%
  );
  background-size: 300% 300%;
  animation: rainbow-shift 10s ease-in-out infinite;
}

.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.star {
  position: absolute;
  color: #fff;
  text-shadow: 0 0 8px #ff69b4, 0 0 16px #ffe66d;
  animation: twinkle var(--dur, 2s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  font-size: var(--size, 1rem);
  opacity: 0.85;
}

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

.unicorn {
  position: absolute;
  width: clamp(90px, 14vw, 160px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(255, 105, 180, 0.5));
  animation: floaty 5s ease-in-out infinite;
}

.u1 {
  top: 4%;
  left: 2%;
  animation-delay: 0s;
}
.u2 {
  top: 12%;
  right: 3%;
  width: clamp(80px, 12vw, 140px);
  animation-delay: -1.2s;
  transform: scaleX(-1);
}
.u3 {
  bottom: 8%;
  left: 4%;
  width: clamp(100px, 15vw, 170px);
  animation-delay: -2.4s;
}
.u4 {
  bottom: 18%;
  right: 2%;
  width: clamp(70px, 11vw, 120px);
  animation-delay: -0.8s;
}
.u5 {
  top: 42%;
  left: -1%;
  width: clamp(70px, 10vw, 110px);
  animation-delay: -3s;
  opacity: 0.9;
}

.deco {
  position: absolute;
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  animation: bounce-spin 3.5s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(255, 20, 147, 0.35));
}

.h1 {
  top: 22%;
  left: 18%;
  animation-delay: -0.3s;
}
.h2 {
  top: 8%;
  left: 48%;
  animation-delay: -1.1s;
}
.h3 {
  bottom: 12%;
  left: 42%;
  animation-delay: -2s;
}
.b1 {
  top: 30%;
  right: 16%;
  animation-delay: -0.7s;
}
.b2 {
  bottom: 28%;
  left: 12%;
  animation-delay: -1.8s;
}
.s1 {
  top: 18%;
  right: 28%;
}
.s2 {
  top: 55%;
  right: 10%;
  animation-delay: -1s;
}
.s3 {
  bottom: 6%;
  right: 30%;
  animation-delay: -2.2s;
}
.s4 {
  top: 65%;
  left: 22%;
  animation-delay: -0.5s;
}
.s5 {
  top: 4%;
  left: 30%;
  animation-delay: -1.5s;
}
.s6 {
  bottom: 35%;
  right: 22%;
  font-size: clamp(1.8rem, 4vw, 3rem);
  animation-delay: -2.8s;
}
.p1 {
  top: 38%;
  right: 6%;
  font-size: clamp(2rem, 4vw, 3.2rem);
}
.p2 {
  bottom: 4%;
  left: 28%;
  font-size: clamp(2rem, 4vw, 3rem);
  animation-delay: -1.4s;
}
.p3 {
  top: 48%;
  left: 8%;
  animation-delay: -2.6s;
}
.p4 {
  top: 72%;
  right: 18%;
  animation-delay: -0.9s;
}

.app {
  position: relative;
  z-index: 1;
  width: min(980px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
  display: grid;
  gap: 1.1rem 1.4rem;
  grid-template-columns: 1fr;
  grid-template-areas:
    "header"
    "words"
    "board";
}

.header {
  grid-area: header;
  text-align: center;
  animation: rise 0.7s ease both;
}

.brand {
  margin: 0 0 0.4rem;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(2.2rem, 7vw, 3.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  background: var(--rainbow);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbow-text 3s linear infinite;
  filter: drop-shadow(0 3px 0 rgba(255, 255, 255, 0.7));
}

.header h1 {
  margin: 0;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  font-weight: 600;
  color: #c2185b;
}

.lede {
  margin: 0.55rem auto 0;
  max-width: 34rem;
  color: #8e24aa;
  font-size: 1rem;
  font-weight: 700;
}

.word-list {
  grid-area: words;
  padding: 1rem 1.2rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 182, 235, 0.85));
  border: 3px solid #ff69b4;
  border-radius: 24px;
  box-shadow: var(--shadow), inset 0 0 0 3px #ffe66d;
  animation: rise 0.7s ease 0.08s both;
}

.word-list h2 {
  margin: 0 0 0.7rem;
  font-family: "Fredoka", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  color: #e91e63;
}

.word-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem 0.85rem;
}

.word-list li {
  font-family: "Fredoka", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #ff6ec7, #c77dff);
  box-shadow: 0 4px 0 #ff1493;
  transition: transform 0.2s ease, filter 0.25s ease, opacity 0.25s ease;
}

.word-list li:nth-child(2) {
  background: linear-gradient(135deg, #ff8c42, #ffe66d);
  box-shadow: 0 4px 0 #ff6f00;
  color: #5b1a6e;
}
.word-list li:nth-child(3) {
  background: linear-gradient(135deg, #7dffb3, #6ecbff);
  box-shadow: 0 4px 0 #00bfa5;
  color: #004d40;
}
.word-list li:nth-child(4) {
  background: linear-gradient(135deg, #c77dff, #ff6ec7);
  box-shadow: 0 4px 0 #7b1fa2;
}
.word-list li:nth-child(5) {
  background: linear-gradient(135deg, #ffe66d, #ff9ad5);
  box-shadow: 0 4px 0 #f9a825;
  color: #5b1a6e;
}

.word-list li.found {
  text-decoration: line-through;
  opacity: 0.55;
  filter: grayscale(0.3);
  transform: scale(0.95);
}

.board-wrap {
  grid-area: board;
  overflow: auto;
  padding: 0.85rem;
  background: linear-gradient(160deg, #fff0fb, #e8f7ff 45%, #fff8d6);
  border: 4px solid transparent;
  border-radius: 28px;
  background-image:
    linear-gradient(160deg, #fff0fb, #e8f7ff 45%, #fff8d6),
    var(--rainbow);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  box-shadow: var(--shadow);
  animation: rise 0.7s ease 0.16s both, glow-pulse 2.4s ease-in-out infinite;
  user-select: none;
  -webkit-user-select: none;
}

.board-frame {
  border-radius: 18px;
  overflow: hidden;
  border: 3px dashed #ff69b4;
  background: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  width: min(680px, 100%);
  margin: 0 auto;
  aspect-ratio: 1;
  gap: 2px;
  background: #fff;
  touch-action: none;
}

.cell {
  display: grid;
  place-items: center;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(0.85rem, 2.6vw, 1.25rem);
  font-weight: 700;
  color: #5b1a6e;
  cursor: crosshair;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
  border-radius: 6px;
}

.cell:nth-child(8n + 1) {
  background: #ffe3f1;
}
.cell:nth-child(8n + 2) {
  background: #ffe9c7;
}
.cell:nth-child(8n + 3) {
  background: #fff5b8;
}
.cell:nth-child(8n + 4) {
  background: #d8ffe8;
}
.cell:nth-child(8n + 5) {
  background: #d6f0ff;
}
.cell:nth-child(8n + 6) {
  background: #ead6ff;
}
.cell:nth-child(8n + 7) {
  background: #ffd6e8;
}
.cell:nth-child(8n) {
  background: #e0fff7;
}

.cell.selecting {
  background: #ff69b4 !important;
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 0 12px #ff1493;
  z-index: 2;
}

.cell.found {
  background: linear-gradient(135deg, #ffe66d, #ff9ad5) !important;
  color: #c2185b;
  box-shadow: inset 0 0 0 2px #ff1493;
}

.victory {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.75rem;
  background: rgba(255, 105, 180, 0.55);
  backdrop-filter: blur(6px);
  z-index: 30;
  animation: fade-in 0.35s ease both;
}

.victory[hidden] {
  display: none;
}

.victory-party {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.victory-party img {
  width: clamp(80px, 18vw, 140px);
  height: auto;
  filter: drop-shadow(0 8px 20px rgba(255, 20, 147, 0.5));
  animation: floaty 2s ease-in-out infinite;
}

.victory-party img:nth-child(2) {
  animation-delay: -0.4s;
}
.victory-party img:nth-child(3) {
  animation-delay: -0.8s;
}

.victory p {
  margin: 0;
  padding: 1.2rem 2.4rem;
  border-radius: 28px;
  background: linear-gradient(135deg, #fff, #ffe6f5);
  border: 4px solid #ff69b4;
  font-family: "Fredoka", sans-serif;
  font-size: clamp(3rem, 12vw, 5.5rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #ff1493;
  box-shadow: 0 16px 40px rgba(255, 20, 147, 0.4), 0 0 0 6px #ffe66d;
  animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

.victory-burst {
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  letter-spacing: 0.2em;
  animation: bounce-spin 1.8s ease-in-out infinite;
}

@keyframes rainbow-shift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@keyframes rainbow-text {
  to {
    background-position: 200% center;
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-18px) rotate(4deg);
  }
}

.u2 {
  animation-name: floaty-flip;
}

@keyframes floaty-flip {
  0%,
  100% {
    transform: scaleX(-1) translateY(0) rotate(-4deg);
  }
  50% {
    transform: scaleX(-1) translateY(-18px) rotate(4deg);
  }
}

@keyframes bounce-spin {
  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  40% {
    transform: translateY(-10px) rotate(12deg) scale(1.12);
  }
  70% {
    transform: translateY(4px) rotate(-8deg) scale(0.96);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.75) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.25) rotate(18deg);
  }
}

@keyframes glow-pulse {
  0%,
  100% {
    box-shadow: 0 20px 50px rgba(255, 105, 180, 0.35);
  }
  50% {
    box-shadow: 0 20px 60px rgba(199, 125, 255, 0.55), 0 0 30px rgba(255, 230, 109, 0.45);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.7) rotate(-6deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@media (min-width: 900px) {
  .app {
    grid-template-columns: 210px 1fr;
    grid-template-areas:
      "header header"
      "words board";
    align-items: start;
  }

  .header {
    text-align: left;
  }

  .lede {
    margin-left: 0;
  }

  .word-list ul {
    flex-direction: column;
    align-items: stretch;
  }

  .word-list li {
    text-align: center;
  }
}

@media (max-width: 700px) {
  .unicorn {
    opacity: 0.7;
  }
  .u5,
  .u4 {
    display: none;
  }
}
