:root {
  --bg-main: #f9f8fc;
  --bg-panel: #fffffe;
  --ink: #0e172c;
  --pink: #fec7d7;
  --purple: #a786df;
  --lilac: #d9d4e7;

  --border-w: 3px;
  --cell-size: 58px;
  --cell-gap: 3px;
}

* {
  box-sizing: border-box;
  border-radius: 0 !important;
  box-shadow: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-main); /* solid color, no gradient */
  color: var(--ink);
  font-family: "Helvetica Neue", Arial, "Hiragino Sans", "Yu Gothic", sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: var(--border-w) solid var(--ink);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.logo {
  font-size: 30px;
  letter-spacing: 0.03em;
  margin: 0;
  font-weight: 800;
}

.stats {
  display: flex;
  gap: 10px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  padding: 6px 10px;
  background: var(--bg-panel);
  border: var(--border-w) solid var(--ink);
}

.stat-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink);
  opacity: 0.65;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}


.stage {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.board-frame {
  position: relative;
  background: var(--bg-panel);
  border: var(--border-w) solid var(--ink);
  padding: 10px;
  flex: 0 0 auto;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, var(--cell-size));
  grid-template-rows: repeat(8, var(--cell-size));
  gap: var(--cell-gap);
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  position: relative;
  transition: transform 0.12s ease;
}

.cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.cell.selected {
  background: var(--lilac);
}

.cell.matched img {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.cell.swapping {
  z-index: 2;
}

.cell.drop-in {
  animation: dropIn 0.18s ease-out;
}

@keyframes dropIn {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-panel);
  border: var(--border-w) solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
}

.overlay.hidden {
  display: none;
}

.overlay-box {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  text-align: center;
  padding: 12px;
}

.congrats-img {
  display: block;
  width: 100%;
  max-width: 260px;
  height: auto;
  margin: 0 auto 12px;
}

.congrats-img.hidden {
  display: none;
}

.overlay-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
}

.overlay-text {
  margin: 0 0 18px;
  font-size: 14px;
  opacity: 0.8;
}

.side-panel {
  flex: 1 1 200px;
  min-width: 200px;
  background: var(--bg-panel);
  border: var(--border-w) solid var(--ink);
  padding: 16px;
}

.side-heading {
  margin: 0 0 10px;
  font-weight: 800;
  font-size: 15px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 8px;
}

.side-heading + .side-heading {
  margin-top: 20px;
}

.difficulty-group {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}

.diff-btn {
  flex: 1;
  padding: 8px 4px;
  background: var(--bg-panel);
  border: 2px solid var(--ink);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.diff-btn:hover {
  background: var(--lilac);
}

.diff-btn.is-active {
  background: var(--purple);
  color: var(--bg-panel);
}

.side-list {
  margin: 0 0 20px;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.7;
}

.side-list li {
  margin-bottom: 6px;
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 10px 14px;
  background: var(--pink);
  border: var(--border-w) solid var(--ink);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.btn:hover {
  background: var(--purple);
}

.btn:active {
  transform: translate(2px, 2px);
}

.btn-outline {
  background: var(--bg-panel);
}

.btn-outline:hover {
  background: var(--lilac);
}


@media (max-width: 560px) {
  :root {
    --cell-size: 38px;
  }
  .logo {
    font-size: 22px;
  }
  .stat {
    min-width: 62px;
    padding: 4px 6px;
  }
  .overlay-box {
    padding: 6px;
  }
  .congrats-img {
    max-width: 180px;
    margin-bottom: 8px;
  }
  .overlay-title {
    font-size: 18px;
    margin-bottom: 4px;
  }
  .overlay-text {
    font-size: 11px;
    margin-bottom: 10px;
  }
  .btn {
    padding: 8px 8px;
    font-size: 12px;
  }
}
