@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Quicksand:wght@600;700&display=swap");

:root {
  --tile-size: 58px;
  --tile-gap: 8px;
  --bg-1: #fff2d8;
  --bg-2: #ffd9e1;
  --bg-3: #c4f1f9;
  --panel: rgba(255, 255, 255, 0.85);
  --ink: #3a2f3d;
  --subtle: #6f6074;
  --accent: #ff6b9f;
  --accent-2: #ff9f68;
  --ok: #1f9d7a;
  --danger: #d64557;
  --trace: #ff4d7a;
  --trace-glow: rgba(255, 112, 150, 0.82);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Quicksand", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 12%, #ffffff 0%, transparent 38%),
    radial-gradient(circle at 88% 16%, #ffe4ef 0%, transparent 30%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2) 50%, var(--bg-3));
}

.bg-blobs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(2px);
  opacity: 0.5;
  animation: floaty 9s ease-in-out infinite;
}

.blob.b1 {
  width: 190px;
  height: 190px;
  left: 3%;
  top: 8%;
  background: #ffc6d9;
}

.blob.b2 {
  width: 250px;
  height: 250px;
  right: 8%;
  top: 20%;
  background: #d7f8ff;
  animation-delay: 1.5s;
}

.blob.b3 {
  width: 230px;
  height: 230px;
  left: 45%;
  bottom: -45px;
  background: #ffe8b6;
  animation-delay: 0.75s;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1220px;
  margin: 0 auto;
  padding: 18px 16px 26px;
}

.topbar {
  background: var(--panel);
  backdrop-filter: blur(9px);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 14px 16px 16px;
  box-shadow: 0 14px 30px rgba(93, 57, 86, 0.16);
}

.title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

h1 {
  margin: 0;
  font-family: "Baloo 2", "Quicksand", sans-serif;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.toggle {
  border: none;
  border-radius: 999px;
  padding: 8px 12px;
  font-family: inherit;
  font-weight: 700;
  background: linear-gradient(90deg, #4d96ff, #79d3ff);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(61, 130, 240, 0.25);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.toggle[aria-pressed="false"] {
  background: linear-gradient(90deg, #95a3b3, #b6c0cd);
  box-shadow: none;
}

.toggle:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px 10px;
  margin-bottom: 10px;
}

.stats p {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--subtle);
}

.stats span {
  color: var(--ink);
  font-size: 1.03rem;
}

.time-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  overflow: hidden;
  box-shadow: inset 0 1px 4px rgba(67, 41, 72, 0.18);
  margin-bottom: 12px;
}

.time-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #26de81, #f7d794 70%, #ff8fab);
  transition: width 0.35s linear, filter 0.22s ease;
}

.time-fill.danger {
  filter: saturate(1.2) brightness(0.95);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions button {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  font-family: "Baloo 2", "Quicksand", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(241, 124, 141, 0.3);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.actions button:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
}

.actions button:active {
  transform: translateY(1px);
}

.main-layout {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 14px;
  align-items: start;
}

.play-area {
  min-width: 0;
}

.message {
  margin: 4px 4px 10px;
  min-height: 1.35em;
  font-weight: 700;
  color: var(--subtle);
}

.message.ok {
  color: var(--ok);
}

.message.error {
  color: var(--danger);
}

.board-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.88)),
    repeating-linear-gradient(
      45deg,
      rgba(255, 185, 204, 0.15),
      rgba(255, 185, 204, 0.15) 12px,
      rgba(199, 235, 255, 0.15) 12px,
      rgba(199, 235, 255, 0.15) 24px
    );
  box-shadow: 0 14px 26px rgba(84, 55, 76, 0.18);
  padding: 8px;
}

.board-stage {
  position: relative;
  margin: 0 auto;
}

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

.board {
  position: absolute;
  display: grid;
  grid-template-columns: repeat(12, var(--tile-size));
  gap: var(--tile-gap);
}

.tile {
  width: var(--tile-size);
  height: var(--tile-size);
  border-radius: 14px;
  border: 2px solid #ffd2b8;
  background: linear-gradient(180deg, #ffffff, #fff5f8);
  box-shadow: 0 3px 0 #ffd9e5;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease,
    filter 0.12s ease;
}

.tile:hover {
  transform: translateY(-1px);
}

.tile:active {
  transform: translateY(1px);
}

.tile.selected {
  border-color: #3bc8af;
  box-shadow: 0 0 0 3px rgba(59, 200, 175, 0.24), 0 3px 0 rgba(74, 205, 177, 0.35);
}

.tile.hint-strong {
  animation: pulseStrong 0.72s ease-in-out 3;
}

.tile.hint-soft {
  animation: pulseSoft 0.74s ease-in-out 3;
}

.tile.match-pop {
  animation: popAway 0.25s ease forwards;
}

.tile.empty {
  cursor: default;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.mascot-panel {
  background: var(--panel);
  backdrop-filter: blur(9px);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 14px 28px rgba(80, 57, 86, 0.16);
}

.mascot-avatar {
  width: 90px;
  height: 90px;
  margin: 0 auto 8px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  background: linear-gradient(145deg, #fff8ea, #ffe6f2);
  border: 2px solid #ffd3e5;
  box-shadow: 0 8px 16px rgba(238, 135, 173, 0.22);
  animation: mascotIdle 2.8s ease-in-out infinite;
}

.mascot-avatar.excited {
  animation: mascotHappy 0.52s ease;
}

.mascot-avatar.support {
  animation: mascotNudge 0.64s ease;
}

.mascot-mood {
  margin: 0 0 8px;
  text-align: center;
  font-weight: 700;
  font-size: 0.98rem;
}

.assistant-tip {
  margin: 0;
  text-align: center;
  color: var(--subtle);
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.4;
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-12px) scale(1.04);
  }
}

@keyframes pulseStrong {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(252, 188, 45, 0.3);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 10px rgba(252, 188, 45, 0);
  }
}

@keyframes pulseSoft {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(56, 178, 245, 0.25);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 9px rgba(56, 178, 245, 0);
  }
}

@keyframes popAway {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.32);
    opacity: 0;
  }
}

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

@keyframes mascotHappy {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.1) rotate(8deg);
  }
  70% {
    transform: scale(1.08) rotate(-6deg);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes mascotNudge {
  0%,
  100% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(4px);
  }
  60% {
    transform: translateX(-4px);
  }
}

@media (max-width: 1100px) {
  :root {
    --tile-size: 50px;
    --tile-gap: 7px;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .main-layout {
    grid-template-columns: 1fr;
  }

  .mascot-panel {
    display: grid;
    grid-template-columns: 90px 1fr;
    gap: 12px;
    align-items: center;
  }

  .mascot-avatar {
    margin: 0;
  }

  .mascot-mood,
  .assistant-tip {
    text-align: left;
  }
}

@media (max-width: 720px) {
  :root {
    --tile-size: 40px;
    --tile-gap: 5px;
  }

  .app {
    padding: 10px 8px 18px;
  }

  .topbar {
    padding: 12px;
  }

  .title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(110px, 1fr));
  }

  .actions button,
  .toggle {
    padding: 8px 11px;
    font-size: 0.9rem;
  }

  .board-wrap {
    padding: 6px;
  }

  .mascot-panel {
    grid-template-columns: 1fr;
  }

  .mascot-avatar {
    margin: 0 auto;
  }

  .mascot-mood,
  .assistant-tip {
    text-align: center;
  }
}
