:root {
  --ink: #25304f;
  --muted: #68708f;
  --paper: #fff9ee;
  --card: #ffffff;
  --pink: #ff5fa2;
  --coral: #ff896b;
  --mint: #42d9a7;
  --blue: #5a8dff;
  --yellow: #ffd84d;
  --line: #d8dcef;
  --shadow: 0 18px 45px rgba(55, 66, 110, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: ui-rounded, "Avenir Next", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 14% 8%, rgba(255, 216, 77, 0.55), transparent 24%),
    radial-gradient(circle at 86% 12%, rgba(90, 141, 255, 0.38), transparent 22%),
    linear-gradient(135deg, #fff5d6 0%, #ffe4f1 46%, #dff8ff 100%);
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 2px;
  color: #b13d78;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 12vw, 4.6rem);
  line-height: 0.92;
}

.icon-button,
.pill-button,
.number-pad button {
  border: 0;
  color: var(--ink);
  font-weight: 900;
  box-shadow: 0 8px 0 rgba(37, 48, 79, 0.12);
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

.icon-button:active,
.pill-button:active,
.number-pad button:active {
  transform: translateY(4px) scale(0.98);
  box-shadow: 0 3px 0 rgba(37, 48, 79, 0.12);
}

.icon-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--yellow);
  font-size: 1.45rem;
}

.stats,
.controls {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

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

.stat,
.select-wrap {
  min-width: 0;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 8px 26px rgba(65, 78, 126, 0.1);
}

.stat {
  padding: 10px;
}

.stat-label,
.select-wrap span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(1rem, 5vw, 1.35rem);
}

.controls {
  grid-template-columns: 1fr 1fr;
}

.select-wrap {
  padding: 8px 10px;
}

select {
  width: 100%;
  margin-top: 2px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
  outline: 0;
}

.pill-button {
  min-height: 48px;
  border-radius: 8px;
  background: var(--card);
}

.pill-button.primary {
  background: var(--mint);
}

.pill-button.active {
  color: #fff;
  background: var(--pink);
}

.game-area {
  margin-top: 18px;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(100%, 92vw, 600px);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border: 4px solid var(--ink);
  border-radius: 10px;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--blue);
  font-size: clamp(1.15rem, 6.5vw, 2.4rem);
  font-weight: 950;
  outline: 0;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.cell:nth-child(3n) {
  border-right: 3px solid var(--ink);
}

.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 3px solid var(--ink);
}

.cell:nth-child(9n) {
  border-right: 0;
}

.cell.given {
  color: var(--ink);
  background: #fff0bd;
}

.cell.selected {
  z-index: 2;
  background: #dff7ff;
  transform: scale(1.06);
  box-shadow: inset 0 0 0 3px var(--blue);
}

.cell.related {
  background: #effaff;
}

.cell.same {
  z-index: 1;
  background: #c9ffe9;
  color: #117b61;
  box-shadow: inset 0 0 0 3px rgba(66, 217, 167, 0.72);
}

.cell.same.selected {
  z-index: 3;
  background: #dff7ff;
  color: var(--blue);
  box-shadow: inset 0 0 0 3px var(--blue), inset 0 0 0 6px rgba(66, 217, 167, 0.65);
}

.number-pad button.active-number {
  filter: saturate(1.35);
  transform: translateY(-2px);
  box-shadow: 0 10px 0 rgba(37, 48, 79, 0.16), inset 0 0 0 3px var(--blue);
}

.cell.conflict {
  animation: shake 280ms ease-in-out;
  background: #ffe1e8;
  color: #d21f5b;
}

.cell.pop {
  animation: pop 220ms ease-out;
}

.notes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 82%;
  height: 82%;
  color: #8690b7;
  font-size: clamp(0.48rem, 2.1vw, 0.82rem);
  font-weight: 800;
  line-height: 1;
}

.notes-grid span {
  display: grid;
  place-items: center;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 9px;
  margin-top: 16px;
}

.number-pad button {
  min-height: 50px;
  border-radius: 8px;
  background: var(--card);
  font-size: 1.25rem;
}

.number-pad button:nth-child(3n + 1) {
  background: #dff8ff;
}

.number-pad button:nth-child(3n + 2) {
  background: #ffe4f1;
}

.number-pad button:nth-child(3n) {
  background: #fff0bd;
}

.number-pad .erase {
  grid-column: span 1;
  background: #e9e8ff;
  font-size: 0.9rem;
}

.message {
  min-height: 24px;
  margin: 16px 0 0;
  color: #5a3150;
  font-weight: 800;
  text-align: center;
}

.celebration {
  pointer-events: none;
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: fall 1300ms ease-in forwards;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@keyframes pop {
  0% { transform: scale(0.82); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes fall {
  to {
    transform: translateY(108vh) rotate(620deg);
    opacity: 0;
  }
}

@media (min-width: 660px) {
  .app-shell {
    padding-top: 30px;
  }

  .controls {
    grid-template-columns: 1.25fr repeat(3, 1fr);
  }

  .number-pad {
    grid-template-columns: repeat(10, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
