@font-face {
  font-family: "Baloo 2";
  font-style: normal;
  font-weight: 800;
  font-display: optional;
  src: url("/fonts/baloo-2-800.woff2") format("woff2");
}

:root {
  --bg: oklch(0.985 0.01 85);
  --ink: oklch(0.22 0.02 60);
  --ink-2: oklch(0.5 0.02 60);
  --muted: oklch(0.955 0.015 85);
  --empty: oklch(0.93 0.012 85);
  --border: oklch(0.9 0.02 80);
  --primary: oklch(0.64 0.21 45);
  --s0: #e8605a;
  --s1: #4f8fe8;
  --s2: #c9a227;
  --s3: #9b79e8;
  --s4: #5fbf6a;
  --s5: #f2913d;
  --s6: #3fb8b0;
  --s7: #b5556e;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}

.hud-stats {
  display: flex;
  gap: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}

.hud-stats b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.hud-level {
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
}

.hud-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button {
  font: inherit;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

button.primary {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
  padding: 10px 20px;
  font-size: 16px;
}

.board-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 10px;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  background: var(--muted);
}

.cell {
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: var(--empty);
  display: grid;
  place-items: center;
  transition:
    transform 0.18s ease,
    opacity 0.22s ease;
}

.cell.filled {
  background: var(--sc);
  box-shadow: inset 0 -3px 0 oklch(0 0 0 / 0.14);
}

.cell.head {
  box-shadow:
    inset 0 0 0 3px oklch(1 0 0 / 0.55),
    inset 0 -3px 0 oklch(0 0 0 / 0.14);
}

.cell svg {
  width: 62%;
  height: 62%;
  filter: drop-shadow(0 1px 1px oklch(0 0 0 / 0.25));
}

.cell.hint::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 9px;
  border: 3px solid var(--ink);
  pointer-events: none;
}

.cell.leaving {
  transform: translate(calc(var(--dx) * 130%), calc(var(--dy) * 130%));
  opacity: 0;
}

.cell.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(calc(var(--dx) * 22%), calc(var(--dy) * 22%));
  }
  60% {
    transform: translate(calc(var(--dx) * -8%), calc(var(--dy) * -8%));
  }
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: oklch(1 0 0 / 0.86);
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  text-align: center;
  display: grid;
  gap: 8px;
  padding: 20px;
}

.overlay-title {
  margin: 0;
  font-family: "Baloo 2", system-ui, sans-serif;
  font-weight: 800;
  font-size: 28px;
}

.overlay-card p {
  margin: 0;
  color: var(--ink-2);
}

@media (prefers-reduced-motion: reduce) {
  .cell {
    transition: none;
  }
  .cell.shake {
    animation: none;
  }
}
