.game-wrapper {
  max-width: 860px;
  margin: 24px auto;
}

/* Khung bảng gỗ */
.wooden-board {
  position: relative;
  background-color: #8c5230;
  border: 6px solid #6b3b1e;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  margin-top: 18px;
}

/* Hai chốt gỗ phía trên bảng */
.wooden-peg {
  position: absolute;
  top: -18px;
  width: 34px;
  height: 16px;
  background-color: #deb083;
  border: 3px solid #6b3b1e;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}
.peg-left { left: 16%; }
.peg-right { right: 16%; }

/* Lưới 4 cột x 5 hàng = 20 ô (10 cặp) */
.board-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background-color: #ffffff;
  border: 3px solid #ffffff;
  border-radius: 4px;
}

.math-tile {
  background-color: #0284c7;
  color: #ffffff;
  font-size: clamp(1.25rem, 3.2vw, 1.85rem);
  font-weight: 700;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease, opacity 0.35s ease;
  position: relative;
}

.math-tile:hover:not(.matched):not(.selected) {
  background-color: #0369a1;
}

/* Trạng thái đang được chọn */
.math-tile.selected {
  background-color: #f59e0b;
  color: #ffffff;
  transform: scale(0.96);
  box-shadow: inset 0 0 0 3px #fef08a;
}

/* Trạng thái ghép đúng chuẩn bị biến mất */
.math-tile.correct-flash {
  background-color: #16a34a !important;
  transform: scale(1.03);
  z-index: 2;
}

/* Trạng thái chọn sai rung nhẹ */
.math-tile.wrong-shake {
  background-color: #dc2626 !important;
  animation: shake 0.35s ease-in-out;
}

/* Trạng thái đã biến mất */
.math-tile.matched {
  opacity: 0;
  pointer-events: none;
  cursor: default;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

/* Lớp phủ thông báo thắng / thua lượt */
.board-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  text-align: center;
  padding: 20px;
}