* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  background: #0a0e27;
  color: #e0e0e0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.back-link {
  align-self: flex-start;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 16px;
}
.back-link:hover {
  color: #ff8fab;
}

.game-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #ff6b9d 0%, #ffd93d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hud {
  display: flex;
  gap: 12px;
  width: 100%;
  margin-bottom: 10px;
}

.stat {
  flex: 1;
  background: #1a1f3a;
  border: 1px solid #2d3548;
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.stat .label {
  font-size: 12px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat span:last-child {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.hint {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 16px;
  text-align: center;
}

.board-wrap {
  position: relative;
  width: 100%;
  max-width: 400px;
  touch-action: none;
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #12172e;
  border: 1px solid #2d3548;
  border-radius: 16px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
}

.cell {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

.tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #1a1f3a;
  transition: top 0.12s ease, left 0.12s ease;
  animation: pop 0.15s ease;
}

@keyframes pop {
  from { transform: scale(0.6); opacity: 0.4; }
  to { transform: scale(1); opacity: 1; }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  background: rgba(10, 14, 39, 0.92);
  border-radius: 16px;
  padding: 24px;
}

.overlay.hidden {
  display: none;
}

#overlay-title {
  font-size: 24px;
  font-weight: 700;
  color: #ffffff;
}

#overlay-message {
  font-size: 14px;
  color: #94a3b8;
  margin-bottom: 8px;
}

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

#overlay-btn, .secondary-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

#overlay-btn {
  background: linear-gradient(135deg, #ff6b9d 0%, #ff8fab 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(255, 107, 157, 0.35);
}

.secondary-btn {
  background: transparent;
  border: 1px solid #2d3548;
  color: #e0e0e0;
}

.secondary-btn.hidden {
  display: none;
}
